Search in sources :

Example 1 with GetterSetterComponent

use of org.terasology.entitySystem.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);
}
Also used : GetterSetterComponent(org.terasology.entitySystem.stubs.GetterSetterComponent) Test(org.junit.Test)

Example 2 with GetterSetterComponent

use of org.terasology.entitySystem.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);
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) GetterSetterComponent(org.terasology.entitySystem.stubs.GetterSetterComponent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 GetterSetterComponent (org.terasology.entitySystem.stubs.GetterSetterComponent)2 Vector3f (org.terasology.math.geom.Vector3f)1