Search in sources :

Example 11 with JsonNode

use of org.hisp.dhis.jsontree.JsonNode 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)));
}
Also used : JsonNode(org.hisp.dhis.jsontree.JsonNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Map(java.util.Map) JsonResponse(org.hisp.dhis.jsontree.JsonResponse) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 12 with JsonNode

use of org.hisp.dhis.jsontree.JsonNode 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()));
}
Also used : JsonNode(org.hisp.dhis.jsontree.JsonNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Map(java.util.Map) JsonResponse(org.hisp.dhis.jsontree.JsonResponse) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Aggregations

JsonNode (org.hisp.dhis.jsontree.JsonNode)12 DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)12 Test (org.junit.jupiter.api.Test)12 Map (java.util.Map)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 JsonResponse (org.hisp.dhis.jsontree.JsonResponse)11 JsonIdentifiableObject (org.hisp.dhis.webapi.json.domain.JsonIdentifiableObject)1