use of org.kie.workbench.common.stunner.bpmn.definition.ScriptTask in project kie-wb-common by kiegroup.
the class ContextUtilsTest method testIsFormGenerationSupported.
@Test
public void testIsFormGenerationSupported() {
Assert.assertTrue(ContextUtils.isFormGenerationSupported(createNode(new UserTask())));
Assert.assertFalse(ContextUtils.isFormGenerationSupported(createNode(new ScriptTask())));
Assert.assertFalse(ContextUtils.isFormGenerationSupported(createNode(new BusinessRuleTask())));
Assert.assertFalse(ContextUtils.isFormGenerationSupported(createNode(new NoneTask())));
Assert.assertFalse(ContextUtils.isFormGenerationSupported(createNode(new StartNoneEvent())));
Assert.assertFalse(ContextUtils.isFormGenerationSupported(createNode(new EndNoneEvent())));
Assert.assertFalse(ContextUtils.isFormGenerationSupported(createNode(new ParallelGateway())));
}
use of org.kie.workbench.common.stunner.bpmn.definition.ScriptTask in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallScriptTask.
@Test
public void testUnmarshallScriptTask() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SCRIPTTASK);
ScriptTask javascriptScriptTask = null;
ScriptTask javaScriptTask = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof ScriptTask) {
ScriptTask task = (ScriptTask) oDefinition;
if ("Javascript Script Task".equals(task.getGeneral().getName().getValue())) {
javascriptScriptTask = task;
} else if ("Java Script Task".equals(task.getGeneral().getName().getValue())) {
javaScriptTask = task;
}
}
}
}
assertNotNull(javascriptScriptTask);
assertNotNull(javascriptScriptTask.getExecutionSet());
assertNotNull(javascriptScriptTask.getExecutionSet().getScript());
assertEquals(javascriptScriptTask.getTaskType().getValue(), TaskTypes.SCRIPT);
assertEquals("Javascript Script Task", javascriptScriptTask.getGeneral().getName().getValue());
assertEquals("var str = FirstName + LastName;", javascriptScriptTask.getExecutionSet().getScript().getValue().getScript());
assertEquals("javascript", javascriptScriptTask.getExecutionSet().getScript().getValue().getLanguage());
assertEquals("true", javascriptScriptTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("true", javascriptScriptTask.getExecutionSet().getIsAsync().getValue().toString());
assertNotNull(javaScriptTask);
assertNotNull(javaScriptTask.getExecutionSet());
assertNotNull(javaScriptTask.getExecutionSet().getScript());
assertEquals(javaScriptTask.getTaskType().getValue(), TaskTypes.SCRIPT);
assertEquals("Java Script Task", javaScriptTask.getGeneral().getName().getValue());
assertEquals("if (name.toString().equals(\"Jay\")) {\n" + "\n" + " System.out.println(\"Hello\\n\" + name.toString() + \"\\n\");\n" + "\n" + "} else {\n" + "\n" + "\n" + " System.out.println(\"Hi\\n\" + name.toString() + \"\\n\");\n" + "\n" + "\n" + "}\n", javaScriptTask.getExecutionSet().getScript().getValue().getScript());
assertEquals("java", javaScriptTask.getExecutionSet().getScript().getValue().getLanguage());
assertEquals("true", javaScriptTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("true", javaScriptTask.getExecutionSet().getIsAsync().getValue().toString());
}
Aggregations