@Test(expected = EntityNotFoundException.class) public void testDelete() throws URISyntaxException { String id = resourceService.postEntity(resource, createTestEntity()); setupMocks(BASE_URI + "/" + id); Response response = defaultResource.delete(id, uriInfo); assertEquals("Status code should be OK", Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); defaultResource.getWithId(id, uriInfo); }
@DELETE @Path("{id}") public Response delete(@PathParam("id") final String id, @Context final UriInfo uriInfo) { writeValidator.validateWriteRequest(null, uriInfo, SecurityUtil.getSLIPrincipal()); return defaultResponseBuilder.build(uriInfo, twoPartTemplate, ResourceMethod.DELETE, new ResourceLogic() { @Override public Response run(Resource resource) { resourceService.deleteEntity(resource, id); return Response.status(Response.Status.NO_CONTENT).build(); } }); }
DefaultResource extends GenericResource implements CustomEntityReturnable { @DELETE @Path("{id}") public Response delete(@PathParam("id") final String id, @Context final UriInfo uriInfo) { writeValidator.validateWriteRequest(null, uriInfo, SecurityUtil.getSLIPrincipal()); return defaultResponseBuilder.build(uriInfo, twoPartTemplate, ResourceMethod.DELETE, new ResourceLogic() { @Override public Response run(Resource resource) { resourceService.deleteEntity(resource, id); return Response.status(Response.Status.NO_CONTENT).build(); } }); } }
DefaultResource extends GenericResource implements CustomEntityReturnable { @DELETE @Path("{id}") public Response delete(@PathParam("id") final String id, @Context final UriInfo uriInfo) { writeValidator.validateWriteRequest(null, uriInfo, SecurityUtil.getSLIPrincipal()); return defaultResponseBuilder.build(uriInfo, twoPartTemplate, ResourceMethod.DELETE, new ResourceLogic() { @Override public Response run(Resource resource) { resourceService.deleteEntity(resource, id); return Response.status(Response.Status.NO_CONTENT).build(); } }); } DefaultResource(); }
DefaultResource extends GenericResource implements CustomEntityReturnable { @DELETE @Path("{id}") public Response delete(@PathParam("id") final String id, @Context final UriInfo uriInfo) { writeValidator.validateWriteRequest(null, uriInfo, SecurityUtil.getSLIPrincipal()); return defaultResponseBuilder.build(uriInfo, twoPartTemplate, ResourceMethod.DELETE, new ResourceLogic() { @Override public Response run(Resource resource) { resourceService.deleteEntity(resource, id); return Response.status(Response.Status.NO_CONTENT).build(); } }); } DefaultResource(); @GET Response getAll(@Context final UriInfo uriInfo); @POST Response post(final EntityBody entityBody,
                         @Context final UriInfo uriInfo); @GET @Path("{id}") Response getWithId(@PathParam("id") final String id,
                              @Context final UriInfo uriInfo); @PUT @Path("{id}") Response put(@PathParam("id") final String id,
                        final EntityBody entityBody,
                        @Context final UriInfo uriInfo); @DELETE @Path("{id}") Response delete(@PathParam("id") final String id,
                           @Context final UriInfo uriInfo); @PATCH @Path("{id}") Response patch(@PathParam("id") final String id,
                          final EntityBody entityBody,
                          @Context final UriInfo uriInfo); @Override CustomEntityResource getCustomResource(final String id, final UriInfo uriInfo); }
DefaultResource extends GenericResource implements CustomEntityReturnable { @DELETE @Path("{id}") public Response delete(@PathParam("id") final String id, @Context final UriInfo uriInfo) { writeValidator.validateWriteRequest(null, uriInfo, SecurityUtil.getSLIPrincipal()); return defaultResponseBuilder.build(uriInfo, twoPartTemplate, ResourceMethod.DELETE, new ResourceLogic() { @Override public Response run(Resource resource) { resourceService.deleteEntity(resource, id); return Response.status(Response.Status.NO_CONTENT).build(); } }); } DefaultResource(); @GET Response getAll(@Context final UriInfo uriInfo); @POST Response post(final EntityBody entityBody,
                         @Context final UriInfo uriInfo); @GET @Path("{id}") Response getWithId(@PathParam("id") final String id,
                              @Context final UriInfo uriInfo); @PUT @Path("{id}") Response put(@PathParam("id") final String id,
                        final EntityBody entityBody,
                        @Context final UriInfo uriInfo); @DELETE @Path("{id}") Response delete(@PathParam("id") final String id,
                           @Context final UriInfo uriInfo); @PATCH @Path("{id}") Response patch(@PathParam("id") final String id,
                          final EntityBody entityBody,
                          @Context final UriInfo uriInfo); @Override CustomEntityResource getCustomResource(final String id, final UriInfo uriInfo);  }