optimizer.sinkFlattens(output);
// Execute and assert the result after optimizing
executeAndAssert((LazyCollection<Integer>)output, new Integer[] { 2, 3, 4, 5, 6, 7 });
// Check that optimizer did what it's supposed to do
assertTrue(lOutput.getDeferredOp() instanceof Flatten);
Flatten flatten = (Flatten)lOutput.getDeferredOp();
assertEquals(flatten.getOrigins().size(), 2);
for(int i = 0; i < 2; i++) {
LazyCollection<Integer> origin = (LazyCollection<Integer>) flatten.getOrigins().get(i);
ParallelDo newPDo = (ParallelDo)origin.getDeferredOp();
assertEquals(newPDo.getFunction(), plusOne);
assertTrue(newPDo.getOrigin() == input1 || newPDo.getOrigin() == input2);
}
}