use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testDestroyEntity.
@Test
public void testDestroyEntity() {
EntityRef entity = entityManager.create();
entity.addComponent(new StringComponent());
entity.addComponent(new IntegerComponent());
entity.destroy();
assertNull(entity.getComponent(StringComponent.class));
assertNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testDestroyingEntityInvalidatesEntityRefs.
@Test
public void testDestroyingEntityInvalidatesEntityRefs() {
EntityRef main = entityManager.create();
main.addComponent(new StringComponent());
EntityRef reference = entityManager.create();
EntityRefComponent refComp = reference.addComponent(new EntityRefComponent());
refComp.entityRef = entityManager.getEntitiesWith(StringComponent.class).iterator().next();
assertTrue(main.exists());
entityManager.getEntitiesWith(StringComponent.class).iterator().next().destroy();
assertFalse(main.exists());
assertFalse(refComp.entityRef.exists());
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testIterateEntitiesFindsEntityWithSingleComponent.
@Test
public void testIterateEntitiesFindsEntityWithSingleComponent() {
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
List<EntityRef> results = Lists.newArrayList(entityManager.getEntitiesWith(StringComponent.class));
assertEquals(Lists.newArrayList(entity1), results);
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testChangeComponentsDuringIterator.
@Test
public void testChangeComponentsDuringIterator() {
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
EntityRef entity2 = entityManager.create();
entity2.addComponent(new StringComponent());
Iterator<Map.Entry<EntityRef, StringComponent>> iterator = entityManager.listComponents(StringComponent.class).iterator();
iterator.next();
entity2.removeComponent(StringComponent.class);
iterator.next();
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testIterateEntitiesFindsEntityWithTwoComponents.
@Test
public void testIterateEntitiesFindsEntityWithTwoComponents() {
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
entity1.addComponent(new IntegerComponent());
List<EntityRef> results = Lists.newArrayList(entityManager.getEntitiesWith(StringComponent.class, IntegerComponent.class));
assertEquals(Lists.newArrayList(entity1), results);
}
Aggregations