use of org.hisp.dhis.jsontree.JsonNode in project dhis2-core by dhis2.
the class EventReportControllerTest method testThatGetEventVisualizationsContainsLegacyEventReports.
@Test
void testThatGetEventVisualizationsContainsLegacyEventReports() {
// Given
final String body = "{'name': 'Name Test', 'type':'LINE_LIST', 'program':{'id':'" + mockProgram.getUid() + "'}}";
// 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("name").toString(), containsString("Name Test"));
assertThat(nodeMap.get("type").toString(), containsString("LINE_LIST"));
}
use of org.hisp.dhis.jsontree.JsonNode in project dhis2-core by dhis2.
the class EventVisualizationControllerTest 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': 'STACKED_COLUMN', 'program': {'id':'" + mockProgram.getUid() + "'}, 'columns': [" + dimensionBody + "]}";
// When
final String uid = assertStatus(CREATED, POST("/eventVisualizations/", 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.JsonNode in project dhis2-core by dhis2.
the class EventVisualizationControllerTest method testPostRepetitionForRow.
@Test
void testPostRepetitionForRow() {
// Given
final String dimension = "pe";
final String indexes = "[1,2,0]";
final String repetition = "'repetition': {'indexes': " + indexes + "}";
final String body = "{'name': 'Name Test', 'type': 'STACKED_COLUMN', 'program': {'id':'" + mockProgram.getUid() + "'}, 'rows': [{'dimension': '" + dimension + "', " + repetition + "}]}";
// When
final String uid = assertStatus(CREATED, POST("/eventVisualizations/", body));
// Then
final String getParams = "?fields=:all,rows[:all,items,repetitions]";
final JsonResponse response = GET("/eventVisualizations/" + uid + getParams).content();
final Map<String, JsonNode> nodeMap = (Map<String, JsonNode>) response.node().value();
assertThat(nodeMap.get("repetitions").toString(), containsString("ROW"));
assertThat(nodeMap.get("repetitions").toString(), containsString(indexes));
assertThat(nodeMap.get("repetitions").toString(), containsString(dimension));
assertThat(nodeMap.get("rows").toString(), containsString(indexes));
assertThat(nodeMap.get("columns").toString(), not(containsString(indexes)));
assertThat(nodeMap.get("filters").toString(), not(containsString(indexes)));
}
use of org.hisp.dhis.jsontree.JsonNode in project dhis2-core by dhis2.
the class EventVisualizationControllerTest method testPostRepetitionForColumn.
@Test
void testPostRepetitionForColumn() {
// Given
final String dimension = "pe";
final String indexes = "[1,0,-1]";
final String repetition = "'repetition': {'indexes': " + indexes + "}";
final String body = "{'name': 'Name Test', 'type': 'STACKED_COLUMN', 'program': {'id':'" + mockProgram.getUid() + "'}, 'columns': [{'dimension': '" + dimension + "', " + repetition + "}]}";
// When
final String uid = assertStatus(CREATED, POST("/eventVisualizations/", body));
// Then
final String getParams = "?fields=:all,columns[:all,items,repetitions]";
final JsonResponse response = GET("/eventVisualizations/" + uid + getParams).content();
final Map<String, JsonNode> nodeMap = (Map<String, JsonNode>) response.node().value();
assertThat(nodeMap.get("repetitions").toString(), containsString("COLUMN"));
assertThat(nodeMap.get("repetitions").toString(), containsString(indexes));
assertThat(nodeMap.get("repetitions").toString(), containsString(dimension));
assertThat(nodeMap.get("columns").toString(), containsString(indexes));
assertThat(nodeMap.get("rows").toString(), not(containsString(indexes)));
assertThat(nodeMap.get("filters").toString(), not(containsString(indexes)));
}
use of org.hisp.dhis.jsontree.JsonNode 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"));
}
Aggregations