LOVResource { @PUT @Path("/{name}") @ApiOperation(value = "Update a ListOfValues", response = ListOfValuesDTO.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Successful retrieval of updated ListOfValuesDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public ListOfValuesDTO updateLOV( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Name") @PathParam("name") String name, @ApiParam(required = true, value = "LOV to update") ListOfValuesDTO lovDTO) throws EntityNotFoundException, EntityAlreadyExistsException, CreationException, UserNotActiveException, AccessRightException, WorkspaceNotEnabledException { ListOfValuesKey lovKey = new ListOfValuesKey(workspaceId, name); ListOfValues lov = mapper.map(lovDTO, ListOfValues.class); ListOfValues updatedLOV = lovManager.updateLov(lovKey, lov.getName(), workspaceId, lov.getValues()); return mapper.map(updatedLOV, ListOfValuesDTO.class); } LOVResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get a list of ListOfValues for given parameters", response = ListOfValuesDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of ListOfValuesDTOs. 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 getLOVs(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @POST @ApiOperation(value = "Create a new ListOfValues", response = ListOfValuesDTO.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Successful retrieval of created ListOfValuesDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createLOV(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "LOV to create") ListOfValuesDTO lovDTO); @GET @ApiOperation(value = "Get a ListOfValues from the given parameters", response = ListOfValuesDTO.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Successful retrieval of ListOfValuesDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/{name}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) ListOfValuesDTO getLOV(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Name") @PathParam("name") String name); @PUT @Path("/{name}") @ApiOperation(value = "Update a ListOfValues", response = ListOfValuesDTO.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Successful retrieval of updated ListOfValuesDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) ListOfValuesDTO updateLOV(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Name") @PathParam("name") String name,
            @ApiParam(required = true, value = "LOV to update") ListOfValuesDTO lovDTO); @DELETE @Path("/{name}") @ApiOperation(value = "Delete a ListOfValues", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of ListOfValuesDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response deleteLOV(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Name") @PathParam("name") String name);  }
@Test public void updateLOVTest() throws ApplicationException { String name = "foo"; ListOfValuesDTO lovDTO = new ListOfValuesDTO(); lovDTO.setWorkspaceId(workspaceId); lovDTO.setName(name); List<NameValuePairDTO> values = new ArrayList<>(); NameValuePairDTO value = new NameValuePairDTO(); value.setName("k"); value.setValue("v"); values.add(value); lovDTO.setValues(values); Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance(); ListOfValues lov = mapper.map(lovDTO, ListOfValues.class); Mockito.when(lovManager.updateLov(Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any())) .thenReturn(lov); ListOfValuesDTO result = lovResource.updateLOV(workspaceId, name, lovDTO); Assert.assertEquals(lovDTO.getName(), result.getName()); Assert.assertEquals(lovDTO.getValues().get(0).getName(), result.getValues().get(0).getName()); Assert.assertEquals(lovDTO.getValues().get(0).getValue(), result.getValues().get(0).getValue()); }