Search in sources :

Example 11 with BPMNDiagramImpl

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

the class ProcessVariableProviderTest method mockRootNode.

private Element mockRootNode(String processVariables) {
    BPMNDiagramImpl rootNode = new BPMNDiagramImpl();
    rootNode.setProcessData(new ProcessData(new ProcessVariables(processVariables)));
    return mockNode(rootNode);
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData)

Example 12 with BPMNDiagramImpl

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

the class BPMNDiagramMarshallerTest method testUnmarshallProcessVariables.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessVariables() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
    assertDiagram(diagram, 8);
    assertEquals("ProcessVariables", diagram.getMetadata().getTitle());
    ProcessVariables variables = 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 BPMNDiagram) {
                BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
                variables = bpmnDiagram.getProcessData().getProcessVariables();
                break;
            }
        }
    }
    assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
    Node<? extends Definition, ?> diagramNode = diagram.getGraph().getNode("_luRBMdEjEeWXpsZ1tNStKQ");
    assertTrue(diagramNode.getContent().getDefinition() instanceof BPMNDiagram);
    BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) diagramNode.getContent().getDefinition();
    assertTrue(bpmnDiagram.getProcessData() != null);
    assertTrue(bpmnDiagram.getProcessData().getProcessVariables() != null);
    variables = bpmnDiagram.getProcessData().getProcessVariables();
    assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Graph(org.kie.workbench.common.stunner.core.graph.Graph) 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) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 13 with BPMNDiagramImpl

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

the class BPMNDiagramMarshallerTest method testUnmarshallProcessProperties.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessProperties() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSPROPERTIES);
    assertDiagram(diagram, 4);
    assertEquals("BPSimple", diagram.getMetadata().getTitle());
    DiagramSet diagramProperties = 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 BPMNDiagram) {
                BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
                diagramProperties = bpmnDiagram.getDiagramSet();
                break;
            }
        }
    }
    assertEquals("BPSimple", diagramProperties.getName().getValue());
    assertEquals("This is a\n" + "simple\n" + "process", diagramProperties.getDocumentation().getValue());
    assertEquals("JDLProj.BPSimple", diagramProperties.getId().getValue());
    assertEquals("org.jbpm", diagramProperties.getPackageProperty().getValue());
    assertEquals(Boolean.valueOf(true), diagramProperties.getExecutable().getValue());
    assertEquals(Boolean.valueOf(true), diagramProperties.getAdHoc().getValue());
    assertEquals("This is the\n" + "Process\n" + "Instance\n" + "Description", diagramProperties.getProcessInstanceDescription().getValue());
}
Also used : BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Graph(org.kie.workbench.common.stunner.core.graph.Graph) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) 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) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 14 with BPMNDiagramImpl

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

the class BPMNDiagramTest method testNameInvalid.

@Test
public void testNameInvalid() {
    BPMNDiagramImpl BPMNDiagramImpl = createValidBpmnDiagram();
    BPMNDiagramImpl.getDiagramSet().setName(new Name(NAME_INVALID));
    Set<ConstraintViolation<BPMNDiagramImpl>> violations = this.validator.validate(BPMNDiagramImpl);
    assertEquals(1, violations.size());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) Test(org.junit.Test)

Example 15 with BPMNDiagramImpl

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

the class BPMNDiagramTest method createValidBpmnDiagram.

public BPMNDiagramImpl createValidBpmnDiagram() {
    BPMNDiagramImpl BPMNDiagramImpl = new BPMNDiagramImpl.BPMNDiagramBuilder().build();
    DiagramSet diagramSet = BPMNDiagramImpl.getDiagramSet();
    diagramSet.setName(new Name(NAME_VALID));
    diagramSet.setId(new Id(ID_VALID));
    diagramSet.setPackageProperty(new Package(PACKAGE_VALID));
    diagramSet.setVersion(new Version(VERSION_VALID));
    return BPMNDiagramImpl;
}
Also used : Version(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Version) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Id(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Id) Package(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Package) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Aggregations

BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)16 Test (org.junit.Test)9 ProcessVariables (org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables)7 View (org.kie.workbench.common.stunner.core.graph.content.view.View)7 ConstraintViolation (javax.validation.ConstraintViolation)5 BPMNDiagram (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram)5 DiagramSet (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet)5 Element (org.kie.workbench.common.stunner.core.graph.Element)5 FlowElement (org.eclipse.bpmn2.FlowElement)4 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)4 RootElement (org.eclipse.bpmn2.RootElement)4 ProcessData (org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData)4 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)4 Graph (org.kie.workbench.common.stunner.core.graph.Graph)4 Id (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Id)3 Package (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Package)3 Version (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Version)3 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)3 ArrayList (java.util.ArrayList)1 Process (org.eclipse.bpmn2.Process)1