@Test public void testRunning() throws MigrationException { final Set<MigrationPlugin> plugins = new HashSet<>(); MigrationPlugin plugin1 = mock( MigrationPlugin.class ); when( plugin1.getName() ).thenReturn( "plugin1" ); when( plugin1.getPhase() ).thenReturn( PluginPhase.MIGRATE ); plugins.add( plugin1 ); final MigrationInfoSerialization migrationInfoSerialization = mock( MigrationInfoSerialization.class ); when( migrationInfoSerialization.getStatusCode( "plugin1" ) ) .thenReturn( DataMigrationManagerImpl.StatusCode.RUNNING.status ); final MigrationInfoCache migrationInfoCache = mock(MigrationInfoCache.class); DataMigrationManagerImpl migrationManager = new DataMigrationManagerImpl( plugins, migrationInfoSerialization, migrationInfoCache ); boolean status = migrationManager.isRunning(); assertTrue( "Status is set", status ); when( migrationInfoSerialization.getStatusCode( "plugin1" ) ) .thenReturn( DataMigrationManagerImpl.StatusCode.COMPLETE.status ); status = migrationManager.isRunning(); assertFalse( "Status is not running", status ); when( migrationInfoSerialization.getStatusCode( "plugin1" ) ) .thenReturn( DataMigrationManagerImpl.StatusCode.ERROR.status ); status = migrationManager.isRunning(); assertFalse( "Status is not running", status ); }
@Override public boolean isRunning() { for(final String pluginName :getPluginNames()){ if( migrationInfoSerialization.getStatusCode(pluginName) == StatusCode.RUNNING.status){ return true; } } return false; }
DataMigrationManagerImpl implements DataMigrationManager { @Override public boolean isRunning() { for(final String pluginName :getPluginNames()){ if( migrationInfoSerialization.getStatusCode(pluginName) == StatusCode.RUNNING.status){ return true; } } return false; } }
DataMigrationManagerImpl implements DataMigrationManager { @Override public boolean isRunning() { for(final String pluginName :getPluginNames()){ if( migrationInfoSerialization.getStatusCode(pluginName) == StatusCode.RUNNING.status){ return true; } } return false; } @Inject  DataMigrationManagerImpl( final Set<MigrationPlugin> plugins,
                                     final MigrationInfoSerialization migrationInfoSerialization,
                                     final MigrationInfoCache migrationInfoCache
    ); }
DataMigrationManagerImpl implements DataMigrationManager { @Override public boolean isRunning() { for(final String pluginName :getPluginNames()){ if( migrationInfoSerialization.getStatusCode(pluginName) == StatusCode.RUNNING.status){ return true; } } return false; } @Inject  DataMigrationManagerImpl( final Set<MigrationPlugin> plugins,
                                     final MigrationInfoSerialization migrationInfoSerialization,
                                     final MigrationInfoCache migrationInfoCache
    ); @Override boolean pluginExists(final String name); @Override void migrate(final String name); @Override void migrate(); @Override boolean isRunning(); @Override int getCurrentVersion( final String pluginName ); @Override void resetToVersion( final String pluginName, final int version ); @Override String getLastStatus( final String pluginName ); @Override Set<String> getPluginNames(); List<MigrationPlugin> getExecutionOrder(); }
DataMigrationManagerImpl implements DataMigrationManager { @Override public boolean isRunning() { for(final String pluginName :getPluginNames()){ if( migrationInfoSerialization.getStatusCode(pluginName) == StatusCode.RUNNING.status){ return true; } } return false; } @Inject  DataMigrationManagerImpl( final Set<MigrationPlugin> plugins,
                                     final MigrationInfoSerialization migrationInfoSerialization,
                                     final MigrationInfoCache migrationInfoCache
    ); @Override boolean pluginExists(final String name); @Override void migrate(final String name); @Override void migrate(); @Override boolean isRunning(); @Override int getCurrentVersion( final String pluginName ); @Override void resetToVersion( final String pluginName, final int version ); @Override String getLastStatus( final String pluginName ); @Override Set<String> getPluginNames(); List<MigrationPlugin> getExecutionOrder();  }