use of com.pushtorefresh.storio.sqlite.Changes in project storio by pushtorefresh.
the class ObserveChangesTest method updateEmission.
@Test
public void updateEmission() {
final List<User> users = putUsersBlocking(10);
final List<User> updated = new ArrayList<User>(users.size());
for (User user : users) {
updated.add(User.newInstance(user.id(), user.email()));
}
final Queue<Changes> expectedChanges = new LinkedList<Changes>();
expectedChanges.add(Changes.newInstance(UserTableMeta.TABLE));
final EmissionChecker emissionChecker = new EmissionChecker(expectedChanges);
final Subscription subscription = emissionChecker.subscribe();
storIOSQLite.put().objects(updated).prepare().executeAsBlocking();
// Should receive changes of Users table
emissionChecker.awaitNextExpectedValue();
emissionChecker.assertThatNoExpectedValuesLeft();
subscription.unsubscribe();
}
use of com.pushtorefresh.storio.sqlite.Changes in project storio by pushtorefresh.
the class DefaultStorIOSQLiteTest method observeChangesAndNotifyAboutChangesShouldWorkCorrectly.
@Test
public void observeChangesAndNotifyAboutChangesShouldWorkCorrectly() {
SQLiteOpenHelper sqLiteOpenHelper = mock(SQLiteOpenHelper.class);
StorIOSQLite storIOSQLite = DefaultStorIOSQLite.builder().sqliteOpenHelper(sqLiteOpenHelper).build();
TestSubscriber<Changes> testSubscriber = new TestSubscriber<Changes>();
storIOSQLite.observeChanges().subscribe(testSubscriber);
testSubscriber.assertNoValues();
Changes changes = Changes.newInstance("test_table");
storIOSQLite.lowLevel().notifyAboutChanges(changes);
testSubscriber.assertValue(changes);
testSubscriber.assertNoErrors();
testSubscriber.unsubscribe();
}
Aggregations