use of org.apache.ignite.binary.BinaryObject 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.BinaryObject 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.BinaryObject in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testGetFromCopiedObj.
/**
*
*/
public void testGetFromCopiedObj() {
BinaryObject objStr = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName()).setField("str", "aaa").build();
BinaryObjectBuilderImpl builder = builder(objStr);
assertEquals("aaa", builder.getField("str"));
builder.setField("str", "bbb");
assertEquals("bbb", builder.getField("str"));
assertNull(builder.getField("i_"));
TestCase.assertEquals("bbb", builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
}
use of org.apache.ignite.binary.BinaryObject 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.BinaryObject 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"));
}
Aggregations