Search in sources :

Example 6 with TypeMappingFinder

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

the class DefaultStorIOContentResolverTest method typeMappingShouldWorkForMultipleTypes.

@Test
public void typeMappingShouldWorkForMultipleTypes() {
    class AnotherEntity {
    }
    TypeMappingFinder typeMappingFinder = new TypeMappingFinderImpl();
    //noinspection unchecked
    ContentResolverTypeMapping<ClassEntity> typeMapping = ContentResolverTypeMapping.builder().putResolver(mock(PutResolver.class)).getResolver(mock(GetResolver.class)).deleteResolver(mock(DeleteResolver.class)).build();
    //noinspection unchecked
    ContentResolverTypeMapping<AnotherEntity> anotherMapping = 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).addTypeMapping(AnotherEntity.class, anotherMapping).build();
    assertThat(storIOContentResolver.lowLevel().typeMapping(ClassEntity.class)).isEqualTo(typeMapping);
    assertThat(storIOContentResolver.lowLevel().typeMapping(AnotherEntity.class)).isEqualTo(anotherMapping);
}
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) ContentResolver(android.content.ContentResolver) StorIOContentResolver(com.pushtorefresh.storio.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Example 7 with TypeMappingFinder

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

the class DefaultStorIOSQLiteTest method typeMappingShouldWorkWithSpecifiedTypeMappingFinder.

@Test
public void typeMappingShouldWorkWithSpecifiedTypeMappingFinder() {
    TypeMappingFinder typeMappingFinder = new TypeMappingFinderImpl();
    //noinspection unchecked
    SQLiteTypeMapping<ClassEntity> typeMapping = SQLiteTypeMapping.builder().putResolver(mock(PutResolver.class)).getResolver(mock(GetResolver.class)).deleteResolver(mock(DeleteResolver.class)).build();
    DefaultStorIOSQLite storIOSQLite = DefaultStorIOSQLite.builder().sqliteOpenHelper(mock(SQLiteOpenHelper.class)).typeMappingFinder(typeMappingFinder).addTypeMapping(ClassEntity.class, typeMapping).build();
    assertThat(storIOSQLite.lowLevel().typeMapping(ClassEntity.class)).isEqualTo(typeMapping);
}
Also used : TypeMappingFinderImpl(com.pushtorefresh.storio.internal.TypeMappingFinderImpl) TypeMappingFinder(com.pushtorefresh.storio.TypeMappingFinder) GetResolver(com.pushtorefresh.storio.sqlite.operations.get.GetResolver) Test(org.junit.Test)

Example 8 with TypeMappingFinder

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

the class DefaultStorIOSQLiteTest method getTypeMappingFinder.

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

Example 9 with TypeMappingFinder

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

the class DefaultStorIOSQLiteTest method deprecatedInternalImplShouldReturnSentToConstructorTypeMapping.

@Test
public void deprecatedInternalImplShouldReturnSentToConstructorTypeMapping() throws NoSuchFieldException, IllegalAccessException {
    TypeMappingFinder typeMappingFinder = mock(TypeMappingFinder.class);
    TestDefaultStorIOSQLite storIOSQLite = new TestDefaultStorIOSQLite(mock(SQLiteOpenHelper.class), typeMappingFinder);
    assertThat(storIOSQLite.typeMappingFinder()).isSameAs(typeMappingFinder);
}
Also used : SQLiteOpenHelper(android.database.sqlite.SQLiteOpenHelper) TypeMappingFinder(com.pushtorefresh.storio.TypeMappingFinder) 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