@Test public void testCreateRepository() throws Exception { String id = ID; Map<String, Object> items = new HashMap<>(); when( pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ) ) .thenReturn( repositoryMeta ); when( pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ) ) .thenReturn( repository ); when( repository.test() ).thenReturn( true ); RepositoryMeta result = controller.createRepository( id, items ); assertNotEquals( null, result ); when( repository.test() ).thenReturn( false ); result = controller.createRepository( id, items ); assertEquals( null, result ); when( repository.test() ).thenReturn( true ); doThrow( new KettleException( "forced exception" ) ).when( repositoriesMeta ).writeData(); result = controller.createRepository( id, items ); assertEquals( null, result ); }
public RepositoryMeta createRepository( String id, Map<String, Object> items ) { RepositoriesMeta repositoriesMeta = getRepositoriesMeta(); RepositoryMeta repositoryMeta; try { repositoryMeta = pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ); repositoryMeta.populate( items, repositoriesMeta ); if ( repositoryMeta.getName() != null ) { Repository repository = pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ); repository.init( repositoryMeta ); repositoriesMeta.addRepository( repositoryMeta ); repositoriesMeta.writeData(); setCurrentRepository( repositoryMeta ); if ( !testRepository( repository ) ) { return null; } ( (AbstractRepository) repository ).create(); } } catch ( KettleException ke ) { log.logError( "Unable to load repository type", ke ); return null; } return repositoryMeta; }
RepositoryConnectController implements IConnectedRepositoryInstance { public RepositoryMeta createRepository( String id, Map<String, Object> items ) { RepositoriesMeta repositoriesMeta = getRepositoriesMeta(); RepositoryMeta repositoryMeta; try { repositoryMeta = pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ); repositoryMeta.populate( items, repositoriesMeta ); if ( repositoryMeta.getName() != null ) { Repository repository = pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ); repository.init( repositoryMeta ); repositoriesMeta.addRepository( repositoryMeta ); repositoriesMeta.writeData(); setCurrentRepository( repositoryMeta ); if ( !testRepository( repository ) ) { return null; } ( (AbstractRepository) repository ).create(); } } catch ( KettleException ke ) { log.logError( "Unable to load repository type", ke ); return null; } return repositoryMeta; } }
RepositoryConnectController implements IConnectedRepositoryInstance { public RepositoryMeta createRepository( String id, Map<String, Object> items ) { RepositoriesMeta repositoriesMeta = getRepositoriesMeta(); RepositoryMeta repositoryMeta; try { repositoryMeta = pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ); repositoryMeta.populate( items, repositoriesMeta ); if ( repositoryMeta.getName() != null ) { Repository repository = pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ); repository.init( repositoryMeta ); repositoriesMeta.addRepository( repositoryMeta ); repositoriesMeta.writeData(); setCurrentRepository( repositoryMeta ); if ( !testRepository( repository ) ) { return null; } ( (AbstractRepository) repository ).create(); } } catch ( KettleException ke ) { log.logError( "Unable to load repository type", ke ); return null; } return repositoryMeta; } RepositoryConnectController( PluginRegistry pluginRegistry, Supplier<Spoon> spoonSupplier );  RepositoryConnectController(); }
RepositoryConnectController implements IConnectedRepositoryInstance { public RepositoryMeta createRepository( String id, Map<String, Object> items ) { RepositoriesMeta repositoriesMeta = getRepositoriesMeta(); RepositoryMeta repositoryMeta; try { repositoryMeta = pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ); repositoryMeta.populate( items, repositoriesMeta ); if ( repositoryMeta.getName() != null ) { Repository repository = pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ); repository.init( repositoryMeta ); repositoriesMeta.addRepository( repositoryMeta ); repositoriesMeta.writeData(); setCurrentRepository( repositoryMeta ); if ( !testRepository( repository ) ) { return null; } ( (AbstractRepository) repository ).create(); } } catch ( KettleException ke ) { log.logError( "Unable to load repository type", ke ); return null; } return repositoryMeta; } RepositoryConnectController( PluginRegistry pluginRegistry, Supplier<Spoon> spoonSupplier );  RepositoryConnectController(); boolean help(); String createConnection(); String editDatabaseConnection( String database ); boolean deleteDatabaseConnection( String database ); String browse(); @SuppressWarnings( "unchecked" ) String getPlugins(); boolean updateRepository( String id, Map<String, Object> items ); RepositoryMeta createRepository( String id, Map<String, Object> items ); @SuppressWarnings( "unchecked" ) String getRepositories(); String getRepository( String name ); DatabaseMeta getDatabase( String name ); void removeDatabase( String name ); @SuppressWarnings( "unchecked" ) String getDatabases(); void connectToRepository(); void connectToRepository( RepositoryMeta repositoryMeta ); void connectToRepository( String repositoryName, String username, String password ); void connectToRepository( RepositoryMeta repositoryMeta, String username, String password ); void reconnectToRepository( String repositoryName, String username, String password ); void reconnectToRepository( String username, String password ); boolean deleteRepository( String name ); void addDatabase( DatabaseMeta databaseMeta ); boolean setDefaultRepository( String name ); boolean clearDefaultRepository(); String getCurrentUser(); void setCurrentRepository( RepositoryMeta repositoryMeta ); RepositoryMeta getCurrentRepository(); RepositoryMeta getConnectedRepository(); void setConnectedRepository( RepositoryMeta connectedRepository ); RepositoryMeta getDefaultRepositoryMeta(); RepositoryMeta getRepositoryMetaByName( String name ); boolean isConnected( String name ); boolean isConnected(); Repository getConnectedRepositoryInstance(); void save(); boolean checkDuplicate( String name ); PropsUI getPropsUI(); void addListener( RepositoryContollerListener listener ); void removeListener( RepositoryContollerListener listener ); void fireListeners(); boolean isRelogin(); void setRelogin( boolean relogin ); Map<String, Object> modelToMap( RepositoryModel model ); boolean isDatabaseWithNameExist( DatabaseMeta databaseMeta, boolean isNew ); }
RepositoryConnectController implements IConnectedRepositoryInstance { public RepositoryMeta createRepository( String id, Map<String, Object> items ) { RepositoriesMeta repositoriesMeta = getRepositoriesMeta(); RepositoryMeta repositoryMeta; try { repositoryMeta = pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ); repositoryMeta.populate( items, repositoriesMeta ); if ( repositoryMeta.getName() != null ) { Repository repository = pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ); repository.init( repositoryMeta ); repositoriesMeta.addRepository( repositoryMeta ); repositoriesMeta.writeData(); setCurrentRepository( repositoryMeta ); if ( !testRepository( repository ) ) { return null; } ( (AbstractRepository) repository ).create(); } } catch ( KettleException ke ) { log.logError( "Unable to load repository type", ke ); return null; } return repositoryMeta; } RepositoryConnectController( PluginRegistry pluginRegistry, Supplier<Spoon> spoonSupplier );  RepositoryConnectController(); boolean help(); String createConnection(); String editDatabaseConnection( String database ); boolean deleteDatabaseConnection( String database ); String browse(); @SuppressWarnings( "unchecked" ) String getPlugins(); boolean updateRepository( String id, Map<String, Object> items ); RepositoryMeta createRepository( String id, Map<String, Object> items ); @SuppressWarnings( "unchecked" ) String getRepositories(); String getRepository( String name ); DatabaseMeta getDatabase( String name ); void removeDatabase( String name ); @SuppressWarnings( "unchecked" ) String getDatabases(); void connectToRepository(); void connectToRepository( RepositoryMeta repositoryMeta ); void connectToRepository( String repositoryName, String username, String password ); void connectToRepository( RepositoryMeta repositoryMeta, String username, String password ); void reconnectToRepository( String repositoryName, String username, String password ); void reconnectToRepository( String username, String password ); boolean deleteRepository( String name ); void addDatabase( DatabaseMeta databaseMeta ); boolean setDefaultRepository( String name ); boolean clearDefaultRepository(); String getCurrentUser(); void setCurrentRepository( RepositoryMeta repositoryMeta ); RepositoryMeta getCurrentRepository(); RepositoryMeta getConnectedRepository(); void setConnectedRepository( RepositoryMeta connectedRepository ); RepositoryMeta getDefaultRepositoryMeta(); RepositoryMeta getRepositoryMetaByName( String name ); boolean isConnected( String name ); boolean isConnected(); Repository getConnectedRepositoryInstance(); void save(); boolean checkDuplicate( String name ); PropsUI getPropsUI(); void addListener( RepositoryContollerListener listener ); void removeListener( RepositoryContollerListener listener ); void fireListeners(); boolean isRelogin(); void setRelogin( boolean relogin ); Map<String, Object> modelToMap( RepositoryModel model ); boolean isDatabaseWithNameExist( DatabaseMeta databaseMeta, boolean isNew ); static final String DISPLAY_NAME; static final String DESCRIPTION; static final String IS_DEFAULT; static final String URL; static final String DATABASE_CONNECTION; static final String SHOW_HIDDEN_FOLDERS; static final String LOCATION; static final String DO_NOT_MODIFY; static final String ORIGINAL_NAME; static final String DEFAULT_URL; static final String MESSAGE; static final String SUCCESS; static final String ERROR_401; static final String HELP_URL; }