Search in sources :

Example 6 with JsonError

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

the class FollowupAnalysisControllerTest method testPerformFollowupAnalysis_ValidationMaxResultsOverLimit.

@Test
void testPerformFollowupAnalysis_ValidationMaxResultsOverLimit() {
    JsonError error = GET("/dataAnalysis/followup?ou={ou}&de={de}&pe=2021&maxResults=11111", orgUnitId, dataElementId).error(HttpStatus.CONFLICT);
    assertEquals(ErrorCode.E2206, error.getErrorCode());
    assertEquals("Max results exceeds the allowed max limit: `" + NumberFormat.getInstance().format(10000) + "`", error.getMessage());
}
Also used : JsonError(org.hisp.dhis.webapi.json.domain.JsonError) Test(org.junit.jupiter.api.Test)

Example 7 with JsonError

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

the class FollowupAnalysisControllerTest method testPerformFollowupAnalysis_ValidationStartDateNotBeforeEndDate.

@Test
void testPerformFollowupAnalysis_ValidationStartDateNotBeforeEndDate() {
    JsonError error = GET("/dataAnalysis/followup?ou={ou}&de={de}&startDate=2020-01-01&endDate=2019-01-01", orgUnitId, dataElementId).error(HttpStatus.CONFLICT);
    assertEquals(ErrorCode.E2202, error.getErrorCode());
    assertEquals("Start date must be before end date", error.getMessage());
}
Also used : JsonError(org.hisp.dhis.webapi.json.domain.JsonError) Test(org.junit.jupiter.api.Test)

Example 8 with JsonError

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

the class FollowupAnalysisControllerTest method testPerformFollowupAnalysis_ValidationMaxResultsZeroOrNegative.

@Test
void testPerformFollowupAnalysis_ValidationMaxResultsZeroOrNegative() {
    JsonError error = GET("/dataAnalysis/followup?ou={ou}&de={de}&pe=2021&maxResults=0", orgUnitId, dataElementId).error(HttpStatus.CONFLICT);
    assertEquals(ErrorCode.E2205, error.getErrorCode());
    assertEquals("Max results must be a positive number", error.getMessage());
}
Also used : JsonError(org.hisp.dhis.webapi.json.domain.JsonError) Test(org.junit.jupiter.api.Test)

Example 9 with JsonError

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

the class FollowupAnalysisControllerTest method testPerformFollowupAnalysis_ValidationMissingEndDate.

@Test
void testPerformFollowupAnalysis_ValidationMissingEndDate() {
    JsonError error = GET("/dataAnalysis/followup?ou={ou}&de={de}&startDate=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)

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