use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class ResultSetCompareComponentTest method createResultSet.
private static IPentahoResultSet createResultSet(final Object[][] resultSet) {
IPentahoResultSet rs = Mockito.mock(IPentahoResultSet.class);
when(rs.getRowCount()).thenReturn(resultSet.length);
when(rs.getColumnCount()).thenAnswer(new Answer<Integer>() {
@Override
public Integer answer(InvocationOnMock invocation) throws Throwable {
return resultSet.length == 0 ? 0 : resultSet[0].length;
}
});
when(rs.getValueAt(anyInt(), anyInt())).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
int rowNumber = (Integer) args[0];
int colNumber = (Integer) args[1];
return resultSet[rowNumber][colNumber];
}
});
return rs;
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class ScriptableConditionTest method createParameterWithResult.
private static IActionParameter createParameterWithResult(int rowsCount) {
IActionParameter parameter = mock(IActionParameter.class);
IPentahoResultSet resultSet = mock(IPentahoResultSet.class);
when(resultSet.getRowCount()).thenReturn(rowsCount);
when(parameter.getValue()).thenReturn(resultSet);
return parameter;
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class SQLResultSetTest method testMemoryCopy_setMetadaMemory.
@Test
public void testMemoryCopy_setMetadaMemory() throws SQLException {
IPentahoMetaData metadata = new MemoryMetaData(mock(MemoryMetaData.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.IPentahoResultSet 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.IPentahoResultSet in project pentaho-platform by pentaho.
the class SQLResultSetTest method testMemoryCopy.
@Test
public void testMemoryCopy() throws SQLException {
SQLResultSet resultSet = new SQLResultSet(nativeResultSet, nativeConnection);
IPentahoResultSet memoryCopyResultSet = resultSet.memoryCopy();
assertEquals(columns[0].length, memoryCopyResultSet.getColumnCount());
assertTrue(Arrays.equals(columns[0], memoryCopyResultSet.getMetaData().getColumnHeaders()[0]));
verify(nativeResultSet, times(1)).close();
}
Aggregations