@Test public void setAndInitializeSyncProvider() { when(mSyncProviderStore.setSyncProvider(any(SyncProvider.class))).thenReturn(true); mBackupProvidersManager.setAndInitializeSyncProvider(SyncProvider.GoogleDrive, mFragmentActivity); verify(mNoneBackupProvider).deinitialize(); verify(mDriveBackupProvider).initialize(mFragmentActivity); mBackupProvidersManager.onActivityResult(0, 0, null); verify(mDriveBackupProvider).onActivityResult(0, 0, null); mBackupProvidersManager.deinitialize(); verify(mDriveBackupProvider).deinitialize(); mBackupProvidersManager.initialize(mFragmentActivity); verify(mDriveBackupProvider, times(2)).initialize(mFragmentActivity); verify(mBackupProviderChangeListener1).onProviderChanged(SyncProvider.GoogleDrive); mBackupProvidersManager.getRemoteBackups(); verify(mDriveBackupProvider).getRemoteBackups(); mBackupProvidersManager.getDeviceSyncId(); verify(mDriveBackupProvider).getDeviceSyncId(); verifyZeroInteractions(mBackupProviderChangeListener2); }
public synchronized void setAndInitializeSyncProvider(@NonNull SyncProvider syncProvider, @Nullable FragmentActivity fragmentActivity) { if (syncProviderStore.setSyncProvider(syncProvider)) { Logger.info(this, "Initializing new Backup Provider: {}", syncProvider); backupProvider.deinitialize(); backupProvider = syncProviderFactory.get(syncProvider); backupProvider.initialize(fragmentActivity); for (final BackupProviderChangeListener backupProviderChangeListener : backupProviderChangeListeners) { backupProviderChangeListener.onProviderChanged(syncProvider); } } }
BackupProvidersManager implements BackupProvider { public synchronized void setAndInitializeSyncProvider(@NonNull SyncProvider syncProvider, @Nullable FragmentActivity fragmentActivity) { if (syncProviderStore.setSyncProvider(syncProvider)) { Logger.info(this, "Initializing new Backup Provider: {}", syncProvider); backupProvider.deinitialize(); backupProvider = syncProviderFactory.get(syncProvider); backupProvider.initialize(fragmentActivity); for (final BackupProviderChangeListener backupProviderChangeListener : backupProviderChangeListeners) { backupProviderChangeListener.onProviderChanged(syncProvider); } } } }
BackupProvidersManager implements BackupProvider { public synchronized void setAndInitializeSyncProvider(@NonNull SyncProvider syncProvider, @Nullable FragmentActivity fragmentActivity) { if (syncProviderStore.setSyncProvider(syncProvider)) { Logger.info(this, "Initializing new Backup Provider: {}", syncProvider); backupProvider.deinitialize(); backupProvider = syncProviderFactory.get(syncProvider); backupProvider.initialize(fragmentActivity); for (final BackupProviderChangeListener backupProviderChangeListener : backupProviderChangeListeners) { backupProviderChangeListener.onProviderChanged(syncProvider); } } } @Inject  BackupProvidersManager(@NonNull SyncProviderFactory syncProviderFactory,
                                  @NonNull SyncProviderStore syncProviderStore,
                                  @NonNull NetworkManager networkManager); }
BackupProvidersManager implements BackupProvider { public synchronized void setAndInitializeSyncProvider(@NonNull SyncProvider syncProvider, @Nullable FragmentActivity fragmentActivity) { if (syncProviderStore.setSyncProvider(syncProvider)) { Logger.info(this, "Initializing new Backup Provider: {}", syncProvider); backupProvider.deinitialize(); backupProvider = syncProviderFactory.get(syncProvider); backupProvider.initialize(fragmentActivity); for (final BackupProviderChangeListener backupProviderChangeListener : backupProviderChangeListeners) { backupProviderChangeListener.onProviderChanged(syncProvider); } } } @Inject  BackupProvidersManager(@NonNull SyncProviderFactory syncProviderFactory,
                                  @NonNull SyncProviderStore syncProviderStore,
                                  @NonNull NetworkManager networkManager); void registerChangeListener(@NonNull BackupProviderChangeListener backupProviderChangeListener); void unregisterChangeListener(@NonNull BackupProviderChangeListener backupProviderChangeListener); synchronized void setAndInitializeSyncProvider(@NonNull SyncProvider syncProvider, @Nullable FragmentActivity fragmentActivity); synchronized void setAndInitializeNetworkProviderType(@NonNull SupportedNetworkType supportedNetworkType); @NonNull SyncProvider getSyncProvider(); @Override synchronized void initialize(@Nullable FragmentActivity activity); @Override synchronized void deinitialize(); @Override synchronized boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data); @NonNull @Override Single<List<RemoteBackupMetadata>> getRemoteBackups(); @Nullable @Override Identifier getDeviceSyncId(); @NonNull @Override Date getLastDatabaseSyncTime(); @NonNull @Override Single<Boolean> restoreBackup(@NonNull RemoteBackupMetadata remoteBackupMetadata, boolean overwriteExistingData); @NonNull @Override Single<com.google.api.services.drive.model.File> renameBackup(@NonNull RemoteBackupMetadata remoteBackupMetadata, @NonNull String newFileName); @NonNull @Override Single<Boolean> deleteBackup(@NonNull RemoteBackupMetadata remoteBackupMetadata); @Override Single<Boolean> clearCurrentBackupConfiguration(); @NonNull @Override Single<List<File>> downloadAllData(@NonNull RemoteBackupMetadata remoteBackupMetadata, @NonNull File downloadLocation); @NonNull @Override Single<List<File>> debugDownloadAllData(@NonNull RemoteBackupMetadata remoteBackupMetadata, @NonNull File downloadLocation); @NonNull @Override Observable<CriticalSyncError> getCriticalSyncErrorStream(); @Override void markErrorResolved(@NonNull SyncErrorType syncErrorType); }
BackupProvidersManager implements BackupProvider { public synchronized void setAndInitializeSyncProvider(@NonNull SyncProvider syncProvider, @Nullable FragmentActivity fragmentActivity) { if (syncProviderStore.setSyncProvider(syncProvider)) { Logger.info(this, "Initializing new Backup Provider: {}", syncProvider); backupProvider.deinitialize(); backupProvider = syncProviderFactory.get(syncProvider); backupProvider.initialize(fragmentActivity); for (final BackupProviderChangeListener backupProviderChangeListener : backupProviderChangeListeners) { backupProviderChangeListener.onProviderChanged(syncProvider); } } } @Inject  BackupProvidersManager(@NonNull SyncProviderFactory syncProviderFactory,
                                  @NonNull SyncProviderStore syncProviderStore,
                                  @NonNull NetworkManager networkManager); void registerChangeListener(@NonNull BackupProviderChangeListener backupProviderChangeListener); void unregisterChangeListener(@NonNull BackupProviderChangeListener backupProviderChangeListener); synchronized void setAndInitializeSyncProvider(@NonNull SyncProvider syncProvider, @Nullable FragmentActivity fragmentActivity); synchronized void setAndInitializeNetworkProviderType(@NonNull SupportedNetworkType supportedNetworkType); @NonNull SyncProvider getSyncProvider(); @Override synchronized void initialize(@Nullable FragmentActivity activity); @Override synchronized void deinitialize(); @Override synchronized boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data); @NonNull @Override Single<List<RemoteBackupMetadata>> getRemoteBackups(); @Nullable @Override Identifier getDeviceSyncId(); @NonNull @Override Date getLastDatabaseSyncTime(); @NonNull @Override Single<Boolean> restoreBackup(@NonNull RemoteBackupMetadata remoteBackupMetadata, boolean overwriteExistingData); @NonNull @Override Single<com.google.api.services.drive.model.File> renameBackup(@NonNull RemoteBackupMetadata remoteBackupMetadata, @NonNull String newFileName); @NonNull @Override Single<Boolean> deleteBackup(@NonNull RemoteBackupMetadata remoteBackupMetadata); @Override Single<Boolean> clearCurrentBackupConfiguration(); @NonNull @Override Single<List<File>> downloadAllData(@NonNull RemoteBackupMetadata remoteBackupMetadata, @NonNull File downloadLocation); @NonNull @Override Single<List<File>> debugDownloadAllData(@NonNull RemoteBackupMetadata remoteBackupMetadata, @NonNull File downloadLocation); @NonNull @Override Observable<CriticalSyncError> getCriticalSyncErrorStream(); @Override void markErrorResolved(@NonNull SyncErrorType syncErrorType);  }