use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createObjectFromJson_dateAsString.
@Test
public void createObjectFromJson_dateAsString() throws JSONException {
JSONObject json = new JSONObject();
json.put("columnDate", "/Date(1000)/");
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, json);
realm.commitTransaction();
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_streamDecimal128AsInt.
@Test
public void createObjectFromJson_streamDecimal128AsInt() throws IOException {
assumeThat(Build.VERSION.SDK_INT, greaterThanOrEqualTo(Build.VERSION_CODES.HONEYCOMB));
InputStream in = TestHelper.loadJsonFromAssets(context, "decimal128_as_int.json");
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, in);
realm.commitTransaction();
in.close();
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals(new Decimal128(-42), obj.getColumnDecimal128());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createObjectFromJson_realmAnyAsString.
@Test
public void createObjectFromJson_realmAnyAsString() throws JSONException {
JSONObject json = new JSONObject();
String aString = "027ba5ca-aa12-4afa-9219-e20cc3018599";
json.put("columnRealmAny", aString);
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, json);
realm.commitTransaction();
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals(RealmAny.valueOf(aString), obj.getColumnRealmAny());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createObjectFromJson_objectIdAsString.
@Test
public void createObjectFromJson_objectIdAsString() throws JSONException {
JSONObject json = new JSONObject();
String idHex = TestHelper.generateObjectIdHexString(7);
json.put("columnObjectId", idHex);
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, json);
realm.commitTransaction();
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals(new ObjectId(idHex), obj.getColumnObjectId());
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmJsonTests method createUsingJsonStream_decimal128.
@Test
public void createUsingJsonStream_decimal128() throws JSONException {
JSONObject json = new JSONObject();
json.put("columnDecimal128", new Decimal128(BigDecimal.TEN));
realm.beginTransaction();
realm.createObjectFromJson(AllTypes.class, json);
realm.commitTransaction();
AllTypes obj = realm.where(AllTypes.class).findFirst();
assertEquals(new Decimal128(BigDecimal.TEN), obj.getColumnDecimal128());
}
Aggregations