Search in sources :

Example 21 with JsonObject

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

the class SystemControllerTest method testGetTaskSummaryExtendedJson.

@Test
void testGetTaskSummaryExtendedJson() {
    JsonObject summary = GET("/system/taskSummaries/META_DATA_SYNC").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)

Example 22 with JsonObject

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

the class TrackedEntityInstanceControllerTest method testUpdateTrackedEntityInstanceJson.

@Test
void testUpdateTrackedEntityInstanceJson() {
    String uid = assertStatus(HttpStatus.OK, POST("/trackedEntityInstances", "{'name':'A', 'trackedEntityType':'" + tetId + "', 'orgUnit':'" + ouId + "'}"));
    JsonObject tei = GET("/trackedEntityInstances/" + uid).content();
    assertWebMessage("OK", 200, "OK", "Import was successful.", PUT("/trackedEntityInstances/" + uid, tei.toString()).content(HttpStatus.OK));
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 23 with JsonObject

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

the class TrackerRelationshipsExportControllerTest method getRelationshipsByEnrollment.

@Test
void getRelationshipsByEnrollment() {
    TrackedEntityInstance tei = trackedEntityInstance();
    ProgramInstance programInstance = programInstance(tei);
    RelationshipType rType = relationshipType(RelationshipEntity.PROGRAM_INSTANCE, RelationshipEntity.TRACKED_ENTITY_INSTANCE);
    Relationship r = relationship(rType, programInstance, tei);
    JsonObject relationship = GET("/tracker/relationships?enrollment=" + programInstance.getUid()).content(HttpStatus.OK);
    JsonObject jsonRelationship = assertFirstRelationship(relationship, r);
    assertEnrollment(jsonRelationship.getObject("from"), programInstance);
    assertTrackedEntity(jsonRelationship.getObject("to"), tei);
}
Also used : ProgramInstance(org.hisp.dhis.program.ProgramInstance) Relationship(org.hisp.dhis.relationship.Relationship) RelationshipType(org.hisp.dhis.relationship.RelationshipType) JsonObject(org.hisp.dhis.jsontree.JsonObject) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 24 with JsonObject

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

the class TrackerRelationshipsExportControllerTest method getRelationshipsByEvent.

@Test
void getRelationshipsByEvent() {
    TrackedEntityInstance tei = trackedEntityInstance();
    ProgramInstance programInstance = programInstance(tei);
    ProgramStageInstance programStageInstance = programStageInstance(programInstance);
    RelationshipType rType = relationshipType(RelationshipEntity.PROGRAM_STAGE_INSTANCE, RelationshipEntity.TRACKED_ENTITY_INSTANCE);
    Relationship r = relationship(rType, programStageInstance, tei);
    JsonObject relationship = GET("/tracker/relationships?event=" + programStageInstance.getUid()).content(HttpStatus.OK);
    JsonObject jsonRelationship = assertFirstRelationship(relationship, r);
    assertEvent(jsonRelationship.getObject("from"), programStageInstance);
    assertTrackedEntity(jsonRelationship.getObject("to"), tei);
}
Also used : ProgramInstance(org.hisp.dhis.program.ProgramInstance) Relationship(org.hisp.dhis.relationship.Relationship) RelationshipType(org.hisp.dhis.relationship.RelationshipType) JsonObject(org.hisp.dhis.jsontree.JsonObject) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 25 with JsonObject

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

the class MetadataImportExportControllerTest method testPostGmlMetadata_Pre38.

@Test
void testPostGmlMetadata_Pre38() {
    JsonObject report = POST("/37/metadata/gml", Body("<metadata></metadata>"), ContentType("application/xml")).content(HttpStatus.OK);
    assertEquals("OK", report.getString("status").string());
    assertEquals("ImportReport", report.getString("responseType").string());
}
Also used : GeoJsonObject(org.geojson.GeoJsonObject) JsonObject(org.hisp.dhis.jsontree.JsonObject) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

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