use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class DataSetControllerTest method testGetFormJson.
@Test
void testGetFormJson() {
String ouId = assertStatus(HttpStatus.CREATED, POST("/organisationUnits/", "{'name':'My Unit', 'shortName':'OU1', 'openingDate': '2020-01-01'}"));
JsonObject info = GET("/dataSets/{id}/form?ou={ou}", dsId, ouId).content(HttpStatus.OK);
assertTrue(info.isObject());
assertTrue(info.has("label", "options", "groups"));
assertEquals("My data set", info.getString("label").string());
JsonObject options = info.getObject("options");
assertEquals(0, options.getNumber("openPeriodsAfterCoEndDate").intValue());
assertEquals(0, options.getNumber("openFuturePeriods").intValue());
assertEquals(0, options.getNumber("expiryDays").intValue());
assertEquals("Monthly", options.getString("periodType").string());
JsonArray groups = info.getArray("groups");
assertTrue(groups.isArray());
assertEquals(1, groups.size());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class AttributeControllerTest method testObjectTypes.
/**
* Tests that each type only sets the property the type relates to
*/
@Test
void testObjectTypes() {
for (ObjectType testedType : ObjectType.values()) {
String propertyName = testedType.getPropertyName();
String uid = assertStatus(HttpStatus.CREATED, POST("/attributes", "{" + "'name':'" + testedType + "', " + "'valueType':'INTEGER', " + "'" + propertyName + "':true}"));
JsonObject attr = GET("/attributes/{uid}", uid).content();
for (ObjectType otherType : ObjectType.values()) {
assertEquals(testedType == otherType, attr.getBoolean(otherType.getPropertyName()).booleanValue());
}
}
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class DataApprovalControllerTest method testGetMultipleApprovalPermissions_Approvals.
@Test
void testGetMultipleApprovalPermissions_Approvals() {
JsonArray statuses = GET("/dataApprovals/approvals?ou={ou}&pe=202101&wf={wf}", ouId, wfId).content(HttpStatus.OK);
assertEquals(1, statuses.size());
JsonObject status = statuses.getObject(0);
assertTrue(status.has("wf", "pe", "ou", "aoc"));
assertEquals(ouId, status.getString("ou").string());
assertEquals(wfId, status.getString("wf").string());
assertEquals("202101", status.getString("pe").string());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class DataIntegrityReportControllerTest method getDataIntegrityReport.
private JsonDataIntegrityReport getDataIntegrityReport(String url) {
HttpResponse httpResponse = POST(url);
assertTrue(httpResponse.location().startsWith("http://localhost/dataIntegrity/details?checks="));
JsonObject response = httpResponse.content().getObject("response");
String id = response.getString("id").string();
String jobType = response.getString("jobType").string();
return GET("/system/taskSummaries/{type}/{id}", jobType, id).content().as(JsonDataIntegrityReport.class);
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class InterpretationControllerTest method testUpdateComment.
@Test
void testUpdateComment() {
String cuid = assertStatus(HttpStatus.CREATED, POST("/interpretations/" + uid + "/comments", "text/plain:comment"));
assertStatus(HttpStatus.NO_CONTENT, PUT("/interpretations/" + uid + "/comments/" + cuid, "text/plain:new comment"));
JsonObject comments = GET("/interpretations/{uid}/comments/", uid).content();
assertEquals("new comment", comments.getArray("comments").getObject(0).getString("text").string());
}
Aggregations