Search in sources :

Example 1 with WizardPage

use of org.knime.core.node.wizard.page.WizardPage in project knime-core by knime.

the class EnhWEBP674_SinglePageExecution method testReexecuteSinglePage.

/**
 * Tests general partial re-execution of a wizard page.
 */
@Test
public void testReexecuteSinglePage() {
    WizardExecutionController wec = getManager().setAndGetWizardExecutionController();
    reexecuteSinglePageTillExecuted(wec);
    WizardPage pageContent = wec.getCurrentWizardPage();
    assertThat(pageContent.getPageMap().size(), is(4));
    // make sure that sec and wec return the same wizard page
    assertThat(wec.getCurrentWizardPage().getPageMap(), is(pageContent.getPageMap()));
}
Also used : WizardPage(org.knime.core.node.wizard.page.WizardPage) Test(org.junit.Test)

Example 2 with WizardPage

use of org.knime.core.node.wizard.page.WizardPage in project knime-core by knime.

the class EnhWEBP674_SinglePageExecution method testStepBackWhileInSinglePageReexecution.

/**
 * Check reset to previous page while in single page re-execution.
 */
@Test
public void testStepBackWhileInSinglePageReexecution() {
    WorkflowManager wfm = getManager();
    WizardExecutionController wec = wfm.setAndGetWizardExecutionController();
    NodeID projectId = wfm.getID();
    // step to second page
    wec.loadValuesIntoCurrentPage(createWizardPageInput(0));
    wec.stepNext();
    waitForPage(m_page2);
    // re-execute second page
    wec.reexecuteSinglePage(createNodeID(projectId, 6, 0, 6), Collections.emptyMap());
    Awaitility.await().atMost(5, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS).until(() -> {
        WizardPage pc = wec.getCurrentWizardPage();
        return pc.getPageMap().keySet().contains(createNodeIDSuffix(6, 0, 5));
    });
    // step back and check page content
    wfm.cancelExecution();
    waitForSinglePageNotExecutingAnymore(wec);
    wec.stepBack();
    WizardPage pageContent = wec.getCurrentWizardPage();
    assertTrue(pageContent.getPageMap().containsKey(createNodeIDSuffix(7, 0, 3)));
    assertThat(pageContent.getPageMap().size(), is(4));
}
Also used : BugWEBP803_OnlyResetNodesToBeReexecuted.createNodeID(org.knime.core.node.workflow.BugWEBP803_OnlyResetNodesToBeReexecuted.createNodeID) WizardPage(org.knime.core.node.wizard.page.WizardPage) Test(org.junit.Test)

Example 3 with WizardPage

use of org.knime.core.node.wizard.page.WizardPage in project knime-core by knime.

the class TestWizardExec_Loop_Simple method testWizardStepThrough.

@Test
public void testWizardStepThrough() throws Exception {
    final WorkflowManager wfm = getManager();
    assertTrue("should have new wizard execution", WebResourceController.hasWizardExecution(wfm));
    checkState(m_tableCreateNode1, InternalNodeContainerState.CONFIGURED);
    WizardExecutionController wizardController = wfm.getWizardExecutionController();
    wizardController.stepFirst();
    waitWhile(wfm, new WizardHold(), -1);
    assertTrue("should have steps", wizardController.hasCurrentWizardPage());
    checkState(m_subnodeQueryStringBool15, InternalNodeContainerState.EXECUTED);
    // outside loop
    WizardPage currentWizardPage = wizardController.getCurrentWizardPage();
    // TODO: load something real
    wizardController.loadValuesIntoCurrentPage(Collections.<String, String>emptyMap());
    // TODO check IDs
    // assertEquals(m_subnodeQueryStringBool15.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(wfm, InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC, InternalNodeContainerState.UNCONFIGURED_MARKEDFOREXEC);
    checkState(m_subnodeQueryStringBool15, InternalNodeContainerState.EXECUTED);
    checkState(m_subnodeInLOOPQueryInt14, InternalNodeContainerState.EXECUTED);
    assertTrue("should have steps (loop iteration 0)", wizardController.hasCurrentWizardPage());
    // inside loop 1st time
    currentWizardPage = wizardController.getCurrentWizardPage();
    // assertEquals(m_subnodeInLOOPQueryInt14.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(m_subnodeInLOOPQueryInt14, InternalNodeContainerState.EXECUTED);
    checkState(m_loopEnd11, InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
    assertTrue("should have steps (loop iteration 1)", wizardController.hasCurrentWizardPage());
    // inside loop 2nd time
    currentWizardPage = wizardController.getCurrentWizardPage();
    // assertEquals(m_subnodeInLOOPQueryInt14.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    assertFalse("should have no more pages", wizardController.hasCurrentWizardPage());
    checkState(wfm, InternalNodeContainerState.EXECUTED);
    NodeSettings settings = new NodeSettings("test");
    wizardController.save(settings);
    int[] prompted = settings.getIntArray("promptedSubnodeIDs");
    assertTrue("should have saved prompted node ids (15) to settings", Arrays.equals(new int[] { 15 }, prompted));
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) WizardPage(org.knime.core.node.wizard.page.WizardPage) Test(org.junit.Test)

Example 4 with WizardPage

use of org.knime.core.node.wizard.page.WizardPage in project knime-core by knime.

the class TestWizardExec_LoadValuesInSubnode method testWizardStepThroughWithSeveralLoopIterations.

@Test
public void testWizardStepThroughWithSeveralLoopIterations() throws Exception {
    final int numLoops = 3;
    final WorkflowManager wfm = getManager();
    assertTrue("Should have new wizard execution", WebResourceController.hasWizardExecution(wfm));
    checkState(m_filterSubnode, InternalNodeContainerState.CONFIGURED);
    WizardExecutionController wizardController = wfm.getWizardExecutionController();
    wizardController.stepFirst();
    waitWhile(wfm, new WizardHold(), -1);
    assertTrue("Should have steps", wizardController.hasCurrentWizardPage());
    checkState(m_colFilterInFilterSubnode, InternalNodeContainerState.EXECUTED);
    WizardPage currentWizardPage = wizardController.getCurrentWizardPage();
    // don't load anything here, just execute to next subnode (all columns included)
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(m_noClustersSubnode, InternalNodeContainerState.EXECUTED);
    currentWizardPage = wizardController.getCurrentWizardPage();
    Map<String, String> valueMap = new HashMap<String, String>();
    // setting number of clusters to be found (and loop iterations)
    String intInputID = m_noClustersSubnode.getIndex() + ":0:" + m_intInputInNoClusterSubnode.getIndex();
    valueMap.put(intInputID, "{\"integer\":" + numLoops + "}");
    Map<String, ValidationError> errorMap = wizardController.loadValuesIntoCurrentPage(valueMap);
    assertEquals("Loading number of clusters should not have caused errors", 0, errorMap.size());
    // looping over clusters
    for (int curLoop = 1; curLoop <= numLoops; curLoop++) {
        String stringInputID = m_labelClustersSubnode.getIndex() + ":0:" + m_stringInputInLabelClustersSubnode.getIndex();
        wizardController.stepNext();
        waitWhile(wfm, new WizardHold(), -1);
        checkState(m_labelClustersSubnode, InternalNodeContainerState.EXECUTED);
        checkState(m_loopEndNode, InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
        currentWizardPage = wizardController.getCurrentWizardPage();
        assertEquals("Labeling page should have 3 components", 3, currentWizardPage.getPageMap().size());
        assertNotNull("Labeling page should contain string input", currentWizardPage.getPageMap().get(NodeIDSuffix.fromString(stringInputID)));
        valueMap.clear();
        // label for cluster
        valueMap.put(stringInputID, "{\"string\":\"Cluster " + curLoop + "\"}");
        errorMap = wizardController.loadValuesIntoCurrentPage(valueMap);
        assertEquals("Loading cluster label should not have caused errors", 0, errorMap.size());
    }
    // display result of labeling
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(m_showClustersSubnode, InternalNodeContainerState.EXECUTED);
    currentWizardPage = wizardController.getCurrentWizardPage();
    assertEquals("Result page should have 2 components", 2, currentWizardPage.getPageMap().size());
    // finish execute
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    assertFalse("Should have no more pages", wizardController.hasCurrentWizardPage());
    checkState(wfm, InternalNodeContainerState.EXECUTED);
}
Also used : WizardHold(org.knime.core.node.workflow.TestWizardExec_Loop_Simple.WizardHold) HashMap(java.util.HashMap) WizardPage(org.knime.core.node.wizard.page.WizardPage) ValidationError(org.knime.core.node.web.ValidationError) Test(org.junit.Test)

Example 5 with WizardPage

use of org.knime.core.node.wizard.page.WizardPage in project knime-core by knime.

the class Bug6713_newWizardContainingOldMetanode method testWizardStepThrough.

@Test
public void testWizardStepThrough() throws Exception {
    final WorkflowManager wfm = getManager();
    assertTrue("should have new wizard execution", WebResourceController.hasWizardExecution(wfm));
    WizardExecutionController wizardController = wfm.getWizardExecutionController();
    wizardController.stepFirst();
    waitWhile(wfm, new WizardHold(), -1);
    assertTrue("should have steps", wizardController.hasCurrentWizardPage());
    checkState(m_subnodeFirstPage_6, EXECUTED);
    checkState(m_subnodeSecondPage_7, CONFIGURED_MARKEDFOREXEC);
    checkState(m_javaEdit_3, CONFIGURED_MARKEDFOREXEC);
    // outside loop
    WizardPage currentWizardPage = wizardController.getCurrentWizardPage();
    // TODO: load something real
    wizardController.loadValuesIntoCurrentPage(Collections.<String, String>emptyMap());
    // TODO check IDs
    // assertEquals(m_subnodeFirstPage_6.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(wfm, CONFIGURED_MARKEDFOREXEC, UNCONFIGURED_MARKEDFOREXEC);
    checkStateOfMany(EXECUTED, m_subnodeFirstPage_6, m_subnodeSecondPage_7, m_javaEdit_3);
    checkStateOfMany(CONFIGURED_MARKEDFOREXEC, m_metaNode_8, m_javaEdit_InMetaNode_8_4);
    checkStateOfMany(UNCONFIGURED_MARKEDFOREXEC, m_subnodeThirdPage_9);
    assertTrue("should have steps (2nd page)", wizardController.hasCurrentWizardPage());
    // inside loop 1st time
    currentWizardPage = wizardController.getCurrentWizardPage();
    // assertEquals(m_subnodeSecondPage_7.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(m_subnodeThirdPage_9, EXECUTED);
    checkState(wfm, EXECUTED);
    assertTrue("should have steps (3rd/last page)", wizardController.hasCurrentWizardPage());
    // inside loop 2nd time
    currentWizardPage = wizardController.getCurrentWizardPage();
    // assertEquals(m_subnodeSecondPage_7.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    assertFalse("should have no more pages", wizardController.hasCurrentWizardPage());
    checkState(wfm, EXECUTED);
}
Also used : WizardPage(org.knime.core.node.wizard.page.WizardPage) Test(org.junit.Test)

Aggregations

WizardPage (org.knime.core.node.wizard.page.WizardPage)7 Test (org.junit.Test)6 HashMap (java.util.HashMap)1 NodeSettings (org.knime.core.node.NodeSettings)1 ValidationError (org.knime.core.node.web.ValidationError)1 BugWEBP803_OnlyResetNodesToBeReexecuted.createNodeID (org.knime.core.node.workflow.BugWEBP803_OnlyResetNodesToBeReexecuted.createNodeID)1 WizardHold (org.knime.core.node.workflow.TestWizardExec_Loop_Simple.WizardHold)1