use of org.knime.core.node.workflow.action.MetaNodeToSubNodeResult in project knime-core by knime.
the class TestCollapseAndWrapMetaNodeActions method testCollapseIntoMetaNodeThenWrapUnwrap.
/**
* Collect nodes, collapse them, convert to meta node and wrap/unwrap.
*/
@Test
public void testCollapseIntoMetaNodeThenWrapUnwrap() throws Exception {
WorkflowManager mgr = getManager();
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureAll();
// there is only one in the wfm
WorkflowAnnotation annotation = mgr.getWorkflowAnnotations().stream().findFirst().get();
final NodeID[] nodes = new NodeID[] { m_columnFilter_2, m_columnFilter_3, m_columnSplitter_4 };
CollapseIntoMetaNodeResult collapseResult = mgr.collapseIntoMetaNode(nodes, new WorkflowAnnotation[] { annotation }, "Test-Meta/Wrap Node");
WorkflowManager metaNode = mgr.getNodeContainer(collapseResult.getCollapsedMetanodeID(), WorkflowManager.class, true);
NodeID metaSubID = metaNode.getID();
assertFalse("Should have removed node: " + m_columnFilter_2, mgr.containsNodeContainer(m_columnFilter_2));
assertTrue("No annotation expected", mgr.getWorkflowAnnotations().isEmpty());
mgr.getNodeContainer(metaSubID, WorkflowManager.class, true);
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureNode(metaSubID);
MetaNodeToSubNodeResult convertObject = mgr.convertMetaNodeToSubNode(metaSubID);
mgr.getNodeContainer(metaSubID, SubNodeContainer.class, true);
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureNode(metaSubID);
assertTrue("Should be undo-able", convertObject.canUndo());
convertObject.undo();
mgr.getNodeContainer(metaSubID, WorkflowManager.class, true);
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureNode(metaSubID);
convertObject = mgr.convertMetaNodeToSubNode(metaSubID);
// no flow var ports at '0' for meta nodes
mgr.addConnection(m_javaEdit_7, 1, metaSubID, 0);
// no flow var ports at '0' for meta nodes
mgr.addConnection(metaSubID, 0, m_tableView_6, 0);
assertEquals("wrong number inputs", 3, mgr.getIncomingConnectionsFor(metaSubID).size());
assertEquals("wrong number outputs", 3, mgr.getOutgoingConnectionsFor(metaSubID).size());
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureNode(metaSubID);
SubNodeToMetaNodeResult convertSubNodeToMetaNodeResult = mgr.convertSubNodeToMetaNode(metaSubID);
mgr.getNodeContainer(metaSubID, WorkflowManager.class, true);
assertEquals("wrong number inputs", 2, mgr.getIncomingConnectionsFor(metaSubID).size());
assertEquals("wrong number outputs", 2, mgr.getOutgoingConnectionsFor(metaSubID).size());
executeAllAndWait();
checkState(mgr, EXECUTED);
convertSubNodeToMetaNodeResult.undo();
mgr.getNodeContainer(metaSubID, SubNodeContainer.class, true);
executeAllAndWait();
checkState(mgr, EXECUTED);
}
Aggregations