use of com.amplifyframework.core.Action in project amplify-android by aws-amplify.
the class RxDataStoreBindingTest method stopSucceedsWhenCategoryBehaviorDoes.
/**
* The Rx binding for the DataStore's stop() method will propagate success
* faithfully from the underlying delegate.
* @throws InterruptedException If interrupted while test observer is awaiting terminal event
*/
@Test
public void stopSucceedsWhenCategoryBehaviorDoes() throws InterruptedException {
// Arrange success in the category behavior
doAnswer(invocation -> {
// 0 = onComplete, 1 = onFailure
final int positionOfOnSuccess = 0;
Action onSuccess = invocation.getArgument(positionOfOnSuccess);
onSuccess.call();
// "void"
return null;
}).when(delegate).stop(anyAction(), anyConsumer());
// Act: stop the store.
TestObserver<Void> observer = rxDataStore.stop().test();
// Assert: success propagates through binding.
observer.await(TIMEOUT_SECONDS, TimeUnit.SECONDS);
observer.assertComplete();
}
Aggregations