MDXMetaData extends AbstractPentahoMetaData implements IMultiDimensionalMetaData { @Override public int getColumnCount() { Axis[] axes = nativeResultSet.getAxes(); if ( ( axes.length <= MDXMetaData.AXIS_COLUMN ) || ( axes[MDXMetaData.AXIS_COLUMN] == null ) ) { return 0; } else { List positions = axes[MDXMetaData.AXIS_COLUMN].getPositions(); return positions != null ? positions.size() : 0; } } MDXMetaData();  MDXMetaData( final Result nativeResultSet, boolean useExtendedColumnNames );  MDXMetaData( final Result nativeResultSet ); String getColumnName( final int columnNumber ); @Override int getColumnCount(); @Override Object[][] getColumnHeaders(); @Override Object[][] getRowHeaders(); String[] getRowHeaderNames(); void setColumnNameFormat( String formatStr ); void generateColumnNames(); String[] getFlattenedColumnNames();  }
@Test @SuppressWarnings( "rawtypes" ) public void testGetColumnCount() { List positions = mockPositions( COLUMN_SIZE, ROW_SIZE ); Axis axColumn = mockAxis( positions ); Axis axRow = mockAxis( positions ); Axis[] axes = new Axis[] { axColumn, axRow }; Result nativeResultSet = mock( Result.class ); when( nativeResultSet.getAxes() ).thenReturn( axes ); MDXMetaData metadata = new MDXMetaData( nativeResultSet ); int columnCount = metadata.getColumnCount(); assertEquals( positions.size(), columnCount ); }
@Test public void testGetZeroColumnCount() { Result nativeResultSet = mock( Result.class ); when( nativeResultSet.getAxes() ).thenReturn( new Axis[0] ); MDXMetaData metadata = new MDXMetaData( nativeResultSet ); int columnCount = metadata.getColumnCount(); assertEquals( 0, columnCount ); when( nativeResultSet.getAxes() ).thenReturn( new Axis[] { null } ); metadata = new MDXMetaData( nativeResultSet ); columnCount = metadata.getColumnCount(); assertEquals( 0, columnCount ); Axis axColumn = mockAxis( null ); when( nativeResultSet.getAxes() ).thenReturn( new Axis[] { axColumn } ); metadata = new MDXMetaData( nativeResultSet ); columnCount = metadata.getColumnCount(); assertEquals( 0, columnCount ); }