protected void verifyResultRowCount(String queryFolder) throws Exception { printInfo("---------- verify result count in folder: " + queryFolder); List<File> sqlFiles = getFilesFromFolder(new File(queryFolder), ".sql"); for (File sqlFile : sqlFiles) { String queryName = StringUtils.split(sqlFile.getName(), '.')[0]; String sql = getTextFromFile(sqlFile); File expectResultFile = new File(sqlFile.getParent(), sqlFile.getName() + ".expected"); int expectRowCount = Integer.parseInt(Files.readFirstLine(expectResultFile, Charset.defaultCharset())); // execute Kylin printInfo("Query Result from Kylin - " + queryName + " (" + queryFolder + ")"); IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection); ITable kylinTable = executeQuery(kylinConn, queryName, sql, false); // compare the result Assert.assertEquals(expectRowCount, kylinTable.getRowCount()); // Assertion.assertEquals(expectRowCount, kylinTable.getRowCount()); } }
protected static void printResult(ITable resultTable) throws DataSetException { StringBuilder sb = new StringBuilder(); int columnCount = resultTable.getTableMetaData().getColumns().length; String[] columns = new String[columnCount]; for (int i = 0; i < columnCount; i++) { sb.append(resultTable.getTableMetaData().getColumns()[i].getColumnName()); sb.append("-"); sb.append(resultTable.getTableMetaData().getColumns()[i].getDataType()); sb.append("\t"); columns[i] = resultTable.getTableMetaData().getColumns()[i].getColumnName(); } sb.append("\n"); for (int i = 0; i < resultTable.getRowCount(); i++) { for (int j = 0; j < columns.length; j++) { sb.append(resultTable.getValue(i, columns[j])); sb.append("\t"); } sb.append("\n"); } System.out.println(sb.toString()); }
@Override public int getRowCount() { return table.getRowCount(); }
@Override public int getRowCount() { return table.getRowCount(); }
@Override public int getRowCount() { return delegate.getRowCount(); }
@Override public int getRowCount() { return table.getRowCount(); }
public int getRowCount() { return this.target.getRowCount(); }
public int getRowCount() { return delegate.getRowCount(); }
protected void execAndCompQuery(String queryFolder, String[] exclusiveQuerys, boolean needSort) throws Exception { printInfo("---------- test folder: " + queryFolder); Set<String> exclusiveSet = buildExclusiveSet(exclusiveQuerys); List<File> sqlFiles = getFilesFromFolder(new File(queryFolder), ".sql"); for (File sqlFile : sqlFiles) { String queryName = StringUtils.split(sqlFile.getName(), '.')[0]; if (exclusiveSet.contains(queryName)) { continue; } String sql = getTextFromFile(sqlFile); // execute Kylin printInfo("Query Result from Kylin - " + queryName + " (" + queryFolder + ")"); IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection); ITable kylinTable = executeQuery(kylinConn, queryName, sql, needSort); // execute H2 printInfo("Query Result from H2 - " + queryName); H2Connection h2Conn = new H2Connection(h2Connection, null); h2Conn.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new TestH2DataTypeFactory()); ITable h2Table = executeQuery(h2Conn, queryName, sql, needSort); // compare the result Assertion.assertEquals(h2Table, kylinTable); compQueryCount++; if (kylinTable.getRowCount() == 0) { zeroResultQueries.add(sql); } } }
public static int getTableIndexFor(ITable table, String columnName, Object value) throws Exception { for (int i = 0; i < table.getRowCount(); i++) { if (value.equals(table.getValue(i, columnName))) { return i; } } return -1; }
public static List<TableRow> getTableRowsFor(ITable table, String columnName, Object value) throws Exception { List<TableRow> rows = new ArrayList<TableRow>(); for (int i = 0; i < table.getRowCount(); i++) { if (value.equals(table.getValue(i, columnName))) { rows.add(new TableRow(table, i)); } } return rows; }
if(dataSet.getTable(metaData.getTableName()).getRowCount() != rowCount ){ out.write(FOUR_SPACES+"},"+NEW_LINE); }else {
private ITable filterTableByPrimaryKey(ITable expectedDataSet, ITable actualDataSet) throws DataSetException { //PrimaryKeyFilteredTableWrapper uses Set.contains to check PK values, so types should be the same in both datasets DataType dataType = actualDataSet.getTableMetaData().getPrimaryKeys()[0].getDataType(); String pkName = actualDataSet.getTableMetaData().getPrimaryKeys()[0].getColumnName(); Set<Object> pkSet = new HashSet<>(); for (int i = 0; i < expectedDataSet.getRowCount(); i++) { pkSet.add(dataType.typeCast(expectedDataSet.getValue(i, pkName))); } return new PrimaryKeyFilteredTableWrapper(actualDataSet, pkSet); }
for (int i = 0; i < expectedTable.getRowCount(); i++) {
for (int i=0; i<expectedTable.getRowCount(); i++) { for (String orderColumn : orderBy) { if (expectedTable.getValue(i, orderColumn).toString().startsWith("regex:")) {
/** * Adds the rows of the DbUnit table to the given table. * * @param dbUnitTable The DbUnit table containing the rows, not null * @param table The table to add the rows to, not null * @param primaryKeyColumnNames The names of the pk columns, empty if there are none */ protected void addRows(ITable dbUnitTable, Table table, List<String> primaryKeyColumnNames) throws DataSetException { org.dbunit.dataset.Column[] columns = dbUnitTable.getTableMetaData().getColumns(); int rowCount = dbUnitTable.getRowCount(); for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { Row row = new Row(); table.addRow(row); for (org.dbunit.dataset.Column dbUnitColumn : columns) { String columnName = dbUnitColumn.getColumnName(); DataType columnType = dbUnitColumn.getDataType(); Object value = dbUnitTable.getValue(rowIndex, columnName); Column column = new Column(columnName, columnType, value); if (primaryKeyColumnNames.contains(columnName)) { row.addPrimaryKeyColumn(column); } else { row.addColumn(column); } } } }
for (int j = 0; j < table.getRowCount(); j++)