use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmObjectTests method changeListener_triggeredWhenObjectIsdeleted.
@Test
@RunTestInLooperThread
public void changeListener_triggeredWhenObjectIsdeleted() {
final Realm realm = looperThread.realm;
realm.beginTransaction();
AllTypes obj = realm.createObject(AllTypes.class);
realm.commitTransaction();
obj.addChangeListener(new RealmChangeListener<AllTypes>() {
@Override
public void onChange(AllTypes obj) {
assertFalse(obj.isValid());
looperThread.testComplete();
}
});
realm.beginTransaction();
obj.deleteFromRealm();
realm.commitTransaction();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmQueryBenchmarks method before.
@BeforeExperiment
public void before() {
RealmConfiguration config = new RealmConfiguration.Builder().build();
Realm.deleteRealm(config);
realm = Realm.getInstance(config);
realm.beginTransaction();
for (int i = 0; i < DATA_SIZE; i++) {
AllTypes obj = realm.createObject(AllTypes.class);
obj.setColumnLong(i);
obj.setColumnBoolean(i % 2 == 0);
obj.setColumnString("Foo " + i);
obj.setColumnDouble(i + 1.234D);
}
realm.commitTransaction();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RealmResultsBenchmarks method before.
@BeforeExperiment
public void before() {
Realm.init(InstrumentationRegistry.getTargetContext());
RealmConfiguration config = new RealmConfiguration.Builder().build();
Realm.deleteRealm(config);
realm = Realm.getInstance(config);
realm.beginTransaction();
for (int i = 0; i < DATA_SIZE; i++) {
AllTypes obj = realm.createObject(AllTypes.class);
obj.setColumnLong(i);
obj.setColumnBoolean(i % 2 == 0);
obj.setColumnString("Foo " + i);
obj.setColumnDouble(i + 1.234D);
}
realm.commitTransaction();
results = realm.where(AllTypes.class).findAll();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RxJavaTests method realmResults_emittedOnUpdate.
@Test
@RunTestInLooperThread
public void realmResults_emittedOnUpdate() {
final AtomicInteger subscriberCalled = new AtomicInteger(0);
Realm realm = looperThread.realm;
realm.beginTransaction();
RealmResults<AllTypes> results = realm.where(AllTypes.class).findAll();
realm.commitTransaction();
subscription = results.asObservable().subscribe(new Action1<RealmResults<AllTypes>>() {
@Override
public void call(RealmResults<AllTypes> allTypes) {
if (subscriberCalled.incrementAndGet() == 2) {
looperThread.testComplete();
}
}
});
realm.beginTransaction();
realm.createObject(AllTypes.class);
realm.commitTransaction();
}
use of io.realm.entities.AllTypes in project realm-java by realm.
the class RxJavaTests method realmResults_closeInDoOnUnsubscribe.
@Test
@UiThreadTest
public void realmResults_closeInDoOnUnsubscribe() {
Observable<RealmResults<AllTypes>> observable = realm.where(AllTypes.class).findAll().asObservable().doOnUnsubscribe(new Action0() {
@Override
public void call() {
realm.close();
}
});
subscription = observable.subscribe(new Action1<RealmResults<AllTypes>>() {
@Override
public void call(RealmResults<AllTypes> allTypes) {
}
});
subscription.unsubscribe();
assertTrue(realm.isClosed());
}
Aggregations