### Question:
CloudantStore implements ToDoStore { @Override public void delete(String id) throws ToDoStoreException { Response docResp = getRequest(id); int status = docResp.getStatus(); if(status == HttpURLConnection.HTTP_OK) { CloudantToDo ctd = docResp.readEntity(CloudantToDo.class); Response updateReq = target.queryParam(REVISION_PARAM, ctd.get_rev()).path(id). request(MediaType.APPLICATION_JSON).delete(); status = updateReq.getStatus(); if(status != HttpURLConnection.HTTP_OK) { throw new ToDoStoreException("There was an error deleting the ToDo from Cloudant. Error " + status); } } else { throw new ToDoStoreException("There was an error getting the ToDo from Cloudant. Error " + status); } } CloudantStore(WebTarget target); @Override Collection<ToDo> getAll(); @Override ToDo get(String id); @Override ToDo persist(ToDo td); @Override ToDo update(String id, ToDo td); @Override void delete(String id); @Override int count();  }### Answer:
@Test public void testDelete() throws Exception { IMocksControl control = createControl(); Response resp = control.createMock(Response.class); expect(resp.getStatus()).andReturn(200).times(4); Capture<Class<CloudantToDo>> classCapture = new Capture<Class<CloudantToDo>>(); expect(resp.readEntity(capture(classCapture))).andReturn(ctd1); replay(resp); WebTarget wt = createMockWebTarget(); Invocation.Builder builder = createBuilder(); expect(builder.get()).andReturn(resp).times(3); expect(builder.delete()).andReturn(resp); replay(builder); expect(wt.path(eq("bluemix-todo"))).andReturn(wt).times(2); expect(wt.path(eq("todos"))).andReturn(wt); expect(wt.path(eq("_design"))).andReturn(wt).times(1); expect(wt.queryParam(eq("rev"), eq("abc"))).andReturn(wt); expect(wt.path(eq("123"))).andReturn(wt).times(2); expect(wt.request(eq("application/json"))).andReturn(builder).times(4); replay(wt); CloudantStore store = new CloudantStore(wt); store.delete("123"); assertEquals(CloudantToDo.class, classCapture.getValue()); verify(resp); verify(wt); verify(builder); }