use of com.pushtorefresh.storio.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class DeleteOperationTest method deleteByQueryAsSingle.
@Test
public void deleteByQueryAsSingle() {
TestSubscriber<Changes> changesTestSubscriber = new TestSubscriber<Changes>();
storIOContentResolver.observeChangesOfUri(TestItem.CONTENT_URI).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);
BlockingSingle<DeleteResult> deleteResult = storIOContentResolver.delete().byQuery(DeleteQuery.builder().uri(TestItem.CONTENT_URI).build()).prepare().asRxSingle().toBlocking();
assertThat(deleteResult.value().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.storio.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class DeleteOperationDesignTest method deleteByQueryBlocking.
@Test
public void deleteByQueryBlocking() {
final DeleteQuery deleteQuery = DeleteQuery.builder().uri(mock(Uri.class)).where("some_field = ?").whereArgs("someValue").build();
DeleteResult deleteResult = storIOContentResolver().delete().byQuery(deleteQuery).prepare().executeAsBlocking();
}
use of com.pushtorefresh.storio.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class DeleteOperationDesignTest method deleteObjectBlocking.
@Test
public void deleteObjectBlocking() {
Article article = mock(Article.class);
DeleteResult deleteResult = storIOContentResolver().delete().object(article).withDeleteResolver(ArticleMeta.DELETE_RESOLVER).prepare().executeAsBlocking();
}
use of com.pushtorefresh.storio.contentresolver.operations.delete.DeleteResult in project storio by pushtorefresh.
the class DeleteOperationTest method deleteByQueryExecuteAsBlocking.
@Test
public void deleteByQueryExecuteAsBlocking() {
TestSubscriber<Changes> changesTestSubscriber = new TestSubscriber<Changes>();
storIOContentResolver.observeChangesOfUri(TestItem.CONTENT_URI).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);
DeleteResult deleteResult = storIOContentResolver.delete().byQuery(DeleteQuery.builder().uri(TestItem.CONTENT_URI).build()).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.storio.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).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);
BlockingSingle<DeleteResult> deleteResult = storIOContentResolver.delete().object(testItem).prepare().asRxSingle().toBlocking();
assertThat(deleteResult.value().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