### Question:
ExplicitIndexMigrator extends AbstractStoreMigrationParticipant { @Override public void migrate( DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressMonitor, String versionToMigrateFrom, String versionToMigrateTo ) throws IOException { IndexImplementation indexImplementation = explicitIndexProvider.getProviderByName( LUCENE_EXPLICIT_INDEX_PROVIDER_NAME ); if ( indexImplementation != null ) { RecordFormats from = RecordFormatSelector.selectForVersion( versionToMigrateFrom ); RecordFormats to = RecordFormatSelector.selectForVersion( versionToMigrateTo ); if ( !from.hasCompatibleCapabilities( to, CapabilityType.INDEX ) ) { originalExplicitIndexesRoot = indexImplementation.getIndexImplementationDirectory( directoryLayout ); migrationExplicitIndexesRoot = indexImplementation.getIndexImplementationDirectory( migrationLayout ); if ( isNotEmptyDirectory( originalExplicitIndexesRoot ) ) { migrateExplicitIndexes( progressMonitor ); explicitIndexMigrated = true; } } } else { log.debug( "Lucene index provider not found, nothing to migrate." ); } } ExplicitIndexMigrator( FileSystemAbstraction fileSystem, ExplicitIndexProvider explicitIndexProvider,
            LogProvider logProvider ); @Override void migrate( DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressMonitor,
            String versionToMigrateFrom, String versionToMigrateTo ); @Override void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToMigrateFrom,
            String versionToMigrateTo ); @Override void cleanup( DatabaseLayout migrationLayout );  }### Answer:
@Test public void skipEmptyIndexStorageMigration() throws IOException { when( fs.listFiles( originalIndexStore ) ).thenReturn( null ); ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); verify( fs, never() ).deleteRecursively( originalIndexStore ); verify( fs, never() ).moveToDirectory( migratedIndexStore, storeLayout.databaseDirectory() ); }
@Test public void transferOriginalDataToMigrationDirectory() throws IOException { ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); verify( fs ).copyRecursively( originalIndexStore, migratedIndexStore ); }
@Test public void logErrorWithIndexNameOnIndexMigrationException() { Log log = mock( Log.class ); when( logProvider.getLog( TestExplicitIndexMigrator.class ) ).thenReturn( log ); ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); try { ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, false ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); fail( "Index migration should fail" ); } catch ( IOException e ) { } verify( log ).error( eq( "Migration of explicit indexes failed. Index: testIndex can't be migrated." ), any( Throwable.class ) ); }