use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testRemoveComponent.
@Test
public void testRemoveComponent() {
EntityRef entity = entityManager.create();
StringComponent comp = new StringComponent();
entity.addComponent(comp);
entity.removeComponent(StringComponent.class);
assertNull(entity.getComponent(StringComponent.class));
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testAddAndRetrieveComponent.
@Test
public void testAddAndRetrieveComponent() {
EntityRef entity = entityManager.create();
assertNotNull(entity);
StringComponent comp = new StringComponent();
entity.addComponent(comp);
assertEquals(comp, entity.getComponent(StringComponent.class));
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testPriorityAndCancel.
@Test
public void testPriorityAndCancel() {
StringComponent stringComponent = entity.addComponent(new StringComponent());
TestEventHandler handlerNormal = new TestEventHandler();
TestHighPriorityEventHandler handlerHigh = new TestHighPriorityEventHandler();
handlerHigh.cancel = true;
eventSystem.registerEventHandler(handlerNormal);
eventSystem.registerEventHandler(handlerHigh);
TestEvent event = new TestEvent();
eventSystem.send(entity, event);
assertEquals(1, handlerHigh.receivedList.size());
assertEquals(0, handlerNormal.receivedList.size());
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testNoReceiveEventWhenMissingComponents.
@Test
public void testNoReceiveEventWhenMissingComponents() {
StringComponent component = entity.addComponent(new StringComponent());
TestCompoundComponentEventHandler handler = new TestCompoundComponentEventHandler();
eventSystem.registerEventHandler(handler);
TestEvent event = new TestEvent();
eventSystem.send(entity, event);
assertEquals(0, handler.receivedList.size());
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testReceiveEventRequiringMultipleComponents.
@Test
public void testReceiveEventRequiringMultipleComponents() {
StringComponent stringComponent = entity.addComponent(new StringComponent());
IntegerComponent intComponent = entity.addComponent(new IntegerComponent());
TestCompoundComponentEventHandler handler = new TestCompoundComponentEventHandler();
eventSystem.registerEventHandler(handler);
TestEvent event = new TestEvent();
eventSystem.send(entity, event);
assertEquals(1, handler.receivedList.size());
assertEquals(event, handler.receivedList.get(0).event);
assertEquals(entity, handler.receivedList.get(0).entity);
}
Aggregations