@Test
public void verifyGetWhereClauseWithAttributeOrgUnitTypeAndCoordinatesReturnsFetchesCoordinatesFromOrgUnite()
{

    // Given
    DataElement deA = createDataElement( 'A', ValueType.ORGANISATION_UNIT, AggregationType.NONE );
    DimensionalObject periods = new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD,
            Lists.newArrayList( MonthlyPeriodType.getPeriodFromIsoString( "201701" ) ) );
    DimensionalObject orgUnits = new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID,
            DimensionType.ORGANISATION_UNIT, "ouA", Lists.newArrayList( createOrganisationUnit( 'A' ) ) );
    QueryItem qiA = new QueryItem( deA, null, deA.getValueType(), deA.getAggregationType(), null );
    // When
    EventQueryParams params = new EventQueryParams.Builder()
            .addDimension( periods )
            .addDimension( orgUnits )
            .addItem( qiA )
            .withCoordinateField( deA.getUid() )
            .withSkipData( true )
            .withSkipMeta( false )
            .withStartDate(new Date() )
            .withEndDate( new Date() )
            // the not null condition is only triggered by this flag (or withGeometry) being true
            .withCoordinatesOnly( true )
            .build();
    final String whereClause = this.subject.getWhereClause( params );
    // Then
    assertThat( whereClause, containsString( "and ax.\"" + deA.getUid() + "_geom" + "\" is not null" ) );
}