use of com.amplifyframework.predictions.PredictionsCategory in project amplify-android by aws-amplify.
the class AWSPredictionsIdentifyTextTest method setUp.
/**
* Configure Predictions category before each test.
* @throws Exception if mobile client initialization fails
*/
@Before
public void setUp() throws Exception {
Context context = getApplicationContext();
// Set up Auth
SynchronousMobileClient.instance().initialize();
// Delegate to Predictions category
PredictionsCategory asyncDelegate = TestPredictionsCategory.create(context, R.raw.amplifyconfiguration);
predictions = SynchronousPredictions.delegatingTo(asyncDelegate);
}
use of com.amplifyframework.predictions.PredictionsCategory in project amplify-android by aws-amplify.
the class AWSPredictionsTranslateTest method setUp.
/**
* Configure Predictions category before each test.
* @throws Exception if mobile client initialization fails
*/
@Before
public void setUp() throws Exception {
Context context = getApplicationContext();
// Set up Auth
SynchronousMobileClient.instance().initialize();
// Delegate to Predictions category
PredictionsCategory asyncDelegate = TestPredictionsCategory.create(context, R.raw.amplifyconfiguration);
predictions = SynchronousPredictions.delegatingTo(asyncDelegate);
}
use of com.amplifyframework.predictions.PredictionsCategory in project amplify-android by aws-amplify.
the class TestPredictionsCategory method create.
/**
* Creates an instance of {@link PredictionsCategory} using the provided configuration resource.
* @param context Android Context
* @param resourceId Android resource ID for a configuration file
* @return A PredictionsCategory instance using the provided configuration
*/
static PredictionsCategory create(@NonNull Context context, @RawRes int resourceId) {
Objects.requireNonNull(context);
final PredictionsCategory predictionsCategory = new PredictionsCategory();
try {
predictionsCategory.addPlugin(new AWSPredictionsPlugin(AWSMobileClient.getInstance()));
CategoryConfiguration predictionsConfiguration = AmplifyConfiguration.fromConfigFile(context, resourceId).forCategoryType(CategoryType.PREDICTIONS);
predictionsCategory.configure(predictionsConfiguration, context);
predictionsCategory.initialize(context);
} catch (AmplifyException initializationFailure) {
throw new RuntimeException(initializationFailure);
}
return predictionsCategory;
}
Aggregations