use of org.hisp.dhis.attribute.Attribute in project dhis2-core by dhis2.
the class GeoFeatureServiceMockTest method testGeoJsonAttributeWithNoValue.
/**
* GET Request has "coordinateField" parameter.
* <p>
* OrganisationUnit has coordinates from geometry property but not GeoJson
* Attribute.
* <p>
* Expected: only return GeoFeature which has the coordinateField value.
*
* @throws IOException
*/
@Test
public void testGeoJsonAttributeWithNoValue() throws IOException {
OrganisationUnit ouA = createOrgUnitWithCoordinates();
User user = rnd.nextObject(User.class);
DataQueryParams params = DataQueryParams.newBuilder().withOrganisationUnits(getList(ouA)).build();
when(dataQueryService.getFromRequest(any())).thenReturn(params);
when(currentUserService.getCurrentUser()).thenReturn(user);
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
Attribute attribute = new Attribute();
attribute.setValueType(ValueType.GEOJSON);
attribute.setOrganisationUnitAttribute(true);
when(attributeService.getAttribute("GeoJSON_Attribute_ID")).thenReturn(attribute);
List<GeoFeature> features = geoFeatureService.getGeoFeatures(GeoFeatureService.Parameters.builder().request(request).response(response).coordinateField("GeoJSON_Attribute_ID").organisationUnit("ou:LEVEL-2;LEVEL-3").build());
assertEquals(0, features.size());
}
Aggregations