Search in sources :

Example 56 with AllTypes

use of io.realm.entities.AllTypes in project realm-java by realm.

the class RealmJsonTests method createObjectFromJson_streamDecimal128AsDouble.

@Test
public void createObjectFromJson_streamDecimal128AsDouble() throws IOException {
    assumeThat(Build.VERSION.SDK_INT, greaterThanOrEqualTo(Build.VERSION_CODES.HONEYCOMB));
    InputStream in = TestHelper.loadJsonFromAssets(context, "decimal128_as_double.json");
    realm.beginTransaction();
    realm.createObjectFromJson(AllTypes.class, in);
    realm.commitTransaction();
    in.close();
    AllTypes obj = realm.where(AllTypes.class).findFirst();
    assertEquals(Decimal128.parse("0.30000001192092896"), obj.getColumnDecimal128());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) AllTypes(io.realm.entities.AllTypes) Test(org.junit.Test)

Example 57 with AllTypes

use of io.realm.entities.AllTypes in project realm-java by realm.

the class OrderedRealmCollectionSnapshotTests method populateRealm.

private void populateRealm(Realm realm, int testSize) {
    realm.beginTransaction();
    for (int i = 0; i < testSize; i++) {
        AllTypes allTypes = realm.createObject(AllTypes.class);
        allTypes.setColumnLong(i);
    }
    realm.commitTransaction();
}
Also used : AllTypes(io.realm.entities.AllTypes)

Example 58 with AllTypes

use of io.realm.entities.AllTypes in project realm-java by realm.

the class RealmJsonTests method createObjectFromJson_decimal128AsInt.

@Test
public void createObjectFromJson_decimal128AsInt() throws JSONException {
    JSONObject json = new JSONObject();
    json.put("columnDecimal128", -42);
    realm.beginTransaction();
    realm.createObjectFromJson(AllTypes.class, json);
    realm.commitTransaction();
    AllTypes obj = realm.where(AllTypes.class).findFirst();
    assertEquals(new Decimal128(-42), obj.getColumnDecimal128());
}
Also used : JSONObject(org.json.JSONObject) AllTypes(io.realm.entities.AllTypes) Decimal128(org.bson.types.Decimal128) Test(org.junit.Test)

Example 59 with AllTypes

use of io.realm.entities.AllTypes in project realm-java by realm.

the class RealmListTests method set_managedObjectInUnmanagedMode.

@Test
public void set_managedObjectInUnmanagedMode() {
    RealmList<AllTypes> list = new RealmList<AllTypes>();
    list.add(new AllTypes());
    realm.beginTransaction();
    AllTypes managedAllTypes = realm.createObject(AllTypes.class);
    realm.commitTransaction();
    list.set(0, managedAllTypes);
    assertEquals(managedAllTypes, list.get(0));
}
Also used : AllTypes(io.realm.entities.AllTypes) Test(org.junit.Test)

Example 60 with AllTypes

use of io.realm.entities.AllTypes in project realm-java by realm.

the class RealmTests method copyFromRealm_list_invalidListThrows.

@Test
public void copyFromRealm_list_invalidListThrows() {
    realm.beginTransaction();
    AllTypes object = realm.createObject(AllTypes.class);
    List<AllTypes> list = new RealmList<AllTypes>(object);
    object.deleteFromRealm();
    realm.commitTransaction();
    thrown.expect(IllegalArgumentException.class);
    realm.copyFromRealm(list);
}
Also used : AllTypes(io.realm.entities.AllTypes) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

AllTypes (io.realm.entities.AllTypes)225 Test (org.junit.Test)210 RunTestInLooperThread (io.realm.rule.RunTestInLooperThread)70 UiThreadTest (androidx.test.annotation.UiThreadTest)54 Date (java.util.Date)36 DictionaryAllTypes (io.realm.entities.DictionaryAllTypes)32 Dog (io.realm.entities.Dog)27 JSONObject (org.json.JSONObject)26 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)22 RunInLooperThread (io.realm.rule.RunInLooperThread)20 InputStream (java.io.InputStream)19 Decimal128 (org.bson.types.Decimal128)19 ByteArrayInputStream (java.io.ByteArrayInputStream)17 ObjectId (org.bson.types.ObjectId)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 UiThreadTest (android.support.test.annotation.UiThreadTest)10 AtomicLong (java.util.concurrent.atomic.AtomicLong)10 OsSharedRealm (io.realm.internal.OsSharedRealm)9 BigDecimal (java.math.BigDecimal)9 NonLatinFieldNames (io.realm.entities.NonLatinFieldNames)8