Search in sources :

Example 1 with JsonWebMessage

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

the class PredictorControllerTest method testGetSkipTestDescription.

@Test
void testGetSkipTestDescription() {
    JsonWebMessage response = POST("/predictors/skipTest/description", "1 != 1").content().as(JsonWebMessage.class);
    assertWebMessage("OK", 200, "OK", "Valid", response);
    assertEquals("1 != 1", 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 2 with JsonWebMessage

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

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

the class MetadataImportExportControllerTest method testPostProgramStageWithoutProgram.

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

Example 4 with JsonWebMessage

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

the class PredictorControllerTest method testGetExpressionDescription.

@Test
void testGetExpressionDescription() {
    JsonWebMessage response = POST("/predictors/expression/description", "0").content().as(JsonWebMessage.class);
    assertWebMessage("OK", 200, "OK", "Valid", response);
    assertEquals("0", 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 5 with JsonWebMessage

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

the class AbstractCrudControllerTest method testReplaceCollectionItemsJson.

@Test
void testReplaceCollectionItemsJson() {
    String userId = getCurrentUser().getUid();
    // first create an object which has a collection
    String groupId = assertStatus(HttpStatus.CREATED, POST("/userGroups/", "{'name':'testers', 'users':[{'id':'" + userId + "'}]}"));
    String peter = "{'name': 'Peter', 'firstName':'Peter', 'surname':'Pan', 'username':'peter47'}";
    String peterUserId = assertStatus(HttpStatus.CREATED, POST("/users", peter));
    JsonWebMessage message = PUT("/userGroups/" + groupId + "/users", "{'identifiableObjects':[{'id':'" + peterUserId + "'}]}").content(HttpStatus.OK).as(JsonWebMessage.class);
    JsonStats stats = message.getResponse().as(JsonTypeReport.class).getStats();
    assertEquals(1, stats.getUpdated());
    assertEquals(1, stats.getDeleted());
    assertUserGroupHasOnlyUser(groupId, peterUserId);
}
Also used : JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) JsonStats(org.hisp.dhis.webapi.json.domain.JsonStats) 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)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