Search in sources :

Example 46 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallScriptTask.

@Test
public void testMarshallScriptTask() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SCRIPTTASK);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 4, 3);
    assertTrue(result.contains("name=\"Javascript Script Task\" scriptFormat=\"http://www.javascript.com/javascript\""));
    assertTrue(result.contains("name=\"Java Script Task\" scriptFormat=\"http://www.java.com/java\""));
    assertTrue(result.contains("<bpmn2:script><![CDATA[var str = FirstName + LastName;]]></bpmn2:script>"));
    assertTrue(result.contains("<bpmn2:script><![CDATA[if (name.toString().equals(\"Jay\")) {" + NEW_LINE + NEW_LINE + "      System.out.println(\"Hello\\n\" + name.toString() + \"\\n\");" + NEW_LINE + NEW_LINE + "} else {" + NEW_LINE + NEW_LINE + NEW_LINE + "  System.out.println(\"Hi\\n\" + name.toString() + \"\\n\");" + NEW_LINE + NEW_LINE + NEW_LINE + "}" + NEW_LINE + "]]></bpmn2:script>"));
    String flatResult = result.replace(NEW_LINE, " ").replaceAll("( )+", " ");
    assertTrue(flatResult.contains("<drools:metaData name=\"customAsync\"> <drools:metaValue><![CDATA[true]]></drools:metaValue>"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 47 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallIntermediateMessageEventThrowing.

@Test
public void testMarshallIntermediateMessageEventThrowing() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_MESSAGE_EVENTTHROWING);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 1, 0);
    assertTrue(result.contains("<bpmn2:intermediateThrowEvent"));
    assertTrue(result.contains(" name=\"IntermediateMessageEventThrowing\""));
    assertTrue(result.contains("<bpmn2:message "));
    assertTrue(result.contains(" name=\"msgref\""));
    assertTrue(result.contains("<bpmn2:messageEventDefinition"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 48 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallAdHocSubprocess.

public void testMarshallAdHocSubprocess() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ADHOC_SUBPROCESS);
    assertDiagram(diagram, 9);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 8, 5);
    assertTrue(result.contains("<bpmn2:adHocSubProcess id=\"_B65DDF51-9822-4B12-8669-2018A845A01B\""));
    assertTrue(result.contains("name=\"AdHocSubprocess1\""));
    assertTrue(result.contains("<drools:onEntry-script scriptFormat=\"http://www.mvel.org/2.0\">"));
    assertTrue(result.contains("<drools:script><![CDATA[System.out.println(\"onEntryAction\");]]></drools:script>"));
    assertTrue(result.contains("</drools:onEntry-script>"));
    assertTrue(result.contains("<drools:onExit-script scriptFormat=\"http://www.java.com/java\">"));
    assertTrue(result.contains("<drools:script><![CDATA[System.out.println(\"onExitAction\");]]></drools:script>"));
    assertTrue(result.contains("</drools:onExit-script>"));
    assertTrue(result.contains("<bpmn2:completionCondition xsi:type=\"bpmn2:tFormalExpression\""));
    assertTrue(result.contains("language=\"http://www.jboss.org/drools/rule\"><![CDATA[autocomplete]]></bpmn2:completionCondition>"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString)

Example 49 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallUserTaskAssignments.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallUserTaskAssignments() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNMENTS);
    assertDiagram(diagram, 8);
    assertEquals("UserTaskAssignments", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> selfEvaluationNode = diagram.getGraph().getNode("_6063D302-9D81-4C86-920B-E808A45377C2");
    UserTask selfEvaluationTask = (UserTask) selfEvaluationNode.getContent().getDefinition();
    assertEquals(selfEvaluationTask.getTaskType().getValue(), TaskTypes.USER);
    UserTaskExecutionSet executionSet = selfEvaluationTask.getExecutionSet();
    AssignmentsInfo assignmentsinfo = executionSet.getAssignmentsinfo();
    assertEquals(assignmentsinfo.getValue(), "|reason:com.test.Reason,Comment:Object,Skippable:Object||performance:Object|[din]reason->reason,[dout]performance->performance");
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) UserTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.UserTaskExecutionSet) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) Test(org.junit.Test)

Example 50 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallIntermediateMessageEventCatching.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallIntermediateMessageEventCatching() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_MESSAGE_EVENTCATCHING);
    assertDiagram(diagram, 2);
    assertEquals("IntermediateMessageEventCatching", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> intermediateMessageEventCatchingNode = diagram.getGraph().getNode("_BD708E30-CA48-4051-BAEA-BBCB5F396CEE");
    IntermediateMessageEventCatching intermediateMessageEventCatching = (IntermediateMessageEventCatching) intermediateMessageEventCatchingNode.getContent().getDefinition();
    assertNotNull(intermediateMessageEventCatching.getExecutionSet());
    MessageRef messageRef = intermediateMessageEventCatching.getExecutionSet().getMessageRef();
    assertEquals("msgref1", messageRef.getValue());
    DataIOSet dataIOSet = intermediateMessageEventCatching.getDataIOSet();
    AssignmentsInfo assignmentsInfo = dataIOSet.getAssignmentsinfo();
    assertEquals("||IntermediateMessageEventCatchingOutputVar1:String||[dout]IntermediateMessageEventCatchingOutputVar1->var1", assignmentsInfo.getValue());
}
Also used : DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) Graph(org.kie.workbench.common.stunner.core.graph.Graph) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) IntermediateMessageEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventCatching) Test(org.junit.Test)

Aggregations

Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)175 Graph (org.kie.workbench.common.stunner.core.graph.Graph)158 Test (org.junit.Test)156 Matchers.anyString (org.mockito.Matchers.anyString)53 View (org.kie.workbench.common.stunner.core.graph.content.view.View)32 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)30 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)28 RootElement (org.eclipse.bpmn2.RootElement)28 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)28 Element (org.kie.workbench.common.stunner.core.graph.Element)27 FlowElement (org.eclipse.bpmn2.FlowElement)26 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)16 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)14 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)11 StartErrorEvent (org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent)10 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)10 StartSignalEvent (org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent)9 StartTimerEvent (org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent)9 Node (org.kie.workbench.common.stunner.core.graph.Node)9