Search in sources :

Example 11 with JsonErrorReport

use of org.hisp.dhis.webapi.json.domain.JsonErrorReport in project dhis2-core by dhis2.

the class MetadataWorkflowControllerTest method testAcceptUpdateProposal_ConflictTargetAlreadyDeleted.

@Test
void testAcceptUpdateProposal_ConflictTargetAlreadyDeleted() {
    String proposalId = postUpdateNameProposal(defaultTargetId, "New name");
    assertStatus(HttpStatus.OK, DELETE("/organisationUnits/" + defaultTargetId));
    JsonWebMessage message = assertWebMessage("Conflict", 409, "WARNING", "One more more errors occurred, please see full details in import report.", POST("/metadata/proposals/" + proposalId).content(HttpStatus.CONFLICT));
    JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E4015);
    assertEquals("Property `targetId` refers to an object that does not exist, could not find `" + defaultTargetId + "`", error.getMessage());
    assertEquals("targetId", error.getErrorProperties().get(0));
}
Also used : JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) JsonErrorReport(org.hisp.dhis.webapi.json.domain.JsonErrorReport) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 12 with JsonErrorReport

use of org.hisp.dhis.webapi.json.domain.JsonErrorReport in project dhis2-core by dhis2.

the class UserControllerTest method testPostJsonObjectInvalidUsername.

@Test
void testPostJsonObjectInvalidUsername() {
    JsonWebMessage msg = assertWebMessage("Conflict", 409, "ERROR", "One more more errors occurred, please see full details in import report.", POST("/users/", "{'surname':'S.','firstName':'Harry','userCredentials':{'username':'Harrys'}}").content(HttpStatus.CONFLICT));
    JsonErrorReport report = msg.getResponse().find(JsonErrorReport.class, error -> error.getErrorCode() == ErrorCode.E4049);
    assertEquals("username", report.getErrorProperty());
}
Also used : JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) JsonErrorReport(org.hisp.dhis.webapi.json.domain.JsonErrorReport) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 13 with JsonErrorReport

use of org.hisp.dhis.webapi.json.domain.JsonErrorReport in project dhis2-core by dhis2.

the class UserControllerTest method testPutProperty_InvalidWhatsapp.

@Test
void testPutProperty_InvalidWhatsapp() {
    JsonWebMessage msg = assertWebMessage("Conflict", 409, "ERROR", "One more more errors occurred, please see full details in import report.", PATCH("/users/" + peter.getUid() + "?importReportMode=ERRORS", "[{'op': 'add', 'path': '/whatsApp', 'value': 'not-a-phone-no'}]").content(HttpStatus.CONFLICT));
    JsonErrorReport report = msg.getResponse().find(JsonErrorReport.class, error -> error.getErrorCode() == ErrorCode.E4027);
    assertEquals("whatsApp", report.getErrorProperty());
}
Also used : JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) JsonErrorReport(org.hisp.dhis.webapi.json.domain.JsonErrorReport) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Aggregations

JsonErrorReport (org.hisp.dhis.webapi.json.domain.JsonErrorReport)13 DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)12 JsonWebMessage (org.hisp.dhis.webapi.json.domain.JsonWebMessage)12 Test (org.junit.jupiter.api.Test)12 JsonArray (org.hisp.dhis.jsontree.JsonArray)2 User (org.hisp.dhis.user.User)1 JsonMetadataProposal (org.hisp.dhis.webapi.controller.json.JsonMetadataProposal)1 JsonObjectReport (org.hisp.dhis.webapi.json.domain.JsonObjectReport)1