use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testDateInObjectField.
/**
*
*/
public void testDateInObjectField() {
GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
obj.foo = new Date();
BinaryObjectBuilderImpl mutableObj = wrap(obj);
assertEquals(Date.class, mutableObj.getField("foo").getClass());
}
use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testMetadataChanging.
/**
*
*/
public void testMetadataChanging() {
GridBinaryTestClasses.TestObjectContainer c = new GridBinaryTestClasses.TestObjectContainer();
BinaryObjectBuilderImpl mutableObj = wrap(c);
mutableObj.setField("intField", 1);
mutableObj.setField("intArrField", new int[] { 1 });
mutableObj.setField("arrField", new String[] { "1" });
mutableObj.setField("strField", "1");
mutableObj.setField("colField", Lists.newArrayList("1"));
mutableObj.setField("mapField", Maps.newHashMap(ImmutableMap.of(1, "1")));
mutableObj.setField("enumField", GridBinaryTestClasses.TestObjectEnum.A);
mutableObj.setField("enumArrField", new Enum[] { GridBinaryTestClasses.TestObjectEnum.A });
mutableObj.build();
BinaryType metadata = binaries().type(c.getClass());
assertTrue(metadata.fieldNames().containsAll(Arrays.asList("intField", "intArrField", "arrField", "strField", "colField", "mapField", "enumField", "enumArrField")));
assertEquals("int", metadata.fieldTypeName("intField"));
assertEquals("int[]", metadata.fieldTypeName("intArrField"));
assertEquals("String[]", metadata.fieldTypeName("arrField"));
assertEquals("String", metadata.fieldTypeName("strField"));
assertEquals("Collection", metadata.fieldTypeName("colField"));
assertEquals("Map", metadata.fieldTypeName("mapField"));
assertEquals("Enum", metadata.fieldTypeName("enumField"));
assertEquals("Enum[]", metadata.fieldTypeName("enumArrField"));
}
use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testRemoveFromNewObject.
/**
*
*/
public void testRemoveFromNewObject() {
BinaryObjectBuilderImpl wrapper = newWrapper(GridBinaryTestClasses.TestObjectAllTypes.class);
wrapper.setField("str", "a");
wrapper.removeField("str");
TestCase.assertNull(wrapper.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
}
use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testTimestampArrayModification.
/**
*
*/
public void testTimestampArrayModification() {
GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
obj.tsArr = new Timestamp[] { new Timestamp(111222333), new Timestamp(222333444) };
BinaryObjectBuilderImpl mutObj = wrap(obj);
Timestamp[] arr = mutObj.getField("tsArr");
arr[0] = new Timestamp(333444555);
GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
Assert.assertArrayEquals(new Timestamp[] { new Timestamp(333444555), new Timestamp(222333444) }, res.tsArr);
}
use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testPlainBinaryObjectCopyFrom.
/**
*
*/
public void testPlainBinaryObjectCopyFrom() {
GridBinaryTestClasses.TestObjectPlainBinary obj = new GridBinaryTestClasses.TestObjectPlainBinary(toBinary(new GridBinaryTestClasses.TestObjectAllTypes()));
BinaryObjectBuilderImpl builder = builder(toBinary(obj));
assertTrue(builder.getField("plainBinary") instanceof BinaryObject);
GridBinaryTestClasses.TestObjectPlainBinary deserialized = builder.build().deserialize();
assertTrue(deserialized.plainBinary != null);
}
Aggregations