@Override public List<IPlayer> listAllPlayers() { List<IPlayer> players = new ArrayList<>(); ViewQuery query = new ViewQuery().allDocs(); ViewResult vr = db.queryView(query); for (Row r : vr.getRows()) { players.add(getPlayerById(Integer.parseInt(r.getId()))); } return players; }
@Test public void load_query_result() { setupGetDocResponse("doc_id1", "doc_id2"); ViewQuery query = new ViewQuery() .dbPath(TEST_DB_PATH) .designDocId("_design/testdoc") .viewName("test_view") .key("key_value"); when(httpClient.getUncached(query.buildQuery())) .thenReturn(ResponseOnFileStub.newInstance(200, "view_result.json")); ViewResult result = dbCon.queryView(query); assertEquals(2, result.getSize()); assertEquals("doc_id1", result.getRows().get(0).getId()); assertEquals("doc_id2", result.getRows().get(1).getId()); }