package de.gurkenlabs.litiengine.environment;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.awt.Color;
import java.awt.Dimension;

import org.junit.Assert;
import org.junit.Test;

import de.gurkenlabs.litiengine.entities.Collider;
import de.gurkenlabs.litiengine.entities.ICombatEntity;
import de.gurkenlabs.litiengine.entities.IMovableEntity;
import de.gurkenlabs.litiengine.entities.Trigger;
import de.gurkenlabs.litiengine.environment.tilemap.IMap;
import de.gurkenlabs.litiengine.graphics.LightSource;
import de.gurkenlabs.litiengine.graphics.RenderType;

public class EnvironmentTests {

  @Test
  public void testInitialization() {
    IMap map = mock(IMap.class);
    when(map.getSizeInPixels()).thenReturn(new Dimension(100, 100));

    Environment env = new Environment(map);

    Assert.assertNotNull(env);
  }

  @Test
  public void testAddAndGetEntities() {
    IMap map = mock(IMap.class);
    when(map.getSizeInPixels()).thenReturn(new Dimension(100, 100));

    Environment env = new Environment(map);

    Trigger testTrigger = new Trigger("test", "testmessage");

    LightSource testLight = new LightSource(100, 100, Color.WHITE, LightSource.ELLIPSE, true);
    testLight.setMapId(999);

    Collider testCollider = new Collider(true);
    testCollider.setMapId(1);

    ICombatEntity combatEntity = mock(ICombatEntity.class);
    when(combatEntity.getMapId()).thenReturn(123);
    when(combatEntity.getRenderType()).thenReturn(RenderType.NORMAL);

    IMovableEntity movableEntity = mock(IMovableEntity.class);
    when(movableEntity.getMapId()).thenReturn(456);
    when(movableEntity.getRenderType()).thenReturn(RenderType.NORMAL);

    env.add(testTrigger);
    env.add(testLight);
    env.add(testCollider);
    env.add(combatEntity);
    env.add(movableEntity);

    Assert.assertNotNull(env.getTrigger("test"));
    Assert.assertNotNull(env.getLightSource(999));
    Assert.assertNotNull(env.getCollider(1));

    Assert.assertNotNull(env.get(123));
    Assert.assertNotNull(env.getCombatEntity(123));
    Assert.assertNotNull(env.get(456));
    Assert.assertNotNull(env.getMovableEntity(456));

    Assert.assertEquals(2, env.getEntities(RenderType.NORMAL).size());
  }
}

@@ -170,16 +170,44 @@
 mension;
+%0Aimport java.util.ArrayList;
 %0A%0Aimport
@@ -1902,24 +1902,68 @@
 r(%22test%22));%0A
+    Assert.assertNotNull(env.get(%22test%22));%0A%0A
     Assert.a
@@ -2305,14 +2305,826 @@
 ize());%0A
+    Assert.assertEquals(5, env.getEntities().size());%0A    Assert.assertEquals(1, env.getEntitiesByType(Trigger.class).size());%0A  %7D%0A%0A  @Test%0A  public void testAddandGetEntitiesByTag() %7B%0A    IMap map = mock(IMap.class);%0A    when(map.getSizeInPixels()).thenReturn(new Dimension(100, 100));%0A%0A    Environment env = new Environment(map);%0A%0A    IMovableEntity entityWithTags = mock(IMovableEntity.class);%0A    when(entityWithTags.getMapId()).thenReturn(456);%0A    when(entityWithTags.getRenderType()).thenReturn(RenderType.NORMAL);%0A%0A    ArrayList%3CString%3E tags = new ArrayList%3C%3E();%0A    tags.add(%22tag1%22);%0A    tags.add(%22tag2%22);%0A    when(entityWithTags.getTags()).thenReturn(tags);%0A    env.add(entityWithTags);%0A%0A    Assert.assertEquals(1, env.getByTag(%22tag1%22).size());%0A    Assert.assertEquals(1, env.getByTag(%22tag2%22).size());%0A
   %7D%0A%7D%0A

Extend unit test for the environment.