@Test
    public void testProgressEstimation() throws ParseException {
        int distBits = 4;

        BucketIdFactory idFactory = new BucketIdFactory();
        ProgressToken progress = new ProgressToken();

        // Create a range of [0, 16) superbuckets
        VisitorIterator iter = VisitorIterator.createFromDocumentSelection(
                "id.group != \"yahoo.com\"", idFactory, distBits, progress);

        assertEquals(progress.getDistributionBitCount(), 4);

        double epsilon = 0.00001;
        assertEquals(progress.percentFinished(), 0, epsilon);
        VisitorIterator.BucketProgress bp = iter.getNext();
        // Finish first superbucket (6.25% total)
        iter.update(bp.getSuperbucket(), ProgressToken.FINISHED_BUCKET);
        assertEquals(progress.percentFinished(), 6.25, epsilon);
        assertEquals(progress.getFinishedBucketCount(), 1);

        bp = iter.getNext();
        VisitorIterator.BucketProgress bp3 = iter.getNext();
        VisitorIterator.BucketProgress bp4 = iter.getNext();

        // Finish second (12.5% total)
        iter.update(bp.getSuperbucket(), ProgressToken.FINISHED_BUCKET);
        assertEquals(progress.percentFinished(), 12.5, epsilon);
        assertEquals(progress.getFinishedBucketCount(), 2);

        // Finish third bucket 75% through (17.1875% total)
        iter.update(bp3.getSuperbucket(), new BucketId(distBits + 2, bp3.getSuperbucket().getId() | (1 << distBits)));
        assertEquals(progress.percentFinished(), 17.1875, epsilon);
        assertEquals(progress.getFinishedBucketCount(), 2);

        // Finish fourth bucket 25% through (18.75% total)
        iter.update(bp4.getSuperbucket(), new BucketId(distBits + 2, bp4.getSuperbucket().getId()));
        assertEquals(progress.percentFinished(), 18.75, epsilon);
        assertEquals(progress.getFinishedBucketCount(), 2);
        // Finish all buckets
        iter.update(bp4.getSuperbucket(), ProgressToken.FINISHED_BUCKET);
        iter.update(bp3.getSuperbucket(), ProgressToken.FINISHED_BUCKET);
        assertEquals(progress.percentFinished(), 25, epsilon);
        assertEquals(progress.getFinishedBucketCount(), 4);

        while (iter.hasNext()) {
            bp = iter.getNext();
            iter.update(bp.getSuperbucket(), ProgressToken.FINISHED_BUCKET);
        }

        assertEquals(progress.getFinishedBucketCount(), 16);
        assertEquals(progress.percentFinished(), 100, epsilon);
    }
Test that ensures doing update(superbucket, 0) simply puts the bucket back in
pending
documentapi/src/test/java/com/yahoo/documentapi/VisitorIteratorTestCase.java