Search in sources :

Example 1 with JsonStats

use of org.hisp.dhis.webapi.json.domain.JsonStats 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)1 JsonStats (org.hisp.dhis.webapi.json.domain.JsonStats)1 JsonTypeReport (org.hisp.dhis.webapi.json.domain.JsonTypeReport)1 JsonWebMessage (org.hisp.dhis.webapi.json.domain.JsonWebMessage)1 Test (org.junit.jupiter.api.Test)1