use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testNullField.
/**
* @throws Exception If failed.
*/
public void testNullField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("objField", (Object) null);
builder.setField("otherField", "value");
BinaryObject obj = builder.build();
assertNull(obj.field("objField"));
assertEquals("value", obj.field("otherField"));
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(obj), obj.hashCode());
builder = builder(obj);
builder.setField("objField", "value", Object.class);
builder.setField("otherField", (Object) null);
obj = builder.build();
assertNull(obj.field("otherField"));
assertEquals("value", obj.field("objField"));
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(obj), obj.hashCode());
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testStringArrayField.
/**
* @throws Exception If failed.
*/
public void testStringArrayField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("stringArrayField", new String[] { "str1", "str2", "str3" });
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertTrue(Arrays.equals(new String[] { "str1", "str2", "str3" }, po.<String[]>field("stringArrayField")));
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testLongArrayField.
/**
* @throws Exception If failed.
*/
public void testLongArrayField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("longArrayField", new long[] { 1, 2, 3 });
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertTrue(Arrays.equals(new long[] { 1, 2, 3 }, po.<long[]>field("longArrayField")));
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testDecimalField.
/**
* @throws Exception If failed.
*/
public void testDecimalField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("decimalField", BigDecimal.TEN);
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertEquals(BigDecimal.TEN, po.<BigDecimal>field("decimalField"));
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testBooleanField.
/**
* @throws Exception If failed.
*/
public void testBooleanField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("booleanField", true);
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertTrue(po.<Boolean>field("booleanField"));
}
Aggregations