Search in sources :

Example 16 with StorIOContentResolver

use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.

the class DefaultStorIOContentResolverTest method typeMappingShouldWorkWithoutSpecifiedTypeMappingFinder.

@Test
public void typeMappingShouldWorkWithoutSpecifiedTypeMappingFinder() {
    // noinspection unchecked
    ContentResolverTypeMapping<ClassEntity> typeMapping = ContentResolverTypeMapping.builder().putResolver(mock(PutResolver.class)).getResolver(mock(GetResolver.class)).deleteResolver(mock(DeleteResolver.class)).build();
    StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(mock(ContentResolver.class)).addTypeMapping(ClassEntity.class, typeMapping).build();
    assertThat(storIOContentResolver.lowLevel().typeMapping(ClassEntity.class)).isEqualTo(typeMapping);
}
Also used : GetResolver(com.pushtorefresh.storio3.contentresolver.operations.get.GetResolver) StorIOContentResolver(com.pushtorefresh.storio3.contentresolver.StorIOContentResolver) StorIOContentResolver(com.pushtorefresh.storio3.contentresolver.StorIOContentResolver) ContentResolver(android.content.ContentResolver) Test(org.junit.Test)

Example 17 with StorIOContentResolver

use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.

the class DefaultStorIOContentResolverTest method defaultSchedulerReturnsIOSchedulerIfNotSpecified.

@Test
public void defaultSchedulerReturnsIOSchedulerIfNotSpecified() {
    StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(mock(ContentResolver.class)).build();
    assertThat(storIOContentResolver.defaultRxScheduler()).isSameAs(Schedulers.io());
}
Also used : StorIOContentResolver(com.pushtorefresh.storio3.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Example 18 with StorIOContentResolver

use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.

the class RxJavaUtils method createCompletable.

@CheckResult
@NonNull
public static <Result, Data> Completable createCompletable(@NonNull StorIOContentResolver storIOContentResolver, @NonNull PreparedCompletableOperation<Result, Data> operation) {
    throwExceptionIfRxJava2IsNotAvailable("asRxCompletable()");
    final Completable completable = Completable.create(new CompletableOnSubscribeExecuteAsBlocking(operation));
    return subscribeOn(storIOContentResolver, completable);
}
Also used : Completable(io.reactivex.Completable) CompletableOnSubscribeExecuteAsBlocking(com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking) CheckResult(android.support.annotation.CheckResult) NonNull(android.support.annotation.NonNull)

Example 19 with StorIOContentResolver

use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.

the class DefaultDeleteResolver method performDelete.

/**
 * {@inheritDoc}
 */
@NonNull
@Override
public DeleteResult performDelete(@NonNull StorIOContentResolver storIOContentResolver, @NonNull T object) {
    final DeleteQuery deleteQuery = mapToDeleteQuery(object);
    final int numberOfRowsDeleted = storIOContentResolver.lowLevel().delete(deleteQuery);
    return DeleteResult.newInstance(numberOfRowsDeleted, deleteQuery.uri());
}
Also used : DeleteQuery(com.pushtorefresh.storio3.contentresolver.queries.DeleteQuery) NonNull(android.support.annotation.NonNull)

Example 20 with StorIOContentResolver

use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.

the class DefaultStorIOContentResolverTest method shouldUseSpecifiedTypeMappingFinder.

@Test
public void shouldUseSpecifiedTypeMappingFinder() throws NoSuchFieldException, IllegalAccessException {
    TypeMappingFinder typeMappingFinder = mock(TypeMappingFinder.class);
    DefaultStorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(mock(ContentResolver.class)).typeMappingFinder(typeMappingFinder).build();
    assertThat(getTypeMappingFinder(storIOContentResolver)).isEqualTo(typeMappingFinder);
}
Also used : TypeMappingFinder(com.pushtorefresh.storio3.TypeMappingFinder) StorIOContentResolver(com.pushtorefresh.storio3.contentresolver.StorIOContentResolver) ContentResolver(android.content.ContentResolver) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)31 StorIOContentResolver (com.pushtorefresh.storio3.contentresolver.StorIOContentResolver)23 Query (com.pushtorefresh.storio3.contentresolver.queries.Query)11 ContentResolver (android.content.ContentResolver)9 NonNull (android.support.annotation.NonNull)9 ContentValues (android.content.ContentValues)8 Cursor (android.database.Cursor)7 Uri (android.net.Uri)7 DeleteQuery (com.pushtorefresh.storio3.contentresolver.queries.DeleteQuery)6 TypeMappingFinder (com.pushtorefresh.storio3.TypeMappingFinder)5 InsertQuery (com.pushtorefresh.storio3.contentresolver.queries.InsertQuery)5 UpdateQuery (com.pushtorefresh.storio3.contentresolver.queries.UpdateQuery)5 DeleteResult (com.pushtorefresh.storio3.contentresolver.operations.delete.DeleteResult)4 PutResult (com.pushtorefresh.storio3.contentresolver.operations.put.PutResult)4 StorIOException (com.pushtorefresh.storio3.StorIOException)3 GetResolver (com.pushtorefresh.storio3.contentresolver.operations.get.GetResolver)3 Handler (android.os.Handler)2 TypeMappingFinderImpl (com.pushtorefresh.storio3.internal.TypeMappingFinderImpl)2 Completable (io.reactivex.Completable)2 ContentObserver (android.database.ContentObserver)1