use of org.apache.ignite.internal.binary.builder.BinaryBuilderEnum in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testSimpleTypeFieldRead.
/**
* @throws Exception If failed.
*/
public void testSimpleTypeFieldRead() throws Exception {
GridBinaryTestClasses.TestObjectAllTypes exp = new GridBinaryTestClasses.TestObjectAllTypes();
exp.setDefaultData();
BinaryObjectBuilder mutPo = wrap(exp);
for (Field field : GridBinaryTestClasses.TestObjectAllTypes.class.getDeclaredFields()) {
Object expVal = field.get(exp);
Object actVal = mutPo.getField(field.getName());
switch(field.getName()) {
case "anEnum":
assertEquals(((BinaryBuilderEnum) actVal).getOrdinal(), ((Enum) expVal).ordinal());
break;
case "enumArr":
{
BinaryBuilderEnum[] actArr = (BinaryBuilderEnum[]) actVal;
Enum[] expArr = (Enum[]) expVal;
assertEquals(expArr.length, actArr.length);
for (int i = 0; i < actArr.length; i++) assertEquals(expArr[i].ordinal(), actArr[i].getOrdinal());
break;
}
}
}
}
use of org.apache.ignite.internal.binary.builder.BinaryBuilderEnum in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testEnumArrayModification.
/**
*
*/
public void testEnumArrayModification() {
GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
obj.enumArr = new GridBinaryTestClasses.TestObjectEnum[] { GridBinaryTestClasses.TestObjectEnum.A, GridBinaryTestClasses.TestObjectEnum.B };
BinaryObjectBuilderImpl mutObj = wrap(obj);
BinaryBuilderEnum[] arr = mutObj.getField("enumArr");
arr[0] = new BinaryBuilderEnum(mutObj.typeId(), GridBinaryTestClasses.TestObjectEnum.B);
GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
Assert.assertArrayEquals(new GridBinaryTestClasses.TestObjectEnum[] { GridBinaryTestClasses.TestObjectEnum.A, GridBinaryTestClasses.TestObjectEnum.B }, res.enumArr);
}
Aggregations