Search in sources :

Example 6 with PropertyWriterFactory

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method testPostConvertNodes.

@Test
@SuppressWarnings("unchecked")
public void testPostConvertNodes() {
    TestingGraphMockHandler graphTestHandler = new TestingGraphMockHandler();
    BPMNDiagramImpl bpmnDiagram = new BPMNDiagramImpl();
    StartNoneEvent level0StartNode = new StartNoneEvent();
    EndNoneEvent level0EndNode = new EndNoneEvent();
    UserTask level0Node1 = new UserTask();
    UserTask level0Node2 = new UserTask();
    EmbeddedSubprocess level1SubProcess1 = new EmbeddedSubprocess();
    ScriptTask level1Node1 = new ScriptTask();
    IntermediateSignalEventThrowing level1Node2 = new IntermediateSignalEventThrowing();
    AdHocSubprocess level2SubProcess1 = new AdHocSubprocess();
    BusinessRuleTask level2Node1 = new BusinessRuleTask();
    EndCompensationEvent level2Node2 = new EndCompensationEvent();
    TestingGraphInstanceBuilder2.Level2Graph level2Graph = TestingGraphInstanceBuilder2.buildLevel2Graph(graphTestHandler, bpmnDiagram, level0StartNode, level0Node1, level0Node2, level0EndNode, level1SubProcess1, level1Node1, level1Node2, level2SubProcess1, level2Node1, level2Node2);
    DefinitionsBuildingContext ctx = new DefinitionsBuildingContext(level2Graph.graph);
    PropertyWriterFactory writerFactory = new PropertyWriterFactory();
    ConverterFactory factory = spy(new ConverterFactory(ctx, writerFactory));
    FlowElementPostConverter flowElementPostConverter = mock(FlowElementPostConverter.class);
    when(factory.flowElementPostConverter()).thenReturn(flowElementPostConverter);
    MyProcessConverter abstractProcessConverter = new MyProcessConverter(factory);
    ProcessPropertyWriter processWriter = writerFactory.of(bpmn2.createProcess());
    abstractProcessConverter.postConvertChildNodes(processWriter, ctx);
    verify(flowElementPostConverter, times(10)).postConvert(anyObject(), anyObject(), nodeCaptor.capture());
    Map<String, BPMNViewDefinition> nodes = new HashMap<>();
    nodes.put(LEVEL0_START_NODE.uuid(), level0StartNode);
    nodes.put(LEVEL0_NODE1.uuid(), level0Node1);
    nodes.put(LEVEL0_NODE2.uuid(), level0Node2);
    nodes.put(LEVEL0_END_NODE.uuid(), level0EndNode);
    nodes.put(LEVEL1_SUB_PROCESS1.uuid(), level1SubProcess1);
    nodes.put(LEVEL1_NODE1.uuid(), level1Node1);
    nodes.put(LEVEL1_NODE2.uuid(), level1Node2);
    nodes.put(LEVEL2_SUB_PROCESS1.uuid(), level2SubProcess1);
    nodes.put(LEVEL2_NODE1.uuid(), level2Node1);
    nodes.put(LEVEL2_NODE2.uuid(), level2Node2);
    assertEquals(nodes.size(), nodeCaptor.getAllValues().size());
    nodes.entrySet().forEach(entry -> {
        Optional<Node<View<? extends BPMNViewDefinition>, ?>> processed = nodeCaptor.getAllValues().stream().filter(captured -> entry.getKey().equals(captured.getUUID())).findFirst();
        assertTrue("Node: " + entry.getKey() + " was not present in result", processed.isPresent());
        assertEquals(entry.getValue(), processed.get().getContent().getDefinition());
    });
}
Also used : IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) LEVEL2_SUB_PROCESS1(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL2_SUB_PROCESS1) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) Map(java.util.Map) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) ArgumentMatchers.anyObject(org.mockito.ArgumentMatchers.anyObject) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) LEVEL0_START_NODE(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL0_START_NODE) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) LEVEL1_NODE2(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL1_NODE2) Optional(java.util.Optional) Dock(org.kie.workbench.common.stunner.core.graph.content.relationship.Dock) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Node(org.kie.workbench.common.stunner.core.graph.Node) Assertions.assertThatCode(org.assertj.core.api.Assertions.assertThatCode) Mockito.mock(org.mockito.Mockito.mock) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) ProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ProcessPropertyWriter) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) LEVEL1_NODE1(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL1_NODE1) LEVEL1_SUB_PROCESS1(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL1_SUB_PROCESS1) Mockito.spy(org.mockito.Mockito.spy) Captor(org.mockito.Captor) FlowElementPostConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.FlowElementPostConverter) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TestingGraphInstanceBuilder2(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2) ArgumentCaptor(org.mockito.ArgumentCaptor) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) EndCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.EndCompensationEvent) IntermediateSignalEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventThrowing) LEVEL2_NODE1(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL2_NODE1) LEVEL2_NODE2(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL2_NODE2) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) LEVEL0_NODE2(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL0_NODE2) LEVEL0_END_NODE(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL0_END_NODE) LEVEL0_NODE1(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2.NODES.LEVEL0_NODE1) GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) Assert.assertEquals(org.junit.Assert.assertEquals) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) HashMap(java.util.HashMap) Node(org.kie.workbench.common.stunner.core.graph.Node) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) FlowElementPostConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.FlowElementPostConverter) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) IntermediateSignalEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventThrowing) EndCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.EndCompensationEvent) TestingGraphInstanceBuilder2(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder2) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) ProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ProcessPropertyWriter) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) Test(org.junit.Test)

Example 7 with PropertyWriterFactory

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method convertDockedEdges.

@Test
public void convertDockedEdges() {
    GraphNodeStoreImpl nodes = new GraphNodeStoreImpl();
    GraphImpl g = new GraphImpl("g", nodes);
    NodeImpl<Object> root = new NodeImpl<>("root");
    BPMNDiagramImpl bpmnDiagram = new BPMNDiagramImpl();
    root.setContent(new ViewImpl<>(bpmnDiagram, Bounds.create()));
    g.addNode(root);
    NodeImpl<Object> n = new NodeImpl<>("n");
    EmbeddedSubprocess subProcessNode = new EmbeddedSubprocess();
    n.setContent(new ViewImpl<>(subProcessNode, Bounds.create()));
    g.addNode(n);
    NodeImpl<Object> e = new NodeImpl<>("e");
    IntermediateErrorEventCatching intermediateErrorEventCatching = new IntermediateErrorEventCatching();
    e.setContent(new ViewImpl<>(intermediateErrorEventCatching, Bounds.create()));
    g.addNode(e);
    EdgeImpl<Object> edge = new EdgeImpl<>("edge");
    Dock dock = new Dock();
    edge.setContent(dock);
    n.getOutEdges().add(edge);
    edge.setSourceNode(n);
    e.getInEdges().add(edge);
    edge.setTargetNode(e);
    DefinitionsBuildingContext ctx = new DefinitionsBuildingContext(g);
    PropertyWriterFactory pwFactory = new PropertyWriterFactory();
    ConverterFactory factory = new ConverterFactory(ctx, pwFactory);
    MyProcessConverter abstractProcessConverter = new MyProcessConverter(factory);
    ProcessPropertyWriter p = pwFactory.of(bpmn2.createProcess());
    assertThatCode(() -> {
        abstractProcessConverter.convertChildNodes(p, ctx);
        abstractProcessConverter.convertEdges(p, ctx);
    }).doesNotThrowAnyException();
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) ProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ProcessPropertyWriter) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) Dock(org.kie.workbench.common.stunner.core.graph.content.relationship.Dock) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) ArgumentMatchers.anyObject(org.mockito.ArgumentMatchers.anyObject) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Test(org.junit.Test)

Example 8 with PropertyWriterFactory

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.

the class IntermediateThrowEventConverterTest method setUp.

@Before
public void setUp() {
    Event throwEvent = bpmn2.createIntermediateThrowEvent();
    throwEvent.setId("throwEventID");
    throwEventPropertyWriter = spy(new ThrowEventPropertyWriter((ThrowEvent) throwEvent, new FlatVariableScope(), new HashSet<>()));
    propertyWriterFactory = spy(PropertyWriterFactory.class);
    when(propertyWriterFactory.of(any(ThrowEvent.class))).thenReturn(throwEventPropertyWriter);
    generalSet = new BPMNGeneralSet(NAME, DOCUMENTATION);
    assignmentsInfo = new AssignmentsInfo(ASSIGNMENTS_INFO);
    dataIOSet = new DataIOSet(assignmentsInfo);
    advancedData = new AdvancedData();
    signalRef = mock(SignalRef.class);
    signalScope = mock(SignalScope.class);
    linkRef = mock(LinkRef.class);
    messageRef = mock(MessageRef.class);
    escalationRef = mock(EscalationRef.class);
    tested = spy(new IntermediateThrowEventConverter(propertyWriterFactory));
}
Also used : ThrowEvent(org.eclipse.bpmn2.ThrowEvent) SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) AdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData) ThrowEvent(org.eclipse.bpmn2.ThrowEvent) BaseThrowingIntermediateEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseThrowingIntermediateEvent) Event(org.eclipse.bpmn2.Event) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) SignalScope(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalScope) EscalationRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.escalation.EscalationRef) ThrowEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ThrowEventPropertyWriter) LinkRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.link.LinkRef) Before(org.junit.Before)

Example 9 with PropertyWriterFactory

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method setUp.

@Before
public void setUp() {
    PropertyWriterFactory factory = new PropertyWriterFactory();
    DefinitionsBuildingContext definitionsBuildingContext = new DefinitionsBuildingContext(new GraphImpl("x", new GraphNodeStoreImpl()));
    tested = new SubProcessConverter(definitionsBuildingContext, factory, new ConverterFactory(definitionsBuildingContext, factory));
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) Before(org.junit.Before)

Example 10 with PropertyWriterFactory

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method JBPM_7525_eventSubProcessShouldStoreIsAsync.

@Test
public void JBPM_7525_eventSubProcessShouldStoreIsAsync() {
    ConverterFactory f = new ConverterFactory(new DefinitionsBuildingContext(new GraphImpl("x", new GraphNodeStoreImpl())), new PropertyWriterFactory());
    SubProcessConverter c = f.subProcessConverter();
    NodeImpl<View<? extends BPMNViewDefinition>> n = new NodeImpl<>("n");
    EventSubprocess subProcessNode = new EventSubprocess();
    subProcessNode.getExecutionSet().setIsAsync(new IsAsync(true));
    n.setContent(new ViewImpl<>(subProcessNode, Bounds.create()));
    Activity activity = c.convertSubProcess(n).value().getFlowElement();
    Boolean value = CustomElement.async.of(activity).get();
    assertThat(value).isEqualTo(true);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) Activity(org.eclipse.bpmn2.Activity) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) View(org.kie.workbench.common.stunner.core.graph.content.view.View) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) IsAsync(org.kie.workbench.common.stunner.bpmn.definition.property.task.IsAsync) Test(org.junit.Test)

Aggregations

PropertyWriterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)12 Test (org.junit.Test)8 ConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory)5 DefinitionsBuildingContext (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext)5 SLADueDate (org.kie.workbench.common.stunner.bpmn.definition.property.general.SLADueDate)5 GraphImpl (org.kie.workbench.common.stunner.core.graph.impl.GraphImpl)5 GraphNodeStoreImpl (org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl)5 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)4 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)4 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)4 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)4 AdvancedData (org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData)4 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)4 Definitions (org.eclipse.bpmn2.Definitions)3 Before (org.junit.Before)3 Event (org.eclipse.bpmn2.Event)2 FlatVariableScope (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope)2 ProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ProcessPropertyWriter)2 BPMNViewDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition)2 EmbeddedSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)2