### Question:
ToDoAPI { @DELETE @Path("/{id}") public void deleteToDo(@PathParam("id") String id) { if(id == null) { throw new WebApplicationException("Must supply an ID, for example /api/todos/123,", Response.Status.BAD_REQUEST); } try { store.delete(id); } catch (ToDoStoreException e) { throw new WebApplicationException("Error deleting ToDo.", Response.Status.INTERNAL_SERVER_ERROR); } } ToDoAPI();  ToDoAPI(ToDoStore store); @GET @Path("/{id}") @Produces("application/json") ToDo getToDo(@PathParam("id") String id); @GET @Produces("application/json") Collection<ToDo> getToDos(); @POST @Consumes("application/json") @Produces("application/json") ToDo newToDo(ToDo td); @PUT @Path("/{id}") @Produces("application/json") @Consumes("application/json") ToDo updateToDo(@PathParam("id") String id, ToDo td); @DELETE @Path("/{id}") void deleteToDo(@PathParam("id") String id);  }### Answer:
@Test public void testDeleteToDo() { api.deleteToDo(td1.getId()); Collection<ToDo> todos = api.getToDos(); assertTrue(todos.contains(td2)); assertEquals(1, todos.size()); }
@Test public void testDeleteToDoException() { try { errorApi.deleteToDo("123"); fail("Expected exception to be thrown."); } catch (WebApplicationException e) { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getResponse().getStatus()); } }