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

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

        // Verify the result prior to completion of delayed data
        assertEquals(3, response.data().asList().size()); // The sync data list + the (currently empty) future data list) + the data count
        DataList syncData = (DataList) response.data().get(0);
        DataList asyncData = (DataList) response.data().get(1);
        StringData countData = (StringData) response.data().get(2);

        assertEquals(3, syncData.asList().size(), "The sync data is available");
        assertEquals("first.1", syncData.get(0).toString());
        assertEquals("second.1", syncData.get(1).toString());
        assertEquals("third.1", syncData.get(2).toString());
        assertEquals(0, asyncData.asList().size(), "No async data yet");
        assertEquals("Data count: 3", countData.toString(), "The data counter has run and accessed the sync data");

        // complete async data
        futureDataSource.incomingData.get(0).add(new StringData(request, "d1"));
        futureDataSource.incomingData.get(0).addLast(new StringData(request, "d2"));
        assertEquals(0, asyncData.asList().size(), "New data is not visible because we haven't asked for it");
        asyncData.completeFuture().get(1000, TimeUnit.MILLISECONDS);
        assertEquals(2, asyncData.asList().size(), "Now the data is available");
        assertEquals("d1", asyncData.get(0).toString().toString());
        assertEquals("d2", asyncData.get(1).toString().toString());
    }
Federate to one source which returns data immediately and one who return future data
container-core/src/test/java/com/yahoo/processing/execution/test/FutureDataTestCase.java