Search in sources :

Example 6 with ScriptTask

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())));
}
Also used : ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) ParallelGateway(org.kie.workbench.common.stunner.bpmn.definition.ParallelGateway) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) Test(org.junit.Test)

Example 7 with ScriptTask

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());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Aggregations

ScriptTask (org.kie.workbench.common.stunner.bpmn.definition.ScriptTask)7 TaskGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.TaskGeneralSet)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 Test (org.junit.Test)3 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)3 ScriptTaskExecutionSet (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTaskExecutionSet)3 FlowElement (org.eclipse.bpmn2.FlowElement)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 RootElement (org.eclipse.bpmn2.RootElement)2 ScriptTaskPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ScriptTaskPropertyReader)2 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)2 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)2 IsAsync (org.kie.workbench.common.stunner.bpmn.definition.property.task.IsAsync)2 Script (org.kie.workbench.common.stunner.bpmn.definition.property.task.Script)2 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 Element (org.kie.workbench.common.stunner.core.graph.Element)2 Graph (org.kie.workbench.common.stunner.core.graph.Graph)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1