### Question:
ToDoAPI { @GET @Produces("application/json") public Collection<ToDo> getToDos() { try { return store.getAll(); } catch (ToDoStoreException e) { throw new WebApplicationException("Error getting all ToDos.", 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 testGetToDos() { Collection<ToDo> todos = api.getToDos(); assertTrue(todos.contains(td1)); assertTrue(todos.contains(td2)); assertEquals(2, todos.size()); }
@Test public void testGetToDosException() { try { errorApi.getToDos(); fail("Expected exception to be thrown."); } catch(WebApplicationException e) { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getResponse().getStatus()); } }