Search in sources :

Example 6 with NodeViewNodeFactory

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));
}
Also used : NodeViewNodeFactory(org.knime.testing.node.view.NodeViewNodeFactory) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation) Test(org.junit.Test)

Example 7 with NodeViewNodeFactory

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"));
}
Also used : NodeViewNodeFactory(org.knime.testing.node.view.NodeViewNodeFactory) WorkflowLock(org.knime.core.node.workflow.WorkflowLock) NodeID(org.knime.core.node.workflow.NodeID) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 NodeViewNodeFactory (org.knime.testing.node.view.NodeViewNodeFactory)7 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)4 IOException (java.io.IOException)3 List (java.util.List)3 BiConsumer (java.util.function.BiConsumer)3 Awaitility.await (org.awaitility.Awaitility.await)3 FIVE_SECONDS (org.awaitility.Duration.FIVE_SECONDS)3 ONE_HUNDRED_MILLISECONDS (org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS)3 RowKey (org.knime.core.data.RowKey)3 PortType (org.knime.core.node.port.PortType)3 NodeID (org.knime.core.node.workflow.NodeID)3 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)3 SelectionEvent (org.knime.gateway.impl.service.events.SelectionEvent)3 SelectionEventMode (org.knime.gateway.impl.service.events.SelectionEventSource.SelectionEventMode)3 WorkflowManagerUtil (org.knime.testing.util.WorkflowManagerUtil)3 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)3 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)3 Mockito.verify (org.mockito.Mockito.verify)3 Collections (java.util.Collections)2