/**
* {@link StagePlanner#plan(FlowGraph)}
*/
@Test
public void plan_flowpart() {
FlowGraphGenerator comp = new FlowGraphGenerator();
comp.defineInput("in");
comp.defineOperator("op1", "in", "out");
comp.defineOperator("op2", "in", "out", FlowBoundary.SHUFFLE);
comp.defineOutput("out");
comp.connect("in", "op1").connect("op1", "op2").connect("op2", "out");
gen.defineInput("in");
gen.defineFlowPart("c", comp.toGraph());
gen.defineOutput("out");
gen.connect("in", "c").connect("c", "out");
StageGraph stages = getPlanner().plan(gen.toGraph());
assertThat(stages.getInput().getBlockOutputs().size(), is(1));
assertThat(stages.getOutput().getBlockInputs().size(), is(1));
assertThat(stages.getStages().size(), is(1));
StageBlock mr = stages.getStages().get(0);
assertThat(mr.getMapBlocks().size(), is(1));
assertThat(mr.getReduceBlocks().isEmpty(), is(false));
FlowBlock mapper = single(mr.getMapBlocks());
FlowBlock reducer = single(mr.getReduceBlocks());
assertThat(FlowBlock.isConnected(
stages.getInput().getBlockOutputs().get(0),
mapper.getBlockInputs().get(0)), is(true));
assertThat(FlowBlock.isConnected(
mapper.getBlockOutputs().get(0),
reducer.getBlockInputs().get(0)), is(true));
assertThat(FlowBlock.isConnected(
reducer.getBlockOutputs().get(0),
stages.getOutput().getBlockInputs().get(0)), is(true));
assertThat(mapper.getElements().size(), is(1));
FlowElement mapperOp = single(mapper.getElements());
assertThat(mapperOp.getDescription(), is(comp.desc("op1")));
assertThat(reducer.getElements().size(), is(1));
FlowElement reducerOp = single(reducer.getElements());
assertThat(reducerOp.getDescription(), is(comp.desc("op2")));
}