Search in sources :

Example 26 with IPentahoMetaData

use of org.pentaho.commons.connection.IPentahoMetaData in project data-access by pentaho.

the class MetadataServiceTest method getMarshallableResultSet.

private MarshallableResultSet getMarshallableResultSet() {
    // Build the IPentahoResultSet
    Object[][] result = new Object[1][COLUMNS];
    result[0][0] = COLUMN_NAME;
    Object[] values = new Object[1];
    values[0] = RESULT;
    LocalizedString localizedString = mock(LocalizedString.class);
    when(localizedString.getString(anyString())).thenReturn(COLUMN_NAME);
    IPentahoMetaData iPentahoMetaData = mock(IPentahoMetaData.class);
    when(iPentahoMetaData.getColumnHeaders()).thenReturn(result);
    when(iPentahoMetaData.getAttribute(anyInt(), anyInt(), eq(IPhysicalColumn.DATATYPE_PROPERTY))).thenReturn(DataType.STRING);
    when(iPentahoMetaData.getAttribute(anyInt(), anyInt(), eq(Concept.NAME_PROPERTY))).thenReturn(localizedString);
    IPentahoResultSet iPentahoResultSet = mock(IPentahoResultSet.class);
    when(iPentahoResultSet.getRowCount()).thenReturn(ROWS);
    when(iPentahoResultSet.getColumnCount()).thenReturn(COLUMNS);
    when(iPentahoResultSet.getMetaData()).thenReturn(iPentahoMetaData);
    when(iPentahoResultSet.next()).thenReturn(values).thenReturn(null);
    when(metadataService.executeQuery(anyString(), any(Integer.class))).thenReturn(iPentahoResultSet);
    // Build the MarshallableResultSet
    MarshallableResultSet marshallableResultSet = mock(MarshallableResultSet.class);
    doCallRealMethod().when(marshallableResultSet).setResultSet(any(IPentahoResultSet.class));
    when(marshallableResultSet.getRows()).thenCallRealMethod();
    when(marshallableResultSet.getColumnNames()).thenCallRealMethod();
    return marshallableResultSet;
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) MarshallableResultSet(org.pentaho.commons.connection.marshal.MarshallableResultSet) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Aggregations

IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)26 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)12 MemoryMetaData (org.pentaho.commons.connection.memory.MemoryMetaData)9 MemoryResultSet (org.pentaho.commons.connection.memory.MemoryResultSet)7 ArrayList (java.util.ArrayList)4 List (java.util.List)4 SQLConnection (org.pentaho.platform.plugin.services.connections.sql.SQLConnection)4 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 MarshallableResultSet (org.pentaho.commons.connection.marshal.MarshallableResultSet)3 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)3 SQLMetaData (org.pentaho.platform.plugin.services.connections.sql.SQLMetaData)3 StringTokenizer (java.util.StringTokenizer)2 Element (org.dom4j.Element)2 Test (org.junit.Test)2 MarshallableRow (org.pentaho.commons.connection.marshal.MarshallableRow)2 SerializedResultSet (org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet)2 DatasourceServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)2 ModifiableConfiguration (org.pentaho.reporting.libraries.base.config.ModifiableConfiguration)2 FileNotFoundException (java.io.FileNotFoundException)1