LOVResource { @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) public Response getLOVs( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { List<ListOfValuesDTO> LOVDTOs = new ArrayList<>(); List<ListOfValues> LOVs = lovManager.findLOVFromWorkspace(workspaceId); for (ListOfValues lov : LOVs) { ListOfValuesDTO lovDTO = mapper.map(lov, ListOfValuesDTO.class); lovDTO.setDeletable(lovManager.isLOVDeletable(new ListOfValuesKey(lov.getWorkspaceId(), lov.getName()))); LOVDTOs.add(lovDTO); } return Response.ok(new GenericEntity<List<ListOfValuesDTO>>((List<ListOfValuesDTO>) LOVDTOs) { }).build(); } 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 getLOVsTest() throws ApplicationException { ListOfValues lov1 = new ListOfValues(workspace, "lov1"); ListOfValues lov2 = new ListOfValues(workspace, "lov2"); List<ListOfValues> lovList = Arrays.asList(lov1, lov2); Mockito.when(lovManager.findLOVFromWorkspace(workspaceId)) .thenReturn(lovList); Response res = lovResource.getLOVs(workspaceId); Object entity = res.getEntity(); Assert.assertTrue(entity.getClass().isAssignableFrom(ArrayList.class)); ArrayList list = (ArrayList) entity; Assert.assertEquals(lovList.size(), list.size()); }