Search in sources :

Example 71 with IPentahoResultSet

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;
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Example 72 with IPentahoResultSet

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;
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 73 with IPentahoResultSet

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());
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) Test(org.junit.Test)

Example 74 with IPentahoResultSet

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());
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) QueryModelMetaData(org.pentaho.metadata.query.model.util.QueryModelMetaData) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) Test(org.junit.Test)

Example 75 with IPentahoResultSet

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();
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) Test(org.junit.Test)

Aggregations

IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)113 Test (org.junit.Test)26 Node (org.dom4j.Node)18 ArrayList (java.util.ArrayList)17 IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)12 Iterator (java.util.Iterator)10 List (java.util.List)10 IPentahoConnection (org.pentaho.commons.connection.IPentahoConnection)10 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)10 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)10 OutputStream (java.io.OutputStream)9 ResultSetCompareAction (org.pentaho.actionsequence.dom.actions.ResultSetCompareAction)8 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)8 XQConnection (org.pentaho.platform.plugin.services.connections.xquery.XQConnection)8 SQLException (java.sql.SQLException)7 HashMap (java.util.HashMap)6 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)6 Map (java.util.Map)5 Set (java.util.Set)5 IPreparedComponent (org.pentaho.platform.api.data.IPreparedComponent)5