Search in sources :

Example 1 with SubnodeViewValue

use of org.knime.core.wizard.SubnodeViewValue in project knime-core by knime.

the class TestSubnodeView method testSubnodeViewableModel.

/**
 * Creates and tests the {@link SubnodeViewableModel}
 * @throws Exception
 */
@Test
public void testSubnodeViewableModel() throws Exception {
    initialExecute();
    SubNodeContainer snc = getManager().getNodeContainer(m_subnodeID, SubNodeContainer.class, true);
    SubnodeViewableModel svm = new SubnodeViewableModel(snc, "testView");
    JSONWebNodePage page = svm.getViewRepresentation();
    validateJSONPage(page);
    SubnodeViewValue viewValue = svm.getViewValue();
    assertNotNull("Combined view value should exist", viewValue);
    assertNotNull("Combined view value map should exist", viewValue.getViewValues());
    assertEquals("Combined view value should contain three entries", 3, viewValue.getViewValues().size());
    Map<String, String> changedValueMap = new HashMap<String, String>(3);
    changedValueMap.putAll(viewValue.getViewValues());
    changedValueMap = changeStringInputTo("foo", changedValueMap);
    SubnodeViewValue newViewValue = new SubnodeViewValue();
    newViewValue.setViewValues(changedValueMap);
    ValidationError validationError = svm.validateViewValue(newViewValue);
    assertTrue("Validation error should be instance of CollectionValidationError", validationError instanceof CollectionValidationError);
    Map<String, String> errorMap = ((CollectionValidationError) validationError).getErrorMap();
    assertNotNull("Error map should exist", errorMap);
    changedValueMap.putAll(viewValue.getViewValues());
    changeStringInputTo(CHANGED_URL, changedValueMap);
    selectRowInTable(changedValueMap);
    validationError = svm.validateViewValue(newViewValue);
    assertNull("There should not be any validation errors", validationError);
    svm.loadViewValue(newViewValue, false);
    waitWhileNodeInExecution(m_subnodeID);
    assertTrue("Subnode should be executed.", getManager().getNodeContainer(m_subnodeID).getNodeContainerState().isExecuted());
    validateReexecutionResult();
    svm.discard();
    assertNull("Page should be null after reset", svm.getViewRepresentation());
    assertNull("View value should be null after reset", svm.getViewValue());
}
Also used : HashMap(java.util.HashMap) SubnodeViewableModel(org.knime.core.wizard.SubnodeViewableModel) ValidationError(org.knime.core.node.web.ValidationError) CollectionValidationError(org.knime.core.wizard.SubnodeViewableModel.CollectionValidationError) CollectionValidationError(org.knime.core.wizard.SubnodeViewableModel.CollectionValidationError) JSONWebNodePage(org.knime.js.core.JSONWebNodePage) SubnodeViewValue(org.knime.core.wizard.SubnodeViewValue) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Test (org.junit.Test)1 ValidationError (org.knime.core.node.web.ValidationError)1 SubnodeViewValue (org.knime.core.wizard.SubnodeViewValue)1 SubnodeViewableModel (org.knime.core.wizard.SubnodeViewableModel)1 CollectionValidationError (org.knime.core.wizard.SubnodeViewableModel.CollectionValidationError)1 JSONWebNodePage (org.knime.js.core.JSONWebNodePage)1