use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testCharArrayField.
/**
* @throws Exception If failed.
*/
public void testCharArrayField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("charArrayField", new char[] { 1, 2, 3 });
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertTrue(Arrays.equals(new char[] { 1, 2, 3 }, po.<char[]>field("charArrayField")));
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testDoubleField.
/**
* @throws Exception If failed.
*/
public void testDoubleField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("doubleField", 1.0d);
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertEquals(1.0d, po.<Double>field("doubleField").doubleValue(), 0);
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testShortField.
/**
* @throws Exception If failed.
*/
public void testShortField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("shortField", (short) 1);
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
assertEquals((short) 1, po.<Short>field("shortField").shortValue());
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testBuildAndDeserialize.
/**
* @throws Exception If failed.
*/
public void testBuildAndDeserialize() throws Exception {
BinaryObjectBuilder builder = builder(Value.class.getName());
builder.setField("i", 1);
BinaryObject bo = builder.build();
assertEquals(expectedHashCode(Value.class.getName()), bo.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(bo), bo.hashCode());
assertEquals(1, bo.<Value>deserialize().i);
}
use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testCollectionField.
/**
* @throws Exception If failed.
*/
public void testCollectionField() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
builder.setField("collectionField2", Arrays.asList(new Value(1), new Value(2)), Collection.class);
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
List<Value> list = po.field("collectionField");
assertEquals(2, list.size());
assertEquals(1, list.get(0).i);
assertEquals(2, list.get(1).i);
List<BinaryObject> list2 = po.field("collectionField2");
assertEquals(2, list2.size());
assertEquals(1, list2.get(0).<Value>deserialize().i);
assertEquals(2, list2.get(1).<Value>deserialize().i);
}
Aggregations