use of org.eclipse.bpmn2.SequenceFlow in project kie-wb-common by kiegroup.
the class ProcessConverterDelegateTest method mockSequenceFlow.
private SequenceFlow mockSequenceFlow(String id, FlowNode source, FlowNode target) {
SequenceFlow sequenceFlow = Bpmn2Factory.eINSTANCE.createSequenceFlow();
sequenceFlow.setSourceRef(source);
sequenceFlow.setTargetRef(target);
sequenceFlow.setId(id);
BPMNEdge shape = mock(BPMNEdge.class);
when(shape.getWaypoint()).thenReturn(Collections.emptyList());
plane.getPlaneElement().add(shape);
when(shape.getBpmnElement()).thenReturn(sequenceFlow);
return sequenceFlow;
}
use of org.eclipse.bpmn2.SequenceFlow in project kie-wb-common by kiegroup.
the class ProcessConverterDelegateTest method testConvertEdges.
@Test
public void testConvertEdges() {
Task task1 = mockTask("1");
Task task2 = mockTask("2");
BpmnNode task1Node = mockTaskNode(task1);
BpmnNode task2Node = mockTaskNode(task2);
SequenceFlow sequenceFlow = mockSequenceFlow("seq1", task1, task2);
List<BaseElement> elements = Arrays.asList(sequenceFlow, task1, task2);
// ignored because there the tasks are not on the nodes map
assertFalse(converterDelegate.convertEdges(parentNode, elements, new HashMap<>()).value());
// convert with all nodes
Map<String, BpmnNode> nodes = new Maps.Builder<String, BpmnNode>().put(task1.getId(), task1Node).put(task2.getId(), task2Node).build();
assertTrue(converterDelegate.convertEdges(parentNode, elements, nodes).value());
}
use of org.eclipse.bpmn2.SequenceFlow in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallSequenceFlow.
@Test
public void testUnmarshallSequenceFlow() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SEQUENCEFLOW);
SequenceFlow sequenceFlow1 = null;
SequenceFlow sequenceFlow2 = 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 ExclusiveGateway) {
List<Edge> outEdges = ((NodeImpl) element).getOutEdges();
for (Edge edge : outEdges) {
SequenceFlow flow = (SequenceFlow) ((ViewConnectorImpl) edge.getContent()).getDefinition();
if ("route1".equals(flow.getGeneral().getName().getValue())) {
sequenceFlow1 = flow;
}
if ("route2".equals(flow.getGeneral().getName().getValue())) {
sequenceFlow2 = flow;
}
}
}
}
}
assertNotNull(sequenceFlow1);
assertNotNull(sequenceFlow1.getExecutionSet());
assertNotNull(sequenceFlow1.getExecutionSet().getConditionExpression());
assertNotNull(sequenceFlow1.getExecutionSet().getPriority());
assertNotNull(sequenceFlow1.getGeneral());
assertNotNull(sequenceFlow1.getGeneral().getName());
assertEquals("route1", sequenceFlow1.getGeneral().getName().getValue());
assertEquals("age >= 10;", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getScript());
assertEquals("javascript", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getLanguage());
assertEquals("2", sequenceFlow1.getExecutionSet().getPriority().getValue());
assertNotNull(sequenceFlow2);
assertNotNull(sequenceFlow2.getExecutionSet());
assertNotNull(sequenceFlow2.getExecutionSet().getConditionExpression());
assertNotNull(sequenceFlow2.getExecutionSet().getPriority());
assertNotNull(sequenceFlow2.getGeneral());
assertNotNull(sequenceFlow2.getGeneral().getName());
assertEquals("route2", sequenceFlow2.getGeneral().getName().getValue());
assertEquals("age\n" + "<\n" + "10;", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getScript());
assertEquals("java", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getLanguage());
assertEquals("1", sequenceFlow2.getExecutionSet().getPriority().getValue());
}
use of org.eclipse.bpmn2.SequenceFlow in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallEventGateway.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEventGateway() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EVENT_GATEWAY);
assertDiagram(diagram, 7);
assertEquals(diagram.getMetadata().getTitle(), "TestEventGateway");
Graph graph = diagram.getGraph();
Node<? extends Definition, ?> gatewayNode = graph.getNode("_AFDF2596-C521-4753-AC22-2DCCAD391F98");
assertTrue(gatewayNode.getContent().getDefinition() instanceof EventGateway);
EventGateway eventGateway = (EventGateway) gatewayNode.getContent().getDefinition();
assertEquals("EventGatewayName", eventGateway.getGeneral().getName().getValue());
assertEquals("EventGatewayDocumentation", eventGateway.getGeneral().getDocumentation().getValue());
SequenceFlow inSequenceFlow = gatewayNode.getInEdges().stream().filter(edge -> "_E805280D-5862-4F56-B02A-E34F7D519050".equals(edge.getUUID())).map(edge -> (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition()).findFirst().orElseThrow(() -> new Exception("Expected sequenceFlow: _E805280D-5862-4F56-B02A-E34F7D519050 was not found"));
SequenceFlow outSequenceFlow1 = gatewayNode.getOutEdges().stream().filter(edge -> "_CCEF6352-760D-4641-B9C9-0B01FD4DD704".equals(edge.getUUID())).map(edge -> (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition()).findFirst().orElseThrow(() -> new Exception("Expected sequenceFlow: _CCEF6352-760D-4641-B9C9-0B01FD4DD704 was not found"));
SequenceFlow outSequenceFlow2 = gatewayNode.getOutEdges().stream().filter(edge -> "_1CD28E0D-1910-45FE-9AEC-932FA28C77AA".equals(edge.getUUID())).map(edge -> (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition()).findFirst().orElseThrow(() -> new Exception("Expected sequenceFlow: _1CD28E0D-1910-45FE-9AEC-932FA28C77AA was not found"));
assertNotNull(inSequenceFlow);
assertEquals("inSequence", inSequenceFlow.getGeneral().getName().getValue());
assertNotNull(outSequenceFlow1);
assertEquals("outSequence1", outSequenceFlow1.getGeneral().getName().getValue());
assertNotNull(outSequenceFlow2);
assertEquals("outSequence2", outSequenceFlow2.getGeneral().getName().getValue());
}
use of org.eclipse.bpmn2.SequenceFlow in project kie-wb-common by kiegroup.
the class SequenceFlowPropertyReaderTest method getConnectionsWithWaypoints.
@Test
public void getConnectionsWithWaypoints() {
TestDefinitionsWriter d = new TestDefinitionsWriter();
PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver());
Bounds sourceBounds = boundsOf(10, 10, 50, 50);
FlowNode source = d.mockNode(SOURCE_ID, sourceBounds);
Bounds targetBounds = boundsOf(100, 100, 60, 60);
FlowNode target = d.mockNode(TARGET_ID, targetBounds);
Point sourcePoint = pointOf(10, 20);
Point targetPoint = pointOf(100, 120);
List<Point> waypoints = asList(sourcePoint, targetPoint);
SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, waypoints);
SequenceFlowPropertyReader p = factory.of(el);
Connection sourceConnection = p.getSourceConnection();
assertEquals(sourcePoint.getX() - sourceBounds.getX(), (float) sourceConnection.getLocation().getX(), 0);
assertEquals(sourcePoint.getY() - sourceBounds.getY(), (float) sourceConnection.getLocation().getY(), 0);
Connection targetConnection = p.getTargetConnection();
assertEquals(targetPoint.getX() - targetBounds.getX(), (float) targetConnection.getLocation().getX(), 0);
assertEquals(targetPoint.getY() - targetBounds.getY(), (float) targetConnection.getLocation().getY(), 0);
}
Aggregations