use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class TrackerRelationshipsExportControllerTest method getRelationshipsByTrackedEntity.
@Test
void getRelationshipsByTrackedEntity() {
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?trackedEntity=" + tei.getUid()).content(HttpStatus.OK);
JsonObject jsonRelationship = assertFirstRelationship(relationship, r);
assertEnrollment(jsonRelationship.getObject("from"), programInstance);
assertTrackedEntity(jsonRelationship.getObject("to"), tei);
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class TrackerRelationshipsExportControllerTest method getRelationshipsById.
@Test
void getRelationshipsById() {
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/" + r.getUid()).content(HttpStatus.OK);
assertRelationship(relationship, r);
assertEvent(relationship.getObject("from"), programStageInstance);
assertTrackedEntity(relationship.getObject("to"), tei);
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class TrackerRelationshipsExportControllerTest method assertNthRelationship.
private JsonObject assertNthRelationship(JsonObject body, Relationship r, int n) {
assertFalse(body.isEmpty());
JsonArray rels = body.getArray("instances");
assertFalse(rels.isEmpty());
assertTrue(rels.size() >= n);
JsonObject jsonRelationship = rels.get(n).as(JsonObject.class);
assertRelationship(jsonRelationship, r);
return jsonRelationship;
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class TrackerRelationshipsExportControllerTest method getRelationshipsByTei.
@Test
void getRelationshipsByTei() {
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?tei=" + tei.getUid()).content(HttpStatus.OK);
JsonObject jsonRelationship = assertFirstRelationship(relationship, r);
assertEnrollment(jsonRelationship.getObject("from"), programInstance);
assertTrackedEntity(jsonRelationship.getObject("to"), tei);
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class UserControllerTest method testPutJsonObject.
@Test
void testPutJsonObject() {
JsonObject user = GET("/users/{id}", peter.getUid()).content();
assertWebMessage("OK", 200, "OK", null, PUT("/38/users/" + peter.getUid(), user.toString()).content(HttpStatus.OK));
}
Aggregations