use of org.hisp.dhis.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class AbstractCrudControllerTest method replaceTranslationsForNotTranslatableObject.
@Test
void replaceTranslationsForNotTranslatableObject() {
String id = getCurrentUser().getUid();
JsonArray translations = GET("/users/{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("/users/" + id + "/translations", "{'translations': [{'locale':'sv', 'property':'name', 'value':'namn'}]}").content(HttpStatus.CONFLICT));
JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E1107);
assertEquals("Object type `User` is not translatable.", error.getMessage());
}
use of org.hisp.dhis.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class AbstractCrudControllerTest method testSetSharing_InvalidPublicAccess.
@Test
void testSetSharing_InvalidPublicAccess() {
String userId = getCurrentUser().getUid();
// first create an object which can be shared
String programId = assertStatus(HttpStatus.CREATED, POST("/programs/", "{'name':'test', 'shortName':'test', 'programType':'WITHOUT_REGISTRATION'}"));
String sharing = "{'owner':'" + userId + "', 'public':'illegal', 'external': true }";
JsonWebMessage message = PUT("/programs/" + programId + "/sharing", sharing).content(HttpStatus.CONFLICT).as(JsonWebMessage.class);
assertWebMessage("Conflict", 409, "ERROR", "One more more errors occurred, please see full details in import report.", message);
JsonTypeReport response = message.get("response", JsonTypeReport.class);
assertEquals(1, response.getObjectReports().size());
assertEquals(ErrorCode.E3015, response.getObjectReports().get(0).getErrorReports().get(0).getErrorCode());
}
use of org.hisp.dhis.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class AbstractCrudControllerTest method replaceTranslations_MissingProperty.
@Test
void replaceTranslations_MissingProperty() {
String id = assertStatus(HttpStatus.CREATED, POST("/dataSets/", "{'name':'My data set', 'periodType':'Monthly'}"));
JsonWebMessage message = assertWebMessage("Conflict", 409, "WARNING", "One more more errors occurred, please see full details in import report.", PUT("/dataSets/" + id + "/translations", "{'translations': [{'locale':'en', 'value':'namn 1'}]}").content(HttpStatus.CONFLICT));
JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E4000);
assertEquals("Missing required property `property`.", error.getMessage());
}
use of org.hisp.dhis.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class DataValueSetControllerTest method testGetDataValueSetJson.
@Test
void testGetDataValueSetJson() {
String ouId = assertStatus(HttpStatus.CREATED, POST("/organisationUnits/", "{'name':'My Unit', 'shortName':'OU1', 'openingDate': '2020-01-01', 'code':'OU1'}"));
JsonWebMessage response = GET("/dataValueSets/?inputOrgUnitIdScheme=code&idScheme=name&orgUnit={ou}", "OU1").content(HttpStatus.CONFLICT).as(JsonWebMessage.class);
assertEquals(String.format("User is not allowed to view org unit: `%s`", ouId), response.getMessage());
}
use of org.hisp.dhis.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class ExpressionControllerTest method testGetExpressionDescription.
@Test
void testGetExpressionDescription() {
JsonWebMessage response = GET("/expressions/description?expression=0").content().as(JsonWebMessage.class);
assertWebMessage("OK", 200, "OK", "Valid", response);
assertEquals("0", response.getDescription());
}
Aggregations