Search in sources :

Example 1 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class ExclusiveGatewayTest method testExclusiveDatabasedGatewayNameValid.

@Test
public void testExclusiveDatabasedGatewayNameValid() {
    ExclusiveGateway exclusiveGateway = new ExclusiveGateway.ExclusiveGatewayBuilder().build();
    exclusiveGateway.getGeneral().setName(new Name(NAME_VALID));
    Set<ConstraintViolation<ExclusiveGateway>> violations = this.validator.validate(exclusiveGateway);
    assertTrue(violations.isEmpty());
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) ConstraintViolation(javax.validation.ConstraintViolation) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) Test(org.junit.Test)

Example 2 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class DefaultRouteFormProviderTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
    when(session.getSelectionControl()).thenReturn(selectionControl);
    Collection<String> selectedItems = new ArrayList<>();
    when(selectedNode.getUUID()).thenReturn(SELECTED_UUID);
    selectedItems.add(selectedNode.getUUID());
    when(selectionControl.getSelectedItems()).thenReturn(selectedItems);
    when(graph.getNode(SELECTED_UUID)).thenReturn(selectedNode);
    outEdges = new ArrayList<>();
    UserTask userTask1 = new UserTask(new TaskGeneralSet(new Name("UserTask1"), null), null, null, null, null, null, null);
    when(definitionAdapter.getTitle(eq(userTask1))).thenReturn("User Task");
    outEdges.add(mockEdge("Edge1", userTask1));
    UserTask userTask2 = new UserTask(new TaskGeneralSet(new Name("UserTask2"), null), null, null, null, null, null, null);
    when(definitionAdapter.getTitle(eq(userTask2))).thenReturn("User Task");
    outEdges.add(mockEdge("Edge2", userTask2));
    ScriptTask scriptTask3 = new ScriptTask(new TaskGeneralSet(new Name("ScriptTask3"), null), null, null, null, null, null, null);
    when(definitionAdapter.getTitle(eq(scriptTask3))).thenReturn("Script Task");
    outEdges.add(mockEdge("Edge3", scriptTask3));
    ExclusiveGateway gateway4 = new ExclusiveGateway(new BPMNGeneralSet("Gateway4"), null, null, null, null);
    when(definitionAdapter.getTitle(eq(gateway4))).thenReturn("Exclusive Gateway");
    outEdges.add(mockEdge("Edge4", gateway4));
    InclusiveGateway gateway5 = new InclusiveGateway(new BPMNGeneralSet(""), null, null, null, null);
    when(definitionAdapter.getTitle(eq(gateway5))).thenReturn("Inclusive Gateway");
    outEdges.add(mockEdge("Edge5", gateway5));
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) InclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.InclusiveGateway) ArrayList(java.util.ArrayList) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) TaskGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.TaskGeneralSet) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) Before(org.junit.Before)

Example 3 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testUnmarshallXorGateway.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallXorGateway() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_XORGATEWAY);
    assertDiagram(diagram, 7);
    assertEquals(diagram.getMetadata().getTitle(), "XORGateway");
    Graph graph = diagram.getGraph();
    Node<? extends Definition, ?> gatewayNode = graph.getNode("_877EA035-1A14-42E9-8CAA-43E9BF908C70");
    ExclusiveGateway xorGateway = (ExclusiveGateway) gatewayNode.getContent().getDefinition();
    assertEquals("AgeSplit", xorGateway.getGeneral().getName().getValue());
    assertEquals("_5110D608-BDAD-47BF-A3F9-E1DBE43ED7CD", xorGateway.getExecutionSet().getDefaultRoute().getValue());
    SequenceFlow sequenceFlow1 = null;
    SequenceFlow sequenceFlow2 = null;
    List<Edge> outEdges = (List<Edge>) gatewayNode.getOutEdges();
    if (outEdges != null) {
        for (Edge edge : outEdges) {
            if ("_C72E00C3-70DC-4BC9-A08E-761B4263A239".equals(edge.getUUID())) {
                sequenceFlow1 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
            } else if ("_5110D608-BDAD-47BF-A3F9-E1DBE43ED7CD".equals(edge.getUUID())) {
                sequenceFlow2 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
            }
        }
    }
    assertNotNull(sequenceFlow1);
    assertEquals("10 and over", sequenceFlow1.getGeneral().getName().getValue());
    assertNotNull(sequenceFlow2);
    assertEquals("under 10", sequenceFlow2.getGeneral().getName().getValue());
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ArrayList(java.util.ArrayList) List(java.util.List) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 4 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest 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) ((EdgeImpl) 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());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) 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) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 5 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class GatewayConverter method exclusiveGateway.

private BpmnNode exclusiveGateway(Gateway gateway) {
    Node<View<ExclusiveGateway>, Edge> node = factoryManager.newNode(gateway.getId(), ExclusiveGateway.class);
    ExclusiveGateway definition = node.getContent().getDefinition();
    GatewayPropertyReader p = propertyReaderFactory.of(gateway);
    definition.setGeneral(new BPMNGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
    definition.setExecutionSet(new GatewayExecutionSet(new DefaultRoute(p.getDefaultRoute())));
    node.getContent().setBounds(p.getBounds());
    definition.setDimensionsSet(p.getCircleDimensionSet());
    definition.setFontSet(p.getFontSet());
    definition.setBackgroundSet(p.getBackgroundSet());
    return BpmnNode.of(node);
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) DefaultRoute(org.kie.workbench.common.stunner.bpmn.definition.property.gateway.DefaultRoute) GatewayPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.GatewayPropertyReader) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) GatewayExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.gateway.GatewayExecutionSet)

Aggregations

ExclusiveGateway (org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway)9 Test (org.junit.Test)6 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)4 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)4 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)4 Graph (org.kie.workbench.common.stunner.core.graph.Graph)4 ArrayList (java.util.ArrayList)3 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)3 View (org.kie.workbench.common.stunner.core.graph.content.view.View)3 List (java.util.List)2 ConstraintViolation (javax.validation.ConstraintViolation)2 FlowElement (org.eclipse.bpmn2.FlowElement)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 RootElement (org.eclipse.bpmn2.RootElement)2 GatewayExecutionSet (org.kie.workbench.common.stunner.bpmn.definition.property.gateway.GatewayExecutionSet)2 Element (org.kie.workbench.common.stunner.core.graph.Element)2 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)2 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)2 LinkedList (java.util.LinkedList)1