use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntitySerializerTest method testDeltaLoadAddedComponent.
@Test
public void testDeltaLoadAddedComponent() throws Exception {
EntityRef entity = entityManager.create("test:Test");
entity.addComponent(new IntegerComponent(2));
EntityData.Entity entityData = entitySerializer.serialize(entity);
long nextId = entityManager.getNextId();
entityManager.clear();
entityManager.setNextId(nextId);
EntityRef loadedEntity = entitySerializer.deserialize(entityData);
assertTrue(loadedEntity.exists());
assertTrue(loadedEntity.hasComponent(StringComponent.class));
assertEquals("Value", loadedEntity.getComponent(StringComponent.class).value);
assertTrue(loadedEntity.hasComponent(IntegerComponent.class));
assertEquals(2, loadedEntity.getComponent(IntegerComponent.class).value);
}
use of org.terasology.unittest.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.unittest.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.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testSendEventToEntityWithMultipleComponents.
@Test
public void testSendEventToEntityWithMultipleComponents() {
entity.addComponent(new StringComponent());
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.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testChildEventReceivedByUnfilteredHandler.
@Test
public void testChildEventReceivedByUnfilteredHandler() {
entity.addComponent(new IntegerComponent());
TestEventHandler handler = new TestEventHandler();
eventSystem.registerEvent(new ResourceUrn("test:childEvent"), TestChildEvent.class);
eventSystem.registerEventHandler(handler);
TestChildEvent event = new TestChildEvent();
eventSystem.send(entity, event);
assertEquals(1, handler.unfilteredEvents.size());
}
Aggregations