use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testChangedComponentsRevertedBeforeCleanUp.
@Test
public void testChangedComponentsRevertedBeforeCleanUp() {
worldStub.setBlock(Vector3i.zero(), blockWithString);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0));
StringComponent comp = entity.getComponent(StringComponent.class);
comp.value = "Moo";
entity.saveComponent(comp);
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(OnChangedComponent.newInstance(), entity)), checker.receivedEvents);
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testEntityExtraComponentsRemovedBeforeCleanUp.
@Test
public void testEntityExtraComponentsRemovedBeforeCleanUp() {
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0));
entity.addComponent(new StringComponent("test"));
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity), new EventInfo(BeforeRemoveComponent.newInstance(), entity)), checker.receivedEvents);
}
use of org.terasology.entitySystem.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);
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testChangeComponentEventSentWhenAddOverExisting.
@Test
public void testChangeComponentEventSentWhenAddOverExisting() {
EventSystem eventSystem = mock(EventSystem.class);
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
entityManager.setEventSystem(eventSystem);
StringComponent comp2 = entity1.addComponent(new StringComponent());
verify(eventSystem).send(entity1, OnChangedComponent.newInstance(), comp2);
}
use of org.terasology.entitySystem.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);
}
Aggregations