Search in sources :

Example 1 with DataStoreConfigurationProvider

use of com.amplifyframework.datastore.DataStoreConfigurationProvider in project amplify-android by aws-amplify.

the class SyncProcessorTest method initSyncProcessor.

private void initSyncProcessor(int syncMaxRecords) throws AmplifyException {
    SchemaRegistry schemaRegistry = SchemaRegistry.instance();
    schemaRegistry.clear();
    schemaRegistry.register(modelProvider.models());
    InMemoryStorageAdapter inMemoryStorageAdapter = InMemoryStorageAdapter.create();
    this.storageAdapter = SynchronousStorageAdapter.delegatingTo(inMemoryStorageAdapter);
    final SyncTimeRegistry syncTimeRegistry = new SyncTimeRegistry(inMemoryStorageAdapter);
    final MutationOutbox mutationOutbox = new PersistentMutationOutbox(inMemoryStorageAdapter);
    final VersionRepository versionRepository = new VersionRepository(inMemoryStorageAdapter);
    final Merger merger = new Merger(mutationOutbox, versionRepository, inMemoryStorageAdapter);
    DataStoreConfigurationProvider dataStoreConfigurationProvider = () -> DataStoreConfiguration.builder().syncInterval(BASE_SYNC_INTERVAL_MINUTES, TimeUnit.MINUTES).syncMaxRecords(syncMaxRecords).syncPageSize(1_000).errorHandler(dataStoreException -> errorHandlerCallCount++).syncExpression(BlogOwner.class, () -> BlogOwner.NAME.beginsWith("J")).build();
    QueryPredicateProvider queryPredicateProvider = new QueryPredicateProvider(dataStoreConfigurationProvider);
    queryPredicateProvider.resolvePredicates();
    this.syncProcessor = SyncProcessor.builder().modelProvider(modelProvider).schemaRegistry(schemaRegistry).syncTimeRegistry(syncTimeRegistry).appSync(appSync).merger(merger).dataStoreConfigurationProvider(dataStoreConfigurationProvider).queryPredicateProvider(queryPredicateProvider).retryHandler(requestRetry).isSyncRetryEnabled(isSyncRetryEnabled).build();
}
Also used : DataStoreConfigurationProvider(com.amplifyframework.datastore.DataStoreConfigurationProvider) InMemoryStorageAdapter(com.amplifyframework.datastore.storage.InMemoryStorageAdapter) BlogOwner(com.amplifyframework.testmodels.commentsblog.BlogOwner) SchemaRegistry(com.amplifyframework.core.model.SchemaRegistry)

Aggregations

SchemaRegistry (com.amplifyframework.core.model.SchemaRegistry)1 DataStoreConfigurationProvider (com.amplifyframework.datastore.DataStoreConfigurationProvider)1 InMemoryStorageAdapter (com.amplifyframework.datastore.storage.InMemoryStorageAdapter)1 BlogOwner (com.amplifyframework.testmodels.commentsblog.BlogOwner)1