-
Notifications
You must be signed in to change notification settings - Fork 4
chore(code-conversion): fix sb code-examples #1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
ba60122
4c551dc
fb8a0f5
b1b9d98
cdedb4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
| * one or more contributor license agreements. See the NOTICE file distributed | ||
| * with this work for additional information regarding copyright ownership. | ||
| * Licensed under the Camunda License 1.0. You may not use this file | ||
| * except in compliance with the Camunda License 1.0. | ||
| */ | ||
| package org.camunda.conversion.execution_listeners; | ||
|
|
||
| import java.util.Map; | ||
| import org.camunda.bpm.engine.RuntimeService; | ||
| import org.camunda.bpm.engine.runtime.ProcessInstance; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| public class ExecutionListenerTestController { | ||
|
|
||
| private final RuntimeService runtimeService; | ||
|
|
||
| public ExecutionListenerTestController(RuntimeService runtimeService) { | ||
| this.runtimeService = runtimeService; | ||
| } | ||
|
|
||
| /** | ||
| * Start the execution-listener-test process with variable "foo". | ||
| * | ||
| * Usage: curl -X POST "http://localhost:8080/test/execution-listener?foo=bar" | ||
| */ | ||
| @PostMapping("/test/execution-listener") | ||
| public String startProcess(@RequestParam(name = "foo", defaultValue = "bar") String foo) { | ||
| ProcessInstance pi = runtimeService.startProcessInstanceByKey( | ||
| "execution-listener-test", | ||
| Map.of("foo", foo) | ||
| ); | ||
| return "Started process instance: " + pi.getId() + " with foo=" + foo; | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
| * one or more contributor license agreements. See the NOTICE file distributed | ||
| * with this work for additional information regarding copyright ownership. | ||
| * Licensed under the Camunda License 1.0. You may not use this file | ||
| * except in compliance with the Camunda License 1.0. | ||
| */ | ||
| package org.camunda.conversion.execution_listeners; | ||
|
|
||
| import org.camunda.bpm.engine.delegate.DelegateExecution; | ||
| import org.camunda.bpm.engine.delegate.ExecutionListener; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class MyExecutionListener implements ExecutionListener { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(MyExecutionListener.class); | ||
|
|
||
| @Override | ||
| public void notify(DelegateExecution execution) { | ||
| String someVar = (String) execution.getVariable("foo"); | ||
| LOG.info(">>> ExecutionListener triggered! foo = {}", someVar); | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" | ||
| xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" | ||
| xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" | ||
| xmlns:di="http://www.omg.org/spec/DD/20100524/DI" | ||
| xmlns:camunda="http://camunda.org/schema/1.0/bpmn" | ||
| id="Definitions_el_test" | ||
| targetNamespace="http://bpmn.io/schema/bpmn"> | ||
|
|
||
| <bpmn:process id="execution-listener-test" name="Execution Listener Test" isExecutable="true" camunda:historyTimeToLive="180"> | ||
|
|
||
| <bpmn:startEvent id="StartEvent_1"> | ||
| <bpmn:outgoing>Flow_1</bpmn:outgoing> | ||
| </bpmn:startEvent> | ||
|
|
||
| <bpmn:sequenceFlow id="Flow_1" sourceRef="StartEvent_1" targetRef="ServiceTask_1" /> | ||
|
|
||
| <bpmn:serviceTask id="ServiceTask_1" name="Task with Execution Listener" camunda:expression="${true}"> | ||
| <bpmn:extensionElements> | ||
| <camunda:executionListener event="start" delegateExpression="${myExecutionListener}" /> | ||
| </bpmn:extensionElements> | ||
| <bpmn:incoming>Flow_1</bpmn:incoming> | ||
| <bpmn:outgoing>Flow_2</bpmn:outgoing> | ||
| </bpmn:serviceTask> | ||
|
|
||
| <bpmn:sequenceFlow id="Flow_2" sourceRef="ServiceTask_1" targetRef="EndEvent_1" /> | ||
|
|
||
| <bpmn:endEvent id="EndEvent_1"> | ||
| <bpmn:incoming>Flow_2</bpmn:incoming> | ||
| </bpmn:endEvent> | ||
|
|
||
| </bpmn:process> | ||
|
|
||
| <bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
| <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="execution-listener-test"> | ||
| <bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1"> | ||
| <dc:Bounds x="179" y="99" width="36" height="36" /> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="ServiceTask_1_di" bpmnElement="ServiceTask_1"> | ||
| <dc:Bounds x="270" y="77" width="100" height="80" /> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="EndEvent_1_di" bpmnElement="EndEvent_1"> | ||
| <dc:Bounds x="432" y="99" width="36" height="36" /> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1"> | ||
| <di:waypoint x="215" y="117" /> | ||
| <di:waypoint x="270" y="117" /> | ||
| </bpmndi:BPMNEdge> | ||
| <bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2"> | ||
| <di:waypoint x="370" y="117" /> | ||
| <di:waypoint x="432" y="117" /> | ||
| </bpmndi:BPMNEdge> | ||
| </bpmndi:BPMNPlane> | ||
| </bpmndi:BPMNDiagram> | ||
| </bpmn:definitions> | ||
|
|
This file was deleted.
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙃 Maybe move
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Cleaned up the pom.xml file. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
| * one or more contributor license agreements. See the NOTICE file distributed | ||
| * with this work for additional information regarding copyright ownership. | ||
| * Licensed under the Camunda License 1.0. You may not use this file | ||
| * except in compliance with the Camunda License 1.0. | ||
| */ | ||
| package io.camunda.conversion.execution_listeners; | ||
|
|
||
| import io.camunda.client.CamundaClient; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| @RestController | ||
| public class ExecutionListenerTestController { | ||
|
|
||
| private final CamundaClient camundaClient; | ||
|
|
||
| public ExecutionListenerTestController(CamundaClient camundaClient) { | ||
| this.camundaClient = camundaClient; | ||
| } | ||
|
|
||
| /** | ||
| * Start the execution-listener-test process with variable "foo". | ||
| * | ||
| * Usage: curl -X POST "http://localhost:8080/test/execution-listener?foo=bar" | ||
| */ | ||
| @PostMapping("/test/execution-listener") | ||
| public String startProcess(@RequestParam(name = "foo", defaultValue = "bar") String foo) { | ||
| var result = camundaClient.newCreateInstanceCommand() | ||
| .bpmnProcessId("execution-listener-test") | ||
| .latestVersion() | ||
| .variables(Map.of("foo", foo)) | ||
| .send() | ||
| .join(); | ||
| return "Started process instance: " + result.getProcessInstanceKey() + " with foo=" + foo; | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
| * one or more contributor license agreements. See the NOTICE file distributed | ||
| * with this work for additional information regarding copyright ownership. | ||
| * Licensed under the Camunda License 1.0. You may not use this file | ||
| * except in compliance with the Camunda License 1.0. | ||
| */ | ||
| package io.camunda.conversion.execution_listeners; | ||
|
|
||
| import io.camunda.client.annotation.JobWorker; | ||
| import io.camunda.client.api.response.ActivatedJob; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| @Component | ||
| public class MyExecutionListener { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(MyExecutionListener.class); | ||
|
|
||
| @JobWorker(type = "myExecutionListener", autoComplete = true) | ||
| public Map<String, Object> executeJobMigrated(ActivatedJob job) throws Exception { | ||
| Map<String, Object> resultMap = new HashMap<>(); | ||
| String someVar = (String) job.getVariable("foo"); | ||
| LOG.info(">>> Migrated JobWorker triggered! foo = {}", someVar); | ||
| return resultMap; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" | ||
| xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" | ||
| xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" | ||
| xmlns:di="http://www.omg.org/spec/DD/20100524/DI" | ||
| xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" | ||
| id="Definitions_el_test" | ||
| targetNamespace="http://bpmn.io/schema/bpmn" | ||
| exporter="Camunda Modeler" | ||
| exporterVersion="5.25.0"> | ||
|
|
||
| <bpmn:process id="execution-listener-test" name="Execution Listener Test" isExecutable="true"> | ||
|
|
||
| <bpmn:startEvent id="StartEvent_1"> | ||
| <bpmn:outgoing>Flow_1</bpmn:outgoing> | ||
| </bpmn:startEvent> | ||
|
|
||
| <bpmn:sequenceFlow id="Flow_1" sourceRef="StartEvent_1" targetRef="ServiceTask_1" /> | ||
|
|
||
| <bpmn:serviceTask id="ServiceTask_1" name="Migrated Execution Listener"> | ||
| <bpmn:extensionElements> | ||
| <zeebe:taskDefinition type="myExecutionListener" /> | ||
| </bpmn:extensionElements> | ||
| <bpmn:incoming>Flow_1</bpmn:incoming> | ||
| <bpmn:outgoing>Flow_2</bpmn:outgoing> | ||
| </bpmn:serviceTask> | ||
|
|
||
| <bpmn:sequenceFlow id="Flow_2" sourceRef="ServiceTask_1" targetRef="EndEvent_1" /> | ||
|
|
||
| <bpmn:endEvent id="EndEvent_1"> | ||
| <bpmn:incoming>Flow_2</bpmn:incoming> | ||
| </bpmn:endEvent> | ||
|
|
||
| </bpmn:process> | ||
|
|
||
| <bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
| <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="execution-listener-test"> | ||
| <bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1"> | ||
| <dc:Bounds x="179" y="99" width="36" height="36" /> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="ServiceTask_1_di" bpmnElement="ServiceTask_1"> | ||
| <dc:Bounds x="270" y="77" width="100" height="80" /> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="EndEvent_1_di" bpmnElement="EndEvent_1"> | ||
| <dc:Bounds x="432" y="99" width="36" height="36" /> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1"> | ||
| <di:waypoint x="215" y="117" /> | ||
| <di:waypoint x="270" y="117" /> | ||
| </bpmndi:BPMNEdge> | ||
| <bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2"> | ||
| <di:waypoint x="370" y="117" /> | ||
| <di:waypoint x="432" y="117" /> | ||
| </bpmndi:BPMNEdge> | ||
| </bpmndi:BPMNPlane> | ||
| </bpmndi:BPMNDiagram> | ||
| </bpmn:definitions> | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
| * one or more contributor license agreements. See the NOTICE file distributed | ||
| * with this work for additional information regarding copyright ownership. | ||
| * Licensed under the Camunda License 1.0. You may not use this file | ||
| * except in compliance with the Camunda License 1.0. | ||
| */ | ||
| package io.camunda.conversion.execution_listeners; | ||
|
|
||
| import static io.camunda.process.test.api.assertions.ProcessInstanceSelectors.byProcessId; | ||
|
|
||
| import io.camunda.client.CamundaClient; | ||
| import io.camunda.process.test.api.CamundaAssert; | ||
| import io.camunda.process.test.api.CamundaSpringProcessTest; | ||
| import java.util.Map; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
|
|
||
| @SpringBootTest | ||
| @CamundaSpringProcessTest | ||
| class MyExecutionListenerTest { | ||
|
|
||
| @Autowired | ||
| private CamundaClient camundaClient; | ||
|
|
||
| @Test | ||
| void shouldExecuteMigratedExecutionListener() { | ||
| // given: deploy and start process with variable "foo" | ||
| camundaClient.newCreateInstanceCommand() | ||
| .bpmnProcessId("execution-listener-test") | ||
| .latestVersion() | ||
| .variables(Map.of("foo", "bar")) | ||
| .send() | ||
| .join(); | ||
|
|
||
| // then: the process completes (the @JobWorker handles the service task) | ||
| CamundaAssert.assertThat(byProcessId("execution-listener-test")).isCompleted(); | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| spring.application.name=Process payments | ||
|
|
||
| # Connection properties are managed by @CamundaSpringProcessTest / Testcontainers | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Do we want to delete mvnw* in camunda-8 directory too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Removed files