use of com.amplifyframework.api.aws.AWSApiPlugin in project amplify-android by aws-amplify.
the class HybridAssociationSyncInstrumentationTest method setup.
/**
* DataStore is configured with a real AppSync endpoint. API and AppSync clients
* are used to arrange/validate state before/after exercising the DataStore. The {@link Amplify}
* facade is intentionally *not* used, since we don't want to pollute the instrumentation
* test process with global state. We need an *instance* of the DataStore.
* @throws AmplifyException On failure to configure Amplify, API/DataStore categories.
*/
@Ignore("It passes. Not automating due to operational concerns as noted in class-level @Ignore.")
@Before
public void setup() throws AmplifyException {
Amplify.addPlugin(new AndroidLoggingPlugin(LogLevel.VERBOSE));
StrictMode.enable();
Context context = getApplicationContext();
@RawRes int configResourceId = Resources.getRawResourceId(context, "amplifyconfiguration");
// Setup an API
CategoryConfiguration apiCategoryConfiguration = AmplifyConfiguration.fromConfigFile(context, configResourceId).forCategoryType(CategoryType.API);
ApiCategory apiCategory = new ApiCategory();
apiCategory.addPlugin(new AWSApiPlugin());
apiCategory.configure(apiCategoryConfiguration, context);
// To arrange and verify state, we need to access the supporting AppSync API
api = SynchronousApi.delegatingTo(apiCategory);
appSync = SynchronousAppSync.using(AppSyncClient.via(apiCategory));
schemaProvider = SchemaLoader.loadFromAssetsDirectory("schemas/commentsblog");
DataStoreCategory dataStoreCategory = DataStoreCategoryConfigurator.begin().api(apiCategory).clearDatabase(true).context(context).modelProvider(schemaProvider).resourceId(configResourceId).timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS).finish();
AWSDataStorePlugin plugin = (AWSDataStorePlugin) dataStoreCategory.getPlugin("awsDataStorePlugin");
normalBehaviors = SynchronousDataStore.delegatingTo(dataStoreCategory);
hybridBehaviors = SynchronousHybridBehaviors.delegatingTo(plugin);
}
use of com.amplifyframework.api.aws.AWSApiPlugin in project amplify-android by aws-amplify.
the class HybridTemporalSyncInstrumentationTest method setup.
/**
* DataStore is configured with a real AppSync endpoint. API and AppSync clients
* are used to arrange/validate state before/after exercising the DataStore. The {@link Amplify}
* facade is intentionally *not* used, since we don't want to pollute the instrumentation
* test process with global state. We need an *instance* of the DataStore.
* @throws AmplifyException On failure to configure Amplify, API/DataStore categories.
*/
@Ignore("It passes. Not automating due to operational concerns as noted in class-level @Ignore.")
@Before
public void setup() throws AmplifyException {
Amplify.addPlugin(new AndroidLoggingPlugin(LogLevel.VERBOSE));
StrictMode.enable();
Context context = getApplicationContext();
@RawRes int configResourceId = Resources.getRawResourceId(context, "amplifyconfiguration");
// Setup an API
CategoryConfiguration apiCategoryConfiguration = AmplifyConfiguration.fromConfigFile(context, configResourceId).forCategoryType(CategoryType.API);
ApiCategory apiCategory = new ApiCategory();
apiCategory.addPlugin(new AWSApiPlugin());
apiCategory.configure(apiCategoryConfiguration, context);
// To arrange and verify state, we need to access the supporting AppSync API
api = SynchronousApi.delegatingTo(apiCategory);
appSync = SynchronousAppSync.using(AppSyncClient.via(apiCategory));
SchemaProvider schemaProvider = SchemaLoader.loadFromAssetsDirectory("schemas/meeting");
DataStoreCategory dataStoreCategory = DataStoreCategoryConfigurator.begin().api(apiCategory).clearDatabase(true).context(context).modelProvider(schemaProvider).resourceId(configResourceId).timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS).finish();
AWSDataStorePlugin plugin = (AWSDataStorePlugin) dataStoreCategory.getPlugin("awsDataStorePlugin");
hybridBehaviors = SynchronousHybridBehaviors.delegatingTo(plugin);
// Get a handle to the Meeting model schema that we loaded into the DataStore in @Before.
String modelName = Meeting.class.getSimpleName();
modelSchema = schemaProvider.modelSchemas().get(modelName);
}
use of com.amplifyframework.api.aws.AWSApiPlugin in project amplify-android by aws-amplify.
the class AppSyncClientInstrumentationTest method onceBeforeTests.
/**
* Configure Amplify for API tests, if it has not been configured, yet.
* @throws AmplifyException From Amplify configuration
*/
@BeforeClass
public static void onceBeforeTests() throws AmplifyException {
Context context = getApplicationContext();
@RawRes int resourceId = Resources.getRawResourceId(context, "amplifyconfiguration");
ApiCategory asyncDelegate = new ApiCategory();
asyncDelegate.addPlugin(new AWSApiPlugin());
asyncDelegate.configure(AmplifyConfiguration.fromConfigFile(context, resourceId).forCategoryType(CategoryType.API), context);
asyncDelegate.initialize(context);
api = AppSyncClient.via(asyncDelegate);
}
use of com.amplifyframework.api.aws.AWSApiPlugin in project amplify-android by aws-amplify.
the class BasicCloudSyncInstrumentationTest method setup.
/**
* Once, before any/all tests in this class, setup miscellaneous dependencies,
* including synchronous API, AppSync, and DataStore interfaces. The API and AppSync instances
* are used to arrange/validate data. The DataStore interface will delegate to an
* {@link AWSDataStorePlugin}, which is the thing we're actually testing.
* @throws AmplifyException On failure to read config, setup API or DataStore categories
*/
@BeforeClass
public static void setup() throws AmplifyException {
Amplify.addPlugin(new AndroidLoggingPlugin(LogLevel.VERBOSE));
StrictMode.enable();
Context context = getApplicationContext();
@RawRes int configResourceId = Resources.getRawResourceId(context, "amplifyconfiguration");
// Setup an API
CategoryConfiguration apiCategoryConfiguration = AmplifyConfiguration.fromConfigFile(context, configResourceId).forCategoryType(CategoryType.API);
ApiCategory apiCategory = new ApiCategory();
apiCategory.addPlugin(new AWSApiPlugin());
apiCategory.configure(apiCategoryConfiguration, context);
// To arrange and verify state, we need to access the supporting AppSync API
api = SynchronousApi.delegatingTo(apiCategory);
appSync = SynchronousAppSync.using(AppSyncClient.via(apiCategory));
long tenMinutesAgo = new Date().getTime() - TimeUnit.MINUTES.toMillis(10);
Temporal.DateTime tenMinutesAgoDateTime = new Temporal.DateTime(new Date(tenMinutesAgo), 0);
DataStoreCategory dataStoreCategory = DataStoreCategoryConfigurator.begin().api(apiCategory).clearDatabase(true).context(context).modelProvider(AmplifyModelProvider.getInstance()).resourceId(configResourceId).timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS).dataStoreConfiguration(DataStoreConfiguration.builder().syncExpression(BlogOwner.class, () -> BlogOwner.CREATED_AT.gt(tenMinutesAgoDateTime)).syncExpression(Blog.class, () -> Blog.CREATED_AT.gt(tenMinutesAgoDateTime)).syncExpression(Post.class, () -> Post.CREATED_AT.gt(tenMinutesAgoDateTime)).syncExpression(Comment.class, () -> Comment.CREATED_AT.gt(tenMinutesAgoDateTime)).syncExpression(Author.class, () -> Author.CREATED_AT.gt(tenMinutesAgoDateTime)).syncExpression(PostAuthorJoin.class, () -> PostAuthorJoin.CREATED_AT.gt(tenMinutesAgoDateTime)).build()).finish();
dataStore = SynchronousDataStore.delegatingTo(dataStoreCategory);
}
Aggregations