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());
}
Aggregations