/**
* {@link FlowBlock#detach()}
*/
@Test
public void detach_2() {
FlowGraphGenerator gen = new FlowGraphGenerator();
gen.defineInput("in");
gen.defineOperator("op1", "in", "out");
gen.defineOperator("op2", "in", "out");
gen.defineOutput("out");
gen.connect("in", "op1").connect("op1", "op2").connect("op2", "out");
FlowBlock block = FlowBlock.fromPorts(
0,
gen.toGraph(),
new ArrayList<FlowElementInput>(gen.inputs("op1")),
new ArrayList<FlowElementOutput>(gen.outputs("op2")),
gen.getAsSet("op1", "op2"));
block.detach();
assertThat(block.getElements().size(), is(2));
assertThat(block.getBlockInputs().size(), is(1));
assertThat(block.getBlockOutputs().size(), is(1));
FlowBlock.Input input = block.getBlockInputs().get(0);
FlowBlock.Output output = block.getBlockOutputs().get(0);
assertThat(input.getElementPort(), not(sameInstance(gen.input("op1"))));
assertThat(output.getElementPort(), not(sameInstance(gen.output("op2"))));
FlowElement op1 = input.getElementPort().getOwner();
FlowElement op2 = output.getElementPort().getOwner();
assertThat(op1.getInputPorts().get(0).getConnected().size(), is(0));