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;
}
Aggregations