Search in sources :

Example 1 with WizardHold

use of org.knime.core.node.workflow.TestWizardExec_Loop_Simple.WizardHold 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 2 with WizardHold

use of org.knime.core.node.workflow.TestWizardExec_Loop_Simple.WizardHold in project knime-core by knime.

the class TestWizardExec_LoadValuesInSubnode method testWizardStepBackInsideLoop.

@Test
public void testWizardStepBackInsideLoop() throws Exception {
    final WorkflowManager wfm = getManager();
    WizardExecutionController wizardController = wfm.getWizardExecutionController();
    assertFalse("Should have no previous steps", wizardController.hasPreviousWizardPage());
    wizardController.stepFirst();
    waitWhile(wfm, new WizardHold(), -1);
    assertTrue("should have steps", wizardController.hasCurrentWizardPage());
    checkState(m_colFilterInFilterSubnode, InternalNodeContainerState.EXECUTED);
    // standard no of clusters (5)
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(m_noClustersSubnode, InternalNodeContainerState.EXECUTED);
    // two loop iterations
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(m_labelClustersSubnode, InternalNodeContainerState.EXECUTED);
    checkState(m_loopEndNode, InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(), -1);
    checkState(m_labelClustersSubnode, InternalNodeContainerState.EXECUTED);
    checkState(m_loopEndNode, InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
    // step back from inside loop
    assertTrue("Should have previous steps", wizardController.hasPreviousWizardPage());
    wizardController.stepBack();
    checkState(m_noClustersSubnode, InternalNodeContainerState.EXECUTED);
    // checkState(m_labelClustersSubnode, InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
    checkState(wfm, InternalNodeContainerState.IDLE);
    assertTrue("Should have page to prompt", wizardController.hasCurrentWizardPage());
// execute all
// checkState(wfm, InternalNodeContainerState.EXECUTED);
}
Also used : WizardHold(org.knime.core.node.workflow.TestWizardExec_Loop_Simple.WizardHold) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 WizardHold (org.knime.core.node.workflow.TestWizardExec_Loop_Simple.WizardHold)2 HashMap (java.util.HashMap)1 ValidationError (org.knime.core.node.web.ValidationError)1 WizardPage (org.knime.core.node.wizard.page.WizardPage)1