use of org.hisp.dhis.webapi.json.domain.JsonWebMessage 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.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class AbstractCrudControllerTest method replaceTranslations_MissingValue.
@Test
void replaceTranslations_MissingValue() {
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', 'property':'name'}]}").content(HttpStatus.CONFLICT));
JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E4000);
assertEquals("Missing required property `value`.", error.getMessage());
}
use of org.hisp.dhis.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class AbstractCrudControllerTest method replaceTranslations_MissingLocale.
@Test
void replaceTranslations_MissingLocale() {
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': [{'property':'name', 'value':'namn 1'}]}").content(HttpStatus.CONFLICT));
JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E4000);
assertEquals("Missing required property `locale`.", error.getMessage());
}
use of org.hisp.dhis.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class ExpressionControllerTest method testGetExpressionDescription_InvalidExpression.
@Test
void testGetExpressionDescription_InvalidExpression() {
JsonWebMessage response = GET("/expressions/description?expression=invalid").content().as(JsonWebMessage.class);
assertWebMessage("OK", 200, "ERROR", "Expression is not well-formed", response);
assertNull(response.getDescription());
}
use of org.hisp.dhis.webapi.json.domain.JsonWebMessage in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testMakeAddProposal_ConflictIllegalChange.
@Test
void testMakeAddProposal_ConflictIllegalChange() {
JsonWebMessage message = assertWebMessage("Conflict", 409, "WARNING", "One more more errors occurred, please see full details in import report.", POST("/metadata/proposals/", "{" + "'type':'ADD'," + "'target':'ORGANISATION_UNIT'," + "'change':{'name':'hasNoShortName', " + "'openingDate': '2020-01-01'" + "}" + "}").content(HttpStatus.CONFLICT));
JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E4000);
assertEquals("Missing required property `shortName`.", error.getMessage());
assertEquals("shortName", error.getErrorProperties().get(0));
}
Aggregations