@@ -0,0 +1,958 @@
+package pl.ciruk.blog.fanout;%0A%0Aimport com.google.common.collect.ImmutableList;%0Aimport org.junit.Test;%0A%0Aimport java.util.concurrent.CompletableFuture;%0Aimport java.util.stream.Stream;%0A%0Aimport static org.hamcrest.CoreMatchers.equalTo;%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport static pl.ciruk.blog.fanout.CompletableFutures.fanOut;%0A%0Apublic class CompletableFuturesTest %7B%0A%09@Test%0A%09public void shouldExecuteAllFunctionsFromMappings() throws Exception %7B%0A%09%09// Given%0A%09%09CompletableFuture%3CString%3E future = CompletableFuture.completedFuture(%22SampleText%22);%0A%0A%09%09// When%0A%09%09CompletableFuture%3CStream%3CInteger%3E%3E actualFuture = future.thenCompose(%0A%09%09%09%09fanOut(ImmutableList.of(%0A%09%09%09%09%09%09text -%3E 1,%0A%09%09%09%09%09%09text -%3E 2,%0A%09%09%09%09%09%09text -%3E 4%0A%09%09%09%09))%0A%09%09);%0A%09%09CompletableFuture%3CInteger%3E actualSum = actualFuture.thenApply(%0A%09%09%09%09stream -%3E stream.reduce((a, b) -%3E a + b).orElse(-1)%0A%09%09);%0A%0A%09%09// Then%0A%09%09assertThat(actualSum.get(), is(equalTo(7)));%0A%09%7D%0A%7D

Create first test for fanOut method