use of org.hisp.dhis.webapi.json.domain.JsonIdentifiableObject in project dhis2-core by dhis2.
the class BulkPatchSharingControllerTest method testApplyPatches.
@Test
void testApplyPatches() throws IOException {
assertStatus(HttpStatus.CREATED, POST("/users", createUser("usera", userAId)));
assertStatus(HttpStatus.CREATED, POST("/users", createUser("userb", userBId)));
userCId = assertStatus(HttpStatus.CREATED, POST("/users", createUser("userc")));
assertStatus(HttpStatus.CREATED, POST("/dataSets", jsonMapper.writeValueAsString(createDataSet('A', dsIdA, userCId))));
assertStatus(HttpStatus.CREATED, POST("/dataElements", jsonMapper.writeValueAsString(createDataElement('A', deAId, userCId))));
assertStatus(HttpStatus.CREATED, POST("/dataElements", jsonMapper.writeValueAsString(createDataElement('B', deBId, userCId))));
assertStatus(HttpStatus.OK, PATCH("/metadata/sharing", "patch/bulk_sharing_patches.json"));
JsonIdentifiableObject savedDeA = GET("/dataElements/{uid}", deAId).content(HttpStatus.OK).as(JsonIdentifiableObject.class);
JsonIdentifiableObject savedDeB = GET("/dataElements/{uid}", deBId).content(HttpStatus.OK).as(JsonIdentifiableObject.class);
JsonIdentifiableObject savedDsA = GET("/dataSets/{uid}", dsIdA).content(HttpStatus.OK).as(JsonIdentifiableObject.class);
assertEquals(2, savedDeA.getSharing().getUsers().size());
assertEquals(2, savedDeB.getSharing().getUsers().size());
assertEquals(2, savedDsA.getSharing().getUsers().size());
assertNotNull(savedDeA.getSharing().getUsers().get(userAId));
assertNotNull(savedDeB.getSharing().getUsers().get(userAId));
assertNotNull(savedDsA.getSharing().getUsers().get(userAId));
assertNotNull(savedDeA.getSharing().getUsers().get(userBId));
assertNotNull(savedDeB.getSharing().getUsers().get(userBId));
assertNotNull(savedDsA.getSharing().getUsers().get(userBId));
}
use of org.hisp.dhis.webapi.json.domain.JsonIdentifiableObject in project dhis2-core by dhis2.
the class BulkPatchSharingControllerTest method testApplyPatchOk.
@Test
void testApplyPatchOk() throws IOException {
assertStatus(HttpStatus.CREATED, POST("/users", createUser("usera", userAId)));
assertStatus(HttpStatus.CREATED, POST("/users", createUser("userb", userBId)));
userCId = assertStatus(HttpStatus.CREATED, POST("/users", createUser("userc")));
assertStatus(HttpStatus.CREATED, POST("/dataElements", jsonMapper.writeValueAsString(createDataElement('A', deAId, userCId))));
assertStatus(HttpStatus.CREATED, POST("/dataElements", jsonMapper.writeValueAsString(createDataElement('B', deBId, userCId))));
assertStatus(HttpStatus.OK, PATCH("/dataElements/sharing", "patch/bulk_sharing_patch.json"));
JsonIdentifiableObject saveDeA = GET("/dataElements/{uid}", deAId).content(HttpStatus.OK).as(JsonIdentifiableObject.class);
JsonIdentifiableObject saveDeB = GET("/dataElements/{uid}", deBId).content(HttpStatus.OK).as(JsonIdentifiableObject.class);
assertEquals(2, saveDeA.getSharing().getUsers().size());
assertEquals(2, saveDeB.getSharing().getUsers().size());
}
use of org.hisp.dhis.webapi.json.domain.JsonIdentifiableObject in project dhis2-core by dhis2.
the class SharingControllerTest method testPutSharing.
@Test
void testPutSharing() {
String groupId = assertStatus(HttpStatus.CREATED, POST("/userGroups", "{'name':'test'}"));
JsonIdentifiableObject group = GET("/userGroups/{id}", groupId).content().as(JsonIdentifiableObject.class);
assertWebMessage("OK", 200, "OK", "Access control set", PUT("/sharing?type=userGroup&id=" + groupId, group.getSharing().node().getDeclaration()).content(HttpStatus.OK));
}
use of org.hisp.dhis.webapi.json.domain.JsonIdentifiableObject in project dhis2-core by dhis2.
the class SharingControllerTest method testPostSharing.
@Test
void testPostSharing() {
String groupId = assertStatus(HttpStatus.CREATED, POST("/userGroups", "{'name':'test'}"));
JsonIdentifiableObject group = GET("/userGroups/{id}", groupId).content().as(JsonIdentifiableObject.class);
assertWebMessage("OK", 200, "OK", "Access control set", POST("/sharing?type=userGroup&id=" + groupId, group.getSharing().node().getDeclaration()).content(HttpStatus.OK));
}
Aggregations