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