RoleResource { @DELETE @ApiOperation(value = "Delete a role", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of RoleDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{roleName}") @Produces(MediaType.APPLICATION_JSON) public Response deleteRole( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Role name") @PathParam("roleName") String roleName) throws EntityNotFoundException, UserNotActiveException, AccessRightException, EntityConstraintException, WorkspaceNotEnabledException { RoleKey roleKey = new RoleKey(workspaceId, roleName); roleService.deleteRole(roleKey); return Response.noContent().build(); } RoleResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get roles in given workspace", response = RoleDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of RoleDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response getRolesInWorkspace(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @GET @ApiOperation(value = "Get roles in use in given workspace", response = RoleDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of RoleDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("inuse") @Produces(MediaType.APPLICATION_JSON) Response getRolesInUseInWorkspace(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @POST @ApiOperation(value = "Create a new role", response = RoleDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created RoleDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Response createRole(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Role to create") RoleDTO roleDTO); @PUT @ApiOperation(value = "Update a role", response = RoleDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated RoleDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{roleName}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Response updateRole(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Role name") @PathParam("roleName") String roleName,
            @ApiParam(required = true, value = "Role to update") RoleDTO roleDTO); @DELETE @ApiOperation(value = "Delete a role", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of RoleDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{roleName}") @Produces(MediaType.APPLICATION_JSON) Response deleteRole(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Role name") @PathParam("roleName") String roleName);  }
@Test public void deleteRoleTest() throws ApplicationException{ RoleKey roleKey = new RoleKey(workspaceId, "role"); Mockito.doNothing().when(roleService).deleteRole(roleKey); Response res = roleResource.deleteRole(workspaceId, roleKey.getName()); Assert.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), res.getStatus()); }