Search in sources :

Example 1 with InMemoryStorageAdapter

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();
}
Also used : InMemoryStorageAdapter(com.amplifyframework.datastore.storage.InMemoryStorageAdapter) BlogOwner(com.amplifyframework.testmodels.commentsblog.BlogOwner) Before(org.junit.Before)

Example 2 with InMemoryStorageAdapter

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

Example 3 with InMemoryStorageAdapter

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);
}
Also used : InMemoryStorageAdapter(com.amplifyframework.datastore.storage.InMemoryStorageAdapter) Before(org.junit.Before)

Aggregations

InMemoryStorageAdapter (com.amplifyframework.datastore.storage.InMemoryStorageAdapter)3 BlogOwner (com.amplifyframework.testmodels.commentsblog.BlogOwner)2 Before (org.junit.Before)2 SchemaRegistry (com.amplifyframework.core.model.SchemaRegistry)1 DataStoreConfigurationProvider (com.amplifyframework.datastore.DataStoreConfigurationProvider)1