use of org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo in project data-access by pentaho.
the class CsvUtilsTest method ColumnOfIntegerType_HasCorrectLength.
@Test
public void ColumnOfIntegerType_HasCorrectLength() {
ColumnInfo columnInfo = new ColumnInfo();
List<String> data = asList("1", "2");
utils.assumeColumnDetails(columnInfo, data);
assertEquals(DataType.NUMERIC, columnInfo.getDataType());
assertEquals(DEFAULT_INTEGER_SIZE, columnInfo.getLength());
}
use of org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo in project data-access by pentaho.
the class CsvUtilsTest method generateFields_EscapesColumnsNames.
@Test
public void generateFields_EscapesColumnsNames() throws Exception {
String[] headers = { "col.1", "col 2 */+" };
for (String header : headers) {
assertFalse(Util.validateId(header));
}
prepareFile(headers);
ColumnInfo[] columns = generateFields(1, null, 1).getColumns();
for (int i = 0; i < columns.length; i++) {
ColumnInfo column = columns[i];
assertEquals("Keeps original title", headers[i], column.getTitle());
assertTrue("Escapes id", Util.validateId(column.getId()));
}
}
use of org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo in project data-access by pentaho.
the class CsvUtilsTest method setUp.
@Before
public void setUp() throws Exception {
defaultLocale = Locale.getDefault();
Locale.setDefault(new Locale("en", "US"));
utils = new CsvUtils();
columnInfo = new ColumnInfo();
tempFile = File.createTempFile("CsvUtilsTest", ".tmp");
tempFile.deleteOnExit();
}
use of org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo in project data-access by pentaho.
the class CsvUtilsTest method generateFields_OneHeaderLine_OneDataLine.
@Test
public void generateFields_OneHeaderLine_OneDataLine() throws Exception {
prepareFile(new String[] { "col1", "col2" }, new String[] { "1", "2" });
ModelInfo info = generateFields(2, null, 1);
ColumnInfo[] columns = info.getColumns();
assertEquals(2, columns.length);
assertEquals("col1", columns[0].getId());
assertEquals("col2", columns[1].getId());
DataRow[] data = info.getData();
assertEquals(1, data.length);
assertEquals(2, data[0].getCells().length);
assertEquals("1", data[0].getCells()[0]);
assertEquals("2", data[0].getCells()[1]);
}
use of org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo in project data-access by pentaho.
the class ModelerServiceIT method columnsConvertedCorrectly_FromColumnInfos.
@Test
public void columnsConvertedCorrectly_FromColumnInfos() throws Exception {
final String columnId = "id";
final String columnTitle = "title";
ColumnInfo[] columnInfos = new ColumnInfo[] { createColumnInfo(columnId, columnTitle) };
Column[] columns = modelerService.toColumns(columnInfos);
assertEquals(1, columns.length);
Column column = columns[0];
assertEquals(columnId, column.getId());
assertEquals(columnTitle, column.getName());
}
Aggregations