use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.RoleDTO in project ArachneCentralAPI by OHDSI.
the class RoleController method get.
@ApiOperation(value = "Get role description.", hidden = true)
@RequestMapping(value = "/api/v1/admin/roles/{roleId}", method = RequestMethod.GET)
public JsonResult<RoleDTO> get(@PathVariable("roleId") Long id) throws NotExistException {
JsonResult<RoleDTO> result;
if (id == null) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
result.getValidatorErrors().put("roleId", "cannot be null");
} else {
Role role = roleService.getById(id);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(conversionService.convert(role, RoleDTO.class));
}
return result;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.RoleDTO in project ArachneCentralAPI by OHDSI.
the class RoleControllerTests method testRole.
@Test
@DatabaseSetup(value = "/data/role/empty-role.xml")
@ExpectedDatabase(table = "roles", value = "/data/role/added-role.xml", assertionMode = NON_STRICT)
public void testRole() throws Exception {
RoleDTO roleDTO = new RoleDTO();
roleDTO.setName(ROLE_NAME);
roleDTO.setDescription(ROLE_DESCRIPTION);
MvcResult mvcResult = mvc.perform(post("/api/v1/admin/roles/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(roleDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(ROLE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
Aggregations