@@ -0,0 +1,2636 @@
+package de.gurkenlabs.litiengine.environment;%0A%0Aimport static org.mockito.Mockito.any;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.times;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport java.util.List;%0A%0Aimport de.gurkenlabs.litiengine.entities.Creature;%0Aimport de.gurkenlabs.litiengine.entities.Spawnpoint;%0Aimport org.junit.jupiter.api.AfterAll;%0Aimport org.junit.jupiter.api.BeforeAll;%0Aimport org.junit.jupiter.api.BeforeEach;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport de.gurkenlabs.litiengine.Game;%0Aimport de.gurkenlabs.litiengine.GameTest;%0A%0Apublic class EntitySpawnerTests %7B%0A    private Environment testEnvironment;%0A    private Spawnpoint spawnPoint;%0A    private EntitySpawner%3CCreature%3E spawner;%0A    final int spawnAmount = 10;%0A%0A    @BeforeAll%0A    public static void initGame() %7B%0A        // necessary because the environment need access to the game loop and other stuff%0A        Game.init(Game.COMMADLINE_ARG_NOGUI);%0A    %7D%0A%0A    @AfterAll%0A    public static void terminateGame() %7B%0A        GameTest.terminateGame();%0A    %7D%0A%0A    @BeforeEach%0A    public void setup() %7B%0A        testEnvironment = mock(Environment.class);%0A        spawnPoint = mock(Spawnpoint.class);%0A        spawner = new TestCreatureSpawner(spawnPoint, spawnAmount);%0A    %7D%0A%0A    @Test%0A    public void testSpawn_noEnvironment() %7B%0A        // arrange%0A        when(spawnPoint.getEnvironment()).thenReturn(null);%0A%0A        // act%0A        spawner.spawnNewEntities();%0A%0A        // assert%0A        verify(spawnPoint, times(0)).spawn(any(Creature.class));%0A    %7D%0A%0A    @Test%0A    public void testSpawn_environmentNotLoaded() %7B%0A        // arrange%0A        when(testEnvironment.isLoaded()).thenReturn(false);%0A        when(spawnPoint.getEnvironment()).thenReturn(testEnvironment);%0A%0A        // act%0A        spawner.spawnNewEntities();%0A%0A        // assert%0A        verify(spawnPoint, times(0)).spawn(any(Creature.class));%0A    %7D%0A%0A    @Test%0A    public void testSpawn_spawnConfiguredAmount() %7B%0A        // arrange%0A        when(testEnvironment.isLoaded()).thenReturn(true);%0A        when(spawnPoint.getEnvironment()).thenReturn(testEnvironment);%0A%0A        // act%0A        spawner.spawnNewEntities();%0A%0A        // assert%0A        verify(spawnPoint, times(spawnAmount)).spawn(any(Creature.class));%0A    %7D%0A%0A    private class TestCreatureSpawner extends EntitySpawner%3CCreature%3E %7B%0A        TestCreatureSpawner(Spawnpoint spawnPoint, int amount) %7B%0A            super(List.of(spawnPoint), amount, SpawnMode.ONERANDOMSPAWNPOINT);%0A        %7D%0A%0A        @Override%0A        public Creature createNew() %7B%0A            return new Creature();%0A        %7D%0A    %7D%0A%7D%0A

add EntitySpawner tests for spawnEntity