@Test public void testDeleteMapping() throws Exception { String mappingId = "SampleId2"; WebTarget target = target("/" + MappingOptionListContainer.MAPPINGS + "/" + mappingId); when(metadataTransformationManager.deleteMetadataTransformation(mappingId)).thenThrow(new IOException()).thenReturn(false).thenReturn(true); Response response = target.request(MediaType.APPLICATION_XML).delete(); assertEquals(500, response.getStatus()); response = target.request(MediaType.APPLICATION_XML).delete(); assertEquals(404, response.getStatus()); response = target.request(MediaType.APPLICATION_XML).delete(); assertEquals(200, response.getStatus()); }
@DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId) throws DoesNotExistException, InternalServerErrorException { try { if (!metadataTransformationManager.deleteMetadataTransformation(mappingId)) throw new DoesNotExistException("Mapping with id " + mappingId + " does NOT exist!"); } catch (IOException | DocumentException e) { throw new InternalServerErrorException("Error in server : " + e.getMessage()); } return Response.status(200).entity(new Result("Mapping with id " + mappingId + " deleted!")).build(); }
MappingResource { @DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId) throws DoesNotExistException, InternalServerErrorException { try { if (!metadataTransformationManager.deleteMetadataTransformation(mappingId)) throw new DoesNotExistException("Mapping with id " + mappingId + " does NOT exist!"); } catch (IOException | DocumentException e) { throw new InternalServerErrorException("Error in server : " + e.getMessage()); } return Response.status(200).entity(new Result("Mapping with id " + mappingId + " deleted!")).build(); } }
MappingResource { @DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId) throws DoesNotExistException, InternalServerErrorException { try { if (!metadataTransformationManager.deleteMetadataTransformation(mappingId)) throw new DoesNotExistException("Mapping with id " + mappingId + " does NOT exist!"); } catch (IOException | DocumentException e) { throw new InternalServerErrorException("Error in server : " + e.getMessage()); } return Response.status(200).entity(new Result("Mapping with id " + mappingId + " deleted!")).build(); } MappingResource();  MappingResource(DefaultDataManager dataManager, MetadataTransformationManager metadataTransformationManager, MetadataSchemaManager metadataSchemaManager); }
MappingResource { @DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId) throws DoesNotExistException, InternalServerErrorException { try { if (!metadataTransformationManager.deleteMetadataTransformation(mappingId)) throw new DoesNotExistException("Mapping with id " + mappingId + " does NOT exist!"); } catch (IOException | DocumentException e) { throw new InternalServerErrorException("Error in server : " + e.getMessage()); } return Response.status(200).entity(new Result("Mapping with id " + mappingId + " deleted!")).build(); } MappingResource();  MappingResource(DefaultDataManager dataManager, MetadataTransformationManager metadataTransformationManager, MetadataSchemaManager metadataSchemaManager); @OPTIONS @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Get options over mappings conext.", httpMethod = "OPTIONS", response = MappingOptionListContainer.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a list of all available options)") }) MappingOptionListContainer getOptions(); @GET @Path("/" + MappingOptionListContainer.OPTIONS) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Get options over mappings conext.", httpMethod = "GET", response = MappingOptionListContainer.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a list of all available options)") }) MappingOptionListContainer getGETOptions(); @POST @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Create a new mapping - XSL file through HTTP POST.", httpMethod = "POST", response = String.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Created (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response createMapping(MultiPart multiPart); @GET @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Retrieves the specified mapping.", httpMethod = "GET", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing an Dataset)"), @ApiResponse(code = 404, message = "DoesNotExistException") }) MetadataTransformation getMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId); @DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId); @PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId,
            MultiPart multiPart); }
MappingResource { @DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId) throws DoesNotExistException, InternalServerErrorException { try { if (!metadataTransformationManager.deleteMetadataTransformation(mappingId)) throw new DoesNotExistException("Mapping with id " + mappingId + " does NOT exist!"); } catch (IOException | DocumentException e) { throw new InternalServerErrorException("Error in server : " + e.getMessage()); } return Response.status(200).entity(new Result("Mapping with id " + mappingId + " deleted!")).build(); } MappingResource();  MappingResource(DefaultDataManager dataManager, MetadataTransformationManager metadataTransformationManager, MetadataSchemaManager metadataSchemaManager); @OPTIONS @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Get options over mappings conext.", httpMethod = "OPTIONS", response = MappingOptionListContainer.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a list of all available options)") }) MappingOptionListContainer getOptions(); @GET @Path("/" + MappingOptionListContainer.OPTIONS) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Get options over mappings conext.", httpMethod = "GET", response = MappingOptionListContainer.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a list of all available options)") }) MappingOptionListContainer getGETOptions(); @POST @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Create a new mapping - XSL file through HTTP POST.", httpMethod = "POST", response = String.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Created (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response createMapping(MultiPart multiPart); @GET @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Retrieves the specified mapping.", httpMethod = "GET", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing an Dataset)"), @ApiResponse(code = 404, message = "DoesNotExistException") }) MetadataTransformation getMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId); @DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId); @PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId,
            MultiPart multiPart); public DefaultDataManager dataManager; public MetadataTransformationManager metadataTransformationManager; public MetadataSchemaManager metadataSchemaManager; }