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();
}
Aggregations