use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class AbstractCrudControllerTest method replaceTranslationsWithDuplicateLocales.
@Test
public void replaceTranslationsWithDuplicateLocales() {
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());
JsonWebMessage message = assertWebMessage("Conflict", 409, "WARNING", "One more more errors occurred, please see full details in import report.", PUT("/dataSets/" + id + "/translations", "{'translations': [{'locale':'sv', 'property':'name', 'value':'namn 1'},{'locale':'sv', 'property':'name', 'value':'namn2'}]}").content(HttpStatus.CONFLICT));
JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E1106);
assertEquals("There are duplicate translation record for property `name` and locale `sv`", error.getMessage());
assertEquals("name", error.getErrorProperties().get(0));
}
use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class AppControllerTest method testGetApps.
@Test
void testGetApps() {
HttpResponse response = GET("/apps");
JsonArray apps = response.content(HttpStatus.OK);
assertTrue(apps.isArray());
}
use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class AuthoritiesControllerTest method testGetAuthorities.
@Test
void testGetAuthorities() {
JsonArray systemAuthorities = GET("/authorities").content().getArray("systemAuthorities");
assertTrue(systemAuthorities.size() > 10);
// its sorted
JsonObject all = systemAuthorities.getObject(0);
assertEquals("ALL", all.getString("id").string());
assertEquals("ALL", all.getString("name").string());
}
use of org.hisp.dhis.jsontree.JsonArray 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.JsonArray 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());
}
Aggregations