How to force an immediate evaluation on stream in Java8
<p>I am wondering how can I force an immediate evaluate on each map function in Java8 ? The situation I have now is that I need to do multiple levels transforming (from ObjectA -> ObjectB -> ObjectC -> ObjectD), and there could be a failure (throw exception) on every level of this transforming for some object. For example</p>

<pre><code> // stream -&gt; map -&gt; collect sequence
 lists.stream()
      .map(aToB)
      .collect(Collectors.toList())
      .stream()
      .map(bToC)
      .collect(Collectors.toList())
      .stream()
      .map(cToD)
      .collect(Collectors.toList())

 // Try api is from javaslangs
 Function&lt;ObjectA, ObjectB&gt; aToB = a -&gt; Try.of(() -&gt; .....)
                                           .onFailure(....)
                                           .get();

 Function&lt;ObjectB, ObjectC&gt; bToC = b -&gt; Try.of(() -&gt; .....)
                                           .onFailure(....)
                                           .get();

 Function&lt;ObjectC, ObjectD&gt; cToD = c -&gt; Try.of(() -&gt; .....)
                                           .onFailure(....)
                                           .get();
</code></pre>

<p>I wanna to test each transition in my unit test such as test if the test thrown an exception, and if A unsuccessfully transformed to C when there's an exception when transforming A to B something like that, but with lazy evaluation, this becomes impossible to test, and the only way I can think of is to do this sequence of <code>steam() -&gt; map(...)  -&gt; collect(...)</code> calls to force an immediate evaluation. I am wondering is there a better way to write this.</p>