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);
  }
  public void testRemoveFromExistingObjectAfterGet() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.setDefaultData();
    obj.enumArr = null;

    BinaryObjectBuilderImpl builder = builder(toBinary(obj));

    builder.getField("i_");

    builder.removeField("str");

    TestCase.assertNull(
        builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
  }
  @SuppressWarnings("unchecked")
  public void testCopyFromInnerObjects() {
    ArrayList<Object> list = new ArrayList<>();
    list.add(new GridBinaryTestClasses.TestObjectAllTypes());
    list.add(list.get(0));

    GridBinaryTestClasses.TestObjectContainer c =
        new GridBinaryTestClasses.TestObjectContainer(list);

    BinaryObjectBuilderImpl builder = builder(toBinary(c));
    builder.<List>getField("foo").add("!!!");

    BinaryObject res = builder.build();

    GridBinaryTestClasses.TestObjectContainer deserialized = res.deserialize();

    List deserializedList = (List) deserialized.foo;

    assertSame(deserializedList.get(0), deserializedList.get(1));
    assertEquals("!!!", deserializedList.get(2));
    assertTrue(deserializedList.get(0) instanceof GridBinaryTestClasses.TestObjectAllTypes);
  }
  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);
  }