Search in sources :

Example 1 with JsonError

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

the class JwtBearerTokenTest method assertInvalidTokenError.

private void assertInvalidTokenError(String expected, HttpResponse response) {
    JsonError error = response.error(HttpStatus.UNAUTHORIZED);
    assertEquals("invalid_token", error.getMessage());
    assertEquals(expected, error.getDevMessage());
}
Also used : JsonError(org.hisp.dhis.webapi.json.domain.JsonError)

Example 2 with JsonError

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

the class FollowupAnalysisControllerTest method testPerformFollowupAnalysis_ValidationMissingStartDate.

@Test
void testPerformFollowupAnalysis_ValidationMissingStartDate() {
    JsonError error = GET("/dataAnalysis/followup?ou={ou}&de={de}&endDate=2020-01-01", orgUnitId, dataElementId).error(HttpStatus.CONFLICT);
    assertEquals(ErrorCode.E2301, error.getErrorCode());
    assertEquals("Start date and end date must be specified directly or indirectly by specifying a period", error.getMessage());
}
Also used : JsonError(org.hisp.dhis.webapi.json.domain.JsonError) Test(org.junit.jupiter.api.Test)

Example 3 with JsonError

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

the class FollowupAnalysisControllerTest method testPerformFollowupAnalysis_ValidationMissingDataElement.

@Test
void testPerformFollowupAnalysis_ValidationMissingDataElement() {
    JsonError error = GET("/dataAnalysis/followup?ou={ou}&pe=2021", orgUnitId).error(HttpStatus.CONFLICT);
    assertEquals(ErrorCode.E2300, error.getErrorCode());
    assertEquals("At least one data element or data set must be specified", error.getMessage());
}
Also used : JsonError(org.hisp.dhis.webapi.json.domain.JsonError) Test(org.junit.jupiter.api.Test)

Example 4 with JsonError

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

the class AbstractCrudControllerTest method testPartialUpdateObject_Validation.

@Test
void testPartialUpdateObject_Validation() {
    String id = run(SomeUserId::new);
    JsonError error = PATCH("/users/" + id + "?importReportMode=ERRORS", "[{'op': 'add', 'path': '/email', 'value': 'Not-valid'}]").error();
    assertEquals("Property `email` requires a valid email address, was given `Not-valid`.", error.getTypeReport().getErrorReports().get(0).getMessage());
}
Also used : JsonError(org.hisp.dhis.webapi.json.domain.JsonError) SomeUserId(org.hisp.dhis.webapi.snippets.SomeUserId) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 5 with JsonError

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

the class FollowupAnalysisControllerTest method testPerformFollowupAnalysis_ValidationMissingOrganisationUnit.

@Test
void testPerformFollowupAnalysis_ValidationMissingOrganisationUnit() {
    JsonError error = GET("/dataAnalysis/followup?de={de}&pe=2021", dataElementId).error(HttpStatus.CONFLICT);
    assertEquals(ErrorCode.E2203, error.getErrorCode());
    assertEquals("At least one organisation unit must be specified", error.getMessage());
}
Also used : JsonError(org.hisp.dhis.webapi.json.domain.JsonError) Test(org.junit.jupiter.api.Test)

Aggregations

JsonError (org.hisp.dhis.webapi.json.domain.JsonError)9 Test (org.junit.jupiter.api.Test)8 DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)1 SomeUserId (org.hisp.dhis.webapi.snippets.SomeUserId)1