use of org.terasology.unittest.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);
}
use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testIterateEntitiesFindsEntityWithTwoComponents.
@Test
public void testIterateEntitiesFindsEntityWithTwoComponents() {
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
entity1.addComponent(new IntegerComponent());
List<EntityRef> results = Lists.newArrayList(entityManager.getEntitiesWith(StringComponent.class, IntegerComponent.class));
assertEquals(Lists.newArrayList(entity1), results);
}
use of org.terasology.unittest.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testDestroyEntity.
@Test
public void testDestroyEntity() {
EntityRef entity = entityManager.create();
entity.addComponent(new StringComponent());
entity.addComponent(new IntegerComponent());
entity.destroy();
assertNull(entity.getComponent(StringComponent.class));
assertNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.unittest.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());
}
use of org.terasology.unittest.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);
}
Aggregations