use of com.amplifyframework.storage.result.StorageRemoveResult in project amplify-android by aws-amplify.
the class StorageComponentTest method testRemoveObjectGetsKey.
/**
* Test that calling remove method from Storage category correctly
* invokes the registered AWSS3StoragePlugin instance and returns a
* {@link StorageRemoveResult} with key of removed item.
*
* @throws StorageException when an error is encountered while deleting
* file from storage
*/
@Test
public void testRemoveObjectGetsKey() throws StorageException {
final String remoteKey = RandomString.string();
StorageRemoveResult result = Await.<StorageRemoveResult, StorageException>result((onResult, onError) -> storage.remove(remoteKey, onResult, onError));
assertEquals(remoteKey, result.getKey());
}
use of com.amplifyframework.storage.result.StorageRemoveResult in project amplify-android by aws-amplify.
the class RxStorageBindingTest method removeReturnsResult.
/**
* When the {@link StorageCategoryBehavior#remove(String, Consumer, Consumer)} emits
* a result, the {@link Single} returned by {@link RxStorageCategoryBehavior#remove(String)} should
* emit a {@link StorageRemoveResult}.
*/
@Test
public void removeReturnsResult() {
StorageRemoveResult result = StorageRemoveResult.fromKey(remoteKey);
doAnswer(invocation -> {
// 0 remoteKey, 1 onResult, 2 onError
final int indexOfResultConsumer = 1;
Consumer<StorageRemoveResult> resultConsumer = invocation.getArgument(indexOfResultConsumer);
resultConsumer.accept(result);
return mock(StorageRemoveOperation.class);
}).when(delegate).remove(eq(remoteKey), anyConsumer(), anyConsumer());
rxStorage.remove(remoteKey).test().assertValues(result);
}
Aggregations