Search in sources :

Example 21 with BinaryObjectBuilder

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")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) BigDecimal(java.math.BigDecimal)

Example 22 with BinaryObjectBuilder

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"));
}
Also used : BinaryType(org.apache.ignite.binary.BinaryType) BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 23 with BinaryObjectBuilder

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);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 24 with BinaryObjectBuilder

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);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 25 with BinaryObjectBuilder

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")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) UUID(java.util.UUID) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Aggregations

BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)77 BinaryObject (org.apache.ignite.binary.BinaryObject)60 Ignite (org.apache.ignite.Ignite)11 IgniteBinary (org.apache.ignite.IgniteBinary)7 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)7 Date (java.util.Date)4 BinaryType (org.apache.ignite.binary.BinaryType)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)3 Field (java.lang.reflect.Field)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 IgniteCache (org.apache.ignite.IgniteCache)2 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2