Search in sources :

Example 6 with ApiCategory

use of com.amplifyframework.api.ApiCategory in project amplify-android by aws-amplify.

the class ConflictResolverIntegrationTest method setupApiMock.

@SuppressWarnings("unchecked")
private Person setupApiMock(CountDownLatch latch, ApiCategory mockApiCategory) {
    Person person1 = createPerson("Test", "Dummy I");
    // Mock success on subscription.
    doAnswer(invocation -> {
        int indexOfStartConsumer = 1;
        Consumer<String> onStart = invocation.getArgument(indexOfStartConsumer);
        GraphQLOperation<?> mockOperation = mock(GraphQLOperation.class);
        doAnswer(opAnswer -> {
            return null;
        }).when(mockOperation).cancel();
        // Trigger the subscription start event.
        onStart.accept(RandomString.string());
        return mockOperation;
    }).when(mockApiCategory).subscribe(any(GraphQLRequest.class), any(Consumer.class), any(Consumer.class), any(Consumer.class), any(Action.class));
    // When mutate is called on the appsync for the first time unhandled conflict error is returned.
    doAnswer(invocation -> {
        int indexOfResponseConsumer = 1;
        Consumer<GraphQLResponse<ModelWithMetadata<Person>>> onResponse = invocation.getArgument(indexOfResponseConsumer);
        List<GraphQLLocation> locations = new ArrayList<>();
        locations.add(new GraphQLLocation(2, 3));
        List<GraphQLPathSegment> path = new ArrayList<>();
        path.add(new GraphQLPathSegment("updatePost"));
        Map<String, Object> serverModelData = new HashMap<>();
        serverModelData.put("id", "5c895eae-88ef-4ce8-9d58-e27d0c7cbe99");
        serverModelData.put("createdAt", "2022-02-04T19:41:05.973Z");
        serverModelData.put("first_name", "test");
        serverModelData.put("last_name", "server last");
        serverModelData.put("_version", 92);
        serverModelData.put("_deleted", false);
        serverModelData.put("_lastChangedAt", 1_000);
        Map<String, Object> extensions = new HashMap<>();
        extensions.put("errorInfo", null);
        extensions.put("data", serverModelData);
        extensions.put("errorType", "ConflictUnhandled");
        ArrayList<GraphQLResponse.Error> errorList = new ArrayList<>();
        errorList.add(new GraphQLResponse.Error("Conflict resolver rejects mutation.", locations, path, extensions));
        onResponse.accept(new GraphQLResponse<>(null, errorList));
        // latch makes sure conflict unhandled response is returned.
        latch.countDown();
        return mock(GraphQLOperation.class);
    }).doAnswer(invocation -> {
        // When mutate is called on the appsync for the second time success response is returned
        int indexOfResponseConsumer = 1;
        Consumer<GraphQLResponse<ModelWithMetadata<Person>>> onResponse = invocation.getArgument(indexOfResponseConsumer);
        ModelMetadata modelMetadata = new ModelMetadata(person1.getId(), false, 1, Temporal.Timestamp.now());
        ModelWithMetadata<Person> modelWithMetadata = new ModelWithMetadata<>(person1, modelMetadata);
        onResponse.accept(new GraphQLResponse<>(modelWithMetadata, Collections.emptyList()));
        verify(mockApiCategory, atLeast(2)).mutate(argThat(getMatcherFor(person1)), any(), any());
        // latch makes sure success response is returned.
        latch.countDown();
        return mock(GraphQLOperation.class);
    }).when(mockApiCategory).mutate(any(), any(), any());
    // Setup to mimic successful sync
    doAnswer(invocation -> {
        int indexOfResponseConsumer = 1;
        ModelMetadata modelMetadata = new ModelMetadata(person1.getId(), false, 1, Temporal.Timestamp.now());
        ModelWithMetadata<Person> modelWithMetadata = new ModelWithMetadata<>(person1, modelMetadata);
        // Mock the API emitting an ApiEndpointStatusChangeEvent event.
        Consumer<GraphQLResponse<PaginatedResult<ModelWithMetadata<Person>>>> onResponse = invocation.getArgument(indexOfResponseConsumer);
        PaginatedResult<ModelWithMetadata<Person>> data = new PaginatedResult<>(Collections.singletonList(modelWithMetadata), null);
        onResponse.accept(new GraphQLResponse<>(data, Collections.emptyList()));
        latch.countDown();
        return mock(GraphQLOperation.class);
    }).doAnswer(invocation -> {
        int indexOfResponseConsumer = 1;
        Car car = Car.builder().build();
        ModelMetadata modelMetadata = new ModelMetadata(car.getId(), false, 1, Temporal.Timestamp.now());
        ModelWithMetadata<Car> modelWithMetadata = new ModelWithMetadata<>(car, modelMetadata);
        Consumer<GraphQLResponse<PaginatedResult<ModelWithMetadata<Car>>>> onResponse = invocation.getArgument(indexOfResponseConsumer);
        PaginatedResult<ModelWithMetadata<Car>> data = new PaginatedResult<>(Collections.singletonList(modelWithMetadata), null);
        onResponse.accept(new GraphQLResponse<>(data, Collections.emptyList()));
        latch.countDown();
        return mock(GraphQLOperation.class);
    }).when(mockApiCategory).query(any(), any(), any());
    return person1;
}
Also used : AmplifyException(com.amplifyframework.AmplifyException) ApplicationProvider.getApplicationContext(androidx.test.core.app.ApplicationProvider.getApplicationContext) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ModelWithMetadata(com.amplifyframework.datastore.appsync.ModelWithMetadata) ModelProvider(com.amplifyframework.core.model.ModelProvider) GraphQLPathSegment(com.amplifyframework.api.graphql.GraphQLPathSegment) ApiChannelEventName(com.amplifyframework.api.events.ApiChannelEventName) ArgumentMatcher(org.mockito.ArgumentMatcher) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) GraphQLLocation(com.amplifyframework.api.graphql.GraphQLLocation) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Mockito.atLeast(org.mockito.Mockito.atLeast) GraphQLResponse(com.amplifyframework.api.graphql.GraphQLResponse) Assert.fail(org.junit.Assert.fail) HubEvent(com.amplifyframework.hub.HubEvent) HubChannel(com.amplifyframework.hub.HubChannel) ApiCategory(com.amplifyframework.api.ApiCategory) InitializationStatus(com.amplifyframework.core.InitializationStatus) RobolectricTestRunner(org.robolectric.RobolectricTestRunner) Person(com.amplifyframework.testmodels.personcar.Person) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) RandomString(com.amplifyframework.testutils.random.RandomString) Mockito.any(org.mockito.Mockito.any) Mockito.mock(org.mockito.Mockito.mock) Context(android.content.Context) GraphQLRequest(com.amplifyframework.api.graphql.GraphQLRequest) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) Car(com.amplifyframework.testmodels.personcar.Car) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) Consumer(com.amplifyframework.core.Consumer) ApiEndpointStatusChangeEvent(com.amplifyframework.api.events.ApiEndpointStatusChangeEvent) ModelMetadata(com.amplifyframework.datastore.appsync.ModelMetadata) PaginatedResult(com.amplifyframework.api.graphql.PaginatedResult) Before(org.junit.Before) Amplify(com.amplifyframework.core.Amplify) SynchronousDataStore(com.amplifyframework.testutils.sync.SynchronousDataStore) ApiPlugin(com.amplifyframework.api.ApiPlugin) CategoryType(com.amplifyframework.core.category.CategoryType) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Completable(io.reactivex.rxjava3.core.Completable) Action(com.amplifyframework.core.Action) Mockito.when(org.mockito.Mockito.when) AmplifyCliGeneratedModelProvider(com.amplifyframework.testmodels.personcar.AmplifyCliGeneratedModelProvider) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) ApiCategoryConfiguration(com.amplifyframework.api.ApiCategoryConfiguration) Temporal(com.amplifyframework.core.model.temporal.Temporal) GraphQLOperation(com.amplifyframework.api.graphql.GraphQLOperation) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Action(com.amplifyframework.core.Action) GraphQLLocation(com.amplifyframework.api.graphql.GraphQLLocation) ArrayList(java.util.ArrayList) GraphQLPathSegment(com.amplifyframework.api.graphql.GraphQLPathSegment) RandomString(com.amplifyframework.testutils.random.RandomString) GraphQLRequest(com.amplifyframework.api.graphql.GraphQLRequest) Consumer(com.amplifyframework.core.Consumer) List(java.util.List) ArrayList(java.util.ArrayList) ModelWithMetadata(com.amplifyframework.datastore.appsync.ModelWithMetadata) PaginatedResult(com.amplifyframework.api.graphql.PaginatedResult) GraphQLResponse(com.amplifyframework.api.graphql.GraphQLResponse) Car(com.amplifyframework.testmodels.personcar.Car) GraphQLOperation(com.amplifyframework.api.graphql.GraphQLOperation) Person(com.amplifyframework.testmodels.personcar.Person) Map(java.util.Map) HashMap(java.util.HashMap) ModelMetadata(com.amplifyframework.datastore.appsync.ModelMetadata)

Example 7 with ApiCategory

use of com.amplifyframework.api.ApiCategory in project amplify-android by aws-amplify.

the class RxApiBindingTest method createBindingInFrontOfMockPlugin.

/**
 * To test the binding, we construct a category that has been configured
 * with a mock plugin. The binding delegates to the category.
 * @throws AmplifyException On failure to add plugin or configure category
 */
@Before
public void createBindingInFrontOfMockPlugin() throws AmplifyException {
    // Mock plugin on which we will simulate API responses/failures
    this.delegate = mock(ApiPlugin.class);
    when(delegate.getPluginKey()).thenReturn(RandomString.string());
    // Build a category, add the mock plugin, configure and init the category.
    final ApiCategory apiCategory = new ApiCategory();
    apiCategory.addPlugin(delegate);
    apiCategory.configure(new ApiCategoryConfiguration(), mock(Context.class));
    apiCategory.initialize(mock(Context.class));
    // Provide that category as a backing to our binding.
    this.rxApi = new RxApiBinding(apiCategory);
}
Also used : Context(android.content.Context) ApiPlugin(com.amplifyframework.api.ApiPlugin) ApiCategory(com.amplifyframework.api.ApiCategory) ApiCategoryConfiguration(com.amplifyframework.api.ApiCategoryConfiguration) Before(org.junit.Before)

Example 8 with ApiCategory

use of com.amplifyframework.api.ApiCategory 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);
}
Also used : Context(android.content.Context) ApplicationProvider.getApplicationContext(androidx.test.core.app.ApplicationProvider.getApplicationContext) AWSApiPlugin(com.amplifyframework.api.aws.AWSApiPlugin) RawRes(androidx.annotation.RawRes) CategoryConfiguration(com.amplifyframework.core.category.CategoryConfiguration) ApiCategory(com.amplifyframework.api.ApiCategory) AndroidLoggingPlugin(com.amplifyframework.logging.AndroidLoggingPlugin) Before(org.junit.Before) Ignore(org.junit.Ignore)

Example 9 with ApiCategory

use of com.amplifyframework.api.ApiCategory 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);
}
Also used : Context(android.content.Context) ApplicationProvider.getApplicationContext(androidx.test.core.app.ApplicationProvider.getApplicationContext) AWSApiPlugin(com.amplifyframework.api.aws.AWSApiPlugin) RawRes(androidx.annotation.RawRes) CategoryConfiguration(com.amplifyframework.core.category.CategoryConfiguration) ApiCategory(com.amplifyframework.api.ApiCategory) AndroidLoggingPlugin(com.amplifyframework.logging.AndroidLoggingPlugin) Before(org.junit.Before) Ignore(org.junit.Ignore)

Example 10 with ApiCategory

use of com.amplifyframework.api.ApiCategory in project amplify-android by aws-amplify.

the class MultiAuthSyncEngineInstrumentationTest method configure.

/**
 * Method used to configure each scenario.
 * @param modelType The model type.
 * @param signInToCognito Does the test scenario require the user to be logged in with user pools.
 * @param signInWithOidc Does the test scenario require the user to be logged in with an OIDC provider.
 * @param expectedAuthType The auth type that should succeed for the test.
 * @throws AmplifyException No expected.
 * @throws IOException Not expected.
 */
private void configure(Class<? extends Model> modelType, boolean signInToCognito, boolean signInWithOidc, AuthorizationType expectedAuthType) throws AmplifyException, IOException {
    Amplify.addPlugin(new AndroidLoggingPlugin(LogLevel.VERBOSE));
    String tag = modelType.getSimpleName();
    MultiAuthTestModelProvider modelProvider = MultiAuthTestModelProvider.getInstance(Collections.singletonList(modelType));
    SchemaRegistry schemaRegistry = SchemaRegistry.instance();
    ModelSchema modelSchema = ModelSchema.fromModelClass(modelType);
    schemaRegistry.register(modelType.getSimpleName(), modelSchema);
    StrictMode.enable();
    Context context = getApplicationContext();
    @RawRes int configResourceId = Resources.getRawResourceId(context, "amplifyconfiguration");
    AmplifyConfiguration amplifyConfiguration = AmplifyConfiguration.fromConfigFile(context, configResourceId);
    readCredsFromConfig(context);
    // Setup an auth plugin
    CategoryConfiguration authCategoryConfiguration = amplifyConfiguration.forCategoryType(CategoryType.AUTH);
    // Turn off persistence so the mobile client's state for one test does not interfere with the others.
    try {
        authCategoryConfiguration.getPluginConfig("awsCognitoAuthPlugin").getJSONObject("Auth").getJSONObject("Default").put("Persistence", false);
    } catch (JSONException exception) {
        exception.printStackTrace();
        fail();
        return;
    }
    AuthCategory authCategory = new AuthCategory();
    AWSCognitoAuthPlugin authPlugin = new AWSCognitoAuthPlugin();
    authCategory.addPlugin(authPlugin);
    authCategory.configure(authCategoryConfiguration, context);
    auth = SynchronousAuth.delegatingTo(authCategory);
    if (signInToCognito) {
        Log.v(tag, "Test requires signIn.");
        AuthSignInResult authSignInResult = auth.signIn(cognitoUser, cognitoPassword);
        if (!authSignInResult.isSignInComplete()) {
            fail("Unable to complete initial sign-in");
        }
    }
    if (signInWithOidc) {
        oidcLogin();
        if (token.get() == null) {
            fail("Unable to autenticate with OIDC provider");
        }
    }
    // Setup an API
    DefaultCognitoUserPoolsAuthProvider cognitoProvider = new DefaultCognitoUserPoolsAuthProvider(authPlugin.getEscapeHatch());
    CategoryConfiguration apiCategoryConfiguration = amplifyConfiguration.forCategoryType(CategoryType.API);
    ApiAuthProviders apiAuthProviders = ApiAuthProviders.builder().cognitoUserPoolsAuthProvider(cognitoProvider).awsCredentialsProvider(authPlugin.getEscapeHatch()).oidcAuthProvider(token::get).build();
    ApiCategory apiCategory = new ApiCategory();
    requestInterceptor = new HttpRequestInterceptor(expectedAuthType);
    apiCategory.addPlugin(AWSApiPlugin.builder().configureClient("DataStoreIntegTestsApi", okHttpClientBuilder -> okHttpClientBuilder.addInterceptor(requestInterceptor)).apiAuthProviders(apiAuthProviders).build());
    apiCategory.configure(apiCategoryConfiguration, context);
    api = SynchronousApi.delegatingTo(apiCategory);
    // Setup DataStore
    DataStoreConfiguration dsConfig = DataStoreConfiguration.builder().errorHandler(exception -> Log.e(tag, "DataStore error handler received an error.", exception)).syncExpression(modelSchema.getName(), () -> Where.id("FAKE_ID").getQueryPredicate()).build();
    CategoryConfiguration dataStoreCategoryConfiguration = AmplifyConfiguration.fromConfigFile(context, configResourceId).forCategoryType(CategoryType.DATASTORE);
    String databaseName = "IntegTest" + modelType.getSimpleName() + ".db";
    SQLiteStorageAdapter sqLiteStorageAdapter = TestStorageAdapter.create(schemaRegistry, modelProvider, databaseName);
    AWSDataStorePlugin awsDataStorePlugin = AWSDataStorePlugin.builder().storageAdapter(sqLiteStorageAdapter).modelProvider(modelProvider).apiCategory(apiCategory).authModeStrategy(AuthModeStrategyType.MULTIAUTH).schemaRegistry(schemaRegistry).dataStoreConfiguration(dsConfig).build();
    DataStoreCategory dataStoreCategory = new DataStoreCategory();
    dataStoreCategory.addPlugin(awsDataStorePlugin);
    dataStoreCategory.configure(dataStoreCategoryConfiguration, context);
    dataStoreCategory.initialize(context);
    dataStore = SynchronousDataStore.delegatingTo(dataStoreCategory);
}
Also used : MultiAuthTestModelProvider(com.amplifyframework.testmodels.multiauth.MultiAuthTestModelProvider) ApplicationProvider.getApplicationContext(androidx.test.core.app.ApplicationProvider.getApplicationContext) Context(android.content.Context) AmplifyException(com.amplifyframework.AmplifyException) ApplicationProvider.getApplicationContext(androidx.test.core.app.ApplicationProvider.getApplicationContext) AuthorizationType(com.amplifyframework.api.aws.AuthorizationType) PrivatePrivatePublicUPIAMIAMPost(com.amplifyframework.testmodels.multiauth.PrivatePrivatePublicUPIAMIAMPost) PublicPublicIAMAPIPost(com.amplifyframework.testmodels.multiauth.PublicPublicIAMAPIPost) AuthSignOutOptions(com.amplifyframework.auth.options.AuthSignOutOptions) DataStoreHubEventFilters.publicationOf(com.amplifyframework.datastore.DataStoreHubEventFilters.publicationOf) AndroidLoggingPlugin(com.amplifyframework.logging.AndroidLoggingPlugin) OwnerPublicUPAPIPost(com.amplifyframework.testmodels.multiauth.OwnerPublicUPAPIPost) JSONException(org.json.JSONException) AWSApiPlugin(com.amplifyframework.api.aws.AWSApiPlugin) JSONObject(org.json.JSONObject) AmplifyConfiguration(com.amplifyframework.core.AmplifyConfiguration) Map(java.util.Map) PrivateUPPost(com.amplifyframework.testmodels.multiauth.PrivateUPPost) Assert.fail(org.junit.Assert.fail) Log(android.util.Log) ResponseBody(okhttp3.ResponseBody) MultiAuthTestModelProvider(com.amplifyframework.testmodels.multiauth.MultiAuthTestModelProvider) Interceptor(okhttp3.Interceptor) AfterClass(org.junit.AfterClass) Request(okhttp3.Request) GroupUPPost(com.amplifyframework.testmodels.multiauth.GroupUPPost) HubChannel(com.amplifyframework.hub.HubChannel) SerializedModel(com.amplifyframework.core.model.SerializedModel) OwnerPublicOIDAPIPost(com.amplifyframework.testmodels.multiauth.OwnerPublicOIDAPIPost) OwnerPrivateUPIAMPost(com.amplifyframework.testmodels.multiauth.OwnerPrivateUPIAMPost) DefaultCognitoUserPoolsAuthProvider(com.amplifyframework.api.aws.sigv4.DefaultCognitoUserPoolsAuthProvider) UUID(java.util.UUID) ApiCategory(com.amplifyframework.api.ApiCategory) PrivatePublicComboUPPost(com.amplifyframework.testmodels.multiauth.PrivatePublicComboUPPost) Logger(com.amplifyframework.logging.Logger) CognitoJWTParser(com.amazonaws.mobileconnectors.cognitoidentityprovider.util.CognitoJWTParser) Assert.assertFalse(org.junit.Assert.assertFalse) RandomString(com.amplifyframework.testutils.random.RandomString) SynchronousAuth(com.amplifyframework.testutils.sync.SynchronousAuth) LogLevel(com.amplifyframework.logging.LogLevel) PublicAPIPost(com.amplifyframework.testmodels.multiauth.PublicAPIPost) Context(android.content.Context) GroupPrivatePublicUPIAMAPIPost(com.amplifyframework.testmodels.multiauth.GroupPrivatePublicUPIAMAPIPost) AuthCategory(com.amplifyframework.auth.AuthCategory) HashMap(java.util.HashMap) ApiAuthProviders(com.amplifyframework.api.aws.ApiAuthProviders) Resources(com.amplifyframework.testutils.Resources) HubAccumulator(com.amplifyframework.testutils.HubAccumulator) SynchronousApi(com.amplifyframework.testutils.sync.SynchronousApi) IdToken(com.google.auth.oauth2.IdToken) AtomicReference(java.util.concurrent.atomic.AtomicReference) Headers(okhttp3.Headers) RequestBody(okhttp3.RequestBody) SchemaRegistry(com.amplifyframework.core.model.SchemaRegistry) RawRes(androidx.annotation.RawRes) PrivatePublicUPIAMPost(com.amplifyframework.testmodels.multiauth.PrivatePublicUPIAMPost) AuthSignInResult(com.amplifyframework.auth.result.AuthSignInResult) Author(com.amplifyframework.testmodels.commentsblog.Author) ModelSchema(com.amplifyframework.core.model.ModelSchema) PrivatePublicComboAPIPost(com.amplifyframework.testmodels.multiauth.PrivatePublicComboAPIPost) Response(okhttp3.Response) CategoryConfiguration(com.amplifyframework.core.category.CategoryConfiguration) PublicIAMPost(com.amplifyframework.testmodels.multiauth.PublicIAMPost) Amplify(com.amplifyframework.core.Amplify) PrivatePrivatePublicUPIAMAPIPost(com.amplifyframework.testmodels.multiauth.PrivatePrivatePublicUPIAMAPIPost) SynchronousDataStore(com.amplifyframework.testutils.sync.SynchronousDataStore) Buffer(okio.Buffer) CategoryType(com.amplifyframework.core.category.CategoryType) GroupPrivateUPIAMPost(com.amplifyframework.testmodels.multiauth.GroupPrivateUPIAMPost) PrivatePublicUPAPIPost(com.amplifyframework.testmodels.multiauth.PrivatePublicUPAPIPost) Model(com.amplifyframework.core.model.Model) AWSCognitoAuthPlugin(com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin) Test(org.junit.Test) IOException(java.io.IOException) Where(com.amplifyframework.core.model.query.Where) SQLiteStorageAdapter(com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter) GroupPublicUPIAMPost(com.amplifyframework.testmodels.multiauth.GroupPublicUPIAMPost) PrivatePrivateUPIAMPost(com.amplifyframework.testmodels.multiauth.PrivatePrivateUPIAMPost) TimeUnit(java.util.concurrent.TimeUnit) AuthModeStrategyType(com.amplifyframework.api.aws.AuthModeStrategyType) OwnerOIDCPost(com.amplifyframework.testmodels.multiauth.OwnerOIDCPost) OwnerPrivatePublicUPIAMAPIPost(com.amplifyframework.testmodels.multiauth.OwnerPrivatePublicUPIAMAPIPost) TestStorageAdapter(com.amplifyframework.datastore.storage.sqlite.TestStorageAdapter) PrivatePublicPublicUPAPIIAMPost(com.amplifyframework.testmodels.multiauth.PrivatePublicPublicUPAPIIAMPost) Resources.readJsonResourceFromId(com.amplifyframework.core.Resources.readJsonResourceFromId) DataStoreHubEventFilters.networkStatusFailure(com.amplifyframework.datastore.DataStoreHubEventFilters.networkStatusFailure) GroupPublicUPAPIPost(com.amplifyframework.testmodels.multiauth.GroupPublicUPAPIPost) OwnerUPPost(com.amplifyframework.testmodels.multiauth.OwnerUPPost) Collections(java.util.Collections) ServiceAccountCredentials(com.google.auth.oauth2.ServiceAccountCredentials) JSONArray(org.json.JSONArray) RawRes(androidx.annotation.RawRes) AmplifyConfiguration(com.amplifyframework.core.AmplifyConfiguration) DefaultCognitoUserPoolsAuthProvider(com.amplifyframework.api.aws.sigv4.DefaultCognitoUserPoolsAuthProvider) SQLiteStorageAdapter(com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter) CategoryConfiguration(com.amplifyframework.core.category.CategoryConfiguration) JSONException(org.json.JSONException) RandomString(com.amplifyframework.testutils.random.RandomString) AWSCognitoAuthPlugin(com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin) AndroidLoggingPlugin(com.amplifyframework.logging.AndroidLoggingPlugin) ModelSchema(com.amplifyframework.core.model.ModelSchema) AuthCategory(com.amplifyframework.auth.AuthCategory) ApiCategory(com.amplifyframework.api.ApiCategory) ApiAuthProviders(com.amplifyframework.api.aws.ApiAuthProviders) AuthSignInResult(com.amplifyframework.auth.result.AuthSignInResult) SchemaRegistry(com.amplifyframework.core.model.SchemaRegistry)

Aggregations

ApiCategory (com.amplifyframework.api.ApiCategory)21 JSONObject (org.json.JSONObject)9 Test (org.junit.Test)9 SynchronousDataStore (com.amplifyframework.testutils.sync.SynchronousDataStore)8 Context (android.content.Context)7 ApplicationProvider.getApplicationContext (androidx.test.core.app.ApplicationProvider.getApplicationContext)6 Person (com.amplifyframework.testmodels.personcar.Person)6 Before (org.junit.Before)6 RawRes (androidx.annotation.RawRes)5 AWSApiPlugin (com.amplifyframework.api.aws.AWSApiPlugin)5 GraphQLResponse (com.amplifyframework.api.graphql.GraphQLResponse)5 CategoryConfiguration (com.amplifyframework.core.category.CategoryConfiguration)5 ModelWithMetadata (com.amplifyframework.datastore.appsync.ModelWithMetadata)5 HubAccumulator (com.amplifyframework.testutils.HubAccumulator)5 ApiCategoryConfiguration (com.amplifyframework.api.ApiCategoryConfiguration)4 GraphQLRequest (com.amplifyframework.api.graphql.GraphQLRequest)4 Consumer (com.amplifyframework.core.Consumer)4 AndroidLoggingPlugin (com.amplifyframework.logging.AndroidLoggingPlugin)4 ApiEndpointStatusChangeEvent (com.amplifyframework.api.events.ApiEndpointStatusChangeEvent)3 PaginatedResult (com.amplifyframework.api.graphql.PaginatedResult)3