LayerResource { @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) public 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) throws EntityNotFoundException, AccessRightException, WorkspaceNotEnabledException { ConfigurationItemKey ciKey = new ConfigurationItemKey(workspaceId, ciId); Layer l = productService.createLayer(ciKey, layer.getName(), layer.getColor()); return new LayerDTO(l.getId(), l.getName(), l.getColor()); } 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 createLayerTest() throws ApplicationException{ String productId = "product"; ConfigurationItemKey ciKey = new ConfigurationItemKey(workspaceId, productId); Layer layer = new Layer(); layer.setName("foo"); layer.setColor("red"); Mockito.when(productService.createLayer(ciKey, layer.getName(), layer.getColor())) .thenReturn(layer); LayerDTO layerDTO = new LayerDTO(); layerDTO.setName(layer.getName()); layerDTO.setColor(layer.getColor()); LayerDTO result = layerResource.createLayer(workspaceId, productId, layerDTO); Assert.assertEquals(layerDTO.getName(), result.getName()); Assert.assertEquals(layerDTO.getColor(), result.getColor()); }