PentahoPlatformExporter extends ZipExportProcessor { protected void exportDatasources() { log.debug( "export datasources" ); try { for ( IDatabaseConnection datasource : getDatasourceMgmtService().getDatasources() ) { if ( datasource instanceof org.pentaho.database.model.DatabaseConnection ) { getExportManifest().addDatasource( DatabaseConnectionConverter.model2export( datasource ) ); } } } catch ( DatasourceMgmtServiceException e ) { log.warn( e.getMessage(), e ); } } PentahoPlatformExporter( IUnifiedRepository repository ); File performExport(); @Override File performExport( RepositoryFile exportRepositoryFile ); IScheduler getScheduler(); void setScheduler( IScheduler scheduler ); IMetadataDomainRepository getMetadataDomainRepository(); void setMetadataDomainRepository( IMetadataDomainRepository metadataDomainRepository ); IDatasourceMgmtService getDatasourceMgmtService(); void setDatasourceMgmtService( IDatasourceMgmtService datasourceMgmtService ); MondrianCatalogRepositoryHelper getMondrianCatalogRepositoryHelper(); void setMondrianCatalogRepositoryHelper(
    MondrianCatalogRepositoryHelper mondrianCatalogRepositoryHelper ); IMondrianCatalogService getMondrianCatalogService(); void setMondrianCatalogService(
    IMondrianCatalogService mondrianCatalogService ); IUserSettingService getUserSettingService(); void setUserSettingService( IUserSettingService userSettingService ); static final String ROOT; static final String DATA_SOURCES_PATH_IN_ZIP; static final String METADATA_PATH_IN_ZIP; static final String ANALYSIS_PATH_IN_ZIP; static final String CONNECTIONS_PATH_IN_ZIP; static final String METASTORE; static final String METASTORE_BACKUP_EXT; }
@Test public void testExportDatasources() throws Exception { IDatasourceMgmtService svc = mock( IDatasourceMgmtService.class ); exporterSpy.setDatasourceMgmtService( svc ); List<IDatabaseConnection> datasources = new ArrayList<>(); IDatabaseConnection conn = mock( org.pentaho.database.model.DatabaseConnection.class ); when( conn.getName() ).thenReturn( "aDatasourceName" ); IDatabaseConnection icon = mock( IDatabaseConnection.class ); datasources.add( conn ); datasources.add( icon ); when( svc.getDatasources() ).thenReturn( datasources ); exporterSpy.exportDatasources(); assertEquals( 1, exporterSpy.getExportManifest().getDatasourceList().size() ); DatabaseConnection exportedDatabaseConnection = exporterSpy.getExportManifest().getDatasourceList().get( 0 ); assertEquals( "aDatasourceName", exportedDatabaseConnection.getName() ); }