Search in sources :

Example 1 with StorageCategoryConfiguration

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);
}
Also used : DataStoreCategoryConfiguration(com.amplifyframework.datastore.DataStoreCategoryConfiguration) StorageCategoryConfiguration(com.amplifyframework.storage.StorageCategoryConfiguration) AmplifyException(com.amplifyframework.AmplifyException) PredictionsCategoryConfiguration(com.amplifyframework.predictions.PredictionsCategoryConfiguration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AuthCategoryConfiguration(com.amplifyframework.auth.AuthCategoryConfiguration) LoggingCategoryConfiguration(com.amplifyframework.logging.LoggingCategoryConfiguration) AnalyticsCategoryConfiguration(com.amplifyframework.analytics.AnalyticsCategoryConfiguration) AuthCategoryConfiguration(com.amplifyframework.auth.AuthCategoryConfiguration) CategoryConfiguration(com.amplifyframework.core.category.CategoryConfiguration) GeoCategoryConfiguration(com.amplifyframework.geo.GeoCategoryConfiguration) DataStoreCategoryConfiguration(com.amplifyframework.datastore.DataStoreCategoryConfiguration) HubCategoryConfiguration(com.amplifyframework.hub.HubCategoryConfiguration) PredictionsCategoryConfiguration(com.amplifyframework.predictions.PredictionsCategoryConfiguration) StorageCategoryConfiguration(com.amplifyframework.storage.StorageCategoryConfiguration) ApiCategoryConfiguration(com.amplifyframework.api.ApiCategoryConfiguration) EmptyCategoryConfiguration(com.amplifyframework.core.category.EmptyCategoryConfiguration) JSONException(org.json.JSONException) GeoCategoryConfiguration(com.amplifyframework.geo.GeoCategoryConfiguration) AnalyticsCategoryConfiguration(com.amplifyframework.analytics.AnalyticsCategoryConfiguration) ApiCategoryConfiguration(com.amplifyframework.api.ApiCategoryConfiguration) HubCategoryConfiguration(com.amplifyframework.hub.HubCategoryConfiguration) LoggingCategoryConfiguration(com.amplifyframework.logging.LoggingCategoryConfiguration)

Example 2 with StorageCategoryConfiguration

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);
}
Also used : StorageCategoryConfiguration(com.amplifyframework.storage.StorageCategoryConfiguration) Context(android.content.Context) StorageCategory(com.amplifyframework.storage.StorageCategory) StoragePlugin(com.amplifyframework.storage.StoragePlugin) Before(org.junit.Before)

Aggregations

StorageCategoryConfiguration (com.amplifyframework.storage.StorageCategoryConfiguration)2 Context (android.content.Context)1 AmplifyException (com.amplifyframework.AmplifyException)1 AnalyticsCategoryConfiguration (com.amplifyframework.analytics.AnalyticsCategoryConfiguration)1 ApiCategoryConfiguration (com.amplifyframework.api.ApiCategoryConfiguration)1 AuthCategoryConfiguration (com.amplifyframework.auth.AuthCategoryConfiguration)1 CategoryConfiguration (com.amplifyframework.core.category.CategoryConfiguration)1 EmptyCategoryConfiguration (com.amplifyframework.core.category.EmptyCategoryConfiguration)1 DataStoreCategoryConfiguration (com.amplifyframework.datastore.DataStoreCategoryConfiguration)1 GeoCategoryConfiguration (com.amplifyframework.geo.GeoCategoryConfiguration)1 HubCategoryConfiguration (com.amplifyframework.hub.HubCategoryConfiguration)1 LoggingCategoryConfiguration (com.amplifyframework.logging.LoggingCategoryConfiguration)1 PredictionsCategoryConfiguration (com.amplifyframework.predictions.PredictionsCategoryConfiguration)1 StorageCategory (com.amplifyframework.storage.StorageCategory)1 StoragePlugin (com.amplifyframework.storage.StoragePlugin)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 JSONException (org.json.JSONException)1 Before (org.junit.Before)1