use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testRemoveComponentEventSent.
@Test
public void testRemoveComponentEventSent() {
EventSystem eventSystem = mock(EventSystem.class);
EntityRef entity1 = entityManager.create();
StringComponent comp = entity1.addComponent(new StringComponent());
entityManager.setEventSystem(eventSystem);
entity1.removeComponent(StringComponent.class);
verify(eventSystem).send(entity1, BeforeDeactivateComponent.newInstance(), comp);
verify(eventSystem).send(entity1, BeforeRemoveComponent.newInstance(), comp);
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testPrefabCopiedCorrectly.
@Test
public void testPrefabCopiedCorrectly() {
EntityRef entity1 = entityManager.create(prefab);
StringComponent comp = entity1.getComponent(StringComponent.class);
assertEquals("Test", comp.value);
comp.value = "One";
entity1.saveComponent(comp);
assertEquals("Test", prefab.getComponent(StringComponent.class).value);
EntityRef entity2 = entityManager.create(prefab);
assertEquals("Test", prefab.getComponent(StringComponent.class).value);
assertEquals("One", entity1.getComponent(StringComponent.class).value);
assertEquals("Test", entity2.getComponent(StringComponent.class).value);
}
use of org.terasology.entitySystem.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));
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testIterateComponents.
@Test
public void testIterateComponents() {
EntityRef entity = entityManager.create();
StringComponent comp = new StringComponent();
entity.addComponent(comp);
for (Map.Entry<EntityRef, StringComponent> item : entityManager.listComponents(StringComponent.class)) {
assertEquals(entity, item.getKey());
assertEquals(comp, item.getValue());
}
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testMassRemovedComponentEventSentOnDestroy.
@Test
public void testMassRemovedComponentEventSentOnDestroy() {
EventSystem eventSystem = mock(EventSystem.class);
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
entityManager.setEventSystem(eventSystem);
entity1.destroy();
verify(eventSystem).send(entity1, BeforeDeactivateComponent.newInstance());
verify(eventSystem).send(entity1, BeforeRemoveComponent.newInstance());
}
Aggregations