TodoResource { @DELETE @Path("{id}") public void delete(@PathParam("id") String id) { dao.delete(id); } TodoResource(TodoDao dao); @GET List<Todo> list(); @GET @Path("{id}") Todo get(@PathParam("id") String id); @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) Response create(@FormParam("email") String email); @PUT @Path("{id}") Todo update(@PathParam("id") String id, @Valid Todo todo); @DELETE @Path("{id}") void delete(@PathParam("id") String id); @DELETE void deleteAll(); static final Item ITEM; static final Todo TODO; }
@Test public void testDeleteTodo() { final String id = UUID.randomUUID().toString(); final Todo todo = Todo.newBuilder().id(id).created(new Date()).build(); dao.insert(todo); ClientResponse response = client().resource("/todos/" + id).delete(ClientResponse.class); assertThat(response.getStatus()).isEqualTo(Response.Status.NO_CONTENT.getStatusCode()); assertThat(dao.findById(id)).isNull(); }