TodoResource { @DELETE public void deleteAll() { dao.deleteAll(); } 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 testDeleteAll() { final String id = UUID.randomUUID().toString(); final Todo todo = Todo.newBuilder().id(id).created(new Date()).build(); dao.insert(todo); dao.insert(todo.toBuilder().id("dummy").build()); assertThat(dao.findAll()).hasSize(2); ClientResponse response = client().resource("/todos").delete(ClientResponse.class); assertThat(response.getStatus()).isEqualTo(Response.Status.NO_CONTENT.getStatusCode()); assertThat(dao.findAll()).isEmpty(); }