Search in sources :

Example 1 with TypeMappingFinder

use of com.pushtorefresh.storio.TypeMappingFinder 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.storio.TypeMappingFinder) ContentResolver(android.content.ContentResolver) StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Example 2 with TypeMappingFinder

use of com.pushtorefresh.storio.TypeMappingFinder in project storio by pushtorefresh.

the class DefaultStorIOContentResolverTest method getTypeMappingFinder.

@Nullable
private static TypeMappingFinder getTypeMappingFinder(@NonNull DefaultStorIOContentResolver storIOContentResolver) throws NoSuchFieldException, IllegalAccessException {
    Field field = DefaultStorIOContentResolver.LowLevelImpl.class.getDeclaredField("typeMappingFinder");
    field.setAccessible(true);
    return (TypeMappingFinder) field.get(storIOContentResolver.lowLevel());
}
Also used : Field(java.lang.reflect.Field) TypeMappingFinder(com.pushtorefresh.storio.TypeMappingFinder) Nullable(android.support.annotation.Nullable)

Example 3 with TypeMappingFinder

use of com.pushtorefresh.storio.TypeMappingFinder in project storio by pushtorefresh.

the class DefaultStorIOContentResolverTest method typeMappingShouldWorkWithSpecifiedTypeMappingFinder.

@Test
public void typeMappingShouldWorkWithSpecifiedTypeMappingFinder() {
    TypeMappingFinder typeMappingFinder = new TypeMappingFinderImpl();
    //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)).typeMappingFinder(typeMappingFinder).addTypeMapping(ClassEntity.class, typeMapping).build();
    assertThat(storIOContentResolver.lowLevel().typeMapping(ClassEntity.class)).isEqualTo(typeMapping);
}
Also used : TypeMappingFinderImpl(com.pushtorefresh.storio.internal.TypeMappingFinderImpl) TypeMappingFinder(com.pushtorefresh.storio.TypeMappingFinder) GetResolver(com.pushtorefresh.storio.contentresolver.operations.get.GetResolver) StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Example 4 with TypeMappingFinder

use of com.pushtorefresh.storio.TypeMappingFinder in project storio by pushtorefresh.

the class DefaultStorIOSQLiteTest method shouldUseSpecifiedTypeMappingFinder.

@Test
public void shouldUseSpecifiedTypeMappingFinder() throws NoSuchFieldException, IllegalAccessException {
    TypeMappingFinder typeMappingFinder = mock(TypeMappingFinder.class);
    DefaultStorIOSQLite storIOSQLite = DefaultStorIOSQLite.builder().sqliteOpenHelper(mock(SQLiteOpenHelper.class)).typeMappingFinder(typeMappingFinder).build();
    assertThat(getTypeMappingFinder(storIOSQLite)).isEqualTo(typeMappingFinder);
}
Also used : SQLiteOpenHelper(android.database.sqlite.SQLiteOpenHelper) TypeMappingFinder(com.pushtorefresh.storio.TypeMappingFinder) Test(org.junit.Test)

Example 5 with TypeMappingFinder

use of com.pushtorefresh.storio.TypeMappingFinder in project storio by pushtorefresh.

the class DefaultStorIOContentResolverTest method deprecatedInternalImplShouldReturnSentToConstructorTypeMapping.

@Test
public void deprecatedInternalImplShouldReturnSentToConstructorTypeMapping() throws NoSuchFieldException, IllegalAccessException {
    ContentResolver contentResolver = mock(ContentResolver.class);
    TypeMappingFinder typeMappingFinder = mock(TypeMappingFinder.class);
    TestDefaultStorIOContentResolver storIOContentResolver = new TestDefaultStorIOContentResolver(contentResolver, mock(Handler.class), typeMappingFinder);
    assertThat(storIOContentResolver.typeMappingFinder()).isSameAs(typeMappingFinder);
}
Also used : TypeMappingFinder(com.pushtorefresh.storio.TypeMappingFinder) Handler(android.os.Handler) ContentResolver(android.content.ContentResolver) StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Aggregations

TypeMappingFinder (com.pushtorefresh.storio.TypeMappingFinder)9 Test (org.junit.Test)7 StorIOContentResolver (com.pushtorefresh.storio.contentresolver.StorIOContentResolver)4 ContentResolver (android.content.ContentResolver)3 TypeMappingFinderImpl (com.pushtorefresh.storio.internal.TypeMappingFinderImpl)3 SQLiteOpenHelper (android.database.sqlite.SQLiteOpenHelper)2 GetResolver (com.pushtorefresh.storio.contentresolver.operations.get.GetResolver)2 Field (java.lang.reflect.Field)2 Handler (android.os.Handler)1 Nullable (android.support.annotation.Nullable)1 GetResolver (com.pushtorefresh.storio.sqlite.operations.get.GetResolver)1 Nullable (javax.annotation.Nullable)1