Search in sources :

Example 16 with ViewImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method testConvertAdHocSubprocessNode_autostart.

@Test
public void testConvertAdHocSubprocessNode_autostart() {
    final AdHocSubprocess definition = new AdHocSubprocess();
    definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(true));
    final View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    final Node<View<BaseAdHocSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString());
    node.setContent(view);
    SubProcessPropertyWriter writer = tested.convertAdHocSubprocessNode(node);
    assertTrue(AdHocSubProcessPropertyWriter.class.isInstance(writer));
    assertTrue(CustomElement.autoStart.of(writer.getFlowElement()).get());
}
Also used : AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) AdHocAutostart(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocAutostart) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) Test(org.junit.Test)

Example 17 with ViewImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method testConvertAdHocSubprocessNode_notautostart.

@Test
public void testConvertAdHocSubprocessNode_notautostart() {
    final AdHocSubprocess definition = new AdHocSubprocess();
    definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(false));
    final View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    final Node<View<BaseAdHocSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString());
    node.setContent(view);
    SubProcessPropertyWriter writer = tested.convertAdHocSubprocessNode(node);
    assertTrue(AdHocSubProcessPropertyWriter.class.isInstance(writer));
    assertFalse(CustomElement.autoStart.of(writer.getFlowElement()).get());
}
Also used : AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) AdHocAutostart(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocAutostart) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) Test(org.junit.Test)

Example 18 with ViewImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method testConvertAdhocSubprocess.

@Test
public void testConvertAdhocSubprocess() {
    AdHocSubprocess definition = new AdHocSubprocess();
    String adHocOrdering = "Parallel";
    boolean adHocAutostart = true;
    String processVariables = "processVar1:Object,processVar2:Integer";
    definition.getGeneral().getName().setValue(NAME);
    definition.getGeneral().getDocumentation().setValue(DOCUMENTATION);
    definition.getProcessData().getProcessVariables().setValue(processVariables);
    definition.getExecutionSet().getAdHocOrdering().setValue(adHocOrdering);
    definition.getExecutionSet().getAdHocAutostart().setValue(adHocAutostart);
    definition.getExecutionSet().getAdHocActivationCondition().setValue(ACTIVATION_CONDITION);
    definition.getExecutionSet().getAdHocCompletionCondition().setValue(COMPLETION_CONDITION);
    definition.getExecutionSet().getOnEntryAction().getValue().addValue(ON_ENTRY_ACTION);
    definition.getExecutionSet().getOnExitAction().getValue().addValue(ON_EXIT_ACTION);
    setBaseSubprocessExecutionSetValues(definition.getExecutionSet());
    double nodeX1 = 10;
    double nodeY1 = 20;
    double nodeX2 = 40;
    double nodeY2 = 60;
    View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create(nodeX1, nodeY1, nodeX2, nodeY2));
    Node<View<? extends BPMNViewDefinition>, Edge> node = new NodeImpl<>(ELEMENT_ID);
    node.setContent(view);
    double parentX1 = 30;
    double parentY1 = 40;
    double parentX2 = 60;
    double parentY2 = 100;
    Node<View<? extends BPMNViewDefinition>, ?> parent = new NodeImpl<>("parentId");
    View<? extends BPMNViewDefinition> parentView = new ViewImpl<>(null, Bounds.create(parentX1, parentY1, parentX2, parentY2));
    parent.setContent(parentView);
    Edge<Child, Node> edge = new EdgeImpl("edgeId");
    edge.setContent(mock(Child.class));
    node.getInEdges().add(edge);
    edge.setSourceNode(parent);
    edge.setTargetNode(node);
    Result<SubProcessPropertyWriter> result = tested.convertSubProcess(node);
    assertTrue(result.isSuccess());
    AdHocSubProcess adHocSubProcess = (AdHocSubProcess) result.value().getElement();
    assertEquals(ELEMENT_ID, adHocSubProcess.getId());
    assertEquals(NAME, adHocSubProcess.getName());
    assertEquals(asCData(NAME), CustomElement.name.of(adHocSubProcess).get());
    assertEquals(asCData(DOCUMENTATION), adHocSubProcess.getDocumentation().get(0).getText());
    assertEquals(adHocOrdering, adHocSubProcess.getOrdering().getName());
    assertEquals(adHocAutostart, CustomElement.autoStart.of(adHocSubProcess).get());
    assertEquals(asCData(ACTIVATION_CONDITION), CustomElement.customActivationCondition.of(adHocSubProcess).get());
    assertEquals(Scripts.LANGUAGE.valueOf(COMPLETION_CONDITION.getLanguage().toUpperCase()).format(), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getLanguage());
    assertEquals(asCData(COMPLETION_CONDITION.getScript()), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getBody());
    assertEquals(ON_ENTRY_ACTION.getLanguage(), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage());
    assertEquals(asCData(ON_ENTRY_ACTION.getScript()), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript());
    assertEquals(ON_EXIT_ACTION.getLanguage(), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage());
    assertEquals(asCData(ON_EXIT_ACTION.getScript()), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript());
    assertVariables(Arrays.asList(new Pair<>("processVar1", "Object"), new Pair<>("processVar2", "Integer")), adHocSubProcess.getProperties());
    BPMNShape shape = result.value().getShape();
    assertEquals(parentX1 + nodeX1, shape.getBounds().getX(), 0);
    assertEquals(parentY1 + nodeY1, shape.getBounds().getY(), 0);
    assertEquals(nodeX2 - nodeX1, shape.getBounds().getWidth(), 0);
    assertEquals(nodeY2 - nodeY1, shape.getBounds().getHeight(), 0);
    assertBaseSubprocessExecutionSet(result.value());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) Node(org.kie.workbench.common.stunner.core.graph.Node) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Pair(org.uberfire.commons.data.Pair) Test(org.junit.Test)

Example 19 with ViewImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method testConvertEmbeddedSubprocess.

@Test
public void testConvertEmbeddedSubprocess() {
    final EmbeddedSubprocess definition = new EmbeddedSubprocess();
    setBaseSubprocessExecutionSetValues(definition.getExecutionSet());
    final View<EmbeddedSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    final Node<View<EmbeddedSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString());
    node.setContent(view);
    SubProcessPropertyWriter writer = tested.convertEmbeddedSubprocessNode(node);
    assertBaseSubprocessExecutionSet(writer);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) Test(org.junit.Test)

Example 20 with ViewImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.

the class AssignmentsEditorWidgetTest method testAssignments.

@SuppressWarnings("unchecked")
private void testAssignments(String encodedAssignments, List<Variable> expectedInputVariables, List<Variable> expectedOutputVariables, List<Pair<Variable, Variable>> expectedAssignments) {
    doCallRealMethod().when(widget).setValue(anyString());
    doCallRealMethod().when(widget).setValue(anyString(), anyBoolean());
    doCallRealMethod().when(widget).getProcessVariables();
    doCallRealMethod().when(widget).getSelectedElement();
    doCallRealMethod().when(widget).getSelectedElementUUID(anyObject());
    when(canvasSessionManager.getCurrentSession()).thenReturn(session);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getCanvasRootUUID()).thenReturn("rootId");
    when(widget.getParentIds()).thenReturn(new HashSet<>());
    when(diagram.getGraph()).thenReturn(graph);
    when(session.getSelectionControl()).thenReturn(selectionControl);
    List<String> selectedItems = Collections.singletonList("UUID");
    when(selectionControl.getSelectedItems()).thenReturn(selectedItems);
    BPMNDiagramImpl bpmnDiagram = new BPMNDiagramImpl();
    Node parentNode = new NodeImpl("PARENT_UUID");
    View parentNodeView = new ViewImpl(bpmnDiagram, Bounds.create());
    parentNode.setContent(parentNodeView);
    bpmnDiagram.getProcessData().getProcessVariables().setValue("processVar1:Object:,processVar2:Object:,processVar3:Object:,processVar4:Object:");
    Node node = new NodeImpl("UUID");
    Edge edge = new EdgeImpl("edge");
    Child child = mock(Child.class);
    edge.setContent(child);
    edge.setSourceNode(parentNode);
    node.getInEdges().add(edge);
    when(graph.getNode("UUID")).thenReturn(node);
    List<Element> nodes = Arrays.asList(node, parentNode);
    when(graph.nodes()).thenReturn(nodes);
    widget.setValue(encodedAssignments);
    widget.showDataIOEditor(SIMPLE_DATA_TYPES);
    verify(activityDataIOEditor).setAssignmentData(assignmentDataCaptor.capture());
    AssignmentData assignmentData = assignmentDataCaptor.getValue();
    verifyProcessVariables(assignmentData);
    assertVariables(expectedInputVariables, assignmentData.getInputVariables());
    assertVariables(expectedOutputVariables, assignmentData.getOutputVariables());
    assertAssignments(expectedAssignments, assignmentData.getAssignments());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) Element(org.kie.workbench.common.stunner.core.graph.Element) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Mockito.anyString(org.mockito.Mockito.anyString) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) AssignmentData(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentData)

Aggregations

ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)54 Test (org.junit.Test)40 View (org.kie.workbench.common.stunner.core.graph.content.view.View)35 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)35 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)17 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Before (org.junit.Before)11 Node (org.kie.workbench.common.stunner.core.graph.Node)10 QName (javax.xml.namespace.QName)9 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)9 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)9 ReusableSubprocess (org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess)9 TDecision (org.kie.dmn.model.v1_2.TDecision)7 BaseReusableSubprocess (org.kie.workbench.common.stunner.bpmn.definition.BaseReusableSubprocess)7 HashMap (java.util.HashMap)6 AdHocSubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter)6 CallActivityPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CallActivityPropertyWriter)6 PropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriter)6 SubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter)6 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)6