Search in sources :

Example 11 with NodeImpl

use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl 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 12 with NodeImpl

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

Example 13 with NodeImpl

use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.

the class CaseManagementUtilsTest method checkGetFirstDiagramNodeWithNonEmptyGraph.

@Test
@SuppressWarnings("unchecked")
public void checkGetFirstDiagramNodeWithNonEmptyGraph() {
    final Graph graph = new GraphImpl<>("uuid", new GraphNodeStoreImpl());
    final Node node = new NodeImpl<Definition>("node-uuid");
    final CaseManagementDiagram content = new CaseManagementDiagram.CaseManagementDiagramBuilder().build();
    node.setContent(new DefinitionImpl<>(content));
    graph.addNode(node);
    final Node<Definition<CaseManagementDiagram>, ?> fNode = CaseManagementUtils.getFirstDiagramNode(graph);
    assertNotNull(fNode);
    assertEquals("node-uuid", fNode.getUUID());
    assertEquals(content, fNode.getContent().getDefinition());
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) Graph(org.kie.workbench.common.stunner.core.graph.Graph) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) CaseManagementDiagram(org.kie.workbench.common.stunner.cm.definition.CaseManagementDiagram) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Test(org.junit.Test)

Example 14 with NodeImpl

use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.

the class CaseManagementCanvasHandlerTest method makeNode.

@SuppressWarnings("unchecked")
private Node<View<BPMNViewDefinition>, Edge> makeNode(final String uuid, final AbstractElementShape shape) {
    final Node<View<BPMNViewDefinition>, Edge> node = new NodeImpl<>(uuid);
    node.setContent(new ViewImpl(shape.getShapeDefinition(), new BoundsImpl(new BoundImpl(0.0, 0.0), new BoundImpl(10.0, 20.0))));
    when(canvas.getShape(eq(uuid))).thenReturn(shape);
    when(clientDefinitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(definitionAdapter.getMetaProperty(eq(PropertyMetaTypes.NAME), anyObject())).thenReturn(PropertyMetaTypes.NAME);
    when(propertyAdapter.getValue(eq(PropertyMetaTypes.NAME))).thenReturn("name");
    return node;
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) PictureShapeView(org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView) ActivityView(org.kie.workbench.common.stunner.cm.client.shape.view.ActivityView) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 15 with NodeImpl

use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.

the class VariablesEditorFieldRendererTest method testRemoveVariable.

@Test
public void testRemoveVariable() {
    when(variablesEditorWidgetView.getVariableWidget(anyInt())).thenReturn(variableListItemWidgetView);
    when(variablesEditorWidgetView.getVariableRowsCount()).thenReturn(1);
    when(variableRow.getName()).thenReturn("variableName");
    when(abstractClientSessionManager.getCurrentSession()).thenReturn(clientFullSession);
    when(abstractClientSessionManager.getCurrentSession().getCanvasHandler()).thenReturn(canvasHandler);
    when(abstractClientSessionManager.getCurrentSession().getCanvasHandler().getDiagram()).thenReturn(diagram);
    when(abstractClientSessionManager.getCurrentSession().getCanvasHandler().getDiagram().getGraph()).thenReturn(graph);
    final List nodes = new ArrayList<>();
    final Node node = new NodeImpl<>("node1");
    nodes.add(node);
    when(graph.nodes()).thenReturn(nodes);
    when(deleteHandler.isVariableBoundToNodes(graph, variableRow.getName())).thenReturn(true);
    variablesEditorRemove.addVariable();
    variablesEditorRemove.addVariable();
    variablesEditorRemove.removeVariable(variableRow);
    verify(variablesEditorWidgetView, times(3)).getVariableRows();
    verify(variablesEditorWidgetView, times(1)).doSave();
    variablesEditorRemove.removeVariable(variableRow);
    verify(variablesEditorWidgetView, times(4)).getVariableRows();
    verify(variablesEditorWidgetView, times(2)).doSave();
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)22 Test (org.junit.Test)18 Edge (org.kie.workbench.common.stunner.core.graph.Edge)9 GraphImpl (org.kie.workbench.common.stunner.core.graph.impl.GraphImpl)7 GraphNodeStoreImpl (org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl)7 Node (org.kie.workbench.common.stunner.core.graph.Node)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)4 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)4 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)4 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)4 EdgeImpl (org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)4 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 RuleViolations (org.kie.workbench.common.stunner.core.rule.RuleViolations)3 Consumer (java.util.function.Consumer)2 FlowElement (org.eclipse.bpmn2.FlowElement)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 RootElement (org.eclipse.bpmn2.RootElement)2 ExclusiveGateway (org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway)2 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)2