use of com.pushtorefresh.storio3.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class DeleteOperationDesignTest method deleteObjectBlocking.
@Test
public void deleteObjectBlocking() {
User user = newUser();
DeleteResult deleteResult = storIOSQLite().delete().object(user).withDeleteResolver(UserTableMeta.DELETE_RESOLVER).prepare().executeAsBlocking();
}
use of com.pushtorefresh.storio3.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class BaseTest method deleteUserBlocking.
@NonNull
DeleteResult deleteUserBlocking(@NonNull final User user) {
final DeleteResult deleteResult = storIOSQLite.delete().object(user).prepare().executeAsBlocking();
assertThat(deleteResult.numberOfRowsDeleted()).isEqualTo(1);
return deleteResult;
}
use of com.pushtorefresh.storio3.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class DefaultDeleteResolver method performDelete.
/**
* {@inheritDoc}
*/
@NonNull
@Override
public DeleteResult performDelete(@NonNull StorIOSQLite storIOSQLite, @NonNull T object) {
final DeleteQuery deleteQuery = mapToDeleteQuery(object);
final int numberOfRowsDeleted = storIOSQLite.lowLevel().delete(deleteQuery);
return DeleteResult.newInstance(numberOfRowsDeleted, deleteQuery.table(), deleteQuery.affectsTags());
}
use of com.pushtorefresh.storio3.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class DeleteOperationTest method deleteObjectExecuteAsBlocking.
@Test
public void deleteObjectExecuteAsBlocking() {
TestSubscriber<Changes> changesTestSubscriber = new TestSubscriber<Changes>();
storIOContentResolver.observeChangesOfUri(TestItem.CONTENT_URI, BackpressureStrategy.MISSING).take(2).subscribe(changesTestSubscriber);
TestItem testItemToInsert = TestItem.create(null, "value");
contentResolver.insert(TestItem.CONTENT_URI, testItemToInsert.toContentValues());
Cursor firstDbState = contentResolver.query(TestItem.CONTENT_URI, null, null, null, null);
Assertions.assertThat(firstDbState).hasCount(1);
// noinspection ConstantConditions
assertThat(firstDbState.moveToFirst()).isTrue();
TestItem testItem = TestItem.fromCursor(firstDbState);
DeleteResult deleteResult = storIOContentResolver.delete().object(testItem).prepare().executeAsBlocking();
assertThat(deleteResult.numberOfRowsDeleted()).isEqualTo(1);
Cursor secondDbState = contentResolver.query(TestItem.CONTENT_URI, null, null, null, null);
Assertions.assertThat(secondDbState).hasCount(0);
changesTestSubscriber.awaitTerminalEvent(60, SECONDS);
changesTestSubscriber.assertNoErrors();
changesTestSubscriber.assertValues(Changes.newInstance(TestItem.CONTENT_URI), Changes.newInstance(TestItem.CONTENT_URI));
}
use of com.pushtorefresh.storio3.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class DeleteOperationTest method deleteObjectAsSingle.
@Test
public void deleteObjectAsSingle() {
TestSubscriber<Changes> changesTestSubscriber = new TestSubscriber<Changes>();
storIOContentResolver.observeChangesOfUri(TestItem.CONTENT_URI, BackpressureStrategy.MISSING).take(2).subscribe(changesTestSubscriber);
TestItem testItemToInsert = TestItem.create(null, "value");
contentResolver.insert(TestItem.CONTENT_URI, testItemToInsert.toContentValues());
Cursor firstDbState = contentResolver.query(TestItem.CONTENT_URI, null, null, null, null);
Assertions.assertThat(firstDbState).hasCount(1);
// noinspection ConstantConditions
assertThat(firstDbState.moveToFirst()).isTrue();
TestItem testItem = TestItem.fromCursor(firstDbState);
DeleteResult deleteResult = storIOContentResolver.delete().object(testItem).prepare().asRxSingle().blockingGet();
assertThat(deleteResult.numberOfRowsDeleted()).isEqualTo(1);
Cursor secondDbState = contentResolver.query(TestItem.CONTENT_URI, null, null, null, null);
Assertions.assertThat(secondDbState).hasCount(0);
changesTestSubscriber.awaitTerminalEvent(60, SECONDS);
changesTestSubscriber.assertNoErrors();
changesTestSubscriber.assertValues(Changes.newInstance(TestItem.CONTENT_URI), Changes.newInstance(TestItem.CONTENT_URI));
}
Aggregations