Search in sources :

Example 21 with JsonWebMessage

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

the class PredictorControllerTest method testGetSkipTestDescription_InvalidExpression.

@Test
void testGetSkipTestDescription_InvalidExpression() {
    JsonWebMessage response = POST("/predictors/skipTest/description", "1 <> 1").content().as(JsonWebMessage.class);
    assertWebMessage("OK", 200, "ERROR", "Expression is not well-formed", response);
    assertNull(response.getDescription());
}
Also used : JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 22 with JsonWebMessage

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

the class PredictorControllerTest method testGetExpressionDescription_InvalidExpression.

@Test
void testGetExpressionDescription_InvalidExpression() {
    JsonWebMessage response = POST("/predictors/expression/description", "1 <> 1").content().as(JsonWebMessage.class);
    assertWebMessage("OK", 200, "ERROR", "Expression is not well-formed", response);
    assertNull(response.getDescription());
}
Also used : JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 23 with JsonWebMessage

use of org.hisp.dhis.webapi.json.domain.JsonWebMessage 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 24 with JsonWebMessage

use of org.hisp.dhis.webapi.json.domain.JsonWebMessage 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

DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)24 JsonWebMessage (org.hisp.dhis.webapi.json.domain.JsonWebMessage)24 Test (org.junit.jupiter.api.Test)24 JsonErrorReport (org.hisp.dhis.webapi.json.domain.JsonErrorReport)13 JsonTypeReport (org.hisp.dhis.webapi.json.domain.JsonTypeReport)3 JsonArray (org.hisp.dhis.jsontree.JsonArray)2 JsonImportSummary (org.hisp.dhis.webapi.json.domain.JsonImportSummary)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 GeoJsonObject (org.geojson.GeoJsonObject)1 Polygon (org.geojson.Polygon)1 ErrorCode (org.hisp.dhis.feedback.ErrorCode)1 JsonObject (org.hisp.dhis.jsontree.JsonObject)1 User (org.hisp.dhis.user.User)1 Body (org.hisp.dhis.webapi.WebClient.Body)1 ContentType (org.hisp.dhis.webapi.WebClient.ContentType)1 JsonMetadataProposal (org.hisp.dhis.webapi.controller.json.JsonMetadataProposal)1 JsonAttributeValue (org.hisp.dhis.webapi.json.domain.JsonAttributeValue)1 JsonIdentifiableObject (org.hisp.dhis.webapi.json.domain.JsonIdentifiableObject)1 JsonStats (org.hisp.dhis.webapi.json.domain.JsonStats)1