use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createObjectFromJson_streamDateAsLong.
@Test
public void createObjectFromJson_streamDateAsLong() throws IOException {
assumeThat(Build.VERSION.SDK_INT, greaterThanOrEqualTo(Build.VERSION_CODES.HONEYCOMB));
InputStream in = TestHelper.loadJsonFromAssets(context, "date_as_long.json");
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, in);
realm.commitTransaction();
in.close();
// Checks that all primitive types are imported correctly.
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals(new Date(1000), obj.getColumnDate());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createObjectFromJson_streamDateAsString.
@Test
public void createObjectFromJson_streamDateAsString() throws IOException {
assumeThat(Build.VERSION.SDK_INT, greaterThanOrEqualTo(Build.VERSION_CODES.HONEYCOMB));
InputStream in = TestHelper.loadJsonFromAssets(context, "date_as_string.json");
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, in);
realm.commitTransaction();
in.close();
// Checks that all primitive types are imported correctly.
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals(new Date(1000), obj.getColumnDate());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createObjectFromJson_decimal128AsLong.
@Test
public void createObjectFromJson_decimal128AsLong() throws JSONException {
JSONObject json = new JSONObject();
json.put("columnDecimal128", -32361122672259149L);
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, json);
realm.commitTransaction();
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals(new Decimal128(-32361122672259149L), obj.getColumnDecimal128());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createObjectFromJson_childObject.
@Test
public void createObjectFromJson_childObject() throws JSONException {
JSONObject allTypesObject = new JSONObject();
JSONObject dogObject = new JSONObject();
dogObject.put("name", "Fido");
allTypesObject.put("columnRealmObject", dogObject);
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, allTypesObject);
realm.commitTransaction();
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals("Fido", obj.getColumnRealmObject().getName());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createObjectFromJson_streamObjectIdAsString.
@Test
public void createObjectFromJson_streamObjectIdAsString() throws IOException {
assumeThat(Build.VERSION.SDK_INT, greaterThanOrEqualTo(Build.VERSION_CODES.HONEYCOMB));
InputStream in = TestHelper.loadJsonFromAssets(context, "objectid_as_string.json");
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, in);
realm.commitTransaction();
in.close();
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals(new ObjectId("789ABCDEF0123456789ABCDE"), obj.getColumnObjectId());
}
Aggregations