use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallProcessProperties.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessProperties() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSPROPERTIES);
assertDiagram(diagram, 4);
assertEquals("BPSimple", diagram.getMetadata().getTitle());
DiagramSet diagramProperties = 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 BPMNDiagram) {
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
diagramProperties = bpmnDiagram.getDiagramSet();
break;
}
}
}
assertEquals("BPSimple", diagramProperties.getName().getValue());
assertEquals("This is a\n" + "simple\n" + "process", diagramProperties.getDocumentation().getValue());
assertEquals("JDLProj.BPSimple", diagramProperties.getId().getValue());
assertEquals("org.jbpm", diagramProperties.getPackageProperty().getValue());
assertEquals(Boolean.TRUE, diagramProperties.getExecutable().getValue());
assertEquals(Boolean.TRUE, diagramProperties.getAdHoc().getValue());
assertEquals("This is the\n" + "Process\n" + "Instance\n" + "Description", diagramProperties.getProcessInstanceDescription().getValue());
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest 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());
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallUserTaskProperties.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallUserTaskProperties() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKPROPERTIES);
assertDiagram(diagram, 4);
assertEquals("MyBP", diagram.getMetadata().getTitle());
UserTaskExecutionSet userTaskExecutionSet = 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 UserTask) {
UserTask userTask = (UserTask) oDefinition;
userTaskExecutionSet = userTask.getExecutionSet();
break;
}
}
}
assertEquals("MyUserTask", userTaskExecutionSet.getTaskName().getValue());
assertEquals("true", userTaskExecutionSet.getIsAsync().getValue().toString());
assertEquals("false", userTaskExecutionSet.getSkippable().getValue().toString());
assertEquals("my subject", userTaskExecutionSet.getSubject().getValue());
assertEquals("admin", userTaskExecutionSet.getCreatedBy().getValue());
assertEquals("my description", userTaskExecutionSet.getDescription().getValue());
assertEquals("3", userTaskExecutionSet.getPriority().getValue());
assertEquals("true", userTaskExecutionSet.getAdHocAutostart().getValue().toString());
assertEquals("System.out.println(\"Hello\");", userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getScript());
assertEquals("java", userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage());
assertEquals("System.out.println(\"Bye\");", userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getScript());
assertEquals("java", userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMarshallIntermediateTimerEvent.
@Test
public void testMarshallIntermediateTimerEvent() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_TIMER_EVENT);
IntermediateTimerEvent timerEvent = 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 IntermediateTimerEvent) {
timerEvent = (IntermediateTimerEvent) oDefinition;
break;
}
}
}
assertNotNull(timerEvent);
assertNotNull(timerEvent.getGeneral());
assertNotNull(timerEvent.getExecutionSet());
assertEquals("myTimeDateValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeDate());
assertEquals("MyTimeDurationValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeDuration());
assertEquals("myTimeCycleValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeCycle());
assertEquals("cron", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeCycleLanguage());
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallBusinessRuleTask.
@Test
public void testUnmarshallBusinessRuleTask() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BUSINESSRULETASKRULEFLOWGROUP);
BusinessRuleTask businessRuleTask = 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 BusinessRuleTask) {
businessRuleTask = (BusinessRuleTask) oDefinition;
break;
}
}
}
assertNotNull(businessRuleTask);
assertNotNull(businessRuleTask.getExecutionSet());
assertNotNull(businessRuleTask.getExecutionSet().getRuleFlowGroup());
assertNotNull(businessRuleTask.getGeneral());
assertNotNull(businessRuleTask.getGeneral().getName());
assertEquals(businessRuleTask.getTaskType().getValue(), TaskTypes.BUSINESS_RULE);
assertEquals("my business rule task", businessRuleTask.getGeneral().getName().getValue());
assertEquals("my-ruleflow-group", businessRuleTask.getExecutionSet().getRuleFlowGroup().getValue());
assertEquals("true", businessRuleTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("true", businessRuleTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("System.out.println(\"Hello\");", businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getScript());
assertEquals("java", businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getLanguage());
assertEquals("System.out.println(\"Bye\");", businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getScript());
assertEquals("java", businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getLanguage());
}
Aggregations