use of org.dbunit.dataset.SortedTable in project head by mifos.
the class DbUnitUtilities method verifySortedTableWithOrdering.
public void verifySortedTableWithOrdering(String tableName, IDataSet databaseDataSet, IDataSet expectedDataSet, String[] sortingColumns, Boolean actualDBComparableFlag, Boolean expectedDBComparableFlag) throws DataSetException, DatabaseUnitException {
Assert.assertNotNull("Didn't find requested table [" + tableName + "] in columnsToIgnoreWhenVerifyingTables map.", columnsToIgnoreWhenVerifyingTables.get(tableName));
ITable expectedTable = getCaseInsensitiveTable(tableName, expectedDataSet);
ITable actualTable = getCaseInsensitiveTable(tableName, databaseDataSet);
actualTable = DefaultColumnFilter.includedColumnsTable(actualTable, expectedTable.getTableMetaData().getColumns());
SortedTable sortedExpectedTable = new SortedTable(expectedTable, sortingColumns);
sortedExpectedTable.setUseComparable(expectedDBComparableFlag);
expectedTable = sortedExpectedTable;
SortedTable sortedActualTable = new SortedTable(actualTable, sortingColumns);
sortedActualTable.setUseComparable(actualDBComparableFlag);
actualTable = sortedActualTable;
if (LOG.isDebugEnabled()) {
printTable(expectedTable);
printTable(actualTable);
}
try {
Assertion.assertEqualsIgnoreCols(expectedTable, actualTable, columnsToIgnoreWhenVerifyingTables.get(tableName));
} catch (AssertionError e) {
throw new DatabaseUnitException(getTableDiff(expectedTable, actualTable), e);
}
}
use of org.dbunit.dataset.SortedTable in project SSM by Intel-bigdata.
the class TestDBAdapter method testCreateProportionView.
@Test
public void testCreateProportionView() throws Exception {
Statement statement = databaseTester.getConnection().getConnection().createStatement();
statement.execute(AccessCountTable.createTableSQL("table1"));
statement.execute(AccessCountTable.createTableSQL("table2"));
statement.execute(AccessCountTable.createTableSQL("table3"));
statement.execute(AccessCountTable.createTableSQL("expect"));
IDataSet dataSet = new XmlDataSet(getClass().getClassLoader().getResourceAsStream("accessCountTable.xml"));
databaseTester.setDataSet(dataSet);
databaseTester.onSetup();
AccessCountTable table3 = new AccessCountTable("table3", 0L, 10L, TimeGranularity.SECOND);
DBAdapter dbAdapter = new DBAdapter(databaseTester.getConnection().getConnection());
// 50%
AccessCountTable viewTable = new AccessCountTable(0L, 5L);
dbAdapter.createProportionView(viewTable, table3);
ITable actual = databaseTester.getConnection().createTable(viewTable.getTableName());
ITable expect = databaseTester.getConnection().createTable(table3.getTableName());
SortedTable sortedActual = new SortedTable(actual, new String[] { "fid" });
sortedActual.setUseComparable(true);
Assert.assertTrue(sortedActual.getRowCount() == expect.getRowCount());
for (int i = 0; i < expect.getRowCount(); i++) {
Integer actualAC = (Integer) sortedActual.getValue(i, AccessCountTable.ACCESSCOUNT_FIELD);
Integer expectAC = (Integer) expect.getValue(i, AccessCountTable.ACCESSCOUNT_FIELD);
Assert.assertTrue(actualAC == expectAC / 2);
}
}
use of org.dbunit.dataset.SortedTable in project SSM by Intel-bigdata.
the class TestAccessCountTableManager method testAddAccessCountInfo.
@Test
public void testAddAccessCountInfo() throws Exception {
createTables(databaseTester.getConnection());
IDataSet dataSet = new XmlDataSet(getClass().getClassLoader().getResourceAsStream("files.xml"));
databaseTester.setDataSet(dataSet);
databaseTester.onSetup();
DBAdapter adapter = new DBAdapter(databaseTester.getConnection().getConnection());
AccessCountTableManager manager = new AccessCountTableManager(adapter);
List<FileAccessEvent> accessEvents = new ArrayList<>();
accessEvents.add(new FileAccessEvent("file1", 0));
accessEvents.add(new FileAccessEvent("file2", 1));
accessEvents.add(new FileAccessEvent("file2", 2));
accessEvents.add(new FileAccessEvent("file3", 2));
accessEvents.add(new FileAccessEvent("file3", 3));
accessEvents.add(new FileAccessEvent("file3", 4));
accessEvents.add(new FileAccessEvent("file3", 5000));
manager.onAccessEventsArrived(accessEvents);
AccessCountTable accessCountTable = new AccessCountTable(0L, 5000L);
ITable actual = databaseTester.getConnection().createTable(accessCountTable.getTableName());
ITable expect = databaseTester.getDataSet().getTable("expect1");
SortedTable sortedActual = new SortedTable(actual, new String[] { "fid" });
sortedActual.setUseComparable(true);
Assertion.assertEquals(expect, sortedActual);
}
Aggregations