use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testDecimalArrayField.
/**
* @throws Exception If failed.
*/
public void testDecimalArrayField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("decimalArrayField", new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN });
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertTrue(Arrays.equals(new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN }, po.<String[]>field("decimalArrayField")));
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testMetaData2.
/**
* @throws Exception If failed.
*/
public void testMetaData2() throws Exception {
BinaryObjectBuilder builder = builder("org.test.MetaTest2");
builder.setField("objectField", "a", Object.class);
BinaryObject bo = builder.build();
BinaryType meta = bo.type();
assertEquals(expectedTypeName("org.test.MetaTest2"), meta.typeName());
assertEquals("Object", meta.fieldTypeName("objectField"));
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testObjectField.
/**
* @throws Exception If failed.
*/
public void testObjectField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("objectField", new Value(1));
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertEquals(1, po.<BinaryObject>field("objectField").<Value>deserialize().i);
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testRemoveFromExistingObject.
/**
*
*/
public void testRemoveFromExistingObject() {
GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
obj.setDefaultData();
obj.enumArr = null;
BinaryObjectBuilder builder = builder(toBinary(obj));
builder.removeField("str");
BinaryObject binary = builder.build();
GridBinaryTestClasses.TestObjectAllTypes deserialzied = binary.deserialize();
assertNull(deserialzied.str);
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testUuidArrayField.
/**
* @throws Exception If failed.
*/
public void testUuidArrayField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
UUID[] arr = new UUID[] { UUID.randomUUID(), UUID.randomUUID() };
builder.setField("uuidArrayField", arr);
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
}
Aggregations