use of org.knime.testing.node.view.NodeViewNodeFactory in project knime-core by knime.
the class WizardPageUtilTest method testGetAllWizardPageNodes.
/**
* Tests {@link WizardPageUtil#getAllWizardPageNodes(WorkflowManager, boolean)}.
*/
@Test
public void testGetAllWizardPageNodes() {
NodeID n1 = WorkflowManagerUtil.createAndAddNode(m_wfm, new NodeViewNodeFactory(0, 0)).getID();
NodeID n2 = WorkflowManagerUtil.createAndAddNode(m_wfm, new WizardNodeFactory()).getID();
NodeID component = m_wfm.collapseIntoMetaNode(new NodeID[] { n1, n2 }, new WorkflowAnnotation[0], "component").getCollapsedMetanodeID();
m_wfm.convertMetaNodeToSubNode(component);
WorkflowManager componentWfm = ((SubNodeContainer) m_wfm.getNodeContainer(component)).getWorkflowManager();
List<NativeNodeContainer> wizardPageNodes = WizardPageUtil.getAllWizardPageNodes(componentWfm, false);
assertThat(wizardPageNodes.size(), is(2));
WizardNodeModel wnm = (WizardNodeModel) ((NativeNodeContainer) m_wfm.findNodeContainer(component.createChild(0).createChild(2))).getNodeModel();
wnm.setHideInWizard(true);
wizardPageNodes = WizardPageUtil.getAllWizardPageNodes(componentWfm, false);
assertThat(wizardPageNodes.size(), is(2));
wizardPageNodes = WizardPageUtil.getWizardPageNodes(componentWfm);
assertThat(wizardPageNodes.size(), is(1));
}
use of org.knime.testing.node.view.NodeViewNodeFactory in project knime-core by knime.
the class WizardPageUtilTest method testCreateWizardPage.
/**
* Tests {@link WizardPageUtil#createWizardPage(WorkflowManager, NodeID)}.
*/
@Test
public void testCreateWizardPage() {
NodeID n1 = WorkflowManagerUtil.createAndAddNode(m_wfm, new NodeViewNodeFactory(0, 0)).getID();
NodeID n2 = WorkflowManagerUtil.createAndAddNode(m_wfm, new NodeViewNodeFactory(0, 0)).getID();
try (WorkflowLock lock = m_wfm.lock()) {
assertThrows(IllegalArgumentException.class, () -> WizardPageUtil.createWizardPage(m_wfm, n1));
}
NodeID component = m_wfm.collapseIntoMetaNode(new NodeID[] { n1 }, new WorkflowAnnotation[0], "component").getCollapsedMetanodeID();
m_wfm.convertMetaNodeToSubNode(component);
component = m_wfm.collapseIntoMetaNode(new NodeID[] { component, n2 }, new WorkflowAnnotation[0], "component").getCollapsedMetanodeID();
m_wfm.convertMetaNodeToSubNode(component);
WizardPage wizardPage;
try (WorkflowLock lock = m_wfm.lock()) {
wizardPage = WizardPageUtil.createWizardPage(m_wfm, component);
}
assertThat(wizardPage.getPageNodeID(), is(component));
assertThat(wizardPage.getPageMap().size(), is(2));
assertThat(wizardPage.getPageMap().keySet(), containsInAnyOrder(NodeIDSuffix.fromString("4:0:2"), NodeIDSuffix.fromString("4:0:3:0:1")));
assertThat(wizardPage.getPageMap().values().stream().map(n -> n.getName()).collect(Collectors.toList()), containsInAnyOrder("NodeView", "NodeView"));
}
Aggregations