@Test
public void testHandleGridForDataValueSet()
{

    IndicatorType itA = new IndicatorType();
    CategoryOptionCombo ocA = createCategoryOptionCombo( 'A' );
    ocA.setUid( "ceabcdefghA" );
    DataElement dxA = createDataElement( 'A' );
    dxA.setUid( "deabcdefghA" );
    dxA.setValueType( ValueType.INTEGER );
    DataElement dxB = createDataElement( 'B' );
    dxB.setUid( "deabcdefghB" );
    dxB.setValueType( ValueType.NUMBER );
    Indicator dxC = createIndicator( 'C', itA );
    dxC.setUid( "deabcdefghC" );
    dxC.setDecimals( 0 );
    dxC.setAggregateExportAttributeOptionCombo( "ceabcdefghA" );
    Indicator dxD = createIndicator( 'D', itA );
    dxD.setUid( "deabcdefghD" );
    dxD.setDecimals( 2 );
    dxD.setAggregateExportCategoryOptionCombo( "ceabcdefghB" );
    DataElementOperand dxE = new DataElementOperand( dxA, ocA );
    DataElementOperand dxF = new DataElementOperand( dxB, ocA );
    DataQueryParams params = DataQueryParams.newBuilder()
        .addDimension( new BaseDimensionalObject( DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList( dxA, dxB, dxC, dxD, dxE, dxF ) ) )
        .build();
    Grid grid = new ListGrid();
    grid.addHeader( new GridHeader( DimensionalObject.DATA_X_DIM_ID ) );
    grid.addHeader( new GridHeader( DimensionalObject.ORGUNIT_DIM_ID ) );
    grid.addHeader( new GridHeader( DimensionalObject.PERIOD_DIM_ID ) );
    grid.addHeader( new GridHeader( VALUE_ID, VALUE_HEADER_NAME, ValueType.NUMBER, Double.class.getName(), false, false ) );
    grid.addRow().addValuesAsList( Lists.newArrayList( "deabcdefghA", "ouA", "peA", 1d ) );
    grid.addRow().addValuesAsList( Lists.newArrayList( "deabcdefghB", "ouA", "peA", 2d ) );
    grid.addRow().addValuesAsList( Lists.newArrayList( "deabcdefghC", "ouA", "peA", 3d ) );
    grid.addRow().addValuesAsList( Lists.newArrayList( "deabcdefghD", "ouA", "peA", 4d ) );
    grid.addRow().addValuesAsList( Lists.newArrayList( "deabcdefghA.ceabcdefghA", "ouA", "peA", 5d ) );
    grid.addRow().addValuesAsList( Lists.newArrayList( "deabcdefghB.ceabcdefghA", "ouA", "peA", 6d ) );
    assertEquals( 4, grid.getWidth() );
    assertEquals( 6, grid.getHeight() );
    AnalyticsUtils.handleGridForDataValueSet( params, grid );
    assertEquals( 6, grid.getWidth() );
    assertEquals( 6, grid.getHeight() );
    assertEquals( "deabcdefghA", grid.getRow( 0 ).get( 0 ) );
    assertNull( grid.getRow( 0 ).get( 3 ) );
    assertNull( grid.getRow( 0 ).get( 4 ) );
    assertEquals( 1, grid.getRow( 0 ).get( 5 ) );
    assertEquals( "deabcdefghB", grid.getRow( 1 ).get( 0 ) );
    assertNull( grid.getRow( 1 ).get( 3 ) );
    assertNull( grid.getRow( 1 ).get( 4 ) );
    assertEquals( 2d, (Double) grid.getRow( 1 ).get( 5 ), 0.01 );
    assertEquals( "deabcdefghC", grid.getRow( 2 ).get( 0 ) );
    assertNull( grid.getRow( 2 ).get( 3 ) );
    assertEquals( "ceabcdefghA", grid.getRow( 2 ).get( 4 ) );
    assertEquals( 3, grid.getRow( 2 ).get( 5 ) );
    assertEquals( "deabcdefghD", grid.getRow( 3 ).get( 0 ) );
    assertEquals( "ceabcdefghB", grid.getRow( 3 ).get( 3 ) );
    assertNull( grid.getRow( 3 ).get( 4 ) );
    assertEquals( 4d, (Double) grid.getRow( 3 ).get( 5 ), 0.01 );
    assertEquals( "deabcdefghA", grid.getRow( 4 ).get( 0 ) );
    assertEquals( "ceabcdefghA", grid.getRow( 4 ).get( 3 ) );
    assertNull( grid.getRow( 4 ).get( 4 ) );
    assertEquals( 5, grid.getRow( 4 ).get( 5 ) );
    assertEquals( "deabcdefghB", grid.getRow( 5 ).get( 0 ) );
    assertEquals( "ceabcdefghA", grid.getRow( 5 ).get( 3 ) );
    assertNull( grid.getRow( 5 ).get( 4 ) );
    assertEquals( 6d, (Double) grid.getRow( 5 ).get( 5 ), 0.01 );
}