DriveStreamsManager implements GoogleApiClient.ConnectionCallbacks { @NonNull public Single<File> renameBackup(@NonNull final Identifier identifier, @NonNull final String newFileName) { Preconditions.checkNotNull(identifier); Preconditions.checkNotNull(newFileName); return newBlockUntilConnectedCompletable() .andThen(driveDataStreams.renameBackup(identifier, newFileName)) .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);  }
@Test public void rename() throws Exception { final String newFileName = "Test Name"; when(driveDataStreams.renameBackup(identifier, newFileName)).thenReturn(Single.just(driveFile)); final TestObserver<File> testObserver = driveStreamsManager.renameBackup(identifier, newFileName).test(); testObserver.assertValue(driveFile); testObserver.assertComplete(); testObserver.assertNoErrors(); }