Search in sources :

Example 1 with TypeMappingFinder

use of com.pushtorefresh.storio3.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.storio3.TypeMappingFinder) Nullable(android.support.annotation.Nullable)

Example 2 with TypeMappingFinder

use of com.pushtorefresh.storio3.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.storio3.internal.TypeMappingFinderImpl) TypeMappingFinder(com.pushtorefresh.storio3.TypeMappingFinder) GetResolver(com.pushtorefresh.storio3.contentresolver.operations.get.GetResolver) StorIOContentResolver(com.pushtorefresh.storio3.contentresolver.StorIOContentResolver) Test(org.junit.Test)

Example 3 with TypeMappingFinder

use of com.pushtorefresh.storio3.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.storio3.internal.TypeMappingFinderImpl) TypeMappingFinder(com.pushtorefresh.storio3.TypeMappingFinder) 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 4 with TypeMappingFinder

use of com.pushtorefresh.storio3.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(sqLiteOpenHelper).typeMappingFinder(typeMappingFinder).addTypeMapping(ClassEntity.class, typeMapping).build();
    assertThat(storIOSQLite.lowLevel().typeMapping(ClassEntity.class)).isEqualTo(typeMapping);
}
Also used : TypeMappingFinderImpl(com.pushtorefresh.storio3.internal.TypeMappingFinderImpl) TypeMappingFinder(com.pushtorefresh.storio3.TypeMappingFinder) GetResolver(com.pushtorefresh.storio3.sqlite.operations.get.GetResolver) Test(org.junit.Test)

Example 5 with TypeMappingFinder

use of com.pushtorefresh.storio3.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.storio3.TypeMappingFinder) Nullable(android.support.annotation.Nullable)

Aggregations

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