@Test
public void convertAnalyticsRequestWithOrgUnitLevelAsFilter()
{

    OrganisationUnit level2OuA = new OrganisationUnit( "Bo" );
    OrganisationUnit level2OuB = new OrganisationUnit( "Bombali" );
    mockDimensionService();
    when( organisationUnitService.getOrganisationUnitLevelByLevelOrUid( "wjP19dkFeIk" ) ).thenReturn( 2 );
    when( idObjectManager.getObject( OrganisationUnit.class, UID, "ImspTQPwCqd" ) ).thenReturn( rootOu );
    when( organisationUnitService.getOrganisationUnitsAtLevels( Mockito.anyList(),
        Mockito.anyList() ) ).thenReturn( Lists.newArrayList( level2OuA, level2OuB ) );
    when( organisationUnitService.getOrganisationUnitLevelByLevel( 2 ) )
        .thenReturn( buildOrgUnitLevel( 2, "level2UID", "District", null ) );
    rb.addOuFilter( "LEVEL-wjP19dkFeIk;ImspTQPwCqd" );
    rb.addDimension( concatenateUuid( DATA_ELEMENT_1, DATA_ELEMENT_2, DATA_ELEMENT_3 ) );
    rb.addPeDimension( PERIOD_DIMENSION );
    DataQueryRequest request = DataQueryRequest.newBuilder().filter( rb.getFilterParams() )
        .dimension( rb.getDimensionParams() ).build();
    DataQueryParams params = target.getFromRequest( request );
    DimensionalObject filter = params.getFilters().get( 0 );
    assertThat( filter.getDimensionalKeywords().getGroupBy(), hasSize( 2 ) );
    assertThat( filter.getDimensionalKeywords().getGroupBy(),
        IsIterableContainingInAnyOrder.containsInAnyOrder(
            allOf( hasProperty( "name", is( "District" ) ), hasProperty( "uid", is( "level2UID" ) ),
                    hasProperty( "code", is( nullValue() ) ) ),
            allOf( hasProperty( "name", is( "Sierra Leone" ) ), hasProperty( "uid", is( rootOu.getUid() ) ),
                    hasProperty( "code", is( rootOu.getCode() ) ) ) ) );
}