### Question:
CloudantStore implements ToDoStore { @Override public Collection<ToDo> getAll() throws ToDoStoreException { Response allDocsResp = target.queryParam("reduce", false). path("_design").path(DESIGN_DOC_NAME).path("_view").path(VIEW_NAME). request(MediaType.APPLICATION_JSON).get(); int status = allDocsResp.getStatus(); if(status == HttpURLConnection.HTTP_OK) { List<ToDo> todos = new ArrayList<ToDo>(); CloudantAllDocs all = allDocsResp.readEntity(CloudantAllDocs.class); for(CloudantRow row : all.getRows()) { ToDo td = row.getValue(); td.setId(row.getId()); td.setOrder(row.getKey()); todos.add(td); } return todos; } else { throw new ToDoStoreException("There was an error retrieving the tasks 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 testGetAll() throws Exception { IMocksControl control = createControl(); Response resp = control.createMock(Response.class); expect(resp.getStatus()).andReturn(200).times(3); Capture<Class<CloudantAllDocs>> classCapture = new Capture<Class<CloudantAllDocs>>(); expect(resp.readEntity(capture(classCapture))).andReturn(docs); replay(resp); WebTarget wt = createMockWebTarget(); Invocation.Builder builder = createBuilder(); expect(builder.get()).andReturn(resp).times(3); replay(builder); expect(wt.path(eq("bluemix-todo"))).andReturn(wt).times(2); expect(wt.path(eq("todos"))).andReturn(wt).times(2); expect(wt.path(eq("_design"))).andReturn(wt).times(2); expect(wt.path(eq("_view"))).andReturn(wt); expect(wt.path(eq("allTodos"))).andReturn(wt); expect(wt.queryParam(eq("reduce"), eq(false))).andReturn(wt); expect(wt.request(eq("application/json"))).andReturn(builder).anyTimes(); replay(wt); CloudantStore store = new CloudantStore(wt); Collection<ToDo> todos = store.getAll(); List<ToDo> testToDos = new ArrayList<ToDo>(); testToDos.add(ctd1.getToDo()); testToDos.add(ctd2.getToDo()); testToDos.add(ctd3.getToDo()); assertEquals(testToDos, todos); assertEquals(CloudantAllDocs.class, classCapture.getValue()); verify(resp); verify(wt); verify(builder); }