Search in sources :

Example 26 with StringComponent

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);
    }
}
Also used : IntegerComponent(org.terasology.entitySystem.stubs.IntegerComponent) StringComponent(org.terasology.entitySystem.stubs.StringComponent) Test(org.junit.Test)

Example 27 with StringComponent

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);
}
Also used : IntegerComponent(org.terasology.entitySystem.stubs.IntegerComponent) StringComponent(org.terasology.entitySystem.stubs.StringComponent) Test(org.junit.Test)

Example 28 with StringComponent

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);
}
Also used : StringComponent(org.terasology.entitySystem.stubs.StringComponent) Test(org.junit.Test)

Example 29 with StringComponent

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());
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) StringComponent(org.terasology.entitySystem.stubs.StringComponent) ResourceUrn(org.terasology.assets.ResourceUrn) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) Test(org.junit.Test)

Example 30 with StringComponent

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);
}
Also used : StringComponent(org.terasology.entitySystem.stubs.StringComponent) EntityData(org.terasology.protobuf.EntityData) Test(org.junit.Test)

Aggregations

StringComponent (org.terasology.entitySystem.stubs.StringComponent)41 Test (org.junit.Test)38 EntityRef (org.terasology.entitySystem.entity.EntityRef)22 IntegerComponent (org.terasology.entitySystem.stubs.IntegerComponent)8 EntityData (org.terasology.protobuf.EntityData)8 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)5 ResourceUrn (org.terasology.assets.ResourceUrn)4 PrefabData (org.terasology.entitySystem.prefab.PrefabData)4 Prefab (org.terasology.entitySystem.prefab.Prefab)3 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)3 Before (org.junit.Before)2 SimpleUri (org.terasology.engine.SimpleUri)2 Component (org.terasology.entitySystem.Component)2 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 GetterSetterComponent (org.terasology.entitySystem.stubs.GetterSetterComponent)2 Vector3i (org.terasology.math.geom.Vector3i)2 NetworkSystem (org.terasology.network.NetworkSystem)2 Map (java.util.Map)1 EntityRefComponent (org.terasology.entitySystem.stubs.EntityRefComponent)1 StorageManager (org.terasology.persistence.StorageManager)1