use of org.hisp.dhis.jsontree.JsonResponse in project dhis2-core by dhis2.
the class GeoFeatureControllerTest method testGetWithCoordinateField.
@Test
public void testGetWithCoordinateField() {
POST("/metadata", "{\"organisationUnits\": [" + "{\"id\":\"rXnqqH2Pu6N\",\"name\": \"My Unit 1\",\"shortName\": \"OU1\",\"openingDate\": \"2020-01-01\"," + "\"attributeValues\": [{\"value\": \"{\\\"type\\\": \\\"Polygon\\\"," + "\\\"coordinates\\\": [[[100,0],[101,0],[101,1],[100,1],[100,0]]] }\"," + "\"attribute\": {\"id\": \"RRH9IFiZZYN\"}}]}," + "{\"id\":\"NBfMnCrwlQc\",\"name\": \"My Unit 3\",\"shortName\": \"OU3\",\"openingDate\": \"2020-01-01\"}" + "]," + "\"attributes\":[{\"id\":\"RRH9IFiZZYN\",\"valueType\":\"GEOJSON\",\"organisationUnitAttribute\":true,\"name\":\"testgeojson\"}]}").content(HttpStatus.OK);
JsonResponse response = GET("/geoFeatures?ou=ou:LEVEL-1&&coordinateField=RRH9IFiZZYN").content(HttpStatus.OK);
assertEquals(1, response.size());
assertEquals("[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]", response.getObject(0).get("co").node().value().toString());
}
use of org.hisp.dhis.jsontree.JsonResponse in project dhis2-core by dhis2.
the class EventChartControllerTest method testThatGetEventVisualizationsContainsLegacyEventCharts.
@Test
void testThatGetEventVisualizationsContainsLegacyEventCharts() {
// Given
final String body = "{'name': 'Name Test', 'type':'GAUGE', 'program':{'id':'" + mockProgram.getUid() + "'}}";
// When
final String uid = assertStatus(CREATED, POST("/eventCharts/", body));
// Then
final JsonResponse response = GET("/eventVisualizations/" + uid).content();
final Map<String, JsonNode> nodeMap = (Map<String, JsonNode>) response.node().value();
assertThat(nodeMap.get("name").toString(), containsString("Name Test"));
assertThat(nodeMap.get("type").toString(), containsString("GAUGE"));
}
use of org.hisp.dhis.jsontree.JsonResponse in project dhis2-core by dhis2.
the class EventReportControllerTest method testPostForSingleEventDate.
@Test
void testPostForSingleEventDate() {
// Given
final String eventDateDimension = "eventDate";
final String eventDate = "2021-07-21_2021-08-01";
final String dimensionBody = "{'dimension': '" + eventDateDimension + "', 'items': [{'id': '" + eventDate + "'}]}";
final String body = "{'name': 'Name Test', 'type':'LINE_LIST', 'program':{'id':'" + mockProgram.getUid() + "'}, 'columns': [" + dimensionBody + "]}";
// When
final String uid = assertStatus(CREATED, POST("/eventReports/", body));
// Then
final JsonResponse response = GET("/eventVisualizations/" + uid).content();
final Map<String, JsonNode> nodeMap = (Map<String, JsonNode>) response.node().value();
assertThat(nodeMap.get("simpleDimensions").toString(), containsString("COLUMN"));
assertThat(nodeMap.get("simpleDimensions").toString(), containsString(eventDateDimension));
assertThat(nodeMap.get("simpleDimensions").toString(), containsString(eventDate));
assertThat(nodeMap.get("columns").toString(), containsString(eventDateDimension));
assertThat(nodeMap.get("rows").toString(), not(containsString(eventDateDimension)));
assertThat(nodeMap.get("filters").toString(), not(containsString(eventDateDimension)));
}
use of org.hisp.dhis.jsontree.JsonResponse in project dhis2-core by dhis2.
the class EventReportControllerTest method testThatGetEventReportsDoesNotContainNewEventVisualizations.
@Test
void testThatGetEventReportsDoesNotContainNewEventVisualizations() {
// Given
final String body = "{'name': 'Name Test', 'type':'LINE_LIST', 'program':{'id':'" + mockProgram.getUid() + "'}}";
// When
final String uid = assertStatus(CREATED, POST("/eventVisualizations/", body));
// Then
final JsonResponse response = GET("/eventReports/" + uid).content();
final Map<String, JsonNode> nodeMap = (Map<String, JsonNode>) response.node().value();
assertThat(nodeMap.values(), is(empty()));
}
use of org.hisp.dhis.jsontree.JsonResponse in project dhis2-core by dhis2.
the class ProgramStageControllerTest method testCreateProgramStageOk.
@Test
void testCreateProgramStageOk() {
POST("/programs/", "{'name':'test program', 'id':'VoZMWi7rBgj', 'shortName':'test program','programType':'WITH_REGISTRATION' }").content(HttpStatus.CREATED);
String programStageId = assertStatus(HttpStatus.CREATED, POST("/programStages/", "{'name':'test programStage', 'program':{'id':'VoZMWi7rBgj'}}"));
JsonResponse programStage = GET("/programStages/{id}", programStageId).content();
assertEquals("VoZMWi7rBgj", programStage.getString("program.id").string());
JsonResponse program = GET("/programs/{id}", "VoZMWi7rBgj").content();
assertEquals(programStageId, program.getJsonDocument().get("$.programStages[0].id").value());
}
Aggregations