StorageMigrator { public StorageMigrationResult migrate() { storageEraser.clearOdkDirOnScopedStorage(); if (!storageStateProvider.isEnoughSpaceToPerformMigration(storagePathProvider)) { return StorageMigrationResult.NOT_ENOUGH_SPACE; } if (!moveAppDataToScopedStorage()) { return StorageMigrationResult.MOVING_FILES_FAILED; } storageStateProvider.enableUsingScopedStorage(); reopenDatabases(); if (!migrateDatabasePaths()) { storageStateProvider.disableUsingScopedStorage(); reopenDatabases(); return StorageMigrationResult.MOVING_FILES_FAILED; } migrateMapLayerPath(); referenceManager.reset(); storageEraser.removeItemsetsDb(); storageEraser.clearCache(); storageEraser.deleteOdkDirFromUnscopedStorage(); return StorageMigrationResult.SUCCESS; } StorageMigrator(StoragePathProvider storagePathProvider, StorageStateProvider storageStateProvider,
                           StorageEraser storageEraser, StorageMigrationRepository storageMigrationRepository,
                           GeneralSharedPreferences generalSharedPreferences, ReferenceManager referenceManager,
                           Analytics analytics); StorageMigrationResult migrate();  }
@Test public void when_thereIsNoEnoughSpaceToPerformMigration_should_appropriateResultBeReturned() { doReturn(false).when(storageStateProvider).isEnoughSpaceToPerformMigration(storagePathProvider); assertThat(storageMigrator.migrate(), is(StorageMigrationResult.NOT_ENOUGH_SPACE)); }