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());
}
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));
}
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());
}
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());
}
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);
}
Aggregations