Search in sources :

Example 1 with JsonFollowupValue

use of org.hisp.dhis.webapi.json.domain.JsonFollowupValue in project dhis2-core by dhis2.

the class FollowupAnalysisControllerTest method assertFollowupValues.

private void assertFollowupValues(HttpResponse response, String... expectedComments) {
    JsonResponse body = response.content();
    JsonList<JsonFollowupValue> values = body.getList("followupValues", JsonFollowupValue.class);
    assertEquals(expectedComments.length, values.size());
    assertEquals(Arrays.stream(expectedComments).collect(toSet()), values.stream().map(JsonFollowupValue::getComment).collect(toSet()));
    JsonObject metadata = body.getObject("metadata");
    assertTrue(metadata.exists());
    assertEquals(asList("de", "coc", "ou", "startDate", "endDate", "maxResults"), metadata.names());
}
Also used : JsonFollowupValue(org.hisp.dhis.webapi.json.domain.JsonFollowupValue) JsonObject(org.hisp.dhis.jsontree.JsonObject) JsonResponse(org.hisp.dhis.jsontree.JsonResponse)

Example 2 with JsonFollowupValue

use of org.hisp.dhis.webapi.json.domain.JsonFollowupValue in project dhis2-core by dhis2.

the class FollowupAnalysisControllerTest method testPerformFollowupAnalysis_FieldMapping.

/**
 * This test makes sure the fields returned by a
 * {@link org.hisp.dhis.dataanalysis.FollowupValue} are mapped correctly.
 */
@Test
void testPerformFollowupAnalysis_FieldMapping() {
    addDataValue("2021-03", "5", "Needs_check", true);
    JsonList<JsonFollowupValue> values = GET("/dataAnalysis/followup?ou={ou}&de={de}&pe={pe}", orgUnitId, dataElementId, "2021").content().getList("followupValues", JsonFollowupValue.class);
    assertEquals(1, values.size());
    JsonFollowupValue value = values.get(0);
    assertEquals(dataElementId, value.getDe());
    assertEquals("My data element", value.getDeName());
    assertEquals(orgUnitId, value.getOu());
    assertEquals("My Unit", value.getOuName());
    assertEquals("/" + orgUnitId, value.getOuPath());
    assertEquals("202103", value.getPe());
    assertEquals("Monthly", value.getPeType());
    assertEquals(LocalDate.of(2021, 03, 01).atStartOfDay(), value.getPeStartDate());
    assertEquals(LocalDate.of(2021, 03, 31).atStartOfDay(), value.getPeEndDate());
    assertEquals(categoryOptionId, value.getCoc());
    assertEquals("default", value.getCocName());
    assertEquals(categoryOptionId, value.getAoc());
    assertEquals("default", value.getAocName());
    assertEquals("5", value.getValue());
    assertEquals("admin", value.getStoredBy());
    assertEquals("Needs_check", value.getComment());
    assertEquals("March 2021", value.getPeName());
    assertNotNull(value.getLastUpdated());
    assertNotNull(value.getCreated());
}
Also used : JsonFollowupValue(org.hisp.dhis.webapi.json.domain.JsonFollowupValue) Test(org.junit.jupiter.api.Test)

Aggregations

JsonFollowupValue (org.hisp.dhis.webapi.json.domain.JsonFollowupValue)2 JsonObject (org.hisp.dhis.jsontree.JsonObject)1 JsonResponse (org.hisp.dhis.jsontree.JsonResponse)1 Test (org.junit.jupiter.api.Test)1