@Test public void testCreate() throws Exception { RunConfigurationDialog dialog = mock( RunConfigurationDialog.class ); whenNew( RunConfigurationDialog.class ).withAnyArguments().thenReturn( dialog ); List<String> list = new ArrayList<>(); list.add( "Configuration 1" ); DefaultRunConfiguration config = new DefaultRunConfiguration(); config.setName( "Test" ); config.setServer( "localhost" ); doReturn( list ).when( service ).getNames(); doReturn( config ).when( dialog ).open(); delegate.create(); verify( service, times( 1 ) ).save( config ); verify( spoon, times( 1 ) ).refreshTree(); }
public void create() { List<String> names = configurationManager.getNames(); String name = BaseMessages.getString( PKG, "RunConfigurationPopupMenuExtension.Configuration.Default" ) + " "; int index = 1; while ( names.contains( name + String.valueOf( index ) ) ) { index++; } name = name + String.valueOf( index ); DefaultRunConfiguration defaultRunConfiguration = new DefaultRunConfiguration(); defaultRunConfiguration.setName( name ); RunConfigurationDialog dialog = new RunConfigurationDialog( spoonSupplier.get().getShell(), configurationManager, defaultRunConfiguration ); RunConfiguration savedRunConfiguration = dialog.open(); if ( savedRunConfiguration != null ) { configurationManager.save( savedRunConfiguration ); spoonSupplier.get().refreshTree(); } }
RunConfigurationDelegate { public void create() { List<String> names = configurationManager.getNames(); String name = BaseMessages.getString( PKG, "RunConfigurationPopupMenuExtension.Configuration.Default" ) + " "; int index = 1; while ( names.contains( name + String.valueOf( index ) ) ) { index++; } name = name + String.valueOf( index ); DefaultRunConfiguration defaultRunConfiguration = new DefaultRunConfiguration(); defaultRunConfiguration.setName( name ); RunConfigurationDialog dialog = new RunConfigurationDialog( spoonSupplier.get().getShell(), configurationManager, defaultRunConfiguration ); RunConfiguration savedRunConfiguration = dialog.open(); if ( savedRunConfiguration != null ) { configurationManager.save( savedRunConfiguration ); spoonSupplier.get().refreshTree(); } } }
RunConfigurationDelegate { public void create() { List<String> names = configurationManager.getNames(); String name = BaseMessages.getString( PKG, "RunConfigurationPopupMenuExtension.Configuration.Default" ) + " "; int index = 1; while ( names.contains( name + String.valueOf( index ) ) ) { index++; } name = name + String.valueOf( index ); DefaultRunConfiguration defaultRunConfiguration = new DefaultRunConfiguration(); defaultRunConfiguration.setName( name ); RunConfigurationDialog dialog = new RunConfigurationDialog( spoonSupplier.get().getShell(), configurationManager, defaultRunConfiguration ); RunConfiguration savedRunConfiguration = dialog.open(); if ( savedRunConfiguration != null ) { configurationManager.save( savedRunConfiguration ); spoonSupplier.get().refreshTree(); } } RunConfigurationDelegate( RunConfigurationService configurationManager ); }
RunConfigurationDelegate { public void create() { List<String> names = configurationManager.getNames(); String name = BaseMessages.getString( PKG, "RunConfigurationPopupMenuExtension.Configuration.Default" ) + " "; int index = 1; while ( names.contains( name + String.valueOf( index ) ) ) { index++; } name = name + String.valueOf( index ); DefaultRunConfiguration defaultRunConfiguration = new DefaultRunConfiguration(); defaultRunConfiguration.setName( name ); RunConfigurationDialog dialog = new RunConfigurationDialog( spoonSupplier.get().getShell(), configurationManager, defaultRunConfiguration ); RunConfiguration savedRunConfiguration = dialog.open(); if ( savedRunConfiguration != null ) { configurationManager.save( savedRunConfiguration ); spoonSupplier.get().refreshTree(); } } RunConfigurationDelegate( RunConfigurationService configurationManager ); void edit( RunConfiguration runConfiguration ); void delete( RunConfiguration runConfiguration ); void create(); List<RunConfiguration> load(); }
RunConfigurationDelegate { public void create() { List<String> names = configurationManager.getNames(); String name = BaseMessages.getString( PKG, "RunConfigurationPopupMenuExtension.Configuration.Default" ) + " "; int index = 1; while ( names.contains( name + String.valueOf( index ) ) ) { index++; } name = name + String.valueOf( index ); DefaultRunConfiguration defaultRunConfiguration = new DefaultRunConfiguration(); defaultRunConfiguration.setName( name ); RunConfigurationDialog dialog = new RunConfigurationDialog( spoonSupplier.get().getShell(), configurationManager, defaultRunConfiguration ); RunConfiguration savedRunConfiguration = dialog.open(); if ( savedRunConfiguration != null ) { configurationManager.save( savedRunConfiguration ); spoonSupplier.get().refreshTree(); } } RunConfigurationDelegate( RunConfigurationService configurationManager ); void edit( RunConfiguration runConfiguration ); void delete( RunConfiguration runConfiguration ); void create(); List<RunConfiguration> load();  }