use of com.amazonaws.mobile.config.AWSConfiguration in project aws-mobile-appsync-sdk-android by awslabs.
the class MultiClientInstrumentationTest method testConfigHasClientDatabasePrefixAndUseClientDatabasePrefixFalse.
@Test
public void testConfigHasClientDatabasePrefixAndUseClientDatabasePrefixFalse() {
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
JSONObject appSyncConfig = awsConfiguration.optJsonObject("AppSync");
AWSAppSyncClients.validateAppSyncClient(AWSAppSyncClient.builder().context(getTargetContext()).awsConfiguration(awsConfiguration).useClientDatabasePrefix(false).build(), null, JsonExtract.stringValue(appSyncConfig, "AuthMode"));
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-mobile-appsync-sdk-android by awslabs.
the class MultiClientInstrumentationTest method testConfigHasNoClientDatabasePrefixAndUseClientDatabasePrefixFalse.
@Test
public void testConfigHasNoClientDatabasePrefixAndUseClientDatabasePrefixFalse() throws JSONException {
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
awsConfiguration.setConfiguration("MultiAuthAndroidIntegTestApp_NoClientDatabasePrefix");
AWSAppSyncClients.validateAppSyncClient(AWSAppSyncClient.builder().context(getTargetContext()).awsConfiguration(awsConfiguration).useClientDatabasePrefix(false).build(), null, awsConfiguration.optJsonObject("AppSync").getString("AuthMode"));
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-mobile-appsync-sdk-android by awslabs.
the class MultiClientInstrumentationTest method testCodeHasNoClientDatabasePrefixAndUseClientDatabasePrefixTrue.
@Test
public void testCodeHasNoClientDatabasePrefixAndUseClientDatabasePrefixTrue() {
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
JSONObject appSyncConfig = awsConfiguration.optJsonObject("AppSync");
RuntimeException exception = assertThrows(RuntimeException.class, () -> AWSAppSyncClient.builder().context(getTargetContext()).apiKey(new BasicAPIKeyAuthProvider(appSyncConfig.getString("ApiKey"))).serverUrl(appSyncConfig.getString("ApiUrl")).region(Regions.fromName(appSyncConfig.getString("Region"))).useClientDatabasePrefix(true).build());
String expected = "Please pass in a valid ClientDatabasePrefix when useClientDatabasePrefix is true.";
assertEquals(expected, exception.getLocalizedMessage());
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-mobile-appsync-sdk-android by awslabs.
the class MultiClientInstrumentationTest method testNoClientDatabasePrefixViaAwsConfiguration.
@Test
public void testNoClientDatabasePrefixViaAwsConfiguration() {
// Uses the configuration under the "MultiAuthAndroidIntegTestApp_NoClientDatabasePrefix" configuration key.
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
awsConfiguration.setConfiguration("MultiAuthAndroidIntegTestApp_NoClientDatabasePrefix");
AWSAppSyncClient awsAppSyncClient = AWSAppSyncClient.builder().context(getTargetContext()).awsConfiguration(awsConfiguration).build();
SyncStore.validate(awsAppSyncClient, null);
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-mobile-appsync-sdk-android by awslabs.
the class MultiClientInstrumentationTest method testCodeHasNullClientDatabasePrefix.
@Test
public void testCodeHasNullClientDatabasePrefix() {
AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
JSONObject appSyncConfig = awsConfiguration.optJsonObject("AppSync");
// noinspection ConstantConditions null argument is what is is being tested
RuntimeException exception = assertThrows(RuntimeException.class, () -> AWSAppSyncClient.builder().context(getTargetContext()).apiKey(new BasicAPIKeyAuthProvider(appSyncConfig.getString("ApiKey"))).serverUrl(appSyncConfig.getString("ApiUrl")).region(Regions.fromName(appSyncConfig.getString("Region"))).useClientDatabasePrefix(true).clientDatabasePrefix(// Note: this is the problem!!
null).build());
String expected = "Please pass in a valid ClientDatabasePrefix when useClientDatabasePrefix is true.";
assertTrue(exception.getLocalizedMessage().startsWith(expected));
}
Aggregations