@Test
  public void multiple_query_keys_should_be_posted_3() throws IOException {
    List<Object> keys = new ArrayList<Object>();
    keys.add("key1");
    keys.add("key2");
    keys.add("key3");

    ViewQuery query =
        new ViewQuery()
            .dbPath(TEST_DB_PATH)
            .designDocId("_design/testdoc")
            .viewName("test_view")
            .keys(keys);

    when(httpClient.postUncached(anyString(), anyString()))
        .thenReturn(ResponseOnFileStub.newInstance(200, "view_result.json"));
    dbCon.queryForStream(query).close();
    verify(httpClient).postUncached(query.buildQuery(), query.getKeysAsJson());
  }
  @Test
  public void documents_embedded_in_view_result_should_be_read_directly() {
    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_with_embedded_docs.json"));

    List<TestDoc> result = dbCon.queryView(query, TestDoc.class);

    assertEquals(2, result.size());
    assertEquals(TestDoc.class, result.get(0).getClass());
    assertEquals("doc_id1", result.get(0).getId());
    assertEquals("doc_id2", result.get(1).getId());
    verify(httpClient, times(1)).getUncached(anyString());
  }
  @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());
  }
  @Test
  public void queries_with_ignore_not_found() {
    ViewQuery query =
        new ViewQuery()
            .dbPath(TEST_DB_PATH)
            .designDocId("_design/testdoc")
            .viewName("test_view")
            .includeDocs(true)
            .keys(Arrays.asList("doc_id1", "doc_id2", "doc_id3", "doc_id4"));
    query.setIgnoreNotFound(true);

    when(httpClient.postUncached(anyString(), anyString()))
        .thenReturn(ResponseOnFileStub.newInstance(200, "view_result_with_ignored_docs.json"));

    List<TestDoc> result = dbCon.queryView(query, TestDoc.class);

    assertEquals(2, result.size());
    assertEquals(TestDoc.class, result.get(0).getClass());
    assertEquals("doc_id1", result.get(0).getId());
    assertEquals("doc_id3", result.get(1).getId());
    verify(httpClient).postUncached(query.buildQuery(), query.getKeysAsJson());
  }