use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method defaultRxSchedulerReturnsSpecifiedScheduler.
@Test
public void defaultRxSchedulerReturnsSpecifiedScheduler() {
Scheduler scheduler = mock(Scheduler.class);
StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(mock(ContentResolver.class)).defaultRxScheduler(scheduler).build();
assertThat(storIOContentResolver.defaultRxScheduler()).isSameAs(scheduler);
}
use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class DeleteOperationDesignTest method deleteByQueryFlowable.
@Test
public void deleteByQueryFlowable() {
final DeleteQuery deleteQuery = DeleteQuery.builder().uri(mock(Uri.class)).where("some_field = ?").whereArgs("someValue").build();
Flowable<DeleteResult> deleteResultFlowable = storIOContentResolver().delete().byQuery(deleteQuery).prepare().asRxFlowable(BackpressureStrategy.MISSING);
}
use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class PutOperationDesignTest method putObjectBlocking.
@Test
public void putObjectBlocking() {
Article article = Article.newInstance(null, "test");
PutResult putResult = storIOContentResolver().put().object(article).withPutResolver(ArticleMeta.PUT_RESOLVER).prepare().executeAsBlocking();
}
use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class PutOperationDesignTest method putContentValuesBlocking.
@Test
public void putContentValuesBlocking() {
ContentValues contentValues = mock(ContentValues.class);
PutResult putResult = storIOContentResolver().put().contentValues(contentValues).withPutResolver(putResolverForContentValues).prepare().executeAsBlocking();
}
use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class DefaultPutResolver method performPut.
/**
* {@inheritDoc}
*/
@NonNull
@Override
public PutResult performPut(@NonNull StorIOContentResolver storIOContentResolver, @NonNull T object) {
final UpdateQuery updateQuery = mapToUpdateQuery(object);
final Query query = Query.builder().uri(updateQuery.uri()).where(nullableString(updateQuery.where())).whereArgs((Object[]) nullableArrayOfStringsFromListOfStrings(updateQuery.whereArgs())).build();
final StorIOContentResolver.LowLevel lowLevel = storIOContentResolver.lowLevel();
final Cursor cursor = lowLevel.query(query);
try {
final ContentValues contentValues = mapToContentValues(object);
if (cursor.getCount() == 0) {
final InsertQuery insertQuery = mapToInsertQuery(object);
final Uri insertedUri = lowLevel.insert(insertQuery, contentValues);
return PutResult.newInsertResult(insertedUri, insertQuery.uri());
} else {
final int numberOfRowsUpdated = lowLevel.update(updateQuery, contentValues);
return PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.uri());
}
} finally {
cursor.close();
}
}
Aggregations