use of org.pentaho.commons.connection.IPentahoMetaData in project pentaho-platform by pentaho.
the class SQLResultSetTest method testMemoryCopy_setMetadaQuery.
@Test
public void testMemoryCopy_setMetadaQuery() throws SQLException {
IPentahoMetaData metadata = new QueryModelMetaData(mock(QueryModelMetaData.class));
SQLResultSet resultSet = new SQLResultSet(nativeResultSet, nativeConnection);
resultSet.setMetaData(metadata);
IPentahoResultSet memoryCopyResultSet = resultSet.memoryCopy();
assertEquals(metadata.getClass(), memoryCopyResultSet.getMetaData().getClass());
}
use of org.pentaho.commons.connection.IPentahoMetaData in project pentaho-platform by pentaho.
the class PentahoFlashChartTest method createFromLists.
public static MemoryResultSet createFromLists(List colHeaders, List rHeaders, List data) {
Object[][] columnHeaders = new String[1][colHeaders.size()];
for (int i = 0; i < colHeaders.size(); i++) {
columnHeaders[0][i] = colHeaders.get(i);
}
Object[][] rowHeaders = new String[rHeaders.size()][1];
for (int i = 0; i < rHeaders.size(); i++) {
rowHeaders[i][0] = rHeaders.get(i);
}
IPentahoMetaData metaData = new MemoryMetaData(columnHeaders, rowHeaders);
MemoryResultSet result = new MemoryResultSet(metaData);
for (int i = 0; i < data.size(); i++) {
result.addRow(((List) data.get(i)).toArray());
}
return result;
}
use of org.pentaho.commons.connection.IPentahoMetaData in project pentaho-platform by pentaho.
the class MultipleComponentIT method getResultSet.
private IPentahoResultSet getResultSet() {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Object[][] columnHeaders = new Object[][] { { "COL1", "COL2", "COL3" } };
IPentahoMetaData md = new MemoryMetaData(columnHeaders, null);
MemoryResultSet rs = new MemoryResultSet(md);
// $NON-NLS-1$ //$NON-NLS-2$
rs.addRow(new Object[] { "DATA1", "DATA2", new Date() });
rs.isScrollable();
return rs;
}
use of org.pentaho.commons.connection.IPentahoMetaData in project pentaho-platform by pentaho.
the class RulesIT method testQueryRule.
public void testQueryRule() {
startTest();
IPentahoResultSet resultSet = null;
try {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IRuntimeContext context = run("/test/rules/query_rule1.xaction");
// $NON-NLS-1$
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus());
// $NON-NLS-1$
Object result = context.getOutputParameter("rule-result").getValue();
// $NON-NLS-1$
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0001_NULL_RESULT"), result);
// $NON-NLS-1$
assertTrue(Messages.getInstance().getString("RulesTest.ERROR_0007_LOOKUP_RULE_INVALID_RESULT"), (result instanceof IPentahoResultSet));
resultSet = (IPentahoResultSet) result;
IPentahoMetaData metaData = resultSet.getMetaData();
Object[][] columnHeaders = metaData.getColumnHeaders();
String columnHeader = columnHeaders[0][0].toString();
// $NON-NLS-1$ //$NON-NLS-2$
assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), "POSITIONTITLE", columnHeader);
Object[] row = resultSet.next();
// $NON-NLS-1$
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0007_LOOKUP_RULE_INVALID_RESULT"), row);
// $NON-NLS-1$
info(Messages.getInstance().getString("RulesTest.DEBUG_LOOKUP_RULE_SUCCESS", row[0].toString()));
} finally {
if (resultSet != null) {
resultSet.closeConnection();
}
}
finishTest();
}
use of org.pentaho.commons.connection.IPentahoMetaData in project pentaho-platform by pentaho.
the class RulesIT method testQueryRule2.
public void testQueryRule2() {
startTest();
IPentahoResultSet resultSet = null;
try {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IRuntimeContext context = run("/test/rules/query_rule2.xaction");
// $NON-NLS-1$
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus());
// $NON-NLS-1$
Object result = context.getOutputParameter("rule-result").getValue();
// $NON-NLS-1$
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0001_NULL_RESULT"), result);
// $NON-NLS-1$
assertTrue(Messages.getInstance().getString("RulesTest.ERROR_0007_LOOKUP_RULE_INVALID_RESULT"), (result instanceof IPentahoResultSet));
resultSet = (IPentahoResultSet) result;
IPentahoMetaData metaData = resultSet.getMetaData();
Object[][] columnHeaders = metaData.getColumnHeaders();
String regionHeader = columnHeaders[0][0].toString();
String departmentHeader = columnHeaders[0][1].toString();
// $NON-NLS-1$ //$NON-NLS-2$
assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), "REGION", regionHeader);
assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), "DEPARTMENT", // $NON-NLS-1$ //$NON-NLS-2$
departmentHeader);
Object[] row = resultSet.next();
while (row != null) {
String region = row[0].toString();
String department = row[1].toString();
// $NON-NLS-1$
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), region);
// $NON-NLS-1$
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), department);
// $NON-NLS-1$
info(region + ", " + department);
row = resultSet.next();
}
} finally {
if (resultSet != null) {
resultSet.closeConnection();
}
}
finishTest();
}
Aggregations