use of com.amplifyframework.datastore.storage.InMemoryStorageAdapter in project amplify-android by aws-amplify.
the class PersistentMutationOutboxTest method setup.
/**
* Set up the object under test.
* @throws AmplifyException on failure to build schema
*/
@Before
public void setup() throws AmplifyException {
schema = ModelSchema.fromModelClass(BlogOwner.class);
InMemoryStorageAdapter inMemoryStorageAdapter = InMemoryStorageAdapter.create();
storage = SynchronousStorageAdapter.delegatingTo(inMemoryStorageAdapter);
mutationQueue = new MutationQueue();
mutationOutbox = new PersistentMutationOutbox(inMemoryStorageAdapter, mutationQueue);
converter = new GsonPendingMutationConverter();
}
use of com.amplifyframework.datastore.storage.InMemoryStorageAdapter 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();
}
use of com.amplifyframework.datastore.storage.InMemoryStorageAdapter in project amplify-android by aws-amplify.
the class VersionRepositoryTest method setup.
/**
* Sets up the test. A {@link VersionRepository} is tested with respect to the varying
* state of its dependency, the {@link InMemoryStorageAdapter}.
*
* An {@link InMemoryStorageAdapter} is used as a test fake. Versions can be arranged into
* it, and validated against it. To facilitate that arrangement, an {@link SynchronousStorageAdapter}
* utility is used to wrap the {@link InMemoryStorageAdapter}.
*/
@Before
public void setup() {
InMemoryStorageAdapter inMemoryStorageAdapter = InMemoryStorageAdapter.create();
this.storageAdapter = SynchronousStorageAdapter.delegatingTo(inMemoryStorageAdapter);
this.versionRepository = new VersionRepository(inMemoryStorageAdapter);
}
Aggregations