@Test public void delete() { Storage storage = new Storage(); final Task task = Mockito.mock(Task.class); when(storageReference.delete()).thenReturn(task); when(task.addOnFailureListener(Mockito.any(OnFailureListener.class))).thenReturn(task); when(task.addOnSuccessListener(Mockito.any(OnSuccessListener.class))).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { ((OnSuccessListener) invocation.getArgument(0)).onSuccess(null); return task; } }); long byteLimit = 1000; storage.delete("test").subscribe(); Mockito.verify(storageReference, VerificationModeFactory.times(1)).delete(); Mockito.verify(task, VerificationModeFactory.times(1)).addOnFailureListener(Mockito.any(OnFailureListener.class)); Mockito.verify(task, VerificationModeFactory.times(1)).addOnSuccessListener(Mockito.any(OnSuccessListener.class)); }
@Override public Promise<Void> delete(final String path) { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { StorageReference pathRef = firebaseStorage().getReference().child(path); pathRef.delete().addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { voidFuturePromise.doFail(e); } }).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { voidFuturePromise.doComplete(null); } }); } }); }
Storage implements StorageDistribution { @Override public Promise<Void> delete(final String path) { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { StorageReference pathRef = firebaseStorage().getReference().child(path); pathRef.delete().addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { voidFuturePromise.doFail(e); } }).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { voidFuturePromise.doComplete(null); } }); } }); } }
Storage implements StorageDistribution { @Override public Promise<Void> delete(final String path) { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { StorageReference pathRef = firebaseStorage().getReference().child(path); pathRef.delete().addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { voidFuturePromise.doFail(e); } }).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { voidFuturePromise.doComplete(null); } }); } }); }  }
Storage implements StorageDistribution { @Override public Promise<Void> delete(final String path) { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { StorageReference pathRef = firebaseStorage().getReference().child(path); pathRef.delete().addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { voidFuturePromise.doFail(e); } }).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { voidFuturePromise.doComplete(null); } }); } }); }  @Override Promise<FileMetadata> upload(final String path, final FileHandle file); @Override Promise<FileMetadata> upload(final String path, final byte[] data); @Override Promise<byte[]> download(final String path, final long bytesLimit); @Override Promise<FileHandle> download(final String path, final FileHandle targetFile); @Override Promise<Void> delete(final String path); @Override StorageDistribution inBucket(String url); }
Storage implements StorageDistribution { @Override public Promise<Void> delete(final String path) { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { StorageReference pathRef = firebaseStorage().getReference().child(path); pathRef.delete().addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { voidFuturePromise.doFail(e); } }).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { voidFuturePromise.doComplete(null); } }); } }); }  @Override Promise<FileMetadata> upload(final String path, final FileHandle file); @Override Promise<FileMetadata> upload(final String path, final byte[] data); @Override Promise<byte[]> download(final String path, final long bytesLimit); @Override Promise<FileHandle> download(final String path, final FileHandle targetFile); @Override Promise<Void> delete(final String path); @Override StorageDistribution inBucket(String url);  }