use of org.terasology.unittest.stubs.GetterSetterComponent in project Terasology by MovingBlocks.
the class ByteCodeReflectFactoryTest method testCreateFieldAccessorWithGetterSetter.
@Test
public void testCreateFieldAccessorWithGetterSetter() throws Exception {
ReflectFactory reflectFactory = new ByteCodeReflectFactory();
FieldAccessor<GetterSetterComponent, Vector3f> fieldAccessor = reflectFactory.createFieldAccessor(GetterSetterComponent.class, GetterSetterComponent.class.getDeclaredField("value"), Vector3f.class);
GetterSetterComponent comp = new GetterSetterComponent();
Vector3f newVal = new Vector3f(1, 2, 3);
fieldAccessor.setValue(comp, newVal);
assertTrue(comp.setterUsed);
assertEquals(newVal, fieldAccessor.getValue(comp));
assertTrue(comp.getterUsed);
}
use of org.terasology.unittest.stubs.GetterSetterComponent in project Terasology by MovingBlocks.
the class ComponentSerializerTest method testGetterSetterUtilization.
@Test
public void testGetterSetterUtilization() throws Exception {
GetterSetterComponent comp = new GetterSetterComponent();
GetterSetterComponent newComp = (GetterSetterComponent) componentSerializer.deserialize(componentSerializer.serialize(comp));
assertTrue(comp.getterUsed);
assertTrue(newComp.setterUsed);
}
Aggregations