Search in sources :

Example 16 with StringComponent

use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEventSystemTests method testNoReceiveEventWhenMissingComponents.

@Test
public void testNoReceiveEventWhenMissingComponents() {
    entity.addComponent(new StringComponent());
    TestCompoundComponentEventHandler handler = new TestCompoundComponentEventHandler();
    eventSystem.registerEventHandler(handler);
    TestEvent event = new TestEvent();
    eventSystem.send(entity, event);
    assertEquals(0, handler.receivedList.size());
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) Test(org.junit.jupiter.api.Test)

Example 17 with StringComponent

use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method testChangeComponentEventSentWhenSave.

@Test
public void testChangeComponentEventSentWhenSave() {
    EventSystem eventSystem = mock(EventSystem.class);
    EntityRef entity1 = entityManager.create();
    StringComponent comp = entity1.addComponent(new StringComponent());
    entityManager.setEventSystem(eventSystem);
    entity1.saveComponent(comp);
    verify(eventSystem).send(entity1, OnChangedComponent.newInstance(), comp);
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) EventSystem(org.terasology.engine.entitySystem.event.internal.EventSystem) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 18 with StringComponent

use of org.terasology.unittest.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));
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 19 with StringComponent

use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method testIterateEntitiesDoesNotFindEntityMissingAComponent.

@Test
public void testIterateEntitiesDoesNotFindEntityMissingAComponent() {
    EntityRef entity1 = entityManager.create();
    entity1.addComponent(new StringComponent());
    List<EntityRef> results = Lists.newArrayList(entityManager.getEntitiesWith(StringComponent.class, IntegerComponent.class));
    assertEquals(Collections.<EntityRef>emptyList(), results);
}
Also used : IntegerComponent(org.terasology.unittest.stubs.IntegerComponent) StringComponent(org.terasology.unittest.stubs.StringComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 20 with StringComponent

use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method testReplaceComponent.

@Test
public void testReplaceComponent() {
    EntityRef entity = entityManager.create();
    StringComponent comp = new StringComponent();
    comp.value = "Hello";
    StringComponent comp2 = new StringComponent();
    comp2.value = "Goodbye";
    entity.addComponent(comp);
    entity.addComponent(comp2);
    assertEquals(comp2, entity.getComponent(StringComponent.class));
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Aggregations

StringComponent (org.terasology.unittest.stubs.StringComponent)41 Test (org.junit.jupiter.api.Test)38 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)22 EntityData (org.terasology.protobuf.EntityData)8 IntegerComponent (org.terasology.unittest.stubs.IntegerComponent)8 EventSystem (org.terasology.engine.entitySystem.event.internal.EventSystem)5 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)5 PrefabData (org.terasology.engine.entitySystem.prefab.PrefabData)4 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)3 PojoPrefab (org.terasology.engine.entitySystem.prefab.internal.PojoPrefab)3 Vector3i (org.joml.Vector3i)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)2 NetworkSystem (org.terasology.engine.network.NetworkSystem)2 Component (org.terasology.gestalt.entitysystem.component.Component)2 GetterSetterComponent (org.terasology.unittest.stubs.GetterSetterComponent)2 Map (java.util.Map)1 Reflections (org.reflections.Reflections)1 StorageManager (org.terasology.engine.persistence.StorageManager)1 EntitySerializer (org.terasology.engine.persistence.serializers.EntitySerializer)1