@SuppressWarnings({"unchecked", "removal"})
    @Test
    void testAsyncDataProcessing() throws InterruptedException, ExecutionException, TimeoutException {
        // Set up
        FutureDataSource futureDataSource = new FutureDataSource();
        Chain<Processor> asyncChain = new Chain<Processor>(new DataCounter());
        Chain<Processor> chain = new Chain<>(new AsyncDataProcessingInitiator(asyncChain), futureDataSource);

        // Execute
        Request request = new Request();
        Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);

        // Verify the result prior to completion of delayed data
        assertEquals(0, response.data().asList().size(), "No data yet");

        // complete async data
        futureDataSource.incomingData.get(0).add(new StringData(request, "d1"));
        assertEquals(0, response.data().asList().size(), "New data is not visible because it is not complete");
        futureDataSource.incomingData.get(0).addLast(new StringData(request, "d2"));
        assertEquals(0, response.data().asList().size(), "Not visible because it has not been synced yet");
        response.data().completeFuture().get(1000, TimeUnit.MILLISECONDS);
        assertEquals(3, response.data().asList().size(), "Now the data as well as the count is available");
        assertEquals("d1", response.data().get(0).toString().toString());
        assertEquals("d2", response.data().get(1).toString().toString());
        assertEquals("Data count: 2", response.data().get(2).toString());
    }
Register a chain which will be called when some async data is available
container-core/src/test/java/com/yahoo/processing/execution/test/FutureDataTestCase.java