Search in sources :

Example 76 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class JBPMBpmn2ResourceFactory method createAndInitResource.

/*
     *
     * Creates a new BpmnResourceImpl and initializes it.
     *
     * The method creates a DocumentRoot and a Definitions element, as both are
     * mandatory.
     */
public Definitions createAndInitResource(URI uri) {
    DroolsFactoryImpl.init();
    BpsimFactoryImpl.init();
    Resource resource = createResource(uri);
    Bpmn2Factory factory = Bpmn2Factory.eINSTANCE;
    Definitions definitions = factory.createDefinitions();
    DocumentRoot docummentRoot = factory.createDocumentRoot();
    docummentRoot.setDefinitions(definitions);
    resource.getContents().add(docummentRoot);
    return definitions;
}
Also used : Bpmn2Factory(org.eclipse.bpmn2.Bpmn2Factory) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) Definitions(org.eclipse.bpmn2.Definitions) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 77 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class AssociationsTest method marshallAssociations.

@Test
public void marshallAssociations() throws Exception {
    Diagram<Graph, Metadata> d = unmarshall(marshaller, BPMN_FILE_PATH);
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(d.getGraph());
    Definitions definitions = definitionsConverter.toDefinitions();
    Process p = (Process) definitions.getRootElements().get(0);
    org.eclipse.bpmn2.UserTask flowElement = (org.eclipse.bpmn2.UserTask) p.getFlowElements().stream().filter(e -> e.getId().equals(TASK_ID)).findFirst().get();
    List<DataInputAssociation> associations = flowElement.getDataInputAssociations();
    assertEquals("myprocvar", findVar(associations, "From"));
    assertEquals("<![CDATA[HELLO]]>", findAssignment(associations, "Body"));
}
Also used : StartEvent(org.eclipse.bpmn2.StartEvent) FormalExpression(org.eclipse.bpmn2.FormalExpression) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) View(org.kie.workbench.common.stunner.core.graph.content.view.View) HashSet(java.util.HashSet) DataInput(org.eclipse.bpmn2.DataInput) Property(org.eclipse.bpmn2.Property) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Definitions(org.eclipse.bpmn2.Definitions) Ids(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Ids) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Process(org.eclipse.bpmn2.Process) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) Test(org.junit.Test) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) List(java.util.List) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Assignment(org.eclipse.bpmn2.Assignment) CatchEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CatchEventPropertyWriter) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest) Node(org.kie.workbench.common.stunner.core.graph.Node) TestCase.assertEquals(junit.framework.TestCase.assertEquals) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Test(org.junit.Test) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest)

Example 78 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method setUp.

@Before
public void setUp() {
    Definitions definitions = bpmn2.createDefinitions();
    definitions.getRootElements().add(bpmn2.createProcess());
    BPMNDiagram bpmnDiagram = di.createBPMNDiagram();
    bpmnDiagram.setPlane(di.createBPMNPlane());
    definitions.getDiagrams().add(bpmnDiagram);
    definitionResolver = new DefinitionResolver(definitions, Collections.emptyList());
    Node adHocNode = new NodeImpl("");
    View<AdHocSubprocess> adHocContent = new ViewImpl<>(new AdHocSubprocess(), Bounds.create());
    adHocNode.setContent(adHocContent);
    Node multipleInstanceNode = new NodeImpl("");
    View<MultipleInstanceSubprocess> miContent = new ViewImpl<>(new MultipleInstanceSubprocess(), Bounds.create());
    multipleInstanceNode.setContent(miContent);
    Node embeddedNode = new NodeImpl("");
    View<EmbeddedSubprocess> embeddedContent = new ViewImpl<>(new EmbeddedSubprocess(), Bounds.create());
    embeddedNode.setContent(embeddedContent);
    Node eventNode = new NodeImpl("");
    View<EventSubprocess> eventSubprocess = new ViewImpl<>(new EventSubprocess(), Bounds.create());
    eventNode.setContent(eventSubprocess);
    FactoryManager factoryManager = mock(FactoryManager.class);
    when(factoryManager.newElement(any(), eq(getDefinitionId(AdHocSubprocess.class)))).thenReturn(adHocNode);
    when(factoryManager.newElement(any(), eq(getDefinitionId(MultipleInstanceSubprocess.class)))).thenReturn(multipleInstanceNode);
    when(factoryManager.newElement(any(), eq(getDefinitionId(EmbeddedSubprocess.class)))).thenReturn(embeddedNode);
    when(factoryManager.newElement(any(), eq(getDefinitionId(EventSubprocess.class)))).thenReturn(eventNode);
    TypedFactoryManager typedFactoryManager = new TypedFactoryManager(factoryManager);
    tested = new SubProcessConverter(typedFactoryManager, new PropertyReaderFactory(definitionResolver), definitionResolver, new ConverterFactory(definitionResolver, typedFactoryManager));
}
Also used : TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Definitions(org.eclipse.bpmn2.Definitions) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) Node(org.kie.workbench.common.stunner.core.graph.Node) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) PropertyReaderFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) MultipleInstanceSubprocess(org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) Before(org.junit.Before)

Example 79 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class AdHocSubProcessPropertyReaderTest method setUp.

@Before
public void setUp() {
    Definitions definitions = bpmn2.createDefinitions();
    definitions.getRootElements().add(bpmn2.createProcess());
    BPMNDiagram bpmnDiagram = di.createBPMNDiagram();
    bpmnDiagram.setPlane(di.createBPMNPlane());
    definitions.getDiagrams().add(bpmnDiagram);
    definitionResolverReal = new DefinitionResolver(definitions, Collections.emptyList());
    propertyReader = new AdHocSubProcessPropertyReader(process, diagram, definitionResolver);
}
Also used : BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) Definitions(org.eclipse.bpmn2.Definitions) Before(org.junit.Before)

Example 80 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class RootProcessConverterTest method setUp.

@Before
@SuppressWarnings("all")
public void setUp() {
    Definitions definitions = bpmn2.createDefinitions();
    process = bpmn2.createProcess();
    definitions.getRootElements().add(process);
    BPMNDiagram bpmnDiagram = di.createBPMNDiagram();
    bpmnDiagram.setPlane(di.createBPMNPlane());
    definitions.getDiagrams().add(bpmnDiagram);
    ElementDefinition.getExtensionElements(process).add(DefaultImportsElement.extensionOf(new DefaultImport(getClass().getName())));
    definitionResolver = new DefinitionResolver(definitions, Collections.emptyList());
    Node node = new NodeImpl("");
    View<BPMNDiagramImpl> content = new ViewImpl<>(new BPMNDiagramImpl(), Bounds.create());
    node.setContent(content);
    FactoryManager factoryManager = mock(FactoryManager.class);
    when(factoryManager.newElement(any(), eq(getDefinitionId(BPMNDiagramImpl.class)))).thenReturn(node);
    TypedFactoryManager typedFactoryManager = new TypedFactoryManager(factoryManager);
    tested = new RootProcessConverter(typedFactoryManager, new PropertyReaderFactory(definitionResolver), definitionResolver, new ConverterFactory(definitionResolver, typedFactoryManager));
}
Also used : TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Definitions(org.eclipse.bpmn2.Definitions) Node(org.kie.workbench.common.stunner.core.graph.Node) PropertyReaderFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) DefaultImport(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.DefaultImport) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)43 Definitions (org.eclipse.bpmn2.Definitions)42 Definitions (org.kie.dmn.model.api.Definitions)32 TDefinitions (org.kie.dmn.model.v1_1.TDefinitions)31 DecisionNodeImpl (org.kie.dmn.core.ast.DecisionNodeImpl)28 DMNModelImpl (org.kie.dmn.core.impl.DMNModelImpl)28 List (java.util.List)27 DMNResult (org.kie.dmn.api.core.DMNResult)27 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)27 ArrayList (java.util.ArrayList)23 HashMap (java.util.HashMap)23 Collectors (java.util.stream.Collectors)22 DMNModel (org.kie.dmn.api.core.DMNModel)22 Map (java.util.Map)21 Logger (org.slf4j.Logger)21 LoggerFactory (org.slf4j.LoggerFactory)21 Arrays (java.util.Arrays)20 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 Collection (java.util.Collection)19 Collections (java.util.Collections)19