Search in sources :

Example 1 with JsonTypeReport

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

the class ProgramStageControllerTest method testCreateProgramStageWithoutProgram.

@Test
void testCreateProgramStageWithoutProgram() {
    JsonWebMessage message = POST("/programStages/", "{'name':'test programStage'}").content(HttpStatus.CONFLICT).as(JsonWebMessage.class);
    JsonTypeReport response = message.get("response", JsonTypeReport.class);
    assertEquals(1, response.getErrorReports().size());
    assertEquals(ErrorCode.E4053, response.getErrorReports().get(0).getErrorCode());
}
Also used : JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) JsonTypeReport(org.hisp.dhis.webapi.json.domain.JsonTypeReport) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 2 with JsonTypeReport

use of org.hisp.dhis.webapi.json.domain.JsonTypeReport 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());
}
Also used : JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) JsonTypeReport(org.hisp.dhis.webapi.json.domain.JsonTypeReport) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Aggregations

DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)2 JsonTypeReport (org.hisp.dhis.webapi.json.domain.JsonTypeReport)2 JsonWebMessage (org.hisp.dhis.webapi.json.domain.JsonWebMessage)2 Test (org.junit.jupiter.api.Test)2