use of org.terasology.entitySystem.stubs.StringComponent 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.StringComponent 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);
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testSendEventToEntity.
@Test
public void testSendEventToEntity() {
StringComponent component = entity.addComponent(new StringComponent());
TestEventHandler handler = new TestEventHandler();
eventSystem.registerEventHandler(handler);
TestEvent event = new TestEvent();
entity.send(event);
assertEquals(1, handler.receivedList.size());
assertEquals(event, handler.receivedList.get(0).event);
assertEquals(entity, handler.receivedList.get(0).entity);
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoPrefabManagerTest method testRetrievePrefab.
@Test
public void testRetrievePrefab() {
PrefabData data = new PrefabData();
data.addComponent(new StringComponent("Test"));
Prefab prefab = Assets.generateAsset(new ResourceUrn(PREFAB_NAME), data, Prefab.class);
Prefab ref = prefabManager.getPrefab(PREFAB_NAME);
assertNotNull(ref);
assertEquals(PREFAB_NAME, ref.getName());
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class ComponentSerializerTest method testDeltaComponentTypeIdDeserializesWithoutValue.
@Test
public void testDeltaComponentTypeIdDeserializesWithoutValue() throws Exception {
componentSerializer.setIdMapping(ImmutableMap.<Class<? extends Component>, Integer>builder().put(StringComponent.class, 1).build());
EntityData.Component compData = EntityData.Component.newBuilder().setTypeIndex(1).addField(EntityData.NameValue.newBuilder().setName("value")).build();
StringComponent original = new StringComponent("test");
componentSerializer.deserializeOnto(original, compData);
assertEquals(null, original.value);
}
Aggregations