@Test
    void testFutureData() throws InterruptedException, ExecutionException, TimeoutException {
        // Set up
        AsyncProviderSearcher futureDataSource = new AsyncProviderSearcher();
        Chain<Searcher> chain = new Chain<>(List.of(futureDataSource));

        // Execute
        Query query = new Query();
        Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);

        // Verify the result prior to completion of delayed data
        assertEquals(0, result.hits().getConcreteSize(), "The result has been returned, but no hits are available yet");

        // pretend we're the IO layer and complete delayed data - this is typically done in a callback from jDisc
        futureDataSource.simulateOneHitIOComplete(new Hit("hit:0"));
        futureDataSource.simulateOneHitIOComplete(new Hit("hit:1"));
        futureDataSource.simulateAllHitsIOComplete();

        assertEquals(0, result.hits().getConcreteSize(), "Async arriving hits are still not visible because we haven't asked for them");

        // Results with future hit groups will be passed to rendering directly and start rendering immediately.
        // For this test we block and wait for the data instead:
        result.hits().completeFuture().get(1000, TimeUnit.MILLISECONDS);
        assertEquals(2, result.hits().getConcreteSize());
    }
Tests using the async capabilities of the Processing parent framework of searchers.

@author bratseth
container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java