use of org.terasology.entitySystem.stubs.IntegerComponent 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.IntegerComponent 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);
}
use of org.terasology.entitySystem.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testSendEventToEntityWithMultipleComponents.
@Test
public void testSendEventToEntityWithMultipleComponents() {
StringComponent stringComponent = entity.addComponent(new StringComponent());
IntegerComponent intComponent = entity.addComponent(new IntegerComponent());
TestEventHandler handler = new TestEventHandler();
eventSystem.registerEventHandler(handler);
TestEvent event = new TestEvent();
entity.send(event);
assertEquals(2, handler.receivedList.size());
for (TestEventHandler.Received received : handler.receivedList) {
assertEquals(event, received.event);
assertEquals(entity, received.entity);
}
}
use of org.terasology.entitySystem.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testChildEvent.
@Test
public void testChildEvent() {
entity.addComponent(new IntegerComponent());
TestEventHandler handler = new TestEventHandler();
eventSystem.registerEvent(new SimpleUri("test:childEvent"), TestChildEvent.class);
eventSystem.registerEventHandler(handler);
TestChildEvent event = new TestChildEvent();
eventSystem.send(entity, event);
assertEquals(1, handler.childEventReceived.size());
assertEquals(1, handler.receivedList.size());
}
use of org.terasology.entitySystem.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testSendEventToEntityComponent.
@Test
public void testSendEventToEntityComponent() {
StringComponent component = entity.addComponent(new StringComponent());
IntegerComponent intComponent = entity.addComponent(new IntegerComponent());
TestEventHandler handler = new TestEventHandler();
eventSystem.registerEventHandler(handler);
TestEvent event = new TestEvent();
eventSystem.send(entity, event, intComponent);
assertEquals(1, handler.receivedList.size());
assertEquals(event, handler.receivedList.get(0).event);
assertEquals(entity, handler.receivedList.get(0).entity);
}
Aggregations