LayerResource { @POST @ApiOperation(value = "Create a new marker in a given layer", response = MarkerDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created MarkerDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{layerId}/markers") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public MarkerDTO createMarker( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Configuration item id") @PathParam("ciId") String ciId, @ApiParam(required = true, value = "Layer id") @PathParam("layerId") int layerId, @ApiParam(required = true, value = "Marker to create") MarkerDTO markerDTO) throws EntityNotFoundException, AccessRightException, WorkspaceNotEnabledException { Marker marker = productService.createMarker(layerId, markerDTO.getTitle(), markerDTO.getDescription(), markerDTO.getX(), markerDTO.getY(), markerDTO.getZ()); return new MarkerDTO(marker.getId(), marker.getTitle(), marker.getDescription(), marker.getX(), marker.getY(), marker.getZ()); } LayerResource(); @GET @ApiOperation(value = "Get layers for given product", response = LayerDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of LayerDTOs. 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) LayerDTO[] getLayersInProduct(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Configuration item id") @PathParam("ciId") String ciId); @POST @ApiOperation(value = "Create a new layer for given product", response = LayerDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created LayerDTO"), @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) LayerDTO createLayer(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Configuration item id") @PathParam("ciId") String ciId,
            @ApiParam(required = true, value = "Layer to create") LayerDTO layer); @PUT @ApiOperation(value = "Update layer", response = LayerDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated LayerDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{layerId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) LayerDTO updateLayer(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Configuration item id") @PathParam("ciId") String ciId,
            @ApiParam(required = true, value = "Layer id") @PathParam("layerId") int layerId,
            @ApiParam(required = true, value = "Layer to update") LayerDTO layer); @DELETE @ApiOperation(value = "Delete layer", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of LayerDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{layerId}") @Produces(MediaType.APPLICATION_JSON) Response deleteLayer(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Configuration item id") @PathParam("ciId") String ciId,
            @ApiParam(required = true, value = "Layer id") @PathParam("layerId") int layerId); @GET @ApiOperation(value = "Get markers of a given layer", response = MarkerDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of MarkerDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{layerId}/markers") @Produces(MediaType.APPLICATION_JSON) MarkerDTO[] getMarkersInLayer(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Configuration item id") @PathParam("ciId") String ciId,
            @ApiParam(required = true, value = "Layer id") @PathParam("layerId") int layerId); @POST @ApiOperation(value = "Create a new marker in a given layer", response = MarkerDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created MarkerDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{layerId}/markers") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) MarkerDTO createMarker(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Configuration item id") @PathParam("ciId") String ciId,
            @ApiParam(required = true, value = "Layer id") @PathParam("layerId") int layerId,
            @ApiParam(required = true, value = "Marker to create") MarkerDTO markerDTO); @DELETE @ApiOperation(value = "Delete marker", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of LayerDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{layerId}/markers/{markerId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response deleteMarker(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Configuration item id") @PathParam("ciId") String ciId,
            @ApiParam(required = true, value = "Layer id") @PathParam("layerId") int layerId,
            @ApiParam(required = true, value = "Marker id") @PathParam("markerId") int markerId);  }
@Test public void createMarkerTest() throws ApplicationException{ String productId = "product"; int layerId = 42; MarkerDTO markerDTO = new MarkerDTO(); markerDTO.setTitle("title"); markerDTO.setDescription("description"); markerDTO.setX(1.0); markerDTO.setY(1.0); markerDTO.setZ(1.0); Marker marker = new Marker(); marker.setId(37); Mockito.when(productService.createMarker(layerId, markerDTO.getTitle(), markerDTO.getDescription(), markerDTO.getX(), markerDTO.getY(), markerDTO.getZ())) .thenReturn(marker); MarkerDTO result = layerResource.createMarker(workspaceId, productId, layerId, markerDTO); Assert.assertEquals(marker.getId(), result.getId()); }