Source:
public void insertToRealm() { Date date = new Date(); Dog dog = new Dog(); dog.setName("Fido"); RealmList<Dog> list = new RealmList<Dog>(); list.add(dog); AllTypes allTypes = new AllTypes(); allTypes.setColumnString("String"); allTypes.setColumnLong(1l); allTypes.setColumnFloat(1f); allTypes.setColumnDouble(1d); allTypes.setColumnBoolean(true); allTypes.setColumnDate(date); allTypes.setColumnBinary(new byte[]{1, 2, 3}); allTypes.setColumnRealmObject(dog); allTypes.setColumnRealmList(list); realm.beginTransaction(); realm.insertToRealm(allTypes); realm.commitTransaction(); AllTypes realmTypes = realm.where(AllTypes.class).findFirst(); assertNotSame(allTypes, realmTypes); assertEquals(allTypes.getColumnString(), realmTypes.getColumnString()); assertEquals(allTypes.getColumnLong(), realmTypes.getColumnLong()); assertEquals(allTypes.getColumnFloat(), realmTypes.getColumnFloat(), 0); assertEquals(allTypes.getColumnDouble(), realmTypes.getColumnDouble(), 0); assertEquals(allTypes.isColumnBoolean(), realmTypes.isColumnBoolean()); assertEquals(allTypes.getColumnDate(), realmTypes.getColumnDate()); assertArrayEquals(allTypes.getColumnBinary(), realmTypes.getColumnBinary()); assertEquals(allTypes.getColumnRealmObject().getName(), dog.getName()); assertEquals(list.size(), realmTypes.getColumnRealmList().size()); assertEquals(list.get(0).getName(), realmTypes.getColumnRealmList().get(0).getName()); assertEquals(1, realm.where(Dog.class).findAll().size()); }

Target:
public void insertToRealm() { AllJavaTypes obj = new AllJavaTypes(); obj.setFieldIgnored("cookie"); obj.setFieldLong(42); obj.setFieldString("obj1"); RealmList<AllJavaTypes> list = new RealmList<AllJavaTypes>(); list.add(obj); Date date = new Date(); AllJavaTypes allTypes = new AllJavaTypes(); allTypes.setFieldString("String"); allTypes.setFieldLong(1l); allTypes.setFieldFloat(1f); allTypes.setFieldDouble(1d); allTypes.setFieldBoolean(true); allTypes.setFieldDate(date); allTypes.setFieldBinary(new byte[]{1, 2, 3}); allTypes.setFieldObject(obj); allTypes.setFieldList(list); realm.beginTransaction(); realm.insert(allTypes); realm.commitTransaction(); AllJavaTypes realmTypes = realm.where(AllJavaTypes.class).findFirst(); assertNotSame(allTypes, realmTypes); assertEquals(allTypes.getFieldString(), realmTypes.getFieldString()); assertEquals(allTypes.getFieldLong(), realmTypes.getFieldLong()); assertEquals(allTypes.getFieldFloat(), realmTypes.getFieldFloat(), 0); assertEquals(allTypes.getFieldDouble(), realmTypes.getFieldDouble(), 0); assertEquals(allTypes.isFieldBoolean(), realmTypes.isFieldBoolean()); assertEquals(allTypes.getFieldDate(), realmTypes.getFieldDate()); assertArrayEquals(allTypes.getFieldBinary(), realmTypes.getFieldBinary()); assertEquals(allTypes.getFieldObject().getFieldString(), obj.getFieldString()); assertEquals(list.size(), realmTypes.getFieldList().size()); assertEquals(list.get(0).getFieldString(), realmTypes.getFieldList().get(0).getFieldString()); assertEquals(list.get(0).getFieldLong(), realmTypes.getFieldList().get(0).getFieldLong()); assertNull(realmTypes.getFieldList().get(0).getFieldIgnored()); assertEquals(2, realm.where(AllJavaTypes.class).findAll().size()); }