use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentsAlteredIfBlockInSameFamilyWhenForced.
@Test
public void testComponentsAlteredIfBlockInSameFamilyWhenForced() {
worldProvider.setBlock(new Vector3i(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new IntegerComponent());
worldProvider.setBlockForceUpdateEntity(new Vector3i(), blockInFamilyTwo);
assertNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentUntouchedIfRetainRequested.
@Test
public void testComponentUntouchedIfRetainRequested() {
worldProvider.setBlock(new Vector3i(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new IntegerComponent());
worldProvider.setBlockRetainComponent(new Vector3i(), blockWithString, IntegerComponent.class);
assertNotNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class ByteCodeReflectFactoryTest method testAccessIntegerField.
@Test
public void testAccessIntegerField() throws Exception {
ReflectFactory reflectFactory = new ByteCodeReflectFactory();
FieldAccessor fieldAccessor = reflectFactory.createFieldAccessor(IntegerComponent.class, IntegerComponent.class.getDeclaredField("value"));
IntegerComponent comp = new IntegerComponent();
fieldAccessor.setValue(comp, 1);
assertEquals(1, fieldAccessor.getValue(comp));
}
use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testSendEventToEntityComponent.
@Test
public void testSendEventToEntityComponent() {
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);
}
use of org.terasology.unittest.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntitySerializerTest method testDeltaAddNewComponent.
@Test
public void testDeltaAddNewComponent() throws Exception {
EntityRef entity = entityManager.create(prefab);
entity.addComponent(new IntegerComponent(1));
EntityData.Entity entityData = entitySerializer.serialize(entity);
assertEquals(entity.getId(), entityData.getId());
assertEquals(prefab.getName(), entityData.getParentPrefab());
assertEquals(1, entityData.getComponentCount());
assertEquals(0, entityData.getRemovedComponentCount());
EntityData.Component componentData = entityData.getComponent(0);
assertEquals("test:integer", componentData.getType());
assertEquals(1, componentData.getFieldCount());
EntityData.NameValue field = componentData.getField(0);
assertEquals("value", field.getName());
assertEquals(1, field.getValue().getInteger(0));
}
Aggregations