Search in sources :

Example 1 with TestEvaluationException

use of org.knime.testing.node.differNode.TestEvaluationException in project knime-core by knime.

the class AbstractBlobsInWorkflowTest method setUp.

/**
 * {@inheritDoc}
 */
@Override
protected void setUp() throws Exception {
    m_wfmDir = FileUtil.createTempDir(getClass().getSimpleName());
    WorkflowCreationHelper creationHelper = new WorkflowCreationHelper();
    creationHelper.setWorkflowContext(new WorkflowContext.Factory(m_wfmDir).createContext());
    WorkflowManager m = WorkflowManager.ROOT.createAndAddProject("Blob test", creationHelper);
    RuntimeNodeModel createModel = new RuntimeNodeModel(0, 1) {

        /**
         * {@inheritDoc}
         */
        @Override
        protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
            return new BufferedDataTable[] { createBDT(exec) };
        }
    };
    NodeID createID = m.createAndAddNode(new RuntimeNodeFactory(createModel));
    // add a sequence of cache nodes
    NodeID[] cacheIDs = new NodeID[10];
    CacheNodeFactory cacheNodeFactory = new CacheNodeFactory();
    for (int i = 0; i < cacheIDs.length; i++) {
        cacheIDs[i] = m.createAndAddNode(cacheNodeFactory);
        if (i == 0) {
            m.addConnection(createID, 1, cacheIDs[i], 1);
        } else {
            m.addConnection(cacheIDs[i - 1], 1, cacheIDs[i], 1);
        }
    }
    final AtomicReference<Throwable> failure = new AtomicReference<Throwable>();
    RuntimeNodeModel checkModel = new RuntimeNodeModel(1, 0) {

        /**
         * {@inheritDoc}
         */
        @Override
        protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
            try {
                new DataTableDiffer().compare(inData[0], createBDT(exec));
            } catch (TestEvaluationException tee) {
                failure.set(tee);
                throw tee;
            }
            return new BufferedDataTable[] {};
        }
    };
    NodeID checkID = m.createAndAddNode(new RuntimeNodeFactory(checkModel));
    m.addConnection(cacheIDs[cacheIDs.length - 1], 1, checkID, 1);
    m_flow = m;
    m.executeAllAndWaitUntilDone();
    assertNull(failure.get());
    assertTrue(m.getNodeContainerState().isExecuted());
}
Also used : CacheNodeFactory(org.knime.base.node.util.cache.CacheNodeFactory) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) CacheNodeFactory(org.knime.base.node.util.cache.CacheNodeFactory) RuntimeNodeFactory(org.knime.testing.node.runtime.RuntimeNodeFactory) AtomicReference(java.util.concurrent.atomic.AtomicReference) TestEvaluationException(org.knime.testing.node.differNode.TestEvaluationException) DataTableDiffer(org.knime.testing.node.differNode.DataTableDiffer) WorkflowCreationHelper(org.knime.core.node.workflow.WorkflowCreationHelper) ExecutionContext(org.knime.core.node.ExecutionContext) RuntimeNodeModel(org.knime.testing.node.runtime.RuntimeNodeModel) BufferedDataTable(org.knime.core.node.BufferedDataTable) NodeID(org.knime.core.node.workflow.NodeID) RuntimeNodeFactory(org.knime.testing.node.runtime.RuntimeNodeFactory)

Aggregations

AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CacheNodeFactory (org.knime.base.node.util.cache.CacheNodeFactory)1 BufferedDataTable (org.knime.core.node.BufferedDataTable)1 ExecutionContext (org.knime.core.node.ExecutionContext)1 NodeID (org.knime.core.node.workflow.NodeID)1 WorkflowCreationHelper (org.knime.core.node.workflow.WorkflowCreationHelper)1 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)1 DataTableDiffer (org.knime.testing.node.differNode.DataTableDiffer)1 TestEvaluationException (org.knime.testing.node.differNode.TestEvaluationException)1 RuntimeNodeFactory (org.knime.testing.node.runtime.RuntimeNodeFactory)1 RuntimeNodeModel (org.knime.testing.node.runtime.RuntimeNodeModel)1