static ApplicationReindexing withNewReady(ApplicationReindexing reindexing, Supplier<Long> oldestGeneration, Instant now) {
        // Config convergence means reindexing of detected reindex actions may begin.
        for (var cluster : reindexing.clusters().entrySet())
            for (var pending : cluster.getValue().pending().entrySet())
                if (pending.getValue() <= oldestGeneration.get()) {
                    reindexing = reindexing.withReady(cluster.getKey(), pending.getKey(), now, SPEED, CAUSE)
                                           .withoutPending(cluster.getKey(), pending.getKey());
                }

        return reindexing;
    }
@Test
    public void testReadyComputation() {
        ApplicationReindexing reindexing = ApplicationReindexing.empty()
                                                                .withPending("one", "a", 10)
                                                                .withPending("two", "b", 20)
                                                                .withReady("one", "a", Instant.ofEpochMilli(3), SPEED, CAUSE)
                                                                .withReady("two", "b", Instant.ofEpochMilli(2), SPEED, CAUSE)
                                                                .withReady("two", "c", Instant.ofEpochMilli(3), SPEED, CAUSE);

        // Nothing happens without convergence.
        assertEquals(reindexing,
                     withNewReady(reindexing, () -> -1L, Instant.EPOCH));

        // Status for (one, a) changes, but not (two, b).
        Instant later = Instant.ofEpochMilli(3 << 10);
        // Converged, no longer pending.
        assertEquals(reindexing.withoutPending("one", "a").withReady("one", "a", later, SPEED, CAUSE),   // Converged, now ready.
                     withNewReady(reindexing, () -> 19L, later));

        // Converged, no longer pending.
        // Converged, no Longer pending.
        assertEquals(reindexing.withoutPending("one", "a").withReady("one", "a", later, SPEED, CAUSE)
                               .withoutPending("two", "b").withReady("two", "b", later, SPEED, CAUSE),
                     withNewReady(reindexing, () -> 20L, later));

        // Verify generation supplier isn't called when no pending document types.
        withNewReady(reindexing.withoutPending("one", "a").withoutPending("two", "b"),
                     () -> { throw new AssertionError("not supposed to run"); },
                     later);
    }