use of org.knime.core.webui.data.text.TextReExecuteDataService in project knime-core by knime.
the class NodeViewManagerTest method testCallDataServices.
/**
* Tests {@link NodeViewManager#callTextInitialDataService(NodeContainer)},
* {@link NodeViewManager#callTextDataService(NodeContainer, String)} and
* {@link NodeViewManager#callTextApplyDataService(NodeContainer, String)}
*/
@Test
public void testCallDataServices() {
var page = Page.builder(() -> "test page content", "index.html").build();
var nodeView = createNodeView(page, new TextInitialDataService() {
@Override
public String getInitialData() {
return "init service";
}
}, new TextDataService() {
@Override
public String handleRequest(final String request) {
return "general data service";
}
}, new TextReExecuteDataService() {
@Override
public Optional<String> validateData(final String data) throws IOException {
throw new UnsupportedOperationException("should not be called in this test");
}
@Override
public void applyData(final String data) throws IOException {
throw new UnsupportedOperationException("should not be called in this test");
}
@Override
public void reExecute(final String data) throws IOException {
throw new IOException("re-execute data service");
}
});
NativeNodeContainer nc = NodeViewManagerTest.createNodeWithNodeView(m_wfm, m -> nodeView);
var nodeViewManager = NodeViewManager.getInstance();
assertThat(nodeViewManager.callTextInitialDataService(nc), is("init service"));
assertThat(nodeViewManager.callTextDataService(nc, ""), is("general data service"));
String message = assertThrows(IOException.class, () -> nodeViewManager.callTextApplyDataService(nc, "ERROR,test")).getMessage();
assertThat(message, is("re-execute data service"));
}
Aggregations