RxFirebaseStorage { @CheckReturnValue @NonNull public static Single<byte[]> getBytes(@NonNull final StorageReference ref, final long maxDownloadSizeBytes) { return RxTask.single(new Callable<Task<byte[]>>() { @Override public Task<byte[]> call() throws Exception { return ref.getBytes(maxDownloadSizeBytes); } }); } private  RxFirebaseStorage(); @CheckReturnValue @NonNull static Single<byte[]> getBytes(@NonNull final StorageReference ref,
                                          final long maxDownloadSizeBytes); @CheckReturnValue @NonNull static Completable delete(@NonNull final StorageReference ref); @CheckReturnValue @NonNull static Single<FileDownloadTask.TaskSnapshot> getFile(@NonNull final StorageReference ref,
                                                                @NonNull final Uri uri); @CheckReturnValue @NonNull static Single<FileDownloadTask.TaskSnapshot> getFile(@NonNull final StorageReference ref,
                                                                @NonNull final File file); @CheckReturnValue @NonNull static Single<StorageMetadata> getMetadata(@NonNull final StorageReference ref); @CheckReturnValue @NonNull static Single<StreamDownloadTask.TaskSnapshot> getStream(
            @NonNull final StorageReference ref); @CheckReturnValue @NonNull static Single<StreamDownloadTask.TaskSnapshot> getStream(
            @NonNull final StorageReference ref,
            @NonNull final StreamDownloadTask.StreamProcessor streamProcessor); @CheckReturnValue @NonNull static Single<Uri> getDownloadUrl(@NonNull final StorageReference ref); @CheckReturnValue @NonNull static Single<UploadTask.TaskSnapshot> putBytes(@NonNull final StorageReference ref,
                                                           @NonNull final byte[] bytes); @CheckReturnValue @NonNull static Single<UploadTask.TaskSnapshot> putBytes(
            @NonNull final StorageReference ref,
            @NonNull final byte[] bytes,
            @NonNull final StorageMetadata storageMetadata); @CheckReturnValue @NonNull static Single<UploadTask.TaskSnapshot> putFile(@NonNull final StorageReference ref,
                                                          @NonNull final Uri uri); @CheckReturnValue @NonNull static Single<UploadTask.TaskSnapshot> putFile(
            @NonNull final StorageReference ref,
            @NonNull final Uri uri,
            @NonNull final StorageMetadata storageMetadata); @CheckReturnValue @NonNull static Single<UploadTask.TaskSnapshot> putFile(
            @NonNull final StorageReference ref,
            @NonNull final Uri uri,
            @Nullable final StorageMetadata storageMetadata,
            @Nullable final Uri existingUploadUri); @CheckReturnValue @NonNull static Single<UploadTask.TaskSnapshot> putStream(
            @NonNull final StorageReference ref,
            @NonNull final InputStream inputStream); @CheckReturnValue @NonNull static Single<UploadTask.TaskSnapshot> putStream(
            @NonNull final StorageReference ref,
            @NonNull final InputStream inputStream,
            @NonNull final StorageMetadata storageMetadata); @CheckReturnValue @NonNull static Single<StorageMetadata> updateMetadata(
            @NonNull final StorageReference ref,
            @NonNull final StorageMetadata storageMetadata);  }
@Test public void testGetBytes() { mockSuccessfulResultForTask(mockBytesTask, new byte[] { 1, 2, 3 }); Mockito.when(mockStorageReference.getBytes(3)).thenReturn(mockBytesTask); TestObserver<byte[]> obs = TestObserver.create(); RxFirebaseStorage.getBytes(mockStorageReference, 3).subscribe(obs); verifyAddOnCompleteListenerForTask(mockBytesTask); callOnComplete(mockBytesTask); obs.dispose(); callOnComplete(mockBytesTask); obs.assertNoErrors(); obs.assertComplete(); obs.assertValue(new Predicate<byte[]>() { @Override public boolean test(byte[] bytes) throws Exception { return Arrays.equals(bytes, new byte[] { 1, 2, 3 }); } }); }
@Test public void testGetBytes_notSuccessful() { mockNotSuccessfulResultForTask(mockBytesTask, new IllegalStateException()); when(mockStorageReference.getBytes(3)).thenReturn(mockBytesTask); TestObserver<byte[]> obs = TestObserver.create(); RxFirebaseStorage.getBytes(mockStorageReference, 3).subscribe(obs); verifyAddOnCompleteListenerForTask(mockBytesTask); callOnComplete(mockBytesTask); obs.dispose(); callOnComplete(mockBytesTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }