@Test
    public void testMaxTotalHitsEarlyCompletion() {
        VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
        visitorParameters.setMaxTotalHits(10);
        ReplyModifier replyModifier1 = (reply) -> {
            VisitorStatistics stats = new VisitorStatistics();
            stats.setBucketsVisited(1);
            stats.setDocumentsReturned(9);
            reply.setVisitorStatistics(stats);
            reply.setLastBucket(new BucketId(33, 1234 | (1L << 32)));
        };
        ReplyModifier replyModifier2 = (reply) -> {
            VisitorStatistics stats = new VisitorStatistics();
            stats.setBucketsVisited(1);
            stats.setDocumentsReturned(1);
            reply.setVisitorStatistics(stats);
            reply.setLastBucket(new BucketId(34, 1234 | (1L << 33)));
        };
        doTestEarlyCompletion(visitorParameters, replyModifier1, replyModifier2);
    }
Test visitor "prematurely" completing due to max total hits being
reached when no other visitors are currently pending.
documentapi/src/test/java/com/yahoo/documentapi/messagebus/MessageBusVisitorSessionTestCase.java