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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations