Skip to content

Commit

Permalink
update camunda API to 7.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bespaltovyj committed Dec 26, 2021
1 parent ba35be5 commit b3376f4
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 58 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Requirements

1. Project complied with Camunda version 7.13.
1. Project complied with Camunda version 7.14.
2. Spring Boot 2.5.2
3. Kotlin version 1.5

Expand All @@ -18,14 +18,14 @@ Add dependency in gradle
implementation(group = "ru.tinkoff.top", name = "camunda-delegator-spring-boot-starter", version = "version")
```

Activate library by camunda plugin `BpmnParserCamundaPlugin` with other plugins
Activate library by camunda plugin `DelegatorBpmnParserCamundaPlugin` with other plugins

```kotlin
@Bean
fun processEngineConfiguration(
processEnginePlugins: List<ProcessEnginePlugin>
): SpringProcessEngineConfiguration {
val customEngine = SpringProcessEngineBpmnParseConfiguration()
val customEngine = SpringProcessEngineConfiguration()
return CamundaSpringBootUtil.initCustomFields(customEngine).also {
it.isJobExecutorActivate = false
it.processEnginePlugins.add(CompositeProcessEnginePlugin(processEnginePlugins))
Expand All @@ -43,11 +43,11 @@ or
@Qualifier(DELEGATOR_BPMN_PARSE_FACTORY)
delegatorBpmnParseFactory: BpmnParseFactory
): SpringProcessEngineConfiguration {
val customEngine = SpringProcessEngineBpmnParseConfiguration()
val customEngine = SpringProcessEngineConfiguration()
return CamundaSpringBootUtil.initCustomFields(customEngine).also {
it.isJobExecutorActivate = false
it.processEnginePlugins.add(
BpmnParserCamundaPlugin(delegatorExpressionManager, delegatorBpmnParseFactory)
DelegatorBpmnParserCamundaPlugin(delegatorExpressionManager, delegatorBpmnParseFactory)
)
}
}
Expand Down
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ subprojects {

testImplementation("com.h2database:h2")
testImplementation("org.assertj:assertj-core")
testImplementation("org.mockito.kotlin:mockito-kotlin:3.2.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:4.0.0")
testImplementation("org.camunda.bpm:camunda-engine:$camundaVersion")
testImplementation("org.camunda.bpm:camunda-engine-spring:$camundaVersion")
testImplementation("org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-test:$camundaVersion")
testImplementation("org.camunda.bpm.assert:camunda-bpm-assert:8.0.0")
testImplementation("org.camunda.bpm.extension.mockito:camunda-bpm-mockito:5.14.0")
testImplementation("org.camunda.bpm.assert:camunda-bpm-assert:13.0.0")
testImplementation("org.camunda.bpm.extension.mockito:camunda-bpm-mockito:5.16.0")
testImplementation("org.camunda.bpm.extension:camunda-bpm-process-test-coverage:0.4.0")
testImplementation("io.kotest:kotest-assertions-core:4.6.0")
testImplementation("io.kotest:kotest-assertions-core-jvm:5.0.3")


testImplementation(group = "org.junit.jupiter", name = "junit-jupiter-api")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object Versions {
const val KOTLIN = "1.5.31"
const val CAMUNDA = "7.13.0"
const val CAMUNDA = "7.14.0"
const val DETEKT = "1.18.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.camunda.bpm.engine.runtime.ProcessInstance
import org.camunda.bpm.engine.test.Deployment
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.assertThat
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.runtimeService
import org.camunda.bpm.extension.process_test_coverage.junit.rules.ProcessCoverageInMemProcessEngineConfiguration
import org.camunda.bpm.extension.process_test_coverage.junit.rules.TestCoverageProcessEngineRule
import org.camunda.bpm.extension.process_test_coverage.junit.rules.TestCoverageProcessEngineRuleBuilder
import org.junit.Before
Expand All @@ -28,8 +29,8 @@ class DemoProcessTest {
DelegateExecutorImpl()
)

private val camundaConfiguration = TestCamundaConfiguration().also {
it.setBpmnParseFactory(DefaultDelegatorBpmnParseFactory())
private val camundaConfiguration = ProcessCoverageInMemProcessEngineConfiguration().also {
it.bpmnParseFactory = DefaultDelegatorBpmnParseFactory()
}

@Rule
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import org.camunda.bpm.engine.impl.el.ExpressionManager
/**
* Registers delegatorBpmnParseFactory as BpmnParseFactor and delegatorExpressionManager.
*/
@Deprecated(
"The class is left to support older versions of camunda. Will be removed in future releases",
replaceWith = ReplaceWith(
expression = "DelegatorBpmnParserCamundaPlugin",
imports = ["ru.tinkoff.top.camunda.delegator.config.DelegatorBpmnParserCamundaPlugin"]
)
)
class BpmnParserCamundaPlugin(
private val delegatorExpressionManager: ExpressionManager,
private val delegatorBpmnParseFactory: BpmnParseFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ru.tinkoff.top.camunda.delegator.config

import mu.KLogging
import org.camunda.bpm.engine.ProcessEngine
import org.camunda.bpm.engine.impl.cfg.BpmnParseFactory
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl
import org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin
import org.camunda.bpm.engine.impl.el.ExpressionManager

/**
* Registers delegatorBpmnParseFactory as BpmnParseFactor and delegatorExpressionManager.
*/
class DelegatorBpmnParserCamundaPlugin(
private val delegatorExpressionManager: ExpressionManager,
private val delegatorBpmnParseFactory: BpmnParseFactory
) : ProcessEnginePlugin {

companion object : KLogging()

override fun preInit(processEngineConfiguration: ProcessEngineConfigurationImpl) {
logger.info { "Bpm parser camunda plugin is started" }

with(processEngineConfiguration) {
expressionManager = delegatorExpressionManager
bpmnParseFactory = delegatorBpmnParseFactory
}
}

override fun postProcessEngineBuild(processEngine: ProcessEngine?) = Unit

override fun postInit(processEngineConfiguration: ProcessEngineConfigurationImpl?) = Unit
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.tinkoff.top.camunda.delegator.config

import org.camunda.bpm.engine.impl.cfg.BpmnParseFactory
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl
import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration

/**
Expand All @@ -10,13 +11,21 @@ import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration
*
* @author p.pletnev
* */
@Deprecated(
"Since version 7.14, assessors for bpmnParseFactory have been added to the ProcessEngineConfigurationImpl",
replaceWith = ReplaceWith(
expression = "SpringProcessEngineConfiguration",
imports = ["org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration"]
)
)
open class SpringProcessEngineBpmnParseConfiguration : SpringProcessEngineConfiguration() {

fun getBpmnParseFactory(): BpmnParseFactory {
override fun getBpmnParseFactory(): BpmnParseFactory {
return bpmnParseFactory
}

fun setBpmnParseFactory(bpmnParseFactory: BpmnParseFactory) {
override fun setBpmnParseFactory(bpmnParseFactory: BpmnParseFactory): ProcessEngineConfigurationImpl {
this.bpmnParseFactory = bpmnParseFactory
return this
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ru.tinkoff.top.camunda.delegator.example

import org.camunda.bpm.engine.delegate.DelegateExecution
import org.camunda.bpm.engine.delegate.JavaDelegate

class CamundaJavaDelegate : JavaDelegate {
override fun execute(execution: DelegateExecution) {
execution.setVariable("javaDelegateVariableName", "javaDelegateVariableValue")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package ru.tinkoff.top.camunda.delegator.process

import org.camunda.bpm.engine.test.Deployment
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.assertThat
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.complete
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.execute
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.externalTask
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.job
import org.camunda.bpm.engine.test.mock.Mocks
import org.camunda.bpm.extension.process_test_coverage.junit.rules.ProcessCoverageInMemProcessEngineConfiguration
import org.camunda.bpm.extension.process_test_coverage.junit.rules.TestCoverageProcessEngineRule
import org.camunda.bpm.extension.process_test_coverage.junit.rules.TestCoverageProcessEngineRuleBuilder
import org.junit.Before
Expand All @@ -11,13 +18,13 @@ import org.mockito.kotlin.eq
import org.mockito.kotlin.isNull
import org.mockito.kotlin.spy
import org.mockito.kotlin.verify
import ru.tinkoff.top.camunda.delegator.delegates.JavaSimpleDelegate
import ru.tinkoff.top.camunda.delegator.delegates.executors.DelegateExecutorImpl
import ru.tinkoff.top.camunda.delegator.delegates.executors.interceptors.ResolveArgumentsInterceptor
import ru.tinkoff.top.camunda.delegator.delegates.executors.interceptors.output.multiple.MultipleResultExecutionWriter
import ru.tinkoff.top.camunda.delegator.delegates.executors.interceptors.output.single.SingleResultExecutionWriter
import ru.tinkoff.top.camunda.delegator.delegates.resolvers.ContextVariableResolver
import ru.tinkoff.top.camunda.delegator.delegates.resolvers.DelegateExecutionResolver
import ru.tinkoff.top.camunda.delegator.example.CamundaJavaDelegate
import ru.tinkoff.top.camunda.delegator.example.KotlinSimpleDelegate
import ru.tinkoff.top.camunda.delegator.parser.DefaultDelegatorBpmnParseFactory

Expand All @@ -32,15 +39,30 @@ class SimpleProcessTest {
delegateMethodHandlerRegister.initDelegates(
listOf(javaDelegate, kotlinDelegate)
)

Mocks.register("camundaJavaDelegate", CamundaJavaDelegate())
}

@Test
fun testCallDelegateInSimpleProcess() {
val instance = processEngineRule.runtimeService.startProcessInstanceByKey("simpleProcess")

instance.hasPassed("kotlinDelegateActivity", "javaDelegateActivity")
assertThat(instance).isStarted
execute(job("kotlinDelegateActivity"))
execute(job("simpleJavaDelegateActivity"))
execute(job("javaDelegateActivity"))
execute(job("externalTaskActivity"))
complete(externalTask("externalTaskActivity"))

instance.hasPassed(
"kotlinDelegateActivity",
"javaDelegateActivity",
"javaDelegateActivity",
"externalTaskActivity"
)
.contains("delegateResultMapping", "delegateResult")
.contains("javaResultMapping", "valueFromJava")
.contains("javaDelegateVariableName", "javaDelegateVariableValue")
.isEnded

verify(kotlinDelegate).params(eq("requiredValue"), isNull())
Expand All @@ -61,8 +83,8 @@ class SimpleProcessTest {
DelegateExecutorImpl()
)

private val camundaConfiguration = TestCamundaConfiguration().also {
it.setBpmnParseFactory(DefaultDelegatorBpmnParseFactory())
private val camundaConfiguration = ProcessCoverageInMemProcessEngineConfiguration().also {
it.bpmnParseFactory = DefaultDelegatorBpmnParseFactory()
}

@Rule
Expand Down

This file was deleted.

54 changes: 39 additions & 15 deletions camunda-delegator/src/test/resources/processes/simpleProcess.bpmn
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1mx3tfa" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.4.0">
<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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1mx3tfa" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1">
<bpmn:process id="simpleProcess" name="simpleProcess" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_1khm1wt</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1khm1wt" sourceRef="StartEvent_1" targetRef="kotlinDelegateActivity" />
<bpmn:sequenceFlow id="Flow_06m5ksg" sourceRef="kotlinDelegateActivity" targetRef="javaDelegateActivity" />
<bpmn:sequenceFlow id="Flow_06m5ksg" sourceRef="kotlinDelegateActivity" targetRef="simpleJavaDelegateActivity" />
<bpmn:endEvent id="Event_1ojnh9j">
<bpmn:incoming>Flow_0gc8w5i</bpmn:incoming>
<bpmn:incoming>Flow_194eoov</bpmn:incoming>
</bpmn:endEvent>
<bpmn:serviceTask id="kotlinDelegateActivity" name="Kotlin delegate" camunda:delegateExpression="${kotlinSimpleDelegate_params}">
<bpmn:serviceTask id="kotlinDelegateActivity" name="Kotlin delegate" camunda:asyncBefore="true" camunda:delegateExpression="${kotlinSimpleDelegate_params}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="testRequired">requiredValue</camunda:inputParameter>
Expand All @@ -19,8 +19,8 @@
<bpmn:incoming>Flow_1khm1wt</bpmn:incoming>
<bpmn:outgoing>Flow_06m5ksg</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0gc8w5i" sourceRef="javaDelegateActivity" targetRef="Event_1ojnh9j" />
<bpmn:serviceTask id="javaDelegateActivity" name="Java delegate" camunda:delegateExpression="${javaSimpleDelegate_optionalParams}">
<bpmn:sequenceFlow id="Flow_0gc8w5i" sourceRef="simpleJavaDelegateActivity" targetRef="javaDelegateActivity" />
<bpmn:serviceTask id="simpleJavaDelegateActivity" name="Simple delegate in Java" camunda:asyncBefore="true" camunda:delegateExpression="${javaSimpleDelegate_optionalParams}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="test">javaTestParams</camunda:inputParameter>
Expand All @@ -30,32 +30,56 @@
<bpmn:incoming>Flow_06m5ksg</bpmn:incoming>
<bpmn:outgoing>Flow_0gc8w5i</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="javaDelegateActivity" name="Java delegate" camunda:asyncBefore="true" camunda:delegateExpression="${camundaJavaDelegate}">
<bpmn:incoming>Flow_0gc8w5i</bpmn:incoming>
<bpmn:outgoing>Flow_113mp3i</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_113mp3i" sourceRef="javaDelegateActivity" targetRef="externalTaskActivity" />
<bpmn:serviceTask id="externalTaskActivity" name="External task" camunda:asyncBefore="true" camunda:type="external" camunda:topic="topicName">
<bpmn:incoming>Flow_113mp3i</bpmn:incoming>
<bpmn:outgoing>Flow_194eoov</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_194eoov" sourceRef="externalTaskActivity" targetRef="Event_1ojnh9j" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="simpleProcess">
<bpmndi:BPMNEdge id="Flow_1khm1wt_di" bpmnElement="Flow_1khm1wt">
<di:waypoint x="215" y="117" />
<di:waypoint x="390" y="117" />
<bpmndi:BPMNEdge id="Flow_0gc8w5i_di" bpmnElement="Flow_0gc8w5i">
<di:waypoint x="660" y="117" />
<di:waypoint x="710" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_06m5ksg_di" bpmnElement="Flow_06m5ksg">
<di:waypoint x="490" y="117" />
<di:waypoint x="560" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0gc8w5i_di" bpmnElement="Flow_0gc8w5i">
<di:waypoint x="660" y="117" />
<di:waypoint x="802" y="117" />
<bpmndi:BPMNEdge id="Flow_1khm1wt_di" bpmnElement="Flow_1khm1wt">
<di:waypoint x="215" y="117" />
<di:waypoint x="390" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_113mp3i_di" bpmnElement="Flow_113mp3i">
<di:waypoint x="810" y="117" />
<di:waypoint x="870" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_194eoov_di" bpmnElement="Flow_194eoov">
<di:waypoint x="970" y="117" />
<di:waypoint x="1132" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0ab2515_di" bpmnElement="kotlinDelegateActivity">
<dc:Bounds x="390" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1jmpg43_di" bpmnElement="simpleJavaDelegateActivity">
<dc:Bounds x="560" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1ojnh9j_di" bpmnElement="Event_1ojnh9j">
<dc:Bounds x="802" y="99" width="36" height="36" />
<dc:Bounds x="1132" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1jmpg43_di" bpmnElement="javaDelegateActivity">
<dc:Bounds x="560" y="77" width="100" height="80" />
<bpmndi:BPMNShape id="Activity_1gdr97s_di" bpmnElement="javaDelegateActivity">
<dc:Bounds x="710" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1u5uefj_di" bpmnElement="externalTaskActivity">
<dc:Bounds x="870" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import
import org.springframework.core.annotation.Order
import ru.tinkoff.top.camunda.delegator.config.BpmnParserCamundaPlugin
import ru.tinkoff.top.camunda.delegator.config.DelegatorBpmnParserCamundaPlugin
import ru.tinkoff.top.camunda.delegator.config.SpringProcessEngineBpmnParseConfiguration
import ru.tinkoff.top.camunda.delegator.delegates.executors.DelegateExecutor
import ru.tinkoff.top.camunda.delegator.delegates.executors.interceptors.DelegateInterceptor
Expand Down Expand Up @@ -66,13 +66,18 @@ class CamundaDelegatorAutoConfiguration {
}

@Bean
@ConditionalOnProperty(
value = ["delegator.plugins.bpmn-parser.enabled"],
havingValue = "true",
matchIfMissing = true
)
fun bpmnParserCamundaPlugin(
@Qualifier(DELEGATOR_EXPRESSION_MANAGER)
delegatorExpressionManager: ExpressionManager,
@Qualifier(DELEGATOR_BPMN_PARSE_FACTORY)
delegatorBpmnParseFactory: BpmnParseFactory
): BpmnParserCamundaPlugin {
return BpmnParserCamundaPlugin(delegatorExpressionManager, delegatorBpmnParseFactory)
): DelegatorBpmnParserCamundaPlugin {
return DelegatorBpmnParserCamundaPlugin(delegatorExpressionManager, delegatorBpmnParseFactory)
}

@Bean
Expand Down
Loading

0 comments on commit b3376f4

Please sign in to comment.