use of com.amplifyframework.storage.StorageCategoryConfiguration in project amplify-android by aws-amplify.
the class AmplifyConfiguration method configsFromJson.
private static Map<String, CategoryConfiguration> configsFromJson(JSONObject json) throws AmplifyException {
final List<CategoryConfiguration> possibleConfigs = Arrays.asList(new AnalyticsCategoryConfiguration(), new ApiCategoryConfiguration(), new AuthCategoryConfiguration(), new DataStoreCategoryConfiguration(), new GeoCategoryConfiguration(), new HubCategoryConfiguration(), new LoggingCategoryConfiguration(), new PredictionsCategoryConfiguration(), new StorageCategoryConfiguration());
final Map<String, CategoryConfiguration> actualConfigs = new HashMap<>();
try {
for (CategoryConfiguration possibleConfig : possibleConfigs) {
String categoryJsonKey = possibleConfig.getCategoryType().getConfigurationKey();
if (json.has(categoryJsonKey)) {
possibleConfig.populateFromJSON(json.getJSONObject(categoryJsonKey));
actualConfigs.put(categoryJsonKey, possibleConfig);
}
}
} catch (JSONException error) {
throw new AmplifyException("Could not parse amplifyconfiguration.json ", error, "Check any modifications made to the file.");
}
return Immutable.of(actualConfigs);
}
use of com.amplifyframework.storage.StorageCategoryConfiguration in project amplify-android by aws-amplify.
the class RxStorageBindingTest method createBindingInFrontOfMockPlugin.
/**
* Creates a StorageCategory backed by a mock plugin. Uses this category
* as a backing for an Rx Binding, under test.
* @throws AmplifyException On failure to add plugin or config/init the storage category
*/
@Before
public void createBindingInFrontOfMockPlugin() throws AmplifyException {
delegate = mock(StoragePlugin.class);
when(delegate.getPluginKey()).thenReturn(RandomString.string());
final StorageCategory storageCategory = new StorageCategory();
storageCategory.addPlugin(delegate);
storageCategory.configure(new StorageCategoryConfiguration(), mock(Context.class));
storageCategory.initialize(mock(Context.class));
rxStorage = new RxStorageBinding(storageCategory);
}
Aggregations