use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class AbstractCrudControllerTest method replaceTranslationsOk.
@Test
public void replaceTranslationsOk() {
String id = assertStatus(HttpStatus.CREATED, POST("/dataSets/", "{'name':'My data set', 'periodType':'Monthly'}"));
JsonArray translations = GET("/dataSets/{id}/translations", id).content().getArray("translations");
assertTrue(translations.isEmpty());
PUT("/dataSets/" + id + "/translations", "{'translations': [{'locale':'sv', 'property':'name', 'value':'name sv'}]}").content(HttpStatus.NO_CONTENT);
JsonResponse content = GET("/dataSets/{id}", id).content();
translations = GET("/dataSets/{id}/translations", id).content().getArray("translations");
assertEquals(1, translations.size());
JsonTranslation translation = translations.get(0, JsonTranslation.class);
assertEquals("sv", translation.getLocale());
assertEquals("name", translation.getProperty());
assertEquals("name sv", translation.getValue());
}
use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class DataApprovalControllerTest method testGetApproval.
@Test
void testGetApproval() {
JsonArray statuses = GET("/dataApprovals/status?ou={ou}&pe=202101&wf={wf}&ds={ds}", ouId, wfId, dsId).content(HttpStatus.OK).getArray("dataApprovalStateResponses");
assertEquals(1, statuses.size());
JsonObject status_t0 = statuses.getObject(0);
assertEquals("UNAPPROVED_READY", status_t0.getString("state").string());
JsonObject permissions = status_t0.getObject("permissions");
assertFalse(permissions.getString("acceptedBy").exists());
assertFalse(permissions.getString("acceptedAt").exists());
// now create an approval (approve it)
assertStatus(HttpStatus.NO_CONTENT, POST("/dataApprovals?ou={ou}&pe=202101&wf={wf}", ouId, wfId));
JsonObject status_t1 = GET("/dataApprovals/status?ou={ou}&pe=202101&wf={wf}&ds={ds}", ouId, wfId, dsId).content(HttpStatus.OK).getArray("dataApprovalStateResponses").getObject(0);
assertEquals("APPROVED_HERE", status_t1.getString("state").string());
permissions = status_t1.getObject("permissions");
assertFalse(permissions.getBoolean("mayReadAcceptedBy").exists());
assertTrue(permissions.getString("acceptedAt").exists());
}
use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class DataApprovalControllerTest method testGetMultipleApprovalPermissions_Multiple.
@Test
void testGetMultipleApprovalPermissions_Multiple() {
JsonArray statuses = GET("/dataApprovals/multiple?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.JsonArray in project dhis2-core by dhis2.
the class GistFilterControllerTest method testFilter_GroupAND.
@Test
void testFilter_GroupAND() {
createDataSetsForOrganisationUnit(5, orgUnitId, "alpha");
createDataSetsForOrganisationUnit(5, orgUnitId, "beta");
createDataSetsForOrganisationUnit(5, orgUnitId, "gamma");
// both filters in group 2 are combined AND because the root junction is
// set to OR
String url = "/dataSets/gist?filter=1:name:eq:beta1&filter=2:name:like:alpha&filter=2:name:endsWith:4&headless=true&rootJunction=OR&order=name";
JsonArray matches = GET(url).content();
assertEquals(2, matches.size());
assertEquals("alpha4", matches.getObject(0).getString("name").string());
assertEquals("beta1", matches.getObject(1).getString("name").string());
}
use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class DimensionControllerTest method testGetDimensionsForDataSet.
@Test
void testGetDimensionsForDataSet() {
String dsId = assertStatus(HttpStatus.CREATED, POST("/dataSets/", "{'name':'My data set', 'periodType':'Monthly', 'categoryCombo':{'id':'" + ccId + "'}}"));
JsonObject response = GET("/dimensions/dataSet/{ds}", dsId).content();
JsonArray dimensions = response.getArray("dimensions");
assertEquals(1, dimensions.size());
JsonObject gender = dimensions.getObject(0);
assertEquals("Gender", gender.getString("name").string());
}
Aggregations