@Test
public void testMergeQueryResultsWhenCountOptions() {

    ServiceDocumentQueryResult result1 = createServiceDocumentQueryResult(
            new int[] { 9, 7, 5, 4, 3, 1 });
    result1.documentLinks.clear();
    result1.documents.clear();
    ServiceDocumentQueryResult result2 = createServiceDocumentQueryResult(
            new int[] { 9, 6, 5, 4, 3, 2, 10 });
    result2.documentLinks.clear();
    result2.documents.clear();
    ServiceDocumentQueryResult result3 = createServiceDocumentQueryResult(
            new int[] { 8, 4, 3, 2, 10, 1 });
    result3.documentLinks.clear();
    result3.documents.clear();
    List<ServiceDocumentQueryResult> resultsToMerge = Arrays.asList(result1, result2, result3);
    ServiceDocumentQueryResult mergeResult = new ServiceDocumentQueryResult();
    QueryTaskUtils.mergeQueryResults(resultsToMerge,
            false,
            EnumSet.of(QueryOption.COUNT), mergeResult);
    assertEquals(result2.documentCount, mergeResult.documentCount);
}