Search in sources :

Example 86 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class SystemSettingControllerTest method testGetSystemSettingsJson_AllKeys.

@Test
void testGetSystemSettingsJson_AllKeys() {
    assertStatus(HttpStatus.OK, POST("/systemSettings/keyUiLocale?value=de"));
    JsonObject setting = GET("/systemSettings").content(HttpStatus.OK);
    assertTrue(setting.isObject());
    stream(SettingKey.values()).filter(key -> !key.isConfidential() && key.getDefaultValue() != null).forEach(key -> assertTrue(setting.get(key.getName()).exists(), key.getName()));
    stream(SettingKey.values()).filter(SettingKey::isConfidential).forEach(key -> assertFalse(setting.get(key.getName()).exists(), key.getName()));
}
Also used : ContextUtils(org.hisp.dhis.webapi.utils.ContextUtils) ContentType(org.hisp.dhis.webapi.WebClient.ContentType) Body(org.hisp.dhis.webapi.WebClient.Body) WebClientUtils.assertStatus(org.hisp.dhis.webapi.utils.WebClientUtils.assertStatus) Autowired(org.springframework.beans.factory.annotation.Autowired) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test) HttpStatus(org.springframework.http.HttpStatus) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) JsonObject(org.hisp.dhis.jsontree.JsonObject) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SettingKey(org.hisp.dhis.setting.SettingKey) Arrays.stream(java.util.Arrays.stream) SystemSettingManager(org.hisp.dhis.setting.SystemSettingManager) JsonObject(org.hisp.dhis.jsontree.JsonObject) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 87 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class TrackerEnrollmentsExportControllerTest method testGetEnrollmentByIdContainsFollowUp.

@Test
void testGetEnrollmentByIdContainsFollowUp() {
    OrganisationUnit orgUnit = createOrganisationUnit('A');
    manager.save(orgUnit);
    Program program = createProgram('A');
    manager.save(program);
    TrackedEntityType trackedEntityType = createTrackedEntityType('A');
    manager.save(trackedEntityType);
    TrackedEntityInstance tei = createTrackedEntityInstance(orgUnit);
    tei.setTrackedEntityType(trackedEntityType);
    manager.save(tei);
    ProgramInstance programInstance = new ProgramInstance(program, tei, orgUnit);
    programInstance.setAutoFields();
    programInstance.setEnrollmentDate(new Date());
    programInstance.setIncidentDate(new Date());
    programInstance.setStatus(ProgramStatus.COMPLETED);
    programInstance.setFollowup(true);
    manager.save(programInstance);
    JsonObject enrollment = GET("/tracker/enrollments/{id}", programInstance.getUid()).content(HttpStatus.OK);
    assertTrue(enrollment.isObject());
    assertFalse(enrollment.isEmpty());
    assertEquals(programInstance.getUid(), enrollment.getString("enrollment").string());
    assertEquals(tei.getUid(), enrollment.getString("trackedEntity").string());
    assertEquals(program.getUid(), enrollment.getString("program").string());
    assertEquals("COMPLETED", enrollment.getString("status").string());
    assertEquals(orgUnit.getUid(), enrollment.getString("orgUnit").string());
    assertEquals(orgUnit.getName(), enrollment.getString("orgUnitName").string());
    assertTrue(enrollment.has("enrolledAt", "occurredAt"));
    assertTrue(enrollment.getBoolean("followUp").booleanValue());
    assertFalse(enrollment.getBoolean("deleted").booleanValue());
    assertTrue(enrollment.getArray("events").isEmpty());
    assertTrue(enrollment.getArray("relationships").isEmpty());
    assertTrue(enrollment.getArray("attributes").isEmpty());
    assertTrue(enrollment.getArray("notes").isEmpty());
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) TrackedEntityType(org.hisp.dhis.trackedentity.TrackedEntityType) Program(org.hisp.dhis.program.Program) ProgramInstance(org.hisp.dhis.program.ProgramInstance) JsonObject(org.hisp.dhis.jsontree.JsonObject) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) Date(java.util.Date) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 88 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class SystemControllerTest method testGetTasksExtendedJson.

@Test
void testGetTasksExtendedJson() {
    JsonObject tasks = GET("/system/tasks/{jobType}", "META_DATA_SYNC").content(HttpStatus.OK);
    assertTrue(tasks.isObject());
    assertEquals(0, tasks.size());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 89 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class SystemControllerTest method assertObjectMembers.

private static void assertObjectMembers(JsonObject root, String... members) {
    for (String member : members) {
        JsonObject memberObj = root.getObject(member);
        assertTrue(memberObj.isObject(), member + " is not an object");
    }
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject)

Example 90 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class SystemControllerTest method testGetTaskSummaryJson.

@Test
void testGetTaskSummaryJson() {
    JsonObject summary = GET("/system/taskSummaries/META_DATA_SYNC/xyz").content(HttpStatus.OK);
    assertTrue(summary.isObject());
    assertEquals(0, summary.size());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Aggregations

JsonObject (org.hisp.dhis.jsontree.JsonObject)106 Test (org.junit.jupiter.api.Test)92 DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)51 JsonArray (org.hisp.dhis.jsontree.JsonArray)16 ProgramInstance (org.hisp.dhis.program.ProgramInstance)6 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)6 Relationship (org.hisp.dhis.relationship.Relationship)5 RelationshipType (org.hisp.dhis.relationship.RelationshipType)5 GeoJsonObject (org.geojson.GeoJsonObject)3 JsonString (org.hisp.dhis.jsontree.JsonString)3 HttpStatus (org.springframework.http.HttpStatus)3 ObjectType (org.hisp.dhis.attribute.Attribute.ObjectType)2 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)2 Arrays.stream (java.util.Arrays.stream)1 Date (java.util.Date)1 JsonResponse (org.hisp.dhis.jsontree.JsonResponse)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Program (org.hisp.dhis.program.Program)1 ApiToken (org.hisp.dhis.security.apikey.ApiToken)1 SettingKey (org.hisp.dhis.setting.SettingKey)1