use of org.pentaho.metadata.automodel.importing.strategy.CsvDatasourceImportStrategy in project data-access by pentaho.
the class ModelerServiceIT method domainForCsvDatasource_GeneratedWithCsvDatasourceImportStrategy.
@Test
public void domainForCsvDatasource_GeneratedWithCsvDatasourceImportStrategy() throws Exception {
ModelInfo modelInfo = new ModelInfo();
ColumnInfo[] columnInfos = new ColumnInfo[] { createColumnInfo("id", "title") };
modelInfo.setColumns(columnInfos);
modelerService = spy(modelerService);
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
doReturn(dbMeta).when(modelerService).getDatabaseMeta();
TableModelerSource source = mock(TableModelerSource.class);
doReturn(source).when(modelerService).createTableModelerSource(any(DatabaseMeta.class), anyString(), anyString(), anyString());
modelerService.generateCSVDomain(modelInfo);
verify(modelerService).toColumns(columnInfos);
// most important thing here, is that domain is generated with CsvDatasourceImportStrategy
verify(source).generateDomain(any(CsvDatasourceImportStrategy.class));
}
use of org.pentaho.metadata.automodel.importing.strategy.CsvDatasourceImportStrategy in project data-access by pentaho.
the class ModelerService method generateCSVDomain.
public Domain generateCSVDomain(ModelInfo modelInfo) throws Exception {
initKettle();
try {
DatabaseMeta database = getDatabaseMeta();
final String tableName = modelInfo.getStageTableName();
final String datasourceName = modelInfo.getDatasourceName();
Column[] columns = toColumns(modelInfo.getColumns());
PhysicalTableImporter.ImportStrategy importStrategy = new CsvDatasourceImportStrategy(columns);
TableModelerSource source = createTableModelerSource(database, tableName, null, datasourceName);
return source.generateDomain(importStrategy);
} catch (Exception e) {
logger.error(e);
throw new Exception(e.getLocalizedMessage());
}
}
Aggregations