@Test
public void testParallelForLoopIterationFailures() throws Exception {

  final List<Integer> input = new LinkedList<Integer>();
  for(int i = 0; i < 10; i++) {
    input.add(i);
  }
  final List<Integer> failForList = Arrays.asList(new Integer[] { 2, 5, 7});
  ParallelLoopResult<Integer> loopResult = Parallel.forLoop(input, new LoopBody<Integer, Integer>() {
    @Override
    public Integer run(Integer in1) {
      if(failForList.contains(in1)) {
        // Return null
        return null;
      }
      return in1 * in1;
    }
  });
  Assert.assertFalse(loopResult.getIsCompleted());
  Assert.assertNotNull(loopResult.getResult());
  List<Integer> output = loopResult.getResult();
  Assert.assertEquals(input.size(), output.size());
  for(int i = 0; i < input.size(); i++) {
    if(failForList.contains(i)) {
      Assert.assertNull(output.get(i));
      output.set(i, i * i);
    } else {
      Assert.assertEquals(i * i, (int) output.get(i));
    }
  }
}