@Test public void updateDriveFileWithIdentifierErrorIsForwarded() throws Exception { final java.io.File file = new java.io.File("/"); final Exception exception = new Exception("test"); when(driveDataStreams.updateFile(identifier, file)).thenReturn(Single.error(exception)); final TestObserver<Identifier> testObserver = driveStreamsManager.updateDriveFile(identifier, file).test(); testObserver.assertNoValues(); testObserver.assertNotComplete(); testObserver.assertError(Exception.class); verify(driveErrorStream).onNext(Optional.of(criticalSyncError)); }
@NonNull public Single<SyncState> updateDriveFile(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file) { Preconditions.checkNotNull(currentSyncState); Preconditions.checkNotNull(file); return newBlockUntilConnectedCompletable() .andThen(updateDrive(currentSyncState, file)) .flatMap(driveFile -> Single.just(driveStreamMappings.postUpdateSyncState(driveFile))) .doOnError(throwable -> driveErrorStream.onNext(Optional.of(syncErrorTranslator.get(throwable)))); }
DriveStreamsManager implements GoogleApiClient.ConnectionCallbacks { @NonNull public Single<SyncState> updateDriveFile(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file) { Preconditions.checkNotNull(currentSyncState); Preconditions.checkNotNull(file); return newBlockUntilConnectedCompletable() .andThen(updateDrive(currentSyncState, file)) .flatMap(driveFile -> Single.just(driveStreamMappings.postUpdateSyncState(driveFile))) .doOnError(throwable -> driveErrorStream.onNext(Optional.of(syncErrorTranslator.get(throwable)))); } }
DriveStreamsManager implements GoogleApiClient.ConnectionCallbacks { @NonNull public Single<SyncState> updateDriveFile(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file) { Preconditions.checkNotNull(currentSyncState); Preconditions.checkNotNull(file); return newBlockUntilConnectedCompletable() .andThen(updateDrive(currentSyncState, file)) .flatMap(driveFile -> Single.just(driveStreamMappings.postUpdateSyncState(driveFile))) .doOnError(throwable -> driveErrorStream.onNext(Optional.of(syncErrorTranslator.get(throwable)))); } DriveStreamsManager(@NonNull Context context,
                               @NonNull DriveServiceHelper driveServiceHelper,
                               @NonNull GoogleDriveSyncMetadata googleDriveSyncMetadata,
                               @NonNull Subject<Optional<Throwable>> driveErrorStream); @VisibleForTesting  DriveStreamsManager(@NonNull DriveDataStreams driveDataStreams,
                        @NonNull DriveStreamMappings driveStreamMappings,
                        @NonNull Subject<Optional<Throwable>> driveErrorStream,
                        @NonNull DriveThrowableToSyncErrorTranslator syncErrorTranslator); }
DriveStreamsManager implements GoogleApiClient.ConnectionCallbacks { @NonNull public Single<SyncState> updateDriveFile(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file) { Preconditions.checkNotNull(currentSyncState); Preconditions.checkNotNull(file); return newBlockUntilConnectedCompletable() .andThen(updateDrive(currentSyncState, file)) .flatMap(driveFile -> Single.just(driveStreamMappings.postUpdateSyncState(driveFile))) .doOnError(throwable -> driveErrorStream.onNext(Optional.of(syncErrorTranslator.get(throwable)))); } DriveStreamsManager(@NonNull Context context,
                               @NonNull DriveServiceHelper driveServiceHelper,
                               @NonNull GoogleDriveSyncMetadata googleDriveSyncMetadata,
                               @NonNull Subject<Optional<Throwable>> driveErrorStream); @VisibleForTesting  DriveStreamsManager(@NonNull DriveDataStreams driveDataStreams,
                        @NonNull DriveStreamMappings driveStreamMappings,
                        @NonNull Subject<Optional<Throwable>> driveErrorStream,
                        @NonNull DriveThrowableToSyncErrorTranslator syncErrorTranslator); @Override void onConnected(@Nullable Bundle bundle); @Override void onConnectionSuspended(int cause); @NonNull Single<List<RemoteBackupMetadata>> getRemoteBackups(); @NonNull synchronized Single<FileList> getAllFiles(); @NonNull synchronized Single<FileList> getFilesInFolder(@NonNull final String folderId); @NonNull synchronized Single<FileList> getFilesInFolder(@NonNull final String driveFolderId, @NonNull final String fileName); @NonNull Single<SyncState> uploadFileToDrive(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file); @NonNull Single<Identifier> uploadFileToDrive(@NonNull final java.io.File file); @NonNull Single<SyncState> updateDriveFile(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file); @NonNull Single<Identifier> updateDriveFile(@NonNull final Identifier currentIdentifier, @NonNull final java.io.File file); @NonNull Single<SyncState> deleteDriveFile(@NonNull final SyncState currentSyncState, final boolean isFullDelete); @NonNull Single<File> renameBackup(@NonNull final Identifier identifier, @NonNull final String newFileName); @NonNull Single<Boolean> delete(@NonNull final Identifier identifier); void clearCachedData(); @NonNull Single<Optional<java.io.File>> download(@NonNull final String fileId, @NonNull final java.io.File downloadLocationFile); }
DriveStreamsManager implements GoogleApiClient.ConnectionCallbacks { @NonNull public Single<SyncState> updateDriveFile(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file) { Preconditions.checkNotNull(currentSyncState); Preconditions.checkNotNull(file); return newBlockUntilConnectedCompletable() .andThen(updateDrive(currentSyncState, file)) .flatMap(driveFile -> Single.just(driveStreamMappings.postUpdateSyncState(driveFile))) .doOnError(throwable -> driveErrorStream.onNext(Optional.of(syncErrorTranslator.get(throwable)))); } DriveStreamsManager(@NonNull Context context,
                               @NonNull DriveServiceHelper driveServiceHelper,
                               @NonNull GoogleDriveSyncMetadata googleDriveSyncMetadata,
                               @NonNull Subject<Optional<Throwable>> driveErrorStream); @VisibleForTesting  DriveStreamsManager(@NonNull DriveDataStreams driveDataStreams,
                        @NonNull DriveStreamMappings driveStreamMappings,
                        @NonNull Subject<Optional<Throwable>> driveErrorStream,
                        @NonNull DriveThrowableToSyncErrorTranslator syncErrorTranslator); @Override void onConnected(@Nullable Bundle bundle); @Override void onConnectionSuspended(int cause); @NonNull Single<List<RemoteBackupMetadata>> getRemoteBackups(); @NonNull synchronized Single<FileList> getAllFiles(); @NonNull synchronized Single<FileList> getFilesInFolder(@NonNull final String folderId); @NonNull synchronized Single<FileList> getFilesInFolder(@NonNull final String driveFolderId, @NonNull final String fileName); @NonNull Single<SyncState> uploadFileToDrive(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file); @NonNull Single<Identifier> uploadFileToDrive(@NonNull final java.io.File file); @NonNull Single<SyncState> updateDriveFile(@NonNull final SyncState currentSyncState, @NonNull final java.io.File file); @NonNull Single<Identifier> updateDriveFile(@NonNull final Identifier currentIdentifier, @NonNull final java.io.File file); @NonNull Single<SyncState> deleteDriveFile(@NonNull final SyncState currentSyncState, final boolean isFullDelete); @NonNull Single<File> renameBackup(@NonNull final Identifier identifier, @NonNull final String newFileName); @NonNull Single<Boolean> delete(@NonNull final Identifier identifier); void clearCachedData(); @NonNull Single<Optional<java.io.File>> download(@NonNull final String fileId, @NonNull final java.io.File downloadLocationFile);  }