From 14395b5fbc71eb48a1811325df3cc30d83352b00 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Thu, 17 Nov 2022 11:23:55 +0100 Subject: [PATCH 01/67] Update for next development version --- example/coverage-report-aggregator/pom.xml | 2 +- example/example-java/pom.xml | 2 +- example/example-kotlin/pom.xml | 2 +- example/example-no-engine/pom.xml | 2 +- example/itest/pom.xml | 2 +- example/pom.xml | 2 +- example/spin-type-detector/pom.xml | 2 +- extension/core/pom.xml | 2 +- extension/test/pom.xml | 2 +- pom.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/example/coverage-report-aggregator/pom.xml b/example/coverage-report-aggregator/pom.xml index d3afcf65..c655589b 100644 --- a/example/coverage-report-aggregator/pom.xml +++ b/example/coverage-report-aggregator/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.8 + 1.2.9-SNAPSHOT camunda-bpm-data-coverage-report diff --git a/example/example-java/pom.xml b/example/example-java/pom.xml index 28631f57..17119435 100644 --- a/example/example-java/pom.xml +++ b/example/example-java/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.8 + 1.2.9-SNAPSHOT camunda-bpm-data-example-java diff --git a/example/example-kotlin/pom.xml b/example/example-kotlin/pom.xml index 6fd187e5..0ec25272 100644 --- a/example/example-kotlin/pom.xml +++ b/example/example-kotlin/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.8 + 1.2.9-SNAPSHOT camunda-bpm-data-example-kotlin diff --git a/example/example-no-engine/pom.xml b/example/example-no-engine/pom.xml index c6e5e552..eccd2b60 100644 --- a/example/example-no-engine/pom.xml +++ b/example/example-no-engine/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.8 + 1.2.9-SNAPSHOT camunda-bpm-data-example-no-engine diff --git a/example/itest/pom.xml b/example/itest/pom.xml index 24a33935..a497356b 100644 --- a/example/itest/pom.xml +++ b/example/itest/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.8 + 1.2.9-SNAPSHOT camunda-bpm-data-integration-test diff --git a/example/pom.xml b/example/pom.xml index 915acf5f..3ea42d08 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.8 + 1.2.9-SNAPSHOT io.holunda.data.example diff --git a/example/spin-type-detector/pom.xml b/example/spin-type-detector/pom.xml index 23a16a18..2f0479e1 100644 --- a/example/spin-type-detector/pom.xml +++ b/example/spin-type-detector/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.8 + 1.2.9-SNAPSHOT camunda-bpm-data-spin-type-detector diff --git a/extension/core/pom.xml b/extension/core/pom.xml index dd47c040..6f8e5219 100644 --- a/extension/core/pom.xml +++ b/extension/core/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.8 + 1.2.9-SNAPSHOT ../../pom.xml diff --git a/extension/test/pom.xml b/extension/test/pom.xml index 577d6a4f..c49b7a70 100644 --- a/extension/test/pom.xml +++ b/extension/test/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.8 + 1.2.9-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 541a4a7f..27d85ff1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.8 + 1.2.9-SNAPSHOT ${project.artifactId} Camunda BPM Data https://github.com/holunda-io/camunda-bpm-data/ From c8a8992520e3d3e39d4c2d6521b8228aec438503 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 01:42:40 +0000 Subject: [PATCH 02/67] build(deps): bump springdoc.version from 1.6.12 to 1.6.13 Bumps `springdoc.version` from 1.6.12 to 1.6.13. Updates `springdoc-openapi-ui` from 1.6.12 to 1.6.13 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.12...v1.6.13) Updates `springdoc-openapi-webmvc-core` from 1.6.12 to 1.6.13 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.12...v1.6.13) Updates `springdoc-openapi-kotlin` from 1.6.12 to 1.6.13 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.12...v1.6.13) --- updated-dependencies: - dependency-name: org.springdoc:springdoc-openapi-ui dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springdoc:springdoc-openapi-webmvc-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springdoc:springdoc-openapi-kotlin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- example/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pom.xml b/example/pom.xml index 3ea42d08..48df287c 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -15,7 +15,7 @@ pom - 1.6.12 + 1.6.13 true true true From 708a3db76b4e574626744581de522d427ea524a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 01:42:52 +0000 Subject: [PATCH 03/67] build(deps): bump maven-install-plugin from 3.0.1 to 3.1.0 Bumps [maven-install-plugin](https://github.com/apache/maven-install-plugin) from 3.0.1 to 3.1.0. - [Release notes](https://github.com/apache/maven-install-plugin/releases) - [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-3.0.1...maven-install-plugin-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-install-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 27d85ff1..12c976a9 100644 --- a/pom.xml +++ b/pom.xml @@ -480,7 +480,7 @@ maven-install-plugin - 3.0.1 + 3.1.0 From 6b8d6a5083a7393a83517652f8d3e09d34b0becf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Nov 2022 01:29:14 +0000 Subject: [PATCH 04/67] build(deps): bump camunda-bpm-jgiven from 0.2.0 to 0.4.0 Bumps [camunda-bpm-jgiven](https://github.com/holunda-io/camunda-bpm-jgiven) from 0.2.0 to 0.4.0. - [Release notes](https://github.com/holunda-io/camunda-bpm-jgiven/releases) - [Commits](https://github.com/holunda-io/camunda-bpm-jgiven/compare/0.2.0...0.4.0) --- updated-dependencies: - dependency-name: io.holunda.testing:camunda-bpm-jgiven dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- example/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pom.xml b/example/pom.xml index 48df287c..74c47e08 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -66,7 +66,7 @@ io.holunda.testing camunda-bpm-jgiven - 0.2.0 + 0.4.0 test From caaafbe8323327b72471787928545286bf572a62 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Thu, 24 Nov 2022 23:02:05 +0100 Subject: [PATCH 05/67] add codacy --- .github/workflows/default.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index b789da42..b946978a 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -38,3 +38,9 @@ jobs: uses: codecov/codecov-action@v1.0.2 with: token: ${{secrets.CODECOV_TOKEN}} + + - name: Upload test coverage to Codacy + if: github.event_name == 'push' && github.actor != 'dependabot[bot]' + run: bash <(curl -Ls https://coverage.codacy.com/get.sh) + env: + CODACY_PROJECT_TOKEN: "${{secrets.CODACY_PROJECT_TOKEN}}" From 61ad66efaff4da323864b11886f1921b933e7be4 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Thu, 24 Nov 2022 23:07:19 +0100 Subject: [PATCH 06/67] improve CI/CD --- .codacy.yaml | 10 ++++++++++ .github/workflows/default.yml | 4 ++-- .github/workflows/master.yml | 10 ++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 .codacy.yaml diff --git a/.codacy.yaml b/.codacy.yaml new file mode 100644 index 00000000..8f143d41 --- /dev/null +++ b/.codacy.yaml @@ -0,0 +1,10 @@ +--- +engines: + duplications: + exclude_paths: + - "**/src/test/kotlin/**" + +exclude_paths: + - "README.md" + - ".github/**" + - "docs/**" diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index b946978a..707c477e 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -20,9 +20,9 @@ jobs: - name: Set up JDK 11 uses: actions/setup-java@v3 with: - cache: maven distribution: zulu java-version: 11 + cache: maven - name: Prepare mvnw run: chmod +x ./mvnw @@ -35,7 +35,7 @@ jobs: - name: Upload coverage to Codecov if: github.event_name == 'push' && github.actor != 'dependabot[bot]' - uses: codecov/codecov-action@v1.0.2 + uses: codecov/codecov-action@v3 with: token: ${{secrets.CODECOV_TOKEN}} diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 15e954a0..8d76c55a 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -42,5 +42,11 @@ jobs: - name: Deploy a new version to central run: ./mvnw clean deploy -B -DskipTests -DskipExamples -Prelease -Dgpg.keyname="${{secrets.GPG_KEYNAME}}" -Dgpg.passphrase="${{secrets.GPG_PASSPHRASE}}" env: - OSS_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - OSS_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + OSS_CENTRAL_USERNAME: "${{ secrets.SONATYPE_USERNAME }}" + OSS_CENTRAL_PASSWORD: "${{ secrets.SONATYPE_PASSWORD }}" + + - name: Upload test coverage to Codacy + if: github.event_name == 'push' && github.actor != 'dependabot[bot]' + run: bash <(curl -Ls https://coverage.codacy.com/get.sh) + env: + CODACY_PROJECT_TOKEN: "${{secrets.CODACY_PROJECT_TOKEN}}" From 62fca8deef556ffff5564689ff13553fd1f39d28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Nov 2022 01:36:36 +0000 Subject: [PATCH 07/67] build(deps): bump mockito-kotlin from 4.0.0 to 4.1.0 Bumps [mockito-kotlin](https://github.com/mockito/mockito-kotlin) from 4.0.0 to 4.1.0. - [Release notes](https://github.com/mockito/mockito-kotlin/releases) - [Commits](https://github.com/mockito/mockito-kotlin/compare/4.0.0...4.1.0) --- updated-dependencies: - dependency-name: org.mockito.kotlin:mockito-kotlin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 12c976a9..e73f8f51 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ true 3.0.4 - 4.0.0 + 4.1.0 6.17.1 **/*ITest.* From 4c1503b82ea6b96fddb45ac67af3f321175b4559 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 30 Nov 2022 00:07:45 +0100 Subject: [PATCH 08/67] junit 5 wip --- example/example-java/pom.xml | 2 +- .../example/process/GuardProcessTest.java | 2 +- .../process/OrderApprovalProcessTest.java | 2 +- .../rest/ApproveOrderTaskControllerTest.java | 2 +- example/example-kotlin/pom.xml | 2 +- .../src/main/kotlin/process/OrderApproval.kt | 5 +- example/itest/pom.xml | 7 +- .../itest/src/test/kotlin/SmartUpdateTest.kt | 21 +- .../src/test/kotlin/itest/ActionStage.kt | 2 +- .../kotlin/itest/CamundaBpmDataITestBase.kt | 68 ++++--- .../itest/RuntimeServiceAdapterITest.kt | 2 +- .../kotlin/itest/TaskServiceAdapterITest.kt | 2 +- .../kotlin/itest/VariableMapAdapterITest.kt | 4 +- .../kotlin/itest/VariableScopeAdapterITest.kt | 14 +- example/pom.xml | 4 +- .../jackson/JacksonDeserializationTest.java | 2 +- .../data/jackson/SpinDeserializationTest.java | 2 +- extension/c7/pom.xml | 136 +++++++++++++ extension/core/pom.xml | 37 +--- .../camunda/bpm/data/CamundaBpmDataTest.java | 6 +- .../bpm/data/adapter/ReadAdapterTest.java | 2 +- .../data/adapter/ValueWrapperUtilTest.java | 2 +- .../data/builder/VariableMapBuilderTest.java | 2 +- .../factory/BasicVariableFactoryTest.java | 2 +- .../data/factory/ListVariableFactoryTest.java | 2 +- .../data/factory/MapVariableFactoryTest.java | 2 +- .../data/factory/SetVariableFactoryTest.java | 2 +- .../bpm/data/factory/VariableFactoryTest.java | 2 +- .../reader/CaseServiceVariableReaderTest.java | 10 +- .../reader/LockedExternalTaskReaderTest.java | 6 +- .../ProcessExecutionVariableReaderTest.java | 10 +- .../reader/UserServiceVariableReaderTest.java | 10 +- .../data/reader/VariableMapReaderTest.java | 2 +- .../data/reader/VariableScopeReaderTest.java | 2 +- .../writer/CaseServiceVariableWriterTest.java | 10 +- .../RuntimeServiceVariableWriterTest.java | 10 +- .../writer/TaskServiceVariableWriterTest.java | 10 +- .../data/writer/VariableMapWriterTest.java | 2 +- .../data/writer/VariableScopeWriterTest.java | 2 +- .../holunda/camunda/bpm/data/FluentApiTest.kt | 2 +- .../camunda/bpm/data/NullableMapTest.kt | 2 +- .../camunda/bpm/data/VariablesGuardTest.kt | 2 +- .../holunda/camunda/bpm/data/acl/ACLTest.kt | 13 +- .../bpm/data/acl/AntiCorruptionLayerTest.kt | 7 +- .../bpm/data/acl/CamundaBpmDataACLTest.kt | 2 +- .../bpm/data/acl/CamundaBpmDataMapperTest.kt | 2 +- .../apply/GlobalScopeReplaceStrategyTest.kt | 2 +- .../apply/LocalScopeReplaceStrategyTest.kt | 2 +- .../IdentityVariableMapTransformerTest.kt | 2 +- .../adapter/KotlinValueWrapperUtilTest.kt | 2 +- .../ReadAdapterLockedExternalTaskTest.kt | 2 +- .../data/factory/UUIDVariableFactoryTest.kt | 2 +- .../data/guard/CamundaBpmDataGuardsTest.kt | 2 +- .../data/guard/VariableGuardConditionTest.kt | 2 +- .../integration/GuardExecutionListenerTest.kt | 9 +- .../integration/GuardTaskListenerTest.kt | 9 +- .../GuardViolationExceptionTest.kt | 2 +- extension/test/pom.xml | 84 -------- .../src/main/kotlin/CamundaBpmDataMockito.kt | 150 --------------- .../main/kotlin/CaseServiceMockVerifier.kt | 160 ---------------- .../kotlin/CaseServiceVariableMockBuilder.kt | 107 ----------- .../main/kotlin/RuntimeServiceMockVerifier.kt | 157 --------------- .../RuntimeServiceVariableMockBuilder.kt | 107 ----------- .../main/kotlin/TaskServiceMockVerifier.kt | 179 ------------------ .../kotlin/TaskServiceVariableMockBuilder.kt | 106 ----------- extension/test/src/main/kotlin/packages.md | 6 - .../src/test/kotlin/CaseServiceMockingTest.kt | 68 ------- .../test/kotlin/CaseServiceVerifierTest.kt | 153 --------------- .../test/kotlin/RuntimeServiceMockingTest.kt | 68 ------- .../test/kotlin/RuntimeServiceVerifierTest.kt | 158 ---------------- .../src/test/kotlin/TaskServiceMockingTest.kt | 68 ------- .../test/kotlin/TaskServiceVerifierTest.kt | 176 ----------------- pom.xml | 28 +-- 73 files changed, 312 insertions(+), 1941 deletions(-) create mode 100644 extension/c7/pom.xml delete mode 100644 extension/test/pom.xml delete mode 100644 extension/test/src/main/kotlin/CamundaBpmDataMockito.kt delete mode 100644 extension/test/src/main/kotlin/CaseServiceMockVerifier.kt delete mode 100644 extension/test/src/main/kotlin/CaseServiceVariableMockBuilder.kt delete mode 100644 extension/test/src/main/kotlin/RuntimeServiceMockVerifier.kt delete mode 100644 extension/test/src/main/kotlin/RuntimeServiceVariableMockBuilder.kt delete mode 100644 extension/test/src/main/kotlin/TaskServiceMockVerifier.kt delete mode 100644 extension/test/src/main/kotlin/TaskServiceVariableMockBuilder.kt delete mode 100644 extension/test/src/main/kotlin/packages.md delete mode 100644 extension/test/src/test/kotlin/CaseServiceMockingTest.kt delete mode 100644 extension/test/src/test/kotlin/CaseServiceVerifierTest.kt delete mode 100644 extension/test/src/test/kotlin/RuntimeServiceMockingTest.kt delete mode 100644 extension/test/src/test/kotlin/RuntimeServiceVerifierTest.kt delete mode 100644 extension/test/src/test/kotlin/TaskServiceMockingTest.kt delete mode 100644 extension/test/src/test/kotlin/TaskServiceVerifierTest.kt diff --git a/example/example-java/pom.xml b/example/example-java/pom.xml index 17119435..882af44a 100644 --- a/example/example-java/pom.xml +++ b/example/example-java/pom.xml @@ -125,7 +125,7 @@ test - org.camunda.bpm.assert + org.camunda.bpm camunda-bpm-assert test diff --git a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/GuardProcessTest.java b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/GuardProcessTest.java index 633f6820..e991cd62 100644 --- a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/GuardProcessTest.java +++ b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/GuardProcessTest.java @@ -14,7 +14,7 @@ import org.camunda.spin.plugin.impl.SpinProcessEnginePlugin; import org.junit.Before; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.sql.Date; import java.time.Instant; diff --git a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/OrderApprovalProcessTest.java b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/OrderApprovalProcessTest.java index 543ed685..1182d5c3 100644 --- a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/OrderApprovalProcessTest.java +++ b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/OrderApprovalProcessTest.java @@ -13,7 +13,7 @@ import org.camunda.spin.plugin.impl.SpinProcessEnginePlugin; import org.junit.Before; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; import java.sql.Date; diff --git a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java index b0df1de0..fd35ec37 100644 --- a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java +++ b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java @@ -4,7 +4,7 @@ import io.holunda.camunda.bpm.data.mockito.TaskServiceMockVerifier; import org.camunda.bpm.engine.TaskService; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/example/example-kotlin/pom.xml b/example/example-kotlin/pom.xml index 0ec25272..3fadceca 100644 --- a/example/example-kotlin/pom.xml +++ b/example/example-kotlin/pom.xml @@ -159,7 +159,7 @@ com.tngtech.jgiven - jgiven-junit + jgiven-junit5 org.springframework.boot diff --git a/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt b/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt index 9ccfc4ac..03965d26 100644 --- a/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt +++ b/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt @@ -12,6 +12,7 @@ import io.holunda.camunda.bpm.data.example.kotlin.process.OrderApproval.Variable import io.holunda.camunda.bpm.data.example.kotlin.process.OrderApproval.Variables.ORDER_POSITION import io.holunda.camunda.bpm.data.example.kotlin.process.OrderApproval.Variables.ORDER_TOTAL import io.holunda.camunda.bpm.data.factory.VariableFactory +import io.holunda.camunda.bpm.data.guard.VariablesGuard import io.holunda.camunda.bpm.data.guard.condition.exists import io.holunda.camunda.bpm.data.guard.condition.matches import io.holunda.camunda.bpm.data.guard.integration.DefaultGuardTaskListener @@ -86,10 +87,10 @@ class OrderApproval { */ @Bean fun guardTaskListener() = DefaultGuardTaskListener( - listOf( + VariablesGuard(listOf( ORDER_APPROVED.exists(), ORDER_APPROVED.matches(this::isTrueViolationMessageSupplier) { it == true } - ), true + )), true ) private fun isTrueViolationMessageSupplier(variableFactory: VariableFactory, localLabel: String, option: Optional) = diff --git a/example/itest/pom.xml b/example/itest/pom.xml index a497356b..9e66d691 100644 --- a/example/itest/pom.xml +++ b/example/itest/pom.xml @@ -14,6 +14,7 @@ false + false @@ -151,11 +152,11 @@ com.tngtech.jgiven - jgiven-junit + jgiven-junit5 com.tngtech.jgiven - jgiven-spring-junit4 + jgiven-spring-junit5 org.camunda.community.mockito @@ -184,7 +185,7 @@ - -Djava.awt.headless=true ${argLine} -XX:+StartAttachListener + -Djava.awt.headless=true @{argLine} -XX:+StartAttachListener random diff --git a/example/itest/src/test/kotlin/SmartUpdateTest.kt b/example/itest/src/test/kotlin/SmartUpdateTest.kt index d7e311ba..ed4c2cde 100644 --- a/example/itest/src/test/kotlin/SmartUpdateTest.kt +++ b/example/itest/src/test/kotlin/SmartUpdateTest.kt @@ -1,11 +1,12 @@ package io.holunda.camunda.bpm.data -import org.mockito.kotlin.mock -import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.stringVariable -import io.holunda.camunda.bpm.data.mockito.RuntimeServiceMockVerifier -import io.holunda.camunda.bpm.data.mockito.RuntimeServiceVariableMockBuilder +import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable +import io.holunda.camunda.bpm.data.factory.VariableFactory import org.camunda.bpm.engine.RuntimeService -import org.junit.Test +import org.camunda.community.mockito.service.RuntimeServiceStubBuilder +import org.camunda.community.mockito.verify.RuntimeServiceVerification +import org.junit.jupiter.api.Test +import org.mockito.kotlin.mock import java.util.* /** @@ -14,15 +15,15 @@ import java.util.* class SmartUpdateTest { companion object { - val MY_VAR = stringVariable("myVar") + val MY_VAR: VariableFactory = stringVariable("myVar") } @Test fun should_not_touch_global() { val execId = UUID.randomUUID().toString() val runtime: RuntimeService = mock() - val verifier = RuntimeServiceMockVerifier(runtime) - RuntimeServiceVariableMockBuilder(runtime).initial(MY_VAR, "value").build() + val verifier = RuntimeServiceVerification(runtime) + RuntimeServiceStubBuilder(runtime).defineAndInitialize(MY_VAR, "value").build() MY_VAR.on(runtime, execId).update { "value" } verifier.verifyGet(MY_VAR, execId) verifier.verifyNoMoreInteractions() @@ -32,8 +33,8 @@ class SmartUpdateTest { fun should_not_touch_local() { val execId = UUID.randomUUID().toString() val runtime: RuntimeService = mock() - val verifier = RuntimeServiceMockVerifier(runtime) - RuntimeServiceVariableMockBuilder(runtime).initialLocal(MY_VAR, "value").build() + val verifier = RuntimeServiceVerification(runtime) + RuntimeServiceStubBuilder(runtime).defineAndInitializeLocal(MY_VAR, "value").build() MY_VAR.on(runtime, execId).updateLocal { "value" } verifier.verifyGetLocal(MY_VAR, execId) verifier.verifyNoMoreInteractions() diff --git a/example/itest/src/test/kotlin/itest/ActionStage.kt b/example/itest/src/test/kotlin/itest/ActionStage.kt index f5aaccaa..00506853 100644 --- a/example/itest/src/test/kotlin/itest/ActionStage.kt +++ b/example/itest/src/test/kotlin/itest/ActionStage.kt @@ -15,7 +15,7 @@ import org.camunda.bpm.engine.variable.VariableMap import org.camunda.bpm.engine.variable.Variables import org.camunda.bpm.model.bpmn.Bpmn import org.camunda.bpm.model.bpmn.BpmnModelInstance -import org.junit.Assert.assertThrows +import org.junit.jupiter.api.Assertions.assertThrows import org.springframework.beans.factory.annotation.Autowired /** diff --git a/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt b/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt index b0cc32a2..e48de2e5 100644 --- a/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt +++ b/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt @@ -3,7 +3,7 @@ package io.holunda.camunda.bpm.data.itest import com.fasterxml.jackson.annotation.JsonIgnore import com.tngtech.jgiven.base.ScenarioTestBase import com.tngtech.jgiven.integration.spring.EnableJGiven -import com.tngtech.jgiven.integration.spring.SpringScenarioTest +import com.tngtech.jgiven.integration.spring.junit5.SpringScenarioTest import io.holunda.camunda.bpm.data.CamundaBpmData.* import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.customVariable import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.dateVariable @@ -45,7 +45,7 @@ import org.camunda.bpm.engine.delegate.TaskListener import org.camunda.bpm.engine.delegate.VariableScope import org.camunda.bpm.engine.variable.VariableMap import org.camunda.bpm.engine.variable.Variables.createVariables -import org.junit.runner.RunWith +import org.junit.jupiter.api.extension.ExtendWith import org.springframework.boot.SpringBootConfiguration import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.test.context.SpringBootTest @@ -53,7 +53,7 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration import org.springframework.test.context.ActiveProfiles -import org.springframework.test.context.junit4.SpringRunner +import org.springframework.test.context.junit.jupiter.SpringExtension import java.time.Instant import java.time.temporal.ChronoUnit import java.util.* @@ -66,7 +66,7 @@ fun ScenarioTestBase.whenever(): W = `when`() /** * Base for ITests. */ -@RunWith(SpringRunner::class) +@ExtendWith(SpringExtension::class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [CamundaBpmDataITestBase.TestApplication::class]) @ActiveProfiles("itest") abstract class CamundaBpmDataITestBase : SpringScenarioTest() { @@ -103,18 +103,24 @@ abstract class CamundaBpmDataITestBase : SpringScenarioTest com.tngtech.jgiven - jgiven-junit + jgiven-junit5 ${jgiven.version} test com.tngtech.jgiven - jgiven-spring-junit4 + jgiven-spring-junit5 ${jgiven.version} test diff --git a/example/spin-type-detector/src/test/java/io/holunda/camunda/bpm/data/jackson/JacksonDeserializationTest.java b/example/spin-type-detector/src/test/java/io/holunda/camunda/bpm/data/jackson/JacksonDeserializationTest.java index 640510ca..98f8f4a2 100644 --- a/example/spin-type-detector/src/test/java/io/holunda/camunda/bpm/data/jackson/JacksonDeserializationTest.java +++ b/example/spin-type-detector/src/test/java/io/holunda/camunda/bpm/data/jackson/JacksonDeserializationTest.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.CollectionType; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; diff --git a/example/spin-type-detector/src/test/java/io/holunda/camunda/bpm/data/jackson/SpinDeserializationTest.java b/example/spin-type-detector/src/test/java/io/holunda/camunda/bpm/data/jackson/SpinDeserializationTest.java index 46a866f9..46547dc9 100644 --- a/example/spin-type-detector/src/test/java/io/holunda/camunda/bpm/data/jackson/SpinDeserializationTest.java +++ b/example/spin-type-detector/src/test/java/io/holunda/camunda/bpm/data/jackson/SpinDeserializationTest.java @@ -2,7 +2,7 @@ import org.assertj.core.util.Lists; import org.camunda.spin.json.SpinJsonNode; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; diff --git a/extension/c7/pom.xml b/extension/c7/pom.xml new file mode 100644 index 00000000..3c289e1c --- /dev/null +++ b/extension/c7/pom.xml @@ -0,0 +1,136 @@ + + + 4.0.0 + + + io.holunda.data + camunda-bpm-data-parent + 1.2.9-SNAPSHOT + ../../pom.xml + + + camunda-bpm-data-c7 + ${project.artifactId} + jar + + + false + false + + + + + + org.jetbrains.kotlin + kotlin-stdlib-common + + + org.jetbrains.kotlin + kotlin-reflect + + + + + javax.validation + validation-api + 2.0.1.Final + + + + + org.camunda.bpm + camunda-engine + provided + + + org.camunda.spin + camunda-spin-core + provided + + + org.camunda.spin + camunda-spin-dataformat-json-jackson + provided + + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + + + + org.slf4j + slf4j-api + + + + org.camunda.bpm + camunda-bpm-assert + test + + + org.mockito.kotlin + mockito-kotlin + test + + + org.slf4j + slf4j-simple + test + + + com.h2database + h2 + test + + + org.hibernate.validator + hibernate-validator + 6.2.0.Final + test + + + org.glassfish + javax.el + 3.0.0 + test + + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + test + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + test + + + com.fasterxml.jackson.module + jackson-module-kotlin + test + + + org.camunda.community.mockito + camunda-platform-7-mockito + test + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + + diff --git a/extension/core/pom.xml b/extension/core/pom.xml index 6f8e5219..0ef5fac2 100644 --- a/extension/core/pom.xml +++ b/extension/core/pom.xml @@ -20,21 +20,11 @@ - - - org.jetbrains.kotlin - kotlin-stdlib-common - - - org.jetbrains.kotlin - kotlin-reflect - - - javax.validation - validation-api - 2.0.1.Final + ${project.groupId} + camunda-bpm-data-c7 + ${project.version} @@ -54,27 +44,18 @@ provided - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-databind - - - - - org.slf4j - slf4j-api - - org.camunda.bpm.assert + org.camunda.bpm camunda-bpm-assert test + + org.camunda.bpm + camunda-bpm-junit5 + test + org.mockito.kotlin mockito-kotlin diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/CamundaBpmDataTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/CamundaBpmDataTest.java index 1ac77d26..1aeb2323 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/CamundaBpmDataTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/CamundaBpmDataTest.java @@ -24,8 +24,8 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables; import org.camunda.community.mockito.delegate.DelegateExecutionFake; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.Date; import java.util.UUID; @@ -59,7 +59,7 @@ public class CamundaBpmDataTest { private final CaseService caseService = mock(CaseService.class); - @Before + @BeforeEach public void setupStubs() { when(runtimeService.getVariablesLocalTyped(any())).thenReturn(createVariables()); when(runtimeService.getVariablesTyped(any())).thenReturn(createVariables()); diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ReadAdapterTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ReadAdapterTest.java index 1dd9556d..2795896a 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ReadAdapterTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ReadAdapterTest.java @@ -4,7 +4,7 @@ import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.variable.Variables; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.UUID; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtilTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtilTest.java index 9e4892eb..9d1ec67b 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtilTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtilTest.java @@ -16,7 +16,7 @@ import org.camunda.bpm.engine.variable.value.ShortValue; import org.camunda.bpm.engine.variable.value.StringValue; import org.camunda.bpm.engine.variable.value.TypedValue; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ValueWrapperUtilTest { diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/builder/VariableMapBuilderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/builder/VariableMapBuilderTest.java index c4651401..06ce83c8 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/builder/VariableMapBuilderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/builder/VariableMapBuilderTest.java @@ -3,7 +3,7 @@ import io.holunda.camunda.bpm.data.CamundaBpmData; import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.variable.VariableMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable; import static org.assertj.core.api.Assertions.assertThat; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/BasicVariableFactoryTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/BasicVariableFactoryTest.java index 2a39f563..65a6179c 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/BasicVariableFactoryTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/BasicVariableFactoryTest.java @@ -11,7 +11,7 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.variable.VariableMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.UUID; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/ListVariableFactoryTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/ListVariableFactoryTest.java index ce0de0fa..5a099638 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/ListVariableFactoryTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/ListVariableFactoryTest.java @@ -11,7 +11,7 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.variable.VariableMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.UUID; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/MapVariableFactoryTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/MapVariableFactoryTest.java index 8091858b..4a97c134 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/MapVariableFactoryTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/MapVariableFactoryTest.java @@ -11,7 +11,7 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.variable.VariableMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Map; import java.util.UUID; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/SetVariableFactoryTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/SetVariableFactoryTest.java index 60e95696..f95c6e1a 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/SetVariableFactoryTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/SetVariableFactoryTest.java @@ -11,7 +11,7 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.variable.VariableMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Set; import java.util.UUID; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/VariableFactoryTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/VariableFactoryTest.java index 90f07b60..6912d5cc 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/VariableFactoryTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/factory/VariableFactoryTest.java @@ -1,6 +1,6 @@ package io.holunda.camunda.bpm.data.factory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReaderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReaderTest.java index 83a0c2cb..c614afb7 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReaderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReaderTest.java @@ -3,9 +3,9 @@ import io.holunda.camunda.bpm.data.CamundaBpmData; import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.CaseService; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.UUID; @@ -22,13 +22,13 @@ public class CaseServiceVariableReaderTest { private final String value = "value"; private final String localValue = "localValue"; - @Before + @BeforeEach public void mockExecution() { when(caseService.getVariable(this.taskId, STRING.getName())).thenReturn(value); when(caseService.getVariableLocal(this.taskId, STRING.getName())).thenReturn(localValue); } - @After + @AfterEach public void after() { Mockito.reset(caseService); } diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReaderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReaderTest.java index 46b41472..5deca8ef 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReaderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReaderTest.java @@ -4,8 +4,8 @@ import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.variable.Variables; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; @@ -42,7 +42,7 @@ public class LockedExternalTaskReaderTest { private VariableReader reader = CamundaBpmData.reader(externalTask); - @Before + @BeforeEach public void setUp() { when(externalTask.getVariables()).thenReturn( Variables diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/ProcessExecutionVariableReaderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/ProcessExecutionVariableReaderTest.java index 5e89ad97..46a67938 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/ProcessExecutionVariableReaderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/ProcessExecutionVariableReaderTest.java @@ -3,9 +3,9 @@ import io.holunda.camunda.bpm.data.CamundaBpmData; import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.RuntimeService; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.UUID; @@ -22,13 +22,13 @@ public class ProcessExecutionVariableReaderTest { private final String value = "value"; private final String valueLocal = "valueLocal"; - @Before + @BeforeEach public void mockExecution() { when(runtimeService.getVariable(this.executionId, STRING.getName())).thenReturn(value); when(runtimeService.getVariableLocal(this.executionId, STRING.getName())).thenReturn(valueLocal); } - @After + @AfterEach public void after() { Mockito.reset(runtimeService); } diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/UserServiceVariableReaderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/UserServiceVariableReaderTest.java index 87b12ad2..4a0a4a7e 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/UserServiceVariableReaderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/UserServiceVariableReaderTest.java @@ -3,9 +3,9 @@ import io.holunda.camunda.bpm.data.CamundaBpmData; import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.TaskService; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.UUID; @@ -22,13 +22,13 @@ public class UserServiceVariableReaderTest { private final String value = "value"; private final String localValue = "localValue"; - @Before + @BeforeEach public void mockExecution() { when(taskService.getVariable(this.taskId, STRING.getName())).thenReturn(value); when(taskService.getVariableLocal(this.taskId, STRING.getName())).thenReturn(localValue); } - @After + @AfterEach public void after() { Mockito.reset(taskService); } diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableMapReaderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableMapReaderTest.java index 3270de48..5dcdd3c1 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableMapReaderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableMapReaderTest.java @@ -3,7 +3,7 @@ import io.holunda.camunda.bpm.data.CamundaBpmData; import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.variable.VariableMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable; import static org.assertj.core.api.Assertions.assertThat; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableScopeReaderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableScopeReaderTest.java index d086f542..a521d1b0 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableScopeReaderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableScopeReaderTest.java @@ -4,7 +4,7 @@ import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.community.mockito.delegate.DelegateExecutionFake; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable; import static org.assertj.core.api.Assertions.assertThat; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriterTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriterTest.java index 600b6f74..16feaef8 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriterTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriterTest.java @@ -3,9 +3,9 @@ import io.holunda.camunda.bpm.data.CamundaBpmData; import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.CaseService; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.UUID; @@ -24,13 +24,13 @@ public class CaseServiceVariableWriterTest { private final CaseService caseService = Mockito.mock(CaseService.class); - @Before + @BeforeEach public void setUp() { when(caseService.getVariable(CASE_EXECUTION_ID, STRING.getName())).thenReturn(VALUE); when(caseService.getVariableLocal(CASE_EXECUTION_ID, STRING.getName())).thenReturn(LOCAL_VALUE); } - @After + @AfterEach public void after() { Mockito.reset(caseService); } diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriterTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriterTest.java index 19ebab6c..af5c884d 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriterTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriterTest.java @@ -4,9 +4,9 @@ import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.variable.Variables; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.UUID; @@ -25,13 +25,13 @@ public class RuntimeServiceVariableWriterTest { private static final String LOCAL_VALUE = "localValue"; private final RuntimeService runtimeService = Mockito.mock(RuntimeService.class); - @Before + @BeforeEach public void setUp() { when(runtimeService.getVariable(EXECUTION_ID, STRING.getName())).thenReturn(VALUE); when(runtimeService.getVariableLocal(EXECUTION_ID, STRING.getName())).thenReturn(LOCAL_VALUE); } - @After + @AfterEach public void after() { Mockito.reset(runtimeService); } diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriterTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriterTest.java index e11b18df..a2b5d1d7 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriterTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriterTest.java @@ -4,9 +4,9 @@ import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.variable.Variables; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.UUID; @@ -24,13 +24,13 @@ public class TaskServiceVariableWriterTest { private final TaskService taskService = Mockito.mock(TaskService.class); - @Before + @BeforeEach public void setUp() { when(taskService.getVariable(TASK_ID, STRING.getName())).thenReturn(VALUE); when(taskService.getVariableLocal(TASK_ID, STRING.getName())).thenReturn(VALUE); } - @After + @AfterEach public void after() { Mockito.reset(taskService); } diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableMapWriterTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableMapWriterTest.java index 77b1b29e..25abba2e 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableMapWriterTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableMapWriterTest.java @@ -4,7 +4,7 @@ import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.variable.VariableMap; import org.camunda.bpm.engine.variable.Variables; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriterTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriterTest.java index 30b5d9ad..5f7111f8 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriterTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriterTest.java @@ -3,7 +3,7 @@ import io.holunda.camunda.bpm.data.CamundaBpmData; import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.community.mockito.delegate.DelegateExecutionFake; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable; import static org.assertj.core.api.Assertions.assertThat; diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt index 7aed9381..40129a8a 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt @@ -15,7 +15,7 @@ import org.camunda.bpm.engine.TaskService import org.camunda.bpm.engine.variable.Variables.createVariables import org.camunda.bpm.engine.variable.Variables.stringValue import org.camunda.community.mockito.delegate.DelegateExecutionFake -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.* class FluentApiTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/NullableMapTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/NullableMapTest.kt index 54441829..718df0f3 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/NullableMapTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/NullableMapTest.kt @@ -7,7 +7,7 @@ import io.holunda.camunda.bpm.data.NullableMapTest.TestVariables.NULL_MAP import io.holunda.camunda.bpm.data.factory.VariableFactory import org.assertj.core.api.Assertions.assertThat import org.camunda.community.mockito.CamundaMockito.delegateExecutionFake -import org.junit.Test +import org.junit.jupiter.api.Test internal class NullableMapTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/VariablesGuardTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/VariablesGuardTest.kt index d5b18673..c70914e9 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/VariablesGuardTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/VariablesGuardTest.kt @@ -10,7 +10,7 @@ import io.holunda.camunda.bpm.data.guard.VariablesGuard.Companion.ALL import io.holunda.camunda.bpm.data.guard.VariablesGuard.Companion.ONE_OF import org.assertj.core.api.Assertions.assertThat import org.camunda.community.mockito.delegate.DelegateExecutionFake -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.* class VariablesGuardTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt index 81a45a13..e3892bda 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt @@ -13,18 +13,21 @@ import org.camunda.bpm.engine.test.Deployment import org.camunda.bpm.engine.test.ProcessEngineRule import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.task +import org.camunda.bpm.engine.test.junit5.ProcessEngineExtension import org.camunda.bpm.engine.test.mock.MockExpressionManager import org.camunda.bpm.engine.variable.VariableMap import org.camunda.community.mockito.CamundaMockito.registerInstance -import org.junit.Rule -import org.junit.Test +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.RegisterExtension + @Deployment(resources = ["eventBasedSubprocess_no_transientMapping.bpmn", "eventBasedSubprocess_with_transientMapping.bpmn"]) class TransientVariableMappingListenerTest { - @Suppress("RedundantVisibilityModifier") - @get: Rule - public val camunda = camunda() + @RegisterExtension + val camunda: ProcessEngineExtension = ProcessEngineExtension.builder() + .configurationResource("audithistory.camunda.cfg.xml") + .build() @Test fun `NO ACL signal sub-process with variables sets variables on processInstance`() { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt index 2e289dec..82b0464f 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt @@ -16,8 +16,8 @@ import org.camunda.bpm.engine.variable.VariableMap import org.camunda.bpm.engine.variable.value.ObjectValue import org.camunda.community.mockito.delegate.DelegateExecutionFake import org.camunda.community.mockito.delegate.DelegateTaskFake -import org.junit.Assert.assertThrows -import org.junit.Test +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows class AntiCorruptionLayerTest { @@ -92,8 +92,7 @@ class AntiCorruptionLayerTest { @Test fun `should fail checking and wrapping variables`() { val vars = builder().set(FOO, "foo1").set(BAZ, "ba").build() - - assertThrows("ACL Guard Error:\n\tExpecting variable 'baz' to match the condition, but its value 'ba' has not.", GuardViolationException::class.java) { + assertThrows("ACL Guard Error:\n\tExpecting variable 'baz' to match the condition, but its value 'ba' has not.") { MY_ACL.checkAndWrap(vars) } } diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/CamundaBpmDataACLTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/CamundaBpmDataACLTest.kt index f4ab99b7..6ba5125f 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/CamundaBpmDataACLTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/CamundaBpmDataACLTest.kt @@ -8,7 +8,7 @@ import io.holunda.camunda.bpm.data.guard.CamundaBpmDataGuards.exists import io.holunda.camunda.bpm.data.guard.VariablesGuard import org.assertj.core.api.Assertions.assertThat import org.camunda.bpm.engine.variable.VariableMap -import org.junit.Test +import org.junit.jupiter.api.Test class CamundaBpmDataACLTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/CamundaBpmDataMapperTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/CamundaBpmDataMapperTest.kt index 43fdcad9..dda92504 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/CamundaBpmDataMapperTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/CamundaBpmDataMapperTest.kt @@ -7,7 +7,7 @@ import io.holunda.camunda.bpm.data.acl.transform.IdentityVariableMapTransformer import io.holunda.camunda.bpm.data.guard.VariablesGuard import org.assertj.core.api.Assertions.assertThat import org.camunda.bpm.engine.variable.VariableMap -import org.junit.Test +import org.junit.jupiter.api.Test class CamundaBpmDataMapperTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/apply/GlobalScopeReplaceStrategyTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/apply/GlobalScopeReplaceStrategyTest.kt index 3e9b960f..c21476f6 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/apply/GlobalScopeReplaceStrategyTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/apply/GlobalScopeReplaceStrategyTest.kt @@ -4,7 +4,7 @@ import io.holunda.camunda.bpm.data.CamundaBpmData import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable import org.assertj.core.api.Assertions.assertThat import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Test +import org.junit.jupiter.api.Test import org.mockito.Mockito import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/apply/LocalScopeReplaceStrategyTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/apply/LocalScopeReplaceStrategyTest.kt index d5a424ff..2502f01b 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/apply/LocalScopeReplaceStrategyTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/apply/LocalScopeReplaceStrategyTest.kt @@ -4,7 +4,7 @@ import io.holunda.camunda.bpm.data.CamundaBpmData import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable import org.assertj.core.api.Assertions import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Test +import org.junit.jupiter.api.Test import org.mockito.Mockito.* class LocalScopeReplaceStrategyTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/transform/IdentityVariableMapTransformerTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/transform/IdentityVariableMapTransformerTest.kt index 1e60aec0..f1b34b73 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/transform/IdentityVariableMapTransformerTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/transform/IdentityVariableMapTransformerTest.kt @@ -2,7 +2,7 @@ package io.holunda.camunda.bpm.data.acl.transform import io.holunda.camunda.bpm.data.CamundaBpmData import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import org.junit.jupiter.api.Test class IdentityVariableMapTransformerTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/adapter/KotlinValueWrapperUtilTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/adapter/KotlinValueWrapperUtilTest.kt index 4faa1446..79be8691 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/adapter/KotlinValueWrapperUtilTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/adapter/KotlinValueWrapperUtilTest.kt @@ -3,7 +3,7 @@ package io.holunda.camunda.bpm.data.adapter import org.assertj.core.api.Assertions import org.camunda.bpm.engine.variable.type.PrimitiveValueType import org.camunda.bpm.engine.variable.value.* -import org.junit.Test +import org.junit.jupiter.api.Test /** * Check value wrapper util for Kotlin classes. diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTaskTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTaskTest.kt index 7fa3a259..bf1efc09 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTaskTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTaskTest.kt @@ -4,7 +4,7 @@ import io.holunda.camunda.bpm.data.CamundaBpmData import org.assertj.core.api.Assertions.assertThat import org.camunda.bpm.engine.externaltask.LockedExternalTask import org.camunda.bpm.engine.variable.VariableMap -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.* class ReadAdapterLockedExternalTaskTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/factory/UUIDVariableFactoryTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/factory/UUIDVariableFactoryTest.kt index b35aeb63..f648e7c8 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/factory/UUIDVariableFactoryTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/factory/UUIDVariableFactoryTest.kt @@ -3,7 +3,7 @@ package io.holunda.camunda.bpm.data.factory import io.holunda.camunda.bpm.data.CamundaBpmData import org.assertj.core.api.Assertions import org.camunda.bpm.engine.variable.Variables -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.* class UUIDVariableFactoryTest { diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/CamundaBpmDataGuardsTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/CamundaBpmDataGuardsTest.kt index edd76869..f916f459 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/CamundaBpmDataGuardsTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/CamundaBpmDataGuardsTest.kt @@ -3,7 +3,7 @@ package io.holunda.camunda.bpm.data.guard import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable import io.holunda.camunda.bpm.data.guard.condition.* import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.* import java.util.function.Supplier import javax.validation.Validation diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/VariableGuardConditionTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/VariableGuardConditionTest.kt index b52b2f2d..8e3c236a 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/VariableGuardConditionTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/VariableGuardConditionTest.kt @@ -5,7 +5,7 @@ import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable import io.holunda.camunda.bpm.data.guard.condition.* import org.assertj.core.api.Assertions.assertThat import org.camunda.bpm.engine.variable.Variables.createVariables -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.* import java.util.function.Supplier import javax.validation.Validation diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardExecutionListenerTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardExecutionListenerTest.kt index 76e8aa5d..74e16b25 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardExecutionListenerTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardExecutionListenerTest.kt @@ -6,8 +6,8 @@ import io.holunda.camunda.bpm.data.guard.condition.exists import io.holunda.camunda.bpm.data.guard.condition.hasValue import org.assertj.core.api.Assertions.assertThat import org.camunda.community.mockito.delegate.DelegateExecutionFake -import org.junit.Assert.assertThrows -import org.junit.Test +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows val ORDER_REFERENCE = stringVariable("orderReference") @@ -43,9 +43,8 @@ class GuardExecutionListenerTest { ORDER_REFERENCE.on(execution).set("2") val listener = createListener(true) - assertThrows( + assertThrows( "Guard violated by execution '${execution.id}' in activity '${execution.currentActivityName}'", - GuardViolationException::class.java ) { listener.notify(execution) } @@ -56,7 +55,7 @@ class GuardExecutionListenerTest { val execution = DelegateExecutionFake() val listener = DefaultGuardExecutionListener(VariablesGuard("NamedGuard", listOf(ORDER_REFERENCE.exists()))) - val exception = assertThrows(GuardViolationException::class.java) { + val exception = assertThrows { listener.notify(execution) } assertThat(exception.message).startsWith("NamedGuard") diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardTaskListenerTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardTaskListenerTest.kt index 31cee39c..01250ec3 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardTaskListenerTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardTaskListenerTest.kt @@ -6,8 +6,8 @@ import io.holunda.camunda.bpm.data.guard.condition.exists import io.holunda.camunda.bpm.data.guard.condition.hasValue import org.assertj.core.api.Assertions.assertThat import org.camunda.community.mockito.delegate.DelegateTaskFake -import org.junit.Assert.assertThrows -import org.junit.Test +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows val ORDER_ID = stringVariable("orderID") @@ -46,9 +46,8 @@ class GuardTaskListenerTest { ORDER_ID.on(delegateTask).set("2") val listener = createListener(true) - assertThrows( + assertThrows( "Guard violated in task '${delegateTask.name}' (taskId: '${delegateTask.id}')", - GuardViolationException::class.java ) { listener.notify(delegateTask) } @@ -59,7 +58,7 @@ class GuardTaskListenerTest { val delegateTask = DelegateTaskFake().withId("4711").withName("task name") val listener = DefaultGuardTaskListener(VariablesGuard("NamedGuard", listOf(ORDER_ID.exists()))) - val exception = assertThrows(GuardViolationException::class.java) { + val exception = assertThrows() { listener.notify(delegateTask) } assertThat(exception.message).startsWith("NamedGuard") diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardViolationExceptionTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardViolationExceptionTest.kt index 9a1cf468..0922d589 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardViolationExceptionTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardViolationExceptionTest.kt @@ -4,7 +4,7 @@ import io.holunda.camunda.bpm.data.CamundaBpmData import io.holunda.camunda.bpm.data.guard.CamundaBpmDataGuards import io.holunda.camunda.bpm.data.guard.GuardViolation import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.* class GuardViolationExceptionTest { diff --git a/extension/test/pom.xml b/extension/test/pom.xml deleted file mode 100644 index c49b7a70..00000000 --- a/extension/test/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - 4.0.0 - - - io.holunda.data - camunda-bpm-data-parent - 1.2.9-SNAPSHOT - ../../pom.xml - - - camunda-bpm-data-test - ${project.artifactId} - jar - - - false - false - - - - - - io.holunda.data - camunda-bpm-data - ${project.version} - - - org.camunda.bpm - camunda-engine - provided - - - - org.mockito - mockito-core - provided - - - - org.mockito.kotlin - mockito-kotlin - compile - - - - - - org.jetbrains.kotlin - kotlin-stdlib - - - org.jetbrains.kotlin - kotlin-stdlib-common - - - org.jetbrains.kotlin - kotlin-reflect - - - - - org.slf4j - slf4j-simple - test - - - org.camunda.community.mockito - camunda-platform-7-mockito - test - - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - - - - - diff --git a/extension/test/src/main/kotlin/CamundaBpmDataMockito.kt b/extension/test/src/main/kotlin/CamundaBpmDataMockito.kt deleted file mode 100644 index 30533c36..00000000 --- a/extension/test/src/main/kotlin/CamundaBpmDataMockito.kt +++ /dev/null @@ -1,150 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.camunda.bpm.engine.CaseService -import org.camunda.bpm.engine.RuntimeService -import org.camunda.bpm.engine.TaskService -import org.camunda.bpm.engine.variable.VariableMap - -/** - * Collection of fluent mock builder factory methods. - */ -@Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING -) -object CamundaBpmDataMockito { - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a task service variable mock builder. - * @param taskService task service mock. - * @return fluent builder. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.taskServiceVariableStubBuilder(TaskService)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun taskServiceVariableMockBuilder(taskService: TaskService) = TaskServiceVariableMockBuilder(taskService = taskService) - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a task service variable mock builder. - * @param taskService task service mock. - * @param variables variable map to reuse. - * @param localVariables local variable map to reuse. - * @return fluent builder. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.taskServiceVariableStubBuilder(TaskService, VariableMap, VariableMap)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun taskServiceVariableMockBuilder(taskService: TaskService, variables: VariableMap, localVariables: VariableMap) = TaskServiceVariableMockBuilder(taskService = taskService, variables = variables, localVariables = localVariables) - - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a verifier for task service mock. - * @param taskService a mock to work on. - * @return verifier to simplify assertions. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.taskServiceVerification(TaskService)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun taskServiceMockVerifier(taskService: TaskService) = TaskServiceMockVerifier(taskService) - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a runtime service variable mock builder. - * @param runtimeService runtime service mock. - * @return fluent builder. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.runtimeServiceVariableStubBuilder(RuntimeService)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun runtimeServiceVariableMockBuilder(runtimeService: RuntimeService) = RuntimeServiceVariableMockBuilder(runtimeService = runtimeService) - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a runtime service variable mock builder. - * @param runtimeService runtime service mock. - * @param variables variable map to reuse. - * @param localVariables local variable map to reuse. - * @return fluent builder. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.runtimeServiceVariableStubBuilder(RuntimeService, VariableMap, VariableMap)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun runtimeServiceVariableMockBuilder(runtimeService: RuntimeService, variables: VariableMap, localVariables: VariableMap) = RuntimeServiceVariableMockBuilder(runtimeService = runtimeService, variables = variables, localVariables = localVariables) - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a verifier for runtime service mock. - * @param runtimeService a mock to work on. - * @return verifier to simplify assertions. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.runtimeServiceVerification(RuntimeService)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun runtimeServiceMockVerifier(runtimeService: RuntimeService) = RuntimeServiceMockVerifier(runtimeService) - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a case service variable mock builder. - * @param caseService case service mock. - * @return fluent builder. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.caseServiceVariableStubBuilder(CaseService)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun caseServiceVariableMockBuilder(caseService: CaseService) = CaseServiceVariableMockBuilder(caseService = caseService) - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a case service variable mock builder. - * @param caseService case service mock. - * @param variables variable map to reuse. - * @param localVariables local variable map to reuse. - * @return fluent builder. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.caseServiceVariableStubBuilder(CaseService, VariableMap, VariableMap)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun caseServiceVariableMockBuilder(caseService: CaseService, variables: VariableMap, localVariables: VariableMap) = CaseServiceVariableMockBuilder(caseService = caseService, variables = variables, localVariables = localVariables) - - /** - * @Deprecated "Moved to camunda-platform-7-mockito, will be removed in 1.3.x" - * Constructs a verifier for case service mock. - * @param caseService a mock to work on. - * @return verifier to simplify assertions. - */ - @JvmStatic - @Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("ServiceExpressions.caseServiceVerification(CaseService)", "org.camunda.community.mockito.ServiceExpressions"), - level = DeprecationLevel.WARNING - ) - fun caseServiceMockVerifier(caseService: CaseService) = CaseServiceMockVerifier(caseService) -} diff --git a/extension/test/src/main/kotlin/CaseServiceMockVerifier.kt b/extension/test/src/main/kotlin/CaseServiceMockVerifier.kt deleted file mode 100644 index c3505020..00000000 --- a/extension/test/src/main/kotlin/CaseServiceMockVerifier.kt +++ /dev/null @@ -1,160 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.times -import org.mockito.kotlin.verify -import org.mockito.kotlin.verifyNoMoreInteractions -import io.holunda.camunda.bpm.data.factory.VariableFactory -import org.camunda.bpm.engine.CaseService -import org.mockito.verification.VerificationMode - -/** - * Verifier for a mocked runtime service. - * Provides methods for easy verification. - */ -@Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("CaseServiceVerification", "org.camunda.community.mockito.verify.CaseServiceVerification"), - level = DeprecationLevel.WARNING -) -class CaseServiceMockVerifier( - private val caseService: CaseService -) { - - /** - * Verifies if the variable has been set globally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifySet(variableFactory: VariableFactory, value: T, executionId: String, mode: VerificationMode) { - verify(caseService, mode).setVariable(executionId, variableFactory.name, variableFactory.on(caseService, executionId).getTypedValue(value, false)) - } - - /** - * Verifies if the variable has been set globally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param executionId execution id. - * @param T type of variable. - */ - fun verifySet(variableFactory: VariableFactory, value: T, executionId: String) { - verifySet(variableFactory, value, executionId, times(1)) - } - - /** - * Verifies if the variable has been set locally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifySetLocal(variableFactory: VariableFactory, value: T, executionId: String, mode: VerificationMode) { - verify(caseService, mode).setVariableLocal(executionId, variableFactory.name, variableFactory.on(caseService, executionId).getTypedValue(value, false)) - } - - /** - * Verifies if the variable has been set locally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param executionId execution id. - * @param T type of variable. - */ - fun verifySetLocal(variableFactory: VariableFactory, value: T, executionId: String) { - verifySetLocal(variableFactory, value, executionId, times(1)) - } - - /** - * Verifies if the variable has been retrieved from a global scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyGet(variableFactory: VariableFactory, executionId: String, mode: VerificationMode) { - verify(caseService, mode).getVariable(executionId, variableFactory.name) - } - - /** - * Verifies if the variable has been retrieved from a global scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - */ - fun verifyGet(variableFactory: VariableFactory, executionId: String) { - verifyGet(variableFactory, executionId, times(1)) - } - - /** - * Verifies if the variable has been retrieved from a local scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyGetLocal(variableFactory: VariableFactory, executionId: String, mode: VerificationMode) { - verify(caseService, mode).getVariableLocal(executionId, variableFactory.name) - } - - /** - * Verifies if the variable has been retrieved from a local scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - */ - fun verifyGetLocal(variableFactory: VariableFactory, executionId: String) { - verifyGetLocal(variableFactory, executionId, times(1)) - } - - /** - * Verifies if the variable has been removed from a global scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyRemove(variableFactory: VariableFactory, executionId: String, mode: VerificationMode) { - verify(caseService, mode).removeVariable(executionId, variableFactory.name) - } - - /** - * Verifies if the variable has been removed from a global scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - */ - fun verifyRemove(variableFactory: VariableFactory, executionId: String) { - verifyRemove(variableFactory, executionId, times(1)) - } - - /** - * Verifies if the variable has been removed from a local scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyRemoveLocal(variableFactory: VariableFactory, executionId: String, mode: VerificationMode) { - verify(caseService, mode).removeVariable(executionId, variableFactory.name) - } - - /** - * Verifies if the variable has been removed from a local scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - */ - fun verifyRemoveLocal(variableFactory: VariableFactory, executionId: String) { - verifyRemoveLocal(variableFactory, executionId, times(1)) - } - - /** - * Verifies no more interaction has been performed with the mock. - * @see com.nhaarman.mockitokotlin2.verifyNoMoreInteractions - */ - fun verifyNoMoreInteractions() { - verifyNoMoreInteractions(caseService) - } -} diff --git a/extension/test/src/main/kotlin/CaseServiceVariableMockBuilder.kt b/extension/test/src/main/kotlin/CaseServiceVariableMockBuilder.kt deleted file mode 100644 index 6cb6b4ef..00000000 --- a/extension/test/src/main/kotlin/CaseServiceVariableMockBuilder.kt +++ /dev/null @@ -1,107 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.any -import org.mockito.kotlin.doAnswer -import org.mockito.kotlin.eq -import org.mockito.kotlin.whenever -import io.holunda.camunda.bpm.data.factory.VariableFactory -import org.camunda.bpm.engine.CaseService -import org.camunda.bpm.engine.variable.VariableMap -import org.camunda.bpm.engine.variable.Variables.createVariables -import org.mockito.ArgumentMatchers.anyList -import org.mockito.ArgumentMatchers.anyString - -/** - * Builder to mock the runtime service behavior regarding variables. - */ -@Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("CaseServiceStubBuilder", "org.camunda.community.mockito.service.CaseServiceStubBuilder"), - level = DeprecationLevel.WARNING -) -class CaseServiceVariableMockBuilder( - private val caseService: CaseService, - private val variables: VariableMap = createVariables(), - private val localVariables: VariableMap = createVariables(), - private val factories: MutableList> = mutableListOf() -) { - - /** - * Defines a variable. - * @param variableFactory variable to define. - * @return fluent builder. - */ - fun define(variableFactory: VariableFactory): CaseServiceVariableMockBuilder { - factories.add(variableFactory) - return this - } - - /** - * Defines a variable and sets a global value. - * @param variableFactory factory to use. - * @param value initial value. - * @return fluent builder. - */ - fun initial(variableFactory: VariableFactory, value: T): CaseServiceVariableMockBuilder { - define(variableFactory) - variableFactory.on(variables).set(value) - return this - } - - /** - * Defines a variable and sets a local value. - * @param variableFactory factory to use. - * @param value initial value. - * @return fluent builder. - */ - fun initialLocal(variableFactory: VariableFactory, value: T): CaseServiceVariableMockBuilder { - define(variableFactory) - variableFactory.on(localVariables).set(value) - return this - } - - /** - * Performs the modifications on the task service. - */ - fun build() { - - factories.forEach { factory -> - - // global - doAnswer { - factory.from(variables).get() - }.whenever(caseService).getVariable(anyString(), eq(factory.name)) - - doAnswer { invocation -> - // Arguments: 0: taskId, 1: variable name, 2: value - val value = invocation.getArgument(2) - variables[factory.name] = value - }.whenever(caseService).setVariable(anyString(), eq(factory.name), any()) - - // local - doAnswer { - factory.from(localVariables).get() - }.whenever(caseService).getVariableLocal(anyString(), eq(factory.name)) - - doAnswer { invocation -> - // Arguments: 0: taskId, 1: variable name, 2: value - val value = invocation.getArgument(2) - localVariables[factory.name] = value - }.whenever(caseService).setVariableLocal(anyString(), eq(factory.name), any()) - } - - doAnswer { variables }.whenever(caseService).getVariables(anyString()) - doAnswer { invocation -> - // Arguments: 0: taskId, 1: licat of variables - val variablesList = invocation.getArgument>(1) - variables.filter { variablesList.contains(it.key) } - }.whenever(caseService).getVariables(anyString(), anyList()) - - doAnswer { localVariables }.whenever(caseService).getVariablesLocal(anyString()) - doAnswer { invocation -> - // Arguments: 0: taskId, 1: licat of variables - val variablesList = invocation.getArgument>(1) - localVariables.filter { variablesList.contains(it.key) } - }.whenever(caseService).getVariablesLocal(anyString(), anyList()) - } -} diff --git a/extension/test/src/main/kotlin/RuntimeServiceMockVerifier.kt b/extension/test/src/main/kotlin/RuntimeServiceMockVerifier.kt deleted file mode 100644 index 7a4fe78f..00000000 --- a/extension/test/src/main/kotlin/RuntimeServiceMockVerifier.kt +++ /dev/null @@ -1,157 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.times -import org.mockito.kotlin.verify -import org.mockito.kotlin.verifyNoMoreInteractions -import io.holunda.camunda.bpm.data.factory.VariableFactory -import org.camunda.bpm.engine.RuntimeService -import org.mockito.verification.VerificationMode - -/** - * Verifier for a mocked runtime service. - * Provides methods for easy verification. - */ -@Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("RuntimeServiceVerification", "org.camunda.community.mockito.verify.RuntimeServiceVerification"), - level = DeprecationLevel.WARNING -) -class RuntimeServiceMockVerifier( - private val runtimeService: RuntimeService -) { - - /** - * Verifies if the variable has been set globally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param executionId execution id. - * @param mode verification mode. - * @param T type of variable. - */ - fun verifySet(variableFactory: VariableFactory, value: T, executionId: String, mode: VerificationMode) { - verify(runtimeService, mode).setVariable(executionId, variableFactory.name, variableFactory.on(runtimeService, executionId).getTypedValue(value, false)) - } - - /** - * Verifies if the variable has been set globally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param executionId execution id. - * @param T type of variable. - */ - fun verifySet(variableFactory: VariableFactory, value: T, executionId: String) { - verifySet(variableFactory, value, executionId, times(1)) - } - - /** - * Verifies if the variable has been set locally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifySetLocal(variableFactory: VariableFactory, value: T, executionId: String, mode: VerificationMode) { - verify(runtimeService, mode).setVariableLocal(executionId, variableFactory.name, variableFactory.on(runtimeService, executionId).getTypedValue(value, false)) - } - - /** - * Verifies if the variable has been set locally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param executionId execution id. - * @param T type of variable. - */ - fun verifySetLocal(variableFactory: VariableFactory, value: T, executionId: String) { - verifySetLocal(variableFactory, value, executionId, times(1)) - } - - /** - * Verifies if the variable has been retrieved from a global scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyGet(variableFactory: VariableFactory, executionId: String, mode: VerificationMode) { - verify(runtimeService, mode).getVariable(executionId, variableFactory.name) - } - - fun verifyGet(variableFactory: VariableFactory, executionId: String) { - verifyGet(variableFactory, executionId, times(1)) - } - - /** - * Verifies if the variable has been retrieved from a local scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyGetLocal(variableFactory: VariableFactory, executionId: String, mode: VerificationMode) { - verify(runtimeService, mode).getVariableLocal(executionId, variableFactory.name) - } - - /** - * Verifies if the variable has been retrieved from a local scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyGetLocal(variableFactory: VariableFactory, executionId: String) { - verifyGetLocal(variableFactory, executionId, times(1)) - } - - /** - * Verifies if the variable has been removed from a global scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyRemove(variableFactory: VariableFactory, executionId: String, mode: VerificationMode) { - verify(runtimeService, mode).removeVariable(executionId, variableFactory.name) - } - - /** - * Verifies if the variable has been removed from a global scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyRemove(variableFactory: VariableFactory, executionId: String) { - verifyRemove(variableFactory, executionId, times(1)) - } - - /** - * Verifies if the variable has been removed from a local scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyRemoveLocal(variableFactory: VariableFactory, executionId: String, mode: VerificationMode) { - verify(runtimeService, mode).removeVariable(executionId, variableFactory.name) - } - - /** - * Verifies if the variable has been removed from a local scope. - * @param variableFactory factory defining the variable. - * @param executionId execution id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyRemoveLocal(variableFactory: VariableFactory, executionId: String) { - verifyRemoveLocal(variableFactory, executionId, times(1)) - } - - /** - * Verifies no more interaction has been performed with the mock. - * @see com.nhaarman.mockito_kotlin.verifyNoMoreInteractions - */ - fun verifyNoMoreInteractions() { - verifyNoMoreInteractions(runtimeService) - } -} diff --git a/extension/test/src/main/kotlin/RuntimeServiceVariableMockBuilder.kt b/extension/test/src/main/kotlin/RuntimeServiceVariableMockBuilder.kt deleted file mode 100644 index 8c3f4e8c..00000000 --- a/extension/test/src/main/kotlin/RuntimeServiceVariableMockBuilder.kt +++ /dev/null @@ -1,107 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.any -import org.mockito.kotlin.doAnswer -import org.mockito.kotlin.eq -import org.mockito.kotlin.whenever -import io.holunda.camunda.bpm.data.factory.VariableFactory -import org.camunda.bpm.engine.RuntimeService -import org.camunda.bpm.engine.variable.VariableMap -import org.camunda.bpm.engine.variable.Variables.createVariables -import org.mockito.ArgumentMatchers.anyList -import org.mockito.ArgumentMatchers.anyString - -/** - * Builder to mock the runtime service behavior regarding variables. - */ -@Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("RuntimeServiceStubBuilder", "org.camunda.community.mockito.service.RuntimeServiceStubBuilder"), - level = DeprecationLevel.WARNING -) -class RuntimeServiceVariableMockBuilder( - private val runtimeService: RuntimeService, - private val variables: VariableMap = createVariables(), - private val localVariables: VariableMap = createVariables(), - private val factories: MutableList> = mutableListOf() -) { - - /** - * Defines a variable. - * @param variableFactory variable to define. - * @return fluent builder. - */ - fun define(variableFactory: VariableFactory): RuntimeServiceVariableMockBuilder { - factories.add(variableFactory) - return this - } - - /** - * Defines a variable and sets a global value. - * @param variableFactory factory to use. - * @param value initial value. - * @return fluent builder. - */ - fun initial(variableFactory: VariableFactory, value: T): RuntimeServiceVariableMockBuilder { - define(variableFactory) - variableFactory.on(variables).set(value) - return this - } - - /** - * Defines a variable and sets a local value. - * @param variableFactory factory to use. - * @param value initial value. - * @return fluent builder. - */ - fun initialLocal(variableFactory: VariableFactory, value: T): RuntimeServiceVariableMockBuilder { - define(variableFactory) - variableFactory.on(localVariables).set(value) - return this - } - - /** - * Performs the modifications on the task service. - */ - fun build() { - - factories.forEach { factory -> - - // global - doAnswer { - factory.from(variables).get() - }.whenever(runtimeService).getVariable(anyString(), eq(factory.name)) - - doAnswer { invocation -> - // Arguments: 0: taskId, 1: variable name, 2: value - val value = invocation.getArgument(2) - variables[factory.name] = value - }.whenever(runtimeService).setVariable(anyString(), eq(factory.name), any()) - - // local - doAnswer { - factory.from(localVariables).get() - }.whenever(runtimeService).getVariableLocal(anyString(), eq(factory.name)) - - doAnswer { invocation -> - // Arguments: 0: taskId, 1: variable name, 2: value - val value = invocation.getArgument(2) - localVariables[factory.name] = value - }.whenever(runtimeService).setVariableLocal(anyString(), eq(factory.name), any()) - } - - doAnswer { variables }.whenever(runtimeService).getVariables(anyString()) - doAnswer { invocation -> - // Arguments: 0: taskId, 1: licat of variables - val variablesList = invocation.getArgument>(1) - variables.filter { variablesList.contains(it.key) } - }.whenever(runtimeService).getVariables(anyString(), anyList()) - - doAnswer { localVariables }.whenever(runtimeService).getVariablesLocal(anyString()) - doAnswer { invocation -> - // Arguments: 0: taskId, 1: licat of variables - val variablesList = invocation.getArgument>(1) - localVariables.filter { variablesList.contains(it.key) } - }.whenever(runtimeService).getVariablesLocal(anyString(), anyList()) - } -} diff --git a/extension/test/src/main/kotlin/TaskServiceMockVerifier.kt b/extension/test/src/main/kotlin/TaskServiceMockVerifier.kt deleted file mode 100644 index 3e44ff99..00000000 --- a/extension/test/src/main/kotlin/TaskServiceMockVerifier.kt +++ /dev/null @@ -1,179 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.times -import org.mockito.kotlin.verify -import org.mockito.kotlin.verifyNoMoreInteractions -import io.holunda.camunda.bpm.data.factory.VariableFactory -import org.camunda.bpm.engine.TaskService -import org.camunda.bpm.engine.variable.VariableMap -import org.mockito.verification.VerificationMode - -/** - * Verifier for a mocked task service. - * Provides methods for easy verification. - */ -@Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("TaskServiceVerification", "org.camunda.community.mockito.verify.TaskServiceVerification"), - level = DeprecationLevel.WARNING -) -class TaskServiceMockVerifier( - private val taskService: TaskService -) { - - /** - * Verifies if the variable has been set globally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param taskId task id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifySet(variableFactory: VariableFactory, value: T, taskId: String, mode: VerificationMode) { - verify(taskService, mode).setVariable(taskId, variableFactory.name, variableFactory.on(taskService, taskId).getTypedValue(value, false)) - } - - /** - * Verifies if the variable has been set globally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param taskId task id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifySet(variableFactory: VariableFactory, value: T, taskId: String) { - verifySet(variableFactory, value, taskId, times(1)) - } - - /** - * Verifies if the variable has been set locally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param taskId task id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifySetLocal(variableFactory: VariableFactory, value: T, taskId: String, mode: VerificationMode) { - verify(taskService, mode).setVariableLocal(taskId, variableFactory.name, variableFactory.on(taskService, taskId).getTypedValue(value, false)) - } - - /** - * Verifies if the variable has been set locally. - * @param variableFactory factory defining the variable. - * @param value value to set. - * @param taskId task id. - * @param T type of variable. - */ - fun verifySetLocal(variableFactory: VariableFactory, value: T, taskId: String) { - verifySetLocal(variableFactory, value, taskId, times(1)) - } - - /** - * Verifies if the variable has been retrieved from a global scope. - * @param variableFactory factory defining the variable. - * @param taskId task id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyGet(variableFactory: VariableFactory, taskId: String, mode: VerificationMode) { - verify(taskService, mode).getVariable(taskId, variableFactory.name) - } - - /** - * Verifies if the variable has been retrieved from a global scope. - * @param variableFactory factory defining the variable. - * @param taskId task id. - * @param T type of variable. - */ - fun verifyGet(variableFactory: VariableFactory, taskId: String) { - verifyGet(variableFactory, taskId, times(1)) - } - - /** - * Verifies if the variable has been retrieved from a local scope. - * @param variableFactory factory defining the variable. - * @param taskId task id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyGetLocal(variableFactory: VariableFactory, taskId: String, mode: VerificationMode) { - verify(taskService, mode).getVariableLocal(taskId, variableFactory.name) - } - - /** - * Verifies if the variable has been retrieved from a local scope. - * @param variableFactory factory defining the variable. - * @param taskId task id. - * @param T type of variable. - */ - fun verifyGetLocal(variableFactory: VariableFactory, taskId: String) { - verifyGetLocal(variableFactory, taskId, times(1)) - } - - /** - * Verifies if the variable has been removed from a global scope. - * @param variableFactory factory defining the variable. - * @param taskId task id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyRemove(variableFactory: VariableFactory, taskId: String, mode: VerificationMode) { - verify(taskService, mode).removeVariable(taskId, variableFactory.name) - } - - /** - * Verifies if the variable has been removed from a global scope. - * @param variableFactory factory defining the variable. - * @param taskId task id. - * @param T type of variable. - */ - fun verifyRemove(variableFactory: VariableFactory, taskId: String) { - verifyRemove(variableFactory, taskId, times(1)) - } - - /** - * Verifies if the variable has been removed from a local scope. - * @param variableFactory factory defining the variable. - * @param taskId task id. - * @param T type of variable. - * @param mode verification mode. - */ - fun verifyRemoveLocal(variableFactory: VariableFactory, taskId: String, mode: VerificationMode) { - verify(taskService, mode).removeVariable(taskId, variableFactory.name) - } - - /** - * Verifies if the variable has been removed from a local scope. - * @param variableFactory factory defining the variable. - * @param taskId task id. - * @param T type of variable. - */ - fun verifyRemoveLocal(variableFactory: VariableFactory, taskId: String) { - verifyRemoveLocal(variableFactory, taskId, times(1)) - } - - /** - * Verifies if the task has been completed without variables. - * @param taskId task id. - */ - fun verifyComplete(taskId: String) { - verify(taskService).complete(taskId) - } - - /** - * Verifies if the task has been completed with variables. - * @param taskId task id. - * @param variables variables to complete the task. - */ - fun verifyComplete(variables: VariableMap, taskId: String) { - verify(taskService).complete(taskId, variables) - } - - /** - * Verifies no more interaction has been performed with the mock. - * @see [com.nhaarman.mockitokotlin2.verifyNoMoreInteractions] - */ - fun verifyNoMoreInteractions() { - verifyNoMoreInteractions(taskService) - } -} diff --git a/extension/test/src/main/kotlin/TaskServiceVariableMockBuilder.kt b/extension/test/src/main/kotlin/TaskServiceVariableMockBuilder.kt deleted file mode 100644 index e38f8226..00000000 --- a/extension/test/src/main/kotlin/TaskServiceVariableMockBuilder.kt +++ /dev/null @@ -1,106 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import io.holunda.camunda.bpm.data.factory.VariableFactory -import org.camunda.bpm.engine.TaskService -import org.camunda.bpm.engine.variable.VariableMap -import org.camunda.bpm.engine.variable.Variables.createVariables -import org.mockito.ArgumentMatchers.anyList -import org.mockito.ArgumentMatchers.anyString -import org.mockito.kotlin.any -import org.mockito.kotlin.doAnswer -import org.mockito.kotlin.eq -import org.mockito.kotlin.whenever - -/** - * Builder to mock the task service behavior regarding variables. - */ -@Deprecated( - message = "Moved to camunda-platform-7-mockito, will be removed in 1.3.x", - replaceWith = ReplaceWith("TaskServiceStubBuilder", "org.camunda.community.mockito.service.TaskServiceStubBuilder"), - level = DeprecationLevel.WARNING -) -class TaskServiceVariableMockBuilder( - private val taskService: TaskService, - private val variables: VariableMap = createVariables(), - private val localVariables: VariableMap = createVariables(), - private val factories: MutableList> = mutableListOf() -) { - - /** - * Defines a global variable. - * @param variableFactory variable to define. - * @return fluent builder. - */ - fun define(variableFactory: VariableFactory): TaskServiceVariableMockBuilder { - factories.add(variableFactory) - return this - } - - /** - * Defines a variable and sets an initial global value. - * @param variableFactory factory to use. - * @param value initial value. - * @return fluent builder. - */ - fun initial(variableFactory: VariableFactory, value: T): TaskServiceVariableMockBuilder { - define(variableFactory) - variableFactory.on(variables).set(value) - return this - } - - /** - * Defines a variable and sets an initial local value. - * @param variableFactory factory to use. - * @param value initial value. - * @return fluent builder. - */ - fun initialLocal(variableFactory: VariableFactory, value: T): TaskServiceVariableMockBuilder { - factories.add(variableFactory) - variableFactory.on(localVariables).set(value) - return this - } - - /** - * Performs the modifications on the task service. - */ - fun build() { - - factories.forEach { factory -> - - // global - doAnswer { - factory.from(variables).get() - }.whenever(taskService).getVariable(anyString(), eq(factory.name)) - - doAnswer { invocation -> - // Arguments: 0: taskId, 1: variable name, 2: value - val value = invocation.getArgument(2) - variables[factory.name] = value - }.whenever(taskService).setVariable(anyString(), eq(factory.name), any()) - - // local - doAnswer { - factory.from(localVariables).get() - }.whenever(taskService).getVariableLocal(anyString(), eq(factory.name)) - - doAnswer { invocation -> - // Arguments: 0: taskId, 1: variable name, 2: value - val value = invocation.getArgument(2) - localVariables[factory.name] = value - }.whenever(taskService).setVariableLocal(anyString(), eq(factory.name), any()) - } - - doAnswer { variables }.whenever(taskService).getVariables(anyString()) - doAnswer { invocation -> - // Arguments: 0: taskId, 1: licat of variables - val variablesList = invocation.getArgument>(1) - variables.filter { variablesList.contains(it.key) } - }.whenever(taskService).getVariables(anyString(), anyList()) - doAnswer { localVariables }.whenever(taskService).getVariablesLocal(anyString()) - doAnswer { invocation -> - // Arguments: 0: taskId, 1: licat of variables - val variablesList = invocation.getArgument>(1) - localVariables.filter { variablesList.contains(it.key) } - }.whenever(taskService).getVariablesLocal(anyString(), anyList()) - } -} diff --git a/extension/test/src/main/kotlin/packages.md b/extension/test/src/main/kotlin/packages.md deleted file mode 100644 index 9c121b41..00000000 --- a/extension/test/src/main/kotlin/packages.md +++ /dev/null @@ -1,6 +0,0 @@ -# Package io.holunda.camunda.bpm.data.mockito - -Top-level package of the test library. - -check [io.holunda.camunda.bpm.data.mockito.CamundaBpmDataMockito] as entry point. -@since 0.0.2 diff --git a/extension/test/src/test/kotlin/CaseServiceMockingTest.kt b/extension/test/src/test/kotlin/CaseServiceMockingTest.kt deleted file mode 100644 index 113058ea..00000000 --- a/extension/test/src/test/kotlin/CaseServiceMockingTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.mock -import io.holunda.camunda.bpm.data.CamundaBpmData.booleanVariable -import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable -import org.assertj.core.api.Assertions.assertThat -import org.camunda.bpm.engine.CaseService -import org.junit.Test -import java.util.* - -/** - * This test demonstrates the mocking capabilities. - */ -class CaseServiceMockingTest { - - companion object { - val ORDER_ID = stringVariable("orderId") - val ORDER_FLAG = booleanVariable("orderFlag") - } - - private val caseService = mock() - private val testService = CaseServiceAwareService(caseService) - - @Test - fun should_mock_task_service() { - - val executionId = UUID.randomUUID().toString() - - CaseServiceVariableMockBuilder(caseService) - .initialLocal(ORDER_ID, "initial-Value") - .define(ORDER_FLAG) - .build() - - testService.writeLocalOrderId(executionId, "4712") - val orderId = testService.readLocalOrderId(executionId) - - assertThat(testService.flagExists(executionId)).isFalse - testService.writeFlag(executionId, true) - assertThat(testService.flagExists(executionId)).isTrue - val orderFlag = testService.readFlag(executionId) - - assertThat(orderId).isEqualTo("4712") - assertThat(orderFlag).isEqualTo(true) - } - - - /** - * Test service. - * @param runtimeService task service to work on. - */ - class CaseServiceAwareService(val caseService: CaseService) { - - fun readLocalOrderId(executionId: String): String = - ORDER_ID.from(caseService, executionId).local - - fun writeLocalOrderId(executionId: String, value: String) = - ORDER_ID.on(caseService, executionId).setLocal(value) - - fun flagExists(executionId: String) = - caseService.getVariables(executionId).containsKey(ORDER_FLAG.name) - - fun writeFlag(executionId: String, flag: Boolean) = - ORDER_FLAG.on(caseService, executionId).set(flag) - - fun readFlag(executionId: String): Boolean = - ORDER_FLAG.from(caseService, executionId).get() - } -} diff --git a/extension/test/src/test/kotlin/CaseServiceVerifierTest.kt b/extension/test/src/test/kotlin/CaseServiceVerifierTest.kt deleted file mode 100644 index 57833ac3..00000000 --- a/extension/test/src/test/kotlin/CaseServiceVerifierTest.kt +++ /dev/null @@ -1,153 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.mock -import org.mockito.kotlin.reset -import org.mockito.kotlin.times -import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable -import org.camunda.bpm.engine.CaseService -import org.junit.Before -import org.junit.Test -import java.util.* - -class CaseServiceVerifierTest { - - companion object { - val VAR = stringVariable("var") - } - - private val caseService = mock() - - @Before - fun resetMocks() { - reset(caseService) - } - - @Test - fun verifyGet() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).initial(VAR, "value").build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.from(caseService, executionId).get() - verifier.verifyGet(VAR, executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyGetTimes() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).initial(VAR, "value").build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - - VAR.from(caseService, executionId).get() - VAR.from(caseService, executionId).get() - - verifier.verifyGet(VAR, executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - - @Test - fun verifyGetLocal() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).initialLocal(VAR, "value").build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.from(caseService, executionId).local - verifier.verifyGetLocal(VAR, executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyGetLocalTimes() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).initialLocal(VAR, "value").build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.from(caseService, executionId).local - VAR.from(caseService, executionId).local - verifier.verifyGetLocal(VAR, executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySet() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).define(VAR).build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.on(caseService, executionId).set("value") - verifier.verifySet(VAR, "value", executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetTimes() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).define(VAR).build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.on(caseService, executionId).set("value") - VAR.on(caseService, executionId).set("value") - verifier.verifySet(VAR, "value", executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetLocal() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).define(VAR).build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.on(caseService, executionId).setLocal("valueLocal") - verifier.verifySetLocal(VAR, "valueLocal", executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetLocalTimes() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).define(VAR).build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.on(caseService, executionId).setLocal("valueLocal") - VAR.on(caseService, executionId).setLocal("valueLocal") - verifier.verifySetLocal(VAR, "valueLocal", executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemove() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).initial(VAR, "value").build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.on(caseService, executionId).remove() - verifier.verifyRemove(VAR, executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveTimes() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).initial(VAR, "value").build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.on(caseService, executionId).remove() - VAR.on(caseService, executionId).remove() - verifier.verifyRemove(VAR, executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveLocal() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).initialLocal(VAR, "localValue").build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.on(caseService, executionId).remove() - verifier.verifyRemoveLocal(VAR, executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveLocalTimes() { - CamundaBpmDataMockito.caseServiceVariableMockBuilder(caseService).initialLocal(VAR, "localValue").build() - val verifier = CamundaBpmDataMockito.caseServiceMockVerifier(caseService) - val executionId = UUID.randomUUID().toString() - VAR.on(caseService, executionId).remove() - VAR.on(caseService, executionId).remove() - verifier.verifyRemoveLocal(VAR, executionId, times(2)) - verifier.verifyNoMoreInteractions() - } -} diff --git a/extension/test/src/test/kotlin/RuntimeServiceMockingTest.kt b/extension/test/src/test/kotlin/RuntimeServiceMockingTest.kt deleted file mode 100644 index f07bd262..00000000 --- a/extension/test/src/test/kotlin/RuntimeServiceMockingTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.mock -import io.holunda.camunda.bpm.data.CamundaBpmData.booleanVariable -import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable -import org.assertj.core.api.Assertions.assertThat -import org.camunda.bpm.engine.RuntimeService -import org.junit.Test -import java.util.* - -/** - * This test demonstrates the mocking capabilities. - */ -class RuntimeServiceMockingTest { - - companion object { - val ORDER_ID = stringVariable("orderId") - val ORDER_FLAG = booleanVariable("orderFlag") - } - - private val runtimeService = mock() - private val testService = RuntimeServiceAwareService(runtimeService) - - @Test - fun should_mock_runtime_service() { - - val executionId = UUID.randomUUID().toString() - - RuntimeServiceVariableMockBuilder(runtimeService) - .initialLocal(ORDER_ID, "initial-Value") - .define(ORDER_FLAG) - .build() - - testService.writeLocalOrderId(executionId, "4712") - val orderId = testService.readLocalOrderId(executionId) - - assertThat(testService.flagExists(executionId)).isFalse - testService.writeFlag(executionId, true) - assertThat(testService.flagExists(executionId)).isTrue - val orderFlag = testService.readFlag(executionId) - - assertThat(orderId).isEqualTo("4712") - assertThat(orderFlag).isEqualTo(true) - } - - - /** - * Test service. - * @param runtimeService task service to work on. - */ - class RuntimeServiceAwareService(val runtimeService: RuntimeService) { - - fun readLocalOrderId(executionId: String): String = - ORDER_ID.from(runtimeService, executionId).local - - fun writeLocalOrderId(executionId: String, value: String) = - ORDER_ID.on(runtimeService, executionId).setLocal(value) - - fun flagExists(executionId: String) = - runtimeService.getVariables(executionId).containsKey(ORDER_FLAG.name) - - fun writeFlag(executionId: String, flag: Boolean) = - ORDER_FLAG.on(runtimeService, executionId).set(flag) - - fun readFlag(executionId: String): Boolean = - ORDER_FLAG.from(runtimeService, executionId).get() - } -} diff --git a/extension/test/src/test/kotlin/RuntimeServiceVerifierTest.kt b/extension/test/src/test/kotlin/RuntimeServiceVerifierTest.kt deleted file mode 100644 index 9fe38e27..00000000 --- a/extension/test/src/test/kotlin/RuntimeServiceVerifierTest.kt +++ /dev/null @@ -1,158 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.mock -import org.mockito.kotlin.reset -import org.mockito.kotlin.times -import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable -import io.holunda.camunda.bpm.data.mockito.CamundaBpmDataMockito.runtimeServiceMockVerifier -import io.holunda.camunda.bpm.data.mockito.CamundaBpmDataMockito.runtimeServiceVariableMockBuilder -import org.camunda.bpm.engine.RuntimeService -import org.junit.Assert.assertThrows -import org.junit.Before -import org.junit.Test -import org.mockito.exceptions.verification.TooManyActualInvocations -import java.util.* - -class RuntimeServiceVerifierTest { - - companion object { - val VAR = stringVariable("var") - } - - private val runtimeService = mock() - - @Before - fun resetMocks() { - reset(runtimeService) - } - - @Test - fun verifyGet() { - runtimeServiceVariableMockBuilder(runtimeService).initial(VAR, "value").build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.from(runtimeService, executionId).get() - verifier.verifyGet(VAR, executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyGetTimes() { - runtimeServiceVariableMockBuilder(runtimeService).initial(VAR, "value").build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.from(runtimeService, executionId).get() - VAR.from(runtimeService, executionId).get() - assertThrows(TooManyActualInvocations::class.java) { - verifier.verifyGet(VAR, executionId) - } - verifier.verifyGet(VAR, executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyGetLocal() { - runtimeServiceVariableMockBuilder(runtimeService).initialLocal(VAR, "value").build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.from(runtimeService, executionId).local - verifier.verifyGetLocal(VAR, executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyGetLocalTimes() { - runtimeServiceVariableMockBuilder(runtimeService).initialLocal(VAR, "value").build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.from(runtimeService, executionId).local - VAR.from(runtimeService, executionId).local - verifier.verifyGetLocal(VAR, executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySet() { - runtimeServiceVariableMockBuilder(runtimeService).define(VAR).build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.on(runtimeService, executionId).set("value") - verifier.verifySet(VAR, "value", executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetLocal() { - runtimeServiceVariableMockBuilder(runtimeService).define(VAR).build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.on(runtimeService, executionId).setLocal("valueLocal") - verifier.verifySetLocal(VAR, "valueLocal", executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemove() { - runtimeServiceVariableMockBuilder(runtimeService).initial(VAR, "value").build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.on(runtimeService, executionId).remove() - verifier.verifyRemove(VAR, executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveLocal() { - runtimeServiceVariableMockBuilder(runtimeService).initialLocal(VAR, "localValue").build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.on(runtimeService, executionId).remove() - verifier.verifyRemoveLocal(VAR, executionId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetTimes() { - runtimeServiceVariableMockBuilder(runtimeService).define(VAR).build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.on(runtimeService, executionId).set("value") - VAR.on(runtimeService, executionId).set("value") - verifier.verifySet(VAR, "value", executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetLocalTimes() { - runtimeServiceVariableMockBuilder(runtimeService).define(VAR).build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.on(runtimeService, executionId).setLocal("valueLocal") - VAR.on(runtimeService, executionId).setLocal("valueLocal") - verifier.verifySetLocal(VAR, "valueLocal", executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveTimes() { - runtimeServiceVariableMockBuilder(runtimeService).initial(VAR, "value").build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.on(runtimeService, executionId).remove() - VAR.on(runtimeService, executionId).remove() - verifier.verifyRemove(VAR, executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveLocalTimes() { - runtimeServiceVariableMockBuilder(runtimeService).initialLocal(VAR, "localValue").build() - val verifier = runtimeServiceMockVerifier(runtimeService) - val executionId = UUID.randomUUID().toString() - VAR.on(runtimeService, executionId).remove() - VAR.on(runtimeService, executionId).remove() - verifier.verifyRemoveLocal(VAR, executionId, times(2)) - verifier.verifyNoMoreInteractions() - } - -} diff --git a/extension/test/src/test/kotlin/TaskServiceMockingTest.kt b/extension/test/src/test/kotlin/TaskServiceMockingTest.kt deleted file mode 100644 index 22cd1809..00000000 --- a/extension/test/src/test/kotlin/TaskServiceMockingTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.mock -import io.holunda.camunda.bpm.data.CamundaBpmData.booleanVariable -import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable -import org.assertj.core.api.Assertions.assertThat -import org.camunda.bpm.engine.TaskService -import org.junit.Test -import java.util.* - -/** - * This test demonstrates the mocking capabilities. - */ -class TaskServiceMockingTest { - - companion object { - val ORDER_ID = stringVariable("orderId") - val ORDER_FLAG = booleanVariable("orderFlag") - } - - private val taskService = mock() - private val testService = TaskServiceAwareService(taskService) - - @Test - fun should_mock_task_service() { - - val taskId = UUID.randomUUID().toString() - - TaskServiceVariableMockBuilder(taskService) - .initial(ORDER_ID, "initial-Value") - .define(ORDER_FLAG) - .build() - - testService.writeOrderId(taskId, "4712") - val orderId = testService.readOrderId(taskId) - - assertThat(testService.localFlagExists(taskId)).isFalse - testService.writeLocalFlag(taskId, true) - assertThat(testService.localFlagExists(taskId)).isTrue - val orderFlag = testService.readLocalFlag(taskId) - - assertThat(orderId).isEqualTo("4712") - assertThat(orderFlag).isEqualTo(true) - } - - - /** - * Test service. - * @param taskService task service to work on. - */ - class TaskServiceAwareService(val taskService: TaskService) { - - fun readOrderId(taskId: String): String = - ORDER_ID.from(taskService, taskId).get() - - fun writeOrderId(taskId: String, value: String) = - ORDER_ID.on(taskService, taskId).set(value) - - fun localFlagExists(taskId: String) = - taskService.getVariablesLocal(taskId).containsKey(ORDER_FLAG.name) - - fun writeLocalFlag(taskId: String, flag: Boolean) = - ORDER_FLAG.on(taskService, taskId).setLocal(flag) - - fun readLocalFlag(taskId: String): Boolean = - ORDER_FLAG.from(taskService, taskId).local - } -} diff --git a/extension/test/src/test/kotlin/TaskServiceVerifierTest.kt b/extension/test/src/test/kotlin/TaskServiceVerifierTest.kt deleted file mode 100644 index 29c9fe17..00000000 --- a/extension/test/src/test/kotlin/TaskServiceVerifierTest.kt +++ /dev/null @@ -1,176 +0,0 @@ -package io.holunda.camunda.bpm.data.mockito - -import org.mockito.kotlin.mock -import org.mockito.kotlin.reset -import org.mockito.kotlin.times -import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable -import io.holunda.camunda.bpm.data.mockito.CamundaBpmDataMockito.taskServiceMockVerifier -import io.holunda.camunda.bpm.data.mockito.CamundaBpmDataMockito.taskServiceVariableMockBuilder -import io.holunda.camunda.bpm.data.set -import org.camunda.bpm.engine.TaskService -import org.camunda.bpm.engine.variable.Variables.createVariables -import org.junit.Before -import org.junit.Test -import java.util.* -import kotlin.concurrent.timer - -class TaskServiceVerifierTest { - - companion object { - val VAR = stringVariable("var") - } - - private val taskService = mock() - - @Before - fun resetMocks() { - reset(taskService) - } - - @Test - fun verifyGet() { - taskServiceVariableMockBuilder(taskService).initial(VAR, "value").build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.from(taskService, taskId).get() - verifier.verifyGet(VAR, taskId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyGetLocal() { - taskServiceVariableMockBuilder(taskService).initialLocal(VAR, "value").build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.from(taskService, taskId).local - verifier.verifyGetLocal(VAR, taskId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySet() { - taskServiceVariableMockBuilder(taskService).define(VAR).build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.on(taskService, taskId).set("value") - verifier.verifySet(VAR, "value", taskId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetLocal() { - taskServiceVariableMockBuilder(taskService).define(VAR).build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.on(taskService, taskId).setLocal("valueLocal") - verifier.verifySetLocal(VAR, "valueLocal", taskId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemove() { - taskServiceVariableMockBuilder(taskService).initial(VAR, "value").build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.on(taskService, taskId).remove() - verifier.verifyRemove(VAR, taskId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveLocal() { - taskServiceVariableMockBuilder(taskService).initialLocal(VAR, "localValue").build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.on(taskService, taskId).remove() - verifier.verifyRemoveLocal(VAR, taskId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyGetTimes() { - taskServiceVariableMockBuilder(taskService).initial(VAR, "value").build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.from(taskService, taskId).get() - VAR.from(taskService, taskId).get() - verifier.verifyGet(VAR, taskId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyGetLocalTimes() { - taskServiceVariableMockBuilder(taskService).initialLocal(VAR, "value").build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.from(taskService, taskId).local - VAR.from(taskService, taskId).local - verifier.verifyGetLocal(VAR, taskId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetTimes() { - taskServiceVariableMockBuilder(taskService).define(VAR).build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.on(taskService, taskId).set("value") - VAR.on(taskService, taskId).set("value") - verifier.verifySet(VAR, "value", taskId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifySetLocalTimes() { - taskServiceVariableMockBuilder(taskService).define(VAR).build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.on(taskService, taskId).setLocal("valueLocal") - VAR.on(taskService, taskId).setLocal("valueLocal") - verifier.verifySetLocal(VAR, "valueLocal", taskId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveTimes() { - taskServiceVariableMockBuilder(taskService).initial(VAR, "value").build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.on(taskService, taskId).remove() - VAR.on(taskService, taskId).remove() - verifier.verifyRemove(VAR, taskId, times(2)) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyRemoveLocalTimes() { - taskServiceVariableMockBuilder(taskService).initialLocal(VAR, "localValue").build() - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - VAR.on(taskService, taskId).remove() - VAR.on(taskService, taskId).remove() - verifier.verifyRemoveLocal(VAR, taskId, times(2)) - verifier.verifyNoMoreInteractions() - } - - - @Test - fun verifyComplete() { - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - taskService.complete(taskId) - verifier.verifyComplete(taskId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun verifyCompleteWithVars() { - val verifier = taskServiceMockVerifier(taskService) - val taskId = UUID.randomUUID().toString() - val vars = createVariables() - .set(VAR, "someValue") - taskService.complete(taskId, vars) - verifier.verifyComplete(vars, taskId) - verifier.verifyNoMoreInteractions() - } -} diff --git a/pom.xml b/pom.xml index e73f8f51..76dea992 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 2.7.5 2.4.21 1.18.0 - 15.0.0 + ${camunda.version.ce} 1.7.21 1.2.4 @@ -32,7 +32,7 @@ 3.0.4 4.1.0 - 6.17.1 + 6.18.0 **/*ITest.* **/itest/**/*.* @@ -45,7 +45,7 @@ extension/core - extension/test + extension/c7 @@ -71,12 +71,6 @@ io.github.microutils kotlin-logging-jvm ${kotlin-logging.version} - - - org.jetbrains.kotlin - kotlin-stdlib - - @@ -103,13 +97,7 @@ org.camunda.bpm.springboot camunda-bpm-spring-boot-starter-test - ${camunda.version} - test - - - org.camunda.bpm.assert - camunda-bpm-assert - ${camunda-assert.version} + ${camunda.version.ce} test @@ -138,8 +126,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-api test @@ -544,7 +532,7 @@ org.camunda.bpm.springboot camunda-bpm-spring-boot-starter-webapp - ${camunda.version} + ${camunda.version.ce} @@ -571,7 +559,7 @@ org.camunda.bpm.springboot camunda-bpm-spring-boot-starter-webapp-ee - ${camunda.version} + ${camunda.version.ee} From 415fa0a3d4ad6d02e4c34a7bd1f77cc8fef5e682 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Nov 2022 01:13:12 +0000 Subject: [PATCH 09/67] build(deps): bump camunda-platform-7-mockito from 6.17.1 to 6.18.0 Bumps [camunda-platform-7-mockito](https://github.com/camunda/camunda-platform-7-mockito) from 6.17.1 to 6.18.0. - [Release notes](https://github.com/camunda/camunda-platform-7-mockito/releases) - [Commits](https://github.com/camunda/camunda-platform-7-mockito/commits) --- updated-dependencies: - dependency-name: org.camunda.community.mockito:camunda-platform-7-mockito dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e73f8f51..a81b42f1 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ 3.0.4 4.1.0 - 6.17.1 + 6.18.0 **/*ITest.* **/itest/**/*.* From b6828ba512d0dfca6a771eafb618f94841701243 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 2 Dec 2022 17:41:57 +0100 Subject: [PATCH 10/67] updating to Junit 5 --- .codacy.yaml | 10 ---- .codacy.yml | 10 +++- example/example-java/pom.xml | 47 +++++-------------- .../src/main/resources/application.yaml | 3 -- .../example/process/GuardProcessTest.java | 32 +++++++------ .../process/OrderApprovalProcessTest.java | 19 ++++---- .../rest/ApproveOrderTaskControllerTest.java | 21 ++++----- example/example-kotlin/pom.xml | 39 --------------- .../src/main/resources/application.yml | 3 -- example/example-no-engine/pom.xml | 2 +- .../src/main/resources/application.yml | 3 -- example/itest/pom.xml | 45 ++---------------- example/pom.xml | 16 ++++--- .../holunda/camunda/bpm/data/acl/ACLTest.kt | 32 ++++++------- pom.xml | 3 +- 15 files changed, 85 insertions(+), 200 deletions(-) delete mode 100644 .codacy.yaml diff --git a/.codacy.yaml b/.codacy.yaml deleted file mode 100644 index 8f143d41..00000000 --- a/.codacy.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -engines: - duplications: - exclude_paths: - - "**/src/test/kotlin/**" - -exclude_paths: - - "README.md" - - ".github/**" - - "docs/**" diff --git a/.codacy.yml b/.codacy.yml index 0b422286..99248088 100644 --- a/.codacy.yml +++ b/.codacy.yml @@ -1,5 +1,11 @@ --- +engines: + duplications: + exclude_paths: + - "**/src/test/kotlin/**" + exclude_paths: - - '.github/**' - - 'docs/**' + - "README.md" + - ".github/**" + - "docs/**" - '**/packages.md' diff --git a/example/example-java/pom.xml b/example/example-java/pom.xml index 882af44a..671d9e6e 100644 --- a/example/example-java/pom.xml +++ b/example/example-java/pom.xml @@ -81,42 +81,6 @@ com.h2database h2 - - org.codehaus.groovy - groovy - - - org.codehaus.groovy - groovy-datetime - - - org.codehaus.groovy - groovy-jmx - - - org.codehaus.groovy - groovy-json - - - org.codehaus.groovy - groovy-jsr223 - - - org.codehaus.groovy - groovy-macro - - - org.codehaus.groovy - groovy-nio - - - org.codehaus.groovy - groovy-templates - - - org.codehaus.groovy - groovy-xml - @@ -134,6 +98,12 @@ org.camunda.bpm.springboot camunda-bpm-spring-boot-starter-test test + + + org.junit.vintage + junit-vintage-engine + + org.camunda.community.mockito @@ -150,6 +120,11 @@ camunda-bpm-jgiven test + + org.camunda.bpm + camunda-bpm-junit5 + test + diff --git a/example/example-java/src/main/resources/application.yaml b/example/example-java/src/main/resources/application.yaml index fca4374c..c6f55b6d 100644 --- a/example/example-java/src/main/resources/application.yaml +++ b/example/example-java/src/main/resources/application.yaml @@ -5,9 +5,6 @@ spring: name: Camunda BPM Data Java Example jpa: open-in-view: true - groovy: - template: - check-template-location: false camunda: bpm: diff --git a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/GuardProcessTest.java b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/GuardProcessTest.java index e991cd62..28a8c837 100644 --- a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/GuardProcessTest.java +++ b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/GuardProcessTest.java @@ -1,6 +1,5 @@ package io.holunda.camunda.bpm.data.example.process; -import com.google.common.collect.Lists; import io.holunda.camunda.bpm.data.example.domain.Order; import io.holunda.camunda.bpm.data.guard.integration.GuardViolationException; import org.camunda.bpm.engine.ProcessEngineException; @@ -8,13 +7,13 @@ import org.camunda.bpm.engine.runtime.Job; import org.camunda.bpm.engine.task.Task; import org.camunda.bpm.engine.test.Deployment; -import org.camunda.bpm.engine.test.ProcessEngineRule; +import org.camunda.bpm.engine.test.junit5.ProcessEngineExtension; import org.camunda.bpm.engine.test.mock.Mocks; import org.camunda.bpm.spring.boot.starter.test.helper.StandaloneInMemoryTestConfiguration; import org.camunda.spin.plugin.impl.SpinProcessEnginePlugin; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import java.sql.Date; import java.time.Instant; @@ -25,12 +24,15 @@ @Deployment(resources = "order_approval.bpmn") public class GuardProcessTest { - @Rule - public final ProcessEngineRule rule = new StandaloneInMemoryTestConfiguration( - Lists.newArrayList(new SpinProcessEnginePlugin()) - ).rule(); - @Before + @RegisterExtension + private static final ProcessEngineExtension engine = ProcessEngineExtension + .builder() + .useProcessEngine(new StandaloneInMemoryTestConfiguration(new SpinProcessEnginePlugin()).buildProcessEngine()) + .build(); + + + @BeforeEach public void register() { OrderApproval config = new OrderApproval(); Mocks.register("guardExecutionListener", config.guardExecutionListener()); @@ -56,7 +58,7 @@ public void shouldFireExceptionIfOrderIdIsMissing() { assertThrows( GuardViolationException.class, // manual start by-passing the factory - () -> rule.getRuntimeService().startProcessInstanceByKey(OrderApproval.KEY), + () -> engine.getRuntimeService().startProcessInstanceByKey(OrderApproval.KEY), "Guard violated by execution '6' in activity 'Order created'\nExpecting variable 'orderId' to be set, but it was not found.\n"); } @@ -64,17 +66,17 @@ public void shouldFireExceptionIfOrderIdIsMissing() { @Test public void shouldFireExceptionApproveDecisionIsMissing() { - OrderApprovalInstanceFactory factory = new OrderApprovalInstanceFactory(rule.getRuntimeService()); + OrderApprovalInstanceFactory factory = new OrderApprovalInstanceFactory(engine.getRuntimeService()); factory.start("1"); // async after start - Job asyncStart = rule.getManagementService().createJobQuery().singleResult(); - rule.getManagementService().executeJob(asyncStart.getId()); - Task task = rule.getTaskService().createTaskQuery().singleResult(); + Job asyncStart = engine.getManagementService().createJobQuery().singleResult(); + engine.getManagementService().executeJob(asyncStart.getId()); + Task task = engine.getTaskService().createTaskQuery().singleResult(); assertThrows( ProcessEngineException.class, - () -> rule.getTaskService().complete(task.getId()), + () -> engine.getTaskService().complete(task.getId()), "Guard violated in task 'Approve order' (taskId: '21')\nExpecting variable 'orderApproved' to be set, but it was not found.\n" ); } diff --git a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/OrderApprovalProcessTest.java b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/OrderApprovalProcessTest.java index 1182d5c3..773dfa03 100644 --- a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/OrderApprovalProcessTest.java +++ b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/process/OrderApprovalProcessTest.java @@ -7,13 +7,13 @@ import io.holunda.camunda.bpm.data.example.domain.OrderPosition; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.camunda.bpm.engine.test.Deployment; -import org.camunda.bpm.engine.test.ProcessEngineRule; +import org.camunda.bpm.engine.test.junit5.ProcessEngineExtension; import org.camunda.bpm.engine.test.mock.Mocks; import org.camunda.bpm.spring.boot.starter.test.helper.StandaloneInMemoryTestConfiguration; import org.camunda.spin.plugin.impl.SpinProcessEnginePlugin; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import java.math.BigDecimal; import java.sql.Date; @@ -26,17 +26,18 @@ @Deployment(resources = "order_approval.bpmn") public class OrderApprovalProcessTest { - @Rule - public final ProcessEngineRule rule = new StandaloneInMemoryTestConfiguration( - Lists.newArrayList(new SpinProcessEnginePlugin()) - ).rule(); + @RegisterExtension + private static final ProcessEngineExtension engine = ProcessEngineExtension + .builder() + .useProcessEngine(new StandaloneInMemoryTestConfiguration(new SpinProcessEnginePlugin()).buildProcessEngine()) + .build(); private OrderApprovalInstanceFactory factory; - @Before + @BeforeEach public void register() { - factory = new OrderApprovalInstanceFactory(rule.getRuntimeService()); + factory = new OrderApprovalInstanceFactory(engine.getRuntimeService()); OrderApproval config = new OrderApproval(); Mocks.register("guardExecutionListener", config.guardExecutionListener()); Mocks.register("guardTaskListener", config.guardTaskListener()); diff --git a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java index fd35ec37..6755db7a 100644 --- a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java +++ b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java @@ -1,9 +1,10 @@ package io.holunda.camunda.bpm.data.example.rest; import io.holunda.camunda.bpm.data.example.domain.Order; -import io.holunda.camunda.bpm.data.mockito.TaskServiceMockVerifier; import org.camunda.bpm.engine.TaskService; -import org.junit.Before; +import org.camunda.community.mockito.service.TaskServiceStubBuilder; +import org.camunda.community.mockito.verify.TaskServiceVerification; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -14,11 +15,7 @@ import java.util.UUID; import static io.holunda.camunda.bpm.data.CamundaBpmData.builder; -import static io.holunda.camunda.bpm.data.example.process.OrderApproval.ORDER; -import static io.holunda.camunda.bpm.data.example.process.OrderApproval.ORDER_APPROVED; -import static io.holunda.camunda.bpm.data.example.process.OrderApproval.ORDER_TOTAL; -import static io.holunda.camunda.bpm.data.mockito.CamundaBpmDataMockito.taskServiceMockVerifier; -import static io.holunda.camunda.bpm.data.mockito.CamundaBpmDataMockito.taskServiceVariableMockBuilder; +import static io.holunda.camunda.bpm.data.example.process.OrderApproval.*; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; @@ -30,11 +27,11 @@ public class ApproveOrderTaskControllerTest { private final static Order order = new Order("ORDER-ID-1", new Date(), new ArrayList<>()); private final TaskService taskService = mock(TaskService.class); - private final TaskServiceMockVerifier verifier = taskServiceMockVerifier(taskService); + private final TaskServiceVerification verifier = new TaskServiceVerification(taskService); private final ApproveOrderTaskController controller = new ApproveOrderTaskController(taskService); private String taskId; - @Before + @BeforeEach public void prepareTest() { reset(taskService); taskId = UUID.randomUUID().toString(); @@ -43,9 +40,9 @@ public void prepareTest() { @Test public void testLoadTask() { // given - taskServiceVariableMockBuilder(taskService) - .initial(ORDER, order) - .initial(ORDER_TOTAL, BigDecimal.ZERO) + new TaskServiceStubBuilder(taskService) + .defineAndInitialize(ORDER, order) + .defineAndInitialize(ORDER_TOTAL, BigDecimal.ZERO) .build(); // when ResponseEntity responseEntity = controller.loadTask(taskId); diff --git a/example/example-kotlin/pom.xml b/example/example-kotlin/pom.xml index 3fadceca..008b4298 100644 --- a/example/example-kotlin/pom.xml +++ b/example/example-kotlin/pom.xml @@ -70,44 +70,6 @@ com.h2database h2 - - - org.codehaus.groovy - groovy - - - org.codehaus.groovy - groovy-datetime - - - org.codehaus.groovy - groovy-jmx - - - org.codehaus.groovy - groovy-json - - - org.codehaus.groovy - groovy-jsr223 - - - org.codehaus.groovy - groovy-macro - - - org.codehaus.groovy - groovy-nio - - - org.codehaus.groovy - groovy-templates - - - org.codehaus.groovy - groovy-xml - - @@ -143,7 +105,6 @@ org.springdoc springdoc-openapi-kotlin - ${springdoc.version} diff --git a/example/example-kotlin/src/main/resources/application.yml b/example/example-kotlin/src/main/resources/application.yml index a833dd42..1dd61adc 100644 --- a/example/example-kotlin/src/main/resources/application.yml +++ b/example/example-kotlin/src/main/resources/application.yml @@ -5,9 +5,6 @@ spring: name: Camunda BPM Data Kotlin Example jpa: open-in-view: true - groovy: - template: - check-template-location: false camunda: bpm: diff --git a/example/example-no-engine/pom.xml b/example/example-no-engine/pom.xml index eccd2b60..aea1b3be 100644 --- a/example/example-no-engine/pom.xml +++ b/example/example-no-engine/pom.xml @@ -113,7 +113,7 @@ - -Djava.awt.headless=true ${argLine} -XX:+StartAttachListener + -Djava.awt.headless=true @{argLine} -XX:+StartAttachListener random diff --git a/example/example-no-engine/src/main/resources/application.yml b/example/example-no-engine/src/main/resources/application.yml index 7ba53159..cddda52f 100644 --- a/example/example-no-engine/src/main/resources/application.yml +++ b/example/example-no-engine/src/main/resources/application.yml @@ -5,7 +5,4 @@ spring: name: Camunda BPM Data No Engine Example jpa: open-in-view: true - groovy: - template: - check-template-location: false diff --git a/example/itest/pom.xml b/example/itest/pom.xml index 9e66d691..327a4ff8 100644 --- a/example/itest/pom.xml +++ b/example/itest/pom.xml @@ -67,42 +67,6 @@ jackson-module-kotlin - - org.codehaus.groovy - groovy - - - org.codehaus.groovy - groovy-datetime - - - org.codehaus.groovy - groovy-jmx - - - org.codehaus.groovy - groovy-json - - - org.codehaus.groovy - groovy-jsr223 - - - org.codehaus.groovy - groovy-macro - - - org.codehaus.groovy - groovy-nio - - - org.codehaus.groovy - groovy-templates - - - org.codehaus.groovy - groovy-xml - com.h2database h2 @@ -132,14 +96,10 @@ - - io.holunda.data - camunda-bpm-data-test - test - org.mockito.kotlin mockito-kotlin + test org.springframework.boot @@ -149,14 +109,17 @@ io.holunda.testing camunda-bpm-jgiven + test com.tngtech.jgiven jgiven-junit5 + test com.tngtech.jgiven jgiven-spring-junit5 + test org.camunda.community.mockito diff --git a/example/pom.xml b/example/pom.xml index df8dff11..6fa9784e 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -16,6 +16,8 @@ 1.6.13 + 0.4.0 + true true true @@ -48,11 +50,6 @@ - - org.codehaus.groovy - groovy-all - ${groovy.version} - org.springdoc springdoc-openapi-ui @@ -63,14 +60,19 @@ springdoc-openapi-webmvc-core ${springdoc.version} + + org.springdoc + springdoc-openapi-kotlin + ${springdoc.version} + io.holunda.testing camunda-bpm-jgiven - 0.4.0 + ${camunda-bpm-jgiven.version} test - org.camunda.bpm.assert + org.camunda.bpm camunda-bpm-assert ${camunda-assert.version} test diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt index e3892bda..6f326899 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt @@ -24,11 +24,6 @@ import org.junit.jupiter.api.extension.RegisterExtension @Deployment(resources = ["eventBasedSubprocess_no_transientMapping.bpmn", "eventBasedSubprocess_with_transientMapping.bpmn"]) class TransientVariableMappingListenerTest { - @RegisterExtension - val camunda: ProcessEngineExtension = ProcessEngineExtension.builder() - .configurationResource("audithistory.camunda.cfg.xml") - .build() - @Test fun `NO ACL signal sub-process with variables sets variables on processInstance`() { @@ -134,7 +129,8 @@ class TransientVariableMappingListenerTest { variablesGuard = VariablesGuard( listOf( BAZ.matches { it > 40L }, - FOO.exists()) + FOO.exists() + ) ), variableMapTransformer = object : VariableMapTransformer { override fun transform(variableMap: VariableMap): VariableMap { @@ -147,17 +143,19 @@ class TransientVariableMappingListenerTest { } ) - private fun camunda(): ProcessEngineRule { - return ProcessEngineRule( - object : StandaloneInMemProcessEngineConfiguration() { - init { - history = ProcessEngineConfiguration.HISTORY_FULL - databaseSchemaUpdate = ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE - jobExecutorActivate = false - expressionManager = MockExpressionManager() - } - }.buildProcessEngine()) - } + + @RegisterExtension + val camunda: ProcessEngineExtension = ProcessEngineExtension.builder().useProcessEngine( + object : StandaloneInMemProcessEngineConfiguration() { + init { + history = ProcessEngineConfiguration.HISTORY_AUDIT + databaseSchemaUpdate = ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE + jobExecutorActivate = false + expressionManager = MockExpressionManager() + } + }.buildProcessEngine() + ).build() + } } diff --git a/pom.xml b/pom.xml index 76dea992..0955da46 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,6 @@ 7.18.0-ee 2.7.5 - 2.4.21 1.18.0 ${camunda.version.ce} @@ -300,7 +299,7 @@ - -Djava.awt.headless=true ${argLine} -XX:+StartAttachListener -Xmx1024m -XX:MaxPermSize=256m + -Djava.awt.headless=true @{argLine} -XX:+StartAttachListener ${project.build.directory}/jgiven-reports From 1f3de743c7c9ffab00cd08af1602de4669bda0bc Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 2 Dec 2022 18:10:55 +0100 Subject: [PATCH 11/67] get rid of camunda-bpm-data-test --- README.md | 22 ++------ docs/developer-guide/project-setup.md | 1 - docs/quick-start.md | 64 ---------------------- example/coverage-report-aggregator/pom.xml | 6 -- example/example-java/pom.xml | 5 -- example/example-kotlin/pom.xml | 6 -- example/pom.xml | 6 -- extension/c7/pom.xml | 19 +------ extension/core/pom.xml | 18 ++++++ pom.xml | 12 +++- 10 files changed, 37 insertions(+), 122 deletions(-) diff --git a/README.md b/README.md index 2d5d3555..6b00fde9 100644 --- a/README.md +++ b/README.md @@ -133,28 +133,18 @@ public class ApproveOrderTaskController { If you want to write the test for the REST controller, you will need to stub the task service and verify that the correct variables has been set. To simplify -these tests, we created an additional library module `camunda-bpm-data-test`. -Please put the following dependency into your `pom.xml`: +these tests, we added some helper code to the famous library `camunda-platform-7-mockito`. -``` xml - - io.holunda.data - camunda-bpm-data-test - 1.2.6 - test - -``` - -Now you can use `TaskServiceVariableMockBuilder` to stub correct behavior of Camunda Task Service -and `TaskServiceVerifier` to verify the correct access to variables easily. Here is the JUnit -test of the REST controller above, making use of `camunda-bpm-data-test`. +Now you can use `TaskServiceVariableStubBuilder` to stub correct behavior of Camunda Task Service +and `TaskServiceVerification` to verify the correct access to variables easily. Here is the JUnit +test of the REST controller above, making use of `camunda-platform-7-mockito`. ``` java public class ApproveOrderTaskControllerTest { private static Order order = new Order("ORDER-ID-1", new Date(), new ArrayList<>()); private TaskService taskService = mock(TaskService.class); - private TaskServiceMockVerifier verifier = taskServiceMockVerifier(taskService); + private TaskServiceVerification verifier = new TaskServiceVerification(taskService); private ApproveOrderTaskController controller = new ApproveOrderTaskController(taskService); private String taskId; @@ -167,7 +157,7 @@ public class ApproveOrderTaskControllerTest { @Test public void testLoadTask() { // given - taskServiceVariableMockBuilder(taskService).initial(ORDER, order).build(); + new TaskServiceVariableStubBuilder(taskService).initial(ORDER, order).build(); // when ResponseEntity responseEntity = controller.loadTask(taskId); // then diff --git a/docs/developer-guide/project-setup.md b/docs/developer-guide/project-setup.md index 8a658bcf..7f06e8b0 100644 --- a/docs/developer-guide/project-setup.md +++ b/docs/developer-guide/project-setup.md @@ -98,7 +98,6 @@ Currently, the following modules are released to OSS Maven Central: * camunda-bpm-data-parent * camunda-bpm-data -* camunda-bpm-data-test #### Trigger new release diff --git a/docs/quick-start.md b/docs/quick-start.md index 514c577a..46b8b818 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -107,67 +107,3 @@ public class ApproveOrderTaskController { } ``` - -## Testing correct variable access - -If you want to write the test for the REST controller, you will need to stub -the task service and verify that the correct variables has been set. To simplify -these tests, we created an additional library module `camunda-bpm-data-test`. -Please put the following dependency into your `pom.xml`: - -```xml - - - io.holunda.data - camunda-bpm-data-test - ${camunda-bpm-data.version} - test - -``` - -Now you can use `TaskServiceVariableMockBuilder` to stub correct behavior of Camunda Task Service -and `TaskServiceVerifier` to verify the correct access to variables easily. Here is the JUnit -test of the REST controller above, making use of `camunda-bpm-data-test`. - - -```java - -public class ApproveOrderTaskControllerTest { - - private static Order order = new Order("ORDER-ID-1", new Date(), new ArrayList<>()); - private TaskService taskService = mock(TaskService.class); - private TaskServiceMockVerifier verifier = taskServiceMockVerifier(taskService); - private ApproveOrderTaskController controller = new ApproveOrderTaskController(taskService); - private String taskId; - - @Before - public void prepareTest() { - reset(taskService); - taskId = UUID.randomUUID().toString(); - } - - @Test - public void testLoadTask() { - // given - taskServiceVariableMockBuilder(taskService).initial(ORDER, order).build(); - // when - ResponseEntity responseEntity = controller.loadTask(taskId); - // then - assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(responseEntity.getBody()).isEqualTo(new ApproveTaskDto(order)); - verifier.verifyGet(ORDER, taskId); - verifier.verifyNoMoreInteractions(); - } - - @Test - public void testCompleteTask() { - // when - ApproveTaskCompleteDto response = new ApproveTaskCompleteDto(true); - ResponseEntity responseEntity = controller.completeTask(taskId, response); - // then - assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); - verifier.verifyComplete(builder().set(ORDER_APPROVED, response.getApproved()).build(), taskId); - verifier.verifyNoMoreInteractions(); - } -} -``` diff --git a/example/coverage-report-aggregator/pom.xml b/example/coverage-report-aggregator/pom.xml index c655589b..f016fae4 100644 --- a/example/coverage-report-aggregator/pom.xml +++ b/example/coverage-report-aggregator/pom.xml @@ -24,12 +24,6 @@ ${project.version} compile - - io.holunda.data - camunda-bpm-data-test - ${project.version} - compile - io.holunda.data.example camunda-bpm-data-integration-test diff --git a/example/example-java/pom.xml b/example/example-java/pom.xml index 671d9e6e..687920a6 100644 --- a/example/example-java/pom.xml +++ b/example/example-java/pom.xml @@ -83,11 +83,6 @@ - - io.holunda.data - camunda-bpm-data-test - test - org.camunda.bpm camunda-bpm-assert diff --git a/example/example-kotlin/pom.xml b/example/example-kotlin/pom.xml index 008b4298..d118ca15 100644 --- a/example/example-kotlin/pom.xml +++ b/example/example-kotlin/pom.xml @@ -108,12 +108,6 @@ - - io.holunda.data - camunda-bpm-data-test - test - - io.holunda.testing camunda-bpm-jgiven diff --git a/example/pom.xml b/example/pom.xml index 6fa9784e..71084d91 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -42,12 +42,6 @@ camunda-bpm-data ${project.version} - - io.holunda.data - camunda-bpm-data-test - test - ${project.version} - diff --git a/extension/c7/pom.xml b/extension/c7/pom.xml index 3c289e1c..97690757 100644 --- a/extension/c7/pom.xml +++ b/extension/c7/pom.xml @@ -20,22 +20,6 @@ - - - org.jetbrains.kotlin - kotlin-stdlib-common - - - org.jetbrains.kotlin - kotlin-reflect - - - - - javax.validation - validation-api - 2.0.1.Final - @@ -63,12 +47,13 @@ jackson-databind - org.slf4j slf4j-api + + org.camunda.bpm diff --git a/extension/core/pom.xml b/extension/core/pom.xml index 0ef5fac2..ef9c3098 100644 --- a/extension/core/pom.xml +++ b/extension/core/pom.xml @@ -21,11 +21,29 @@ + + + + org.jetbrains.kotlin + kotlin-stdlib-common + + + org.jetbrains.kotlin + kotlin-reflect + + + + + javax.validation + validation-api + 2.0.1.Final + diff --git a/pom.xml b/pom.xml index 0955da46..9505391f 100644 --- a/pom.xml +++ b/pom.xml @@ -90,8 +90,18 @@ org.camunda.community.mockito camunda-platform-7-mockito - test ${camunda-platform-7-mockito.version} + test + + + io.holunda.data + camunda-bpm-data + + + io.holunda.data + camunda-bpm-data-test + + org.camunda.bpm.springboot From 72bef4e9c86af78161676e85e4664de41dcd6dc8 Mon Sep 17 00:00:00 2001 From: Jan Rohwer Date: Sat, 3 Dec 2022 23:23:23 +0100 Subject: [PATCH 12/67] define dependency to junit jupiter engine for surefire --- extension/core/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extension/core/pom.xml b/extension/core/pom.xml index ef9c3098..68d919b7 100644 --- a/extension/core/pom.xml +++ b/extension/core/pom.xml @@ -64,6 +64,11 @@ + + org.junit.jupiter + junit-jupiter-engine + test + org.camunda.bpm camunda-bpm-assert From 6520bcbf7bff4c3db60b1c00a78f79358e5cd6db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Jan 2023 01:39:07 +0000 Subject: [PATCH 13/67] build(deps): bump annotations from 23.0.0 to 24.0.0 Bumps [annotations](https://github.com/JetBrains/java-annotations) from 23.0.0 to 24.0.0. - [Release notes](https://github.com/JetBrains/java-annotations/releases) - [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md) - [Commits](https://github.com/JetBrains/java-annotations/compare/23.0.0...24.0.0) --- updated-dependencies: - dependency-name: org.jetbrains:annotations dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e73f8f51..72212472 100644 --- a/pom.xml +++ b/pom.xml @@ -127,7 +127,7 @@ org.jetbrains annotations - 23.0.0 + 24.0.0 From 9550268134d23c46a7d3a928c2f831b653834cb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Jan 2023 22:10:39 +0000 Subject: [PATCH 14/67] build(deps): bump springdoc.version from 1.6.13 to 1.6.14 Bumps `springdoc.version` from 1.6.13 to 1.6.14. Updates `springdoc-openapi-ui` from 1.6.13 to 1.6.14 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.13...v1.6.14) Updates `springdoc-openapi-webmvc-core` from 1.6.13 to 1.6.14 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.13...v1.6.14) Updates `springdoc-openapi-kotlin` from 1.6.13 to 1.6.14 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.13...v1.6.14) --- updated-dependencies: - dependency-name: org.springdoc:springdoc-openapi-ui dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springdoc:springdoc-openapi-webmvc-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springdoc:springdoc-openapi-kotlin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- example/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pom.xml b/example/pom.xml index 71084d91..2fe58a5d 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -15,7 +15,7 @@ pom - 1.6.13 + 1.6.14 0.4.0 true From 13881adf1ed3134370bca3bb9ab74fb7e5df359e Mon Sep 17 00:00:00 2001 From: Christian Wiejack Date: Thu, 26 Jan 2023 19:26:14 +0100 Subject: [PATCH 15/67] add uuidVariable to for kotlin fix uuid documentation --- .../java/io/holunda/camunda/bpm/data/CamundaBpmData.java | 4 ++-- .../io/holunda/camunda/bpm/data/CamundaBpmDataKotlin.kt | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/CamundaBpmData.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/CamundaBpmData.java index 24712fa6..8c6a707a 100644 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/CamundaBpmData.java +++ b/extension/core/src/main/java/io/holunda/camunda/bpm/data/CamundaBpmData.java @@ -118,10 +118,10 @@ public static VariableFactory booleanVariable(@NotNull String variableN } /** - * Creates a boolean variable factory. + * Creates an uuid variable factory. * * @param variableName name of the variable. - * @return variable factory for boolean. + * @return variable factory for uuid. */ @NotNull public static VariableFactory uuidVariable(@NotNull String variableName) { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmDataKotlin.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmDataKotlin.kt index 6035bbed..78414341 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmDataKotlin.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmDataKotlin.kt @@ -71,6 +71,14 @@ object CamundaBpmDataKotlin { */ fun booleanVariable(variableName: String): VariableFactory = BasicVariableFactory(variableName, Boolean::class.java) + /** + * Creates an uuid variable factory. + * + * @param variableName name of the variable. + * @return variable factory for uuid. + */ + fun uuidVariable(variableName: String): VariableFactory = BasicVariableFactory(variableName, UUID::class.java) + /** * Reified version of the basic variable factory. * @param name The name of the variable. From 9c835c54730d90edf5a2009d67ccddc4cc5f4b17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 01:02:09 +0000 Subject: [PATCH 16/67] build(deps): bump kotlin-logging-jvm from 3.0.4 to 3.0.5 Bumps [kotlin-logging-jvm](https://github.com/oshai/kotlin-logging) from 3.0.4 to 3.0.5. - [Release notes](https://github.com/oshai/kotlin-logging/releases) - [Changelog](https://github.com/oshai/kotlin-logging/blob/master/ChangeLog.md) - [Commits](https://github.com/oshai/kotlin-logging/compare/3.0.4...3.0.5) --- updated-dependencies: - dependency-name: io.github.microutils:kotlin-logging-jvm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 85ed9533..d0d9dc16 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 1.2.4 true - 3.0.4 + 3.0.5 4.1.0 6.18.0 From 6e62e9a8c4a8697971e84af86f5b1049161300d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 01:02:14 +0000 Subject: [PATCH 17/67] build(deps): bump maven-enforcer-plugin from 3.1.0 to 3.2.1 Bumps [maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.1.0 to 3.2.1. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.1.0...enforcer-3.2.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 85ed9533..38642da8 100644 --- a/pom.xml +++ b/pom.xml @@ -484,7 +484,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.1.0 + 3.2.1 enforce-maven From fe821961965f430801abe71e92e658971f50ef3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Feb 2023 01:03:43 +0000 Subject: [PATCH 18/67] build(deps): bump kotlin.version from 1.7.21 to 1.8.10 Bumps `kotlin.version` from 1.7.21 to 1.8.10. Updates `kotlin-bom` from 1.7.21 to 1.8.10 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.21...v1.8.10) Updates `kotlin-maven-allopen` from 1.7.21 to 1.8.10 Updates `kotlin-maven-noarg` from 1.7.21 to 1.8.10 Updates `kotlin-maven-plugin` from 1.7.21 to 1.8.10 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-noarg dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 85ed9533..057c5612 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 1.18.0 ${camunda.version.ce} - 1.7.21 + 1.8.10 1.2.4 true From 6ed69158bb9080bd0a96b7dd2abb31da9df4cf58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Feb 2023 01:58:43 +0000 Subject: [PATCH 19/67] build(deps): bump maven-deploy-plugin from 3.0.0 to 3.1.0 Bumps [maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/apache/maven-deploy-plugin/releases) - [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.0.0...maven-deploy-plugin-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-deploy-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 489f7b15..17302a37 100644 --- a/pom.xml +++ b/pom.xml @@ -446,7 +446,7 @@ maven-deploy-plugin - 3.0.0 + 3.1.0 true From 1c9cc61d2843c459c0998fed21de1337de167685 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 01:57:58 +0000 Subject: [PATCH 20/67] build(deps): bump camunda-spin-bom from 1.18.0 to 1.18.1 Bumps [camunda-spin-bom](https://github.com/camunda/camunda-spin) from 1.18.0 to 1.18.1. - [Release notes](https://github.com/camunda/camunda-spin/releases) - [Commits](https://github.com/camunda/camunda-spin/compare/1.18.0...1.18.1) --- updated-dependencies: - dependency-name: org.camunda.spin:camunda-spin-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 17302a37..ea3c0119 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 7.18.0-ee 2.7.5 - 1.18.0 + 1.18.1 ${camunda.version.ce} 1.8.10 From 074eb5c145161b8d5707e0496a436698fd8c4b70 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Feb 2023 02:37:25 +0000 Subject: [PATCH 21/67] build(deps): bump jgiven.version from 1.2.4 to 1.2.5 Bumps `jgiven.version` from 1.2.4 to 1.2.5. Updates `jgiven-junit5` from 1.2.4 to 1.2.5 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.4...v1.2.5) Updates `jgiven-spring-junit5` from 1.2.4 to 1.2.5 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.4...v1.2.5) Updates `jgiven-spring` from 1.2.4 to 1.2.5 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.4...v1.2.5) Updates `jgiven-html5-report` from 1.2.4 to 1.2.5 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.4...v1.2.5) Updates `jgiven-maven-plugin` from 1.2.4 to 1.2.5 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.4...v1.2.5) --- updated-dependencies: - dependency-name: com.tngtech.jgiven:jgiven-junit5 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.tngtech.jgiven:jgiven-spring-junit5 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.tngtech.jgiven:jgiven-spring dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: com.tngtech.jgiven:jgiven-html5-report dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: com.tngtech.jgiven:jgiven-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea3c0119..4543f68a 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ ${camunda.version.ce} 1.8.10 - 1.2.4 + 1.2.5 true 3.0.5 From a9c6a9efb448adced03a3a7c371753b557bf434b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Feb 2023 01:58:41 +0000 Subject: [PATCH 22/67] build(deps): bump maven-compiler-plugin from 3.10.1 to 3.11.0 Bumps [maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.10.1 to 3.11.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.10.1...maven-compiler-plugin-3.11.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4543f68a..7d66ff68 100644 --- a/pom.xml +++ b/pom.xml @@ -248,7 +248,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.11.0 ${project.build.sourceEncoding} ${maven.compiler.source} From ae728506af49e6292c51e766437227cc5462a54a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Mar 2023 01:58:42 +0000 Subject: [PATCH 23/67] build(deps): bump annotations from 24.0.0 to 24.0.1 Bumps [annotations](https://github.com/JetBrains/java-annotations) from 24.0.0 to 24.0.1. - [Release notes](https://github.com/JetBrains/java-annotations/releases) - [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md) - [Commits](https://github.com/JetBrains/java-annotations/commits) --- updated-dependencies: - dependency-name: org.jetbrains:annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7d66ff68..7c7e3a98 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ org.jetbrains annotations - 24.0.0 + 24.0.1 From 6ec930af6e61c1a60176921736138b24996a2506 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Mar 2023 02:08:55 +0000 Subject: [PATCH 24/67] build(deps): bump dokka-maven-plugin from 1.7.20 to 1.8.10 Bumps [dokka-maven-plugin](https://github.com/Kotlin/dokka) from 1.7.20 to 1.8.10. - [Release notes](https://github.com/Kotlin/dokka/releases) - [Commits](https://github.com/Kotlin/dokka/commits) --- updated-dependencies: - dependency-name: org.jetbrains.dokka:dokka-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c7e3a98..20c6d625 100644 --- a/pom.xml +++ b/pom.xml @@ -327,7 +327,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.7.20 + 1.8.10 attach-javadocs From 0443c980c6db5fa2180c48801a51a933ce4153f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Mar 2023 01:58:16 +0000 Subject: [PATCH 25/67] build(deps): bump maven-surefire-plugin from 2.22.2 to 3.0.0 Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 2.22.2 to 3.0.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-2.22.2...surefire-3.0.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c7e3a98..d4ce811c 100644 --- a/pom.xml +++ b/pom.xml @@ -298,7 +298,7 @@ maven-surefire-plugin - 2.22.2 + 3.0.0 false kill From 15ed78f278b2c31ad1d7d6445793c9c5fb010260 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Mar 2023 01:58:36 +0000 Subject: [PATCH 26/67] build(deps): bump maven-failsafe-plugin from 2.22.2 to 3.0.0 Bumps [maven-failsafe-plugin](https://github.com/apache/maven-surefire) from 2.22.2 to 3.0.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-2.22.2...surefire-3.0.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c7e3a98..a6ab1e3c 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.22.2 + 3.0.0 From e04b687654aa0cde28e8c43218b0a2e42c570452 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 01:59:23 +0000 Subject: [PATCH 27/67] build(deps): bump maven-install-plugin from 3.1.0 to 3.1.1 Bumps [maven-install-plugin](https://github.com/apache/maven-install-plugin) from 3.1.0 to 3.1.1. - [Release notes](https://github.com/apache/maven-install-plugin/releases) - [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-3.1.0...maven-install-plugin-3.1.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-install-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c7e3a98..b2684e02 100644 --- a/pom.xml +++ b/pom.xml @@ -477,7 +477,7 @@ maven-install-plugin - 3.1.0 + 3.1.1 From cd7ed17d190d6428e657e2dd07fd38f1dc1c2380 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 01:59:32 +0000 Subject: [PATCH 28/67] build(deps): bump maven-resources-plugin from 3.3.0 to 3.3.1 Bumps [maven-resources-plugin](https://github.com/apache/maven-resources-plugin) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-resources-plugin/releases) - [Commits](https://github.com/apache/maven-resources-plugin/compare/maven-resources-plugin-3.3.0...maven-resources-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-resources-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c7e3a98..d24df36d 100644 --- a/pom.xml +++ b/pom.xml @@ -289,7 +289,7 @@ org.apache.maven.plugins maven-resources-plugin - 3.3.0 + 3.3.1 ${project.build.sourceEncoding} From cabbb23d289f581b657110d743217f410d0e5c6f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Mar 2023 01:58:21 +0000 Subject: [PATCH 29/67] build(deps): bump maven-deploy-plugin from 3.1.0 to 3.1.1 Bumps [maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.1.0 to 3.1.1. - [Release notes](https://github.com/apache/maven-deploy-plugin/releases) - [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.1.0...maven-deploy-plugin-3.1.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-deploy-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 04400d87..bfa98f3b 100644 --- a/pom.xml +++ b/pom.xml @@ -446,7 +446,7 @@ maven-deploy-plugin - 3.1.0 + 3.1.1 true From f0b13180f2ed9c97748fabcaf02c8a91949ff257 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 Mar 2023 01:59:48 +0000 Subject: [PATCH 30/67] build(deps): bump kotlin.version from 1.8.10 to 1.8.20 Bumps `kotlin.version` from 1.8.10 to 1.8.20. Updates `kotlin-bom` from 1.8.10 to 1.8.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `kotlin-maven-allopen` from 1.8.10 to 1.8.20 Updates `kotlin-maven-noarg` from 1.8.10 to 1.8.20 Updates `kotlin-maven-plugin` from 1.8.10 to 1.8.20 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-noarg dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bfa98f3b..5699dfd9 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 1.18.1 ${camunda.version.ce} - 1.8.10 + 1.8.20 1.2.5 true From e69a781dee67cddcb6ce63555e92707582732800 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 01:59:21 +0000 Subject: [PATCH 31/67] build(deps): bump springdoc.version from 1.6.14 to 1.7.0 Bumps `springdoc.version` from 1.6.14 to 1.7.0. Updates `springdoc-openapi-ui` from 1.6.14 to 1.7.0 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.14...v1.7.0) Updates `springdoc-openapi-webmvc-core` from 1.6.14 to 1.7.0 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.14...v1.7.0) Updates `springdoc-openapi-kotlin` from 1.6.14 to 1.7.0 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v1.6.14...v1.7.0) --- updated-dependencies: - dependency-name: org.springdoc:springdoc-openapi-ui dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.springdoc:springdoc-openapi-webmvc-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.springdoc:springdoc-openapi-kotlin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- example/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pom.xml b/example/pom.xml index 2fe58a5d..40e70b15 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -15,7 +15,7 @@ pom - 1.6.14 + 1.7.0 0.4.0 true From f3cfe9bc45adfeed28be8d90c847941f4be0a041 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 01:57:50 +0000 Subject: [PATCH 32/67] build(deps): bump jacoco-maven-plugin from 0.8.8 to 0.8.9 Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.8 to 0.8.9. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.8...v0.8.9) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5699dfd9..47d209e7 100644 --- a/pom.xml +++ b/pom.xml @@ -163,7 +163,7 @@ org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.9 pre-unit-test From 6ca657488ddd88920da4db9eff8b8df25e58d4ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 05:49:39 +0000 Subject: [PATCH 33/67] build(deps): bump camunda-bpm-jgiven from 0.4.0 to 0.4.1 Bumps [camunda-bpm-jgiven](https://github.com/holunda-io/camunda-bpm-jgiven) from 0.4.0 to 0.4.1. - [Release notes](https://github.com/holunda-io/camunda-bpm-jgiven/releases) - [Commits](https://github.com/holunda-io/camunda-bpm-jgiven/compare/0.4.0...0.4.1) --- updated-dependencies: - dependency-name: io.holunda.testing:camunda-bpm-jgiven dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- example/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pom.xml b/example/pom.xml index 40e70b15..8eae69ce 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -16,7 +16,7 @@ 1.7.0 - 0.4.0 + 0.4.1 true true From 8f2b093780386b441fb695c6c1ba575831b38de0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 01:57:43 +0000 Subject: [PATCH 34/67] build(deps): bump maven-enforcer-plugin from 3.2.1 to 3.3.0 Bumps [maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.2.1 to 3.3.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.2.1...enforcer-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bac6de5f..7dc4c571 100644 --- a/pom.xml +++ b/pom.xml @@ -484,7 +484,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.2.1 + 3.3.0 enforce-maven From e374155237eedcef8592ae4391d5f740ac046445 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Apr 2023 01:57:56 +0000 Subject: [PATCH 35/67] build(deps): bump camunda.version.ce from 7.18.0 to 7.19.0 Bumps `camunda.version.ce` from 7.18.0 to 7.19.0. Updates `camunda-bpm-spring-boot-starter-test` from 7.18.0 to 7.19.0 Updates `camunda-bpm-spring-boot-starter-webapp` from 7.18.0 to 7.19.0 --- updated-dependencies: - dependency-name: org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-test dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7dc4c571..f7ce2196 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ ${java.version} ${java.version} - 7.18.0 + 7.19.0 7.18.0-ee 2.7.5 From e87b054d046b3b1860d2362c0cfde2680665b536 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Apr 2023 01:58:00 +0000 Subject: [PATCH 36/67] build(deps): bump camunda-bom from 7.18.0 to 7.19.0 Bumps [camunda-bom](https://github.com/camunda/camunda-bpm-platform) from 7.18.0 to 7.19.0. - [Release notes](https://github.com/camunda/camunda-bpm-platform/releases) - [Commits](https://github.com/camunda/camunda-bpm-platform/compare/7.18.0...7.19.0) --- updated-dependencies: - dependency-name: org.camunda.bpm:camunda-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7dc4c571..731f9f86 100644 --- a/pom.xml +++ b/pom.xml @@ -534,7 +534,7 @@ - ${camunda.version.ce} + 7.19.0 From ad899a482688e340c98500893f4bcf2fe644b283 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 01:58:05 +0000 Subject: [PATCH 37/67] build(deps): bump jacoco-maven-plugin from 0.8.9 to 0.8.10 Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.9 to 0.8.10. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.9...v0.8.10) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7dc4c571..8b04ba9f 100644 --- a/pom.xml +++ b/pom.xml @@ -163,7 +163,7 @@ org.jacoco jacoco-maven-plugin - 0.8.9 + 0.8.10 pre-unit-test From 74da641da026a92f8764e805bc22a0fc220c6337 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 01:58:52 +0000 Subject: [PATCH 38/67] build(deps): bump kotlin.version from 1.8.20 to 1.8.21 Bumps `kotlin.version` from 1.8.20 to 1.8.21. Updates `kotlin-bom` from 1.8.20 to 1.8.21 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.20...v1.8.21) Updates `kotlin-maven-allopen` from 1.8.20 to 1.8.21 Updates `kotlin-maven-noarg` from 1.8.20 to 1.8.21 Updates `kotlin-maven-plugin` from 1.8.20 to 1.8.21 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-noarg dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7dc4c571..1f415bd4 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 1.18.1 ${camunda.version.ce} - 1.8.20 + 1.8.21 1.2.5 true From 86984857d7cbdc5b788c27d830f0b5dc9cc2cd4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 01:58:38 +0000 Subject: [PATCH 39/67] build(deps): bump camunda-platform-7-mockito from 6.18.0 to 6.19.0 Bumps [camunda-platform-7-mockito](https://github.com/camunda/camunda-platform-7-mockito) from 6.18.0 to 6.19.0. - [Release notes](https://github.com/camunda/camunda-platform-7-mockito/releases) - [Commits](https://github.com/camunda/camunda-platform-7-mockito/commits) --- updated-dependencies: - dependency-name: org.camunda.community.mockito:camunda-platform-7-mockito dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28897c88..fdf4ef85 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 3.0.5 4.1.0 - 6.18.0 + 6.19.0 **/*ITest.* **/itest/**/*.* From 1399d79edbab0de4b1d4a226db90dd89ff38a8a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 01:57:56 +0000 Subject: [PATCH 40/67] build(deps): bump maven-failsafe-plugin from 3.0.0 to 3.1.0 Bumps [maven-failsafe-plugin](https://github.com/apache/maven-surefire) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0...surefire-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28897c88..9c750dff 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.0.0 + 3.1.0 From 39b0846dd3b689539d9eee19be0ac33310a44122 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 01:58:38 +0000 Subject: [PATCH 41/67] build(deps): bump maven-gpg-plugin from 3.0.1 to 3.1.0 Bumps [maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.0.1 to 3.1.0. - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.0.1...maven-gpg-plugin-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28897c88..886db466 100644 --- a/pom.xml +++ b/pom.xml @@ -423,7 +423,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.0.1 + 3.1.0 --batch From aba385cf73745b36743a4f548b8f9bb8a5d34b35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 01:58:50 +0000 Subject: [PATCH 42/67] build(deps): bump maven-surefire-plugin from 3.0.0 to 3.1.0 Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0...surefire-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6abd25f8..8bf84a0a 100644 --- a/pom.xml +++ b/pom.xml @@ -298,7 +298,7 @@ maven-surefire-plugin - 3.0.0 + 3.1.0 false kill From d229f834b46fddc5dead99112311db0ae963a6c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 01:58:35 +0000 Subject: [PATCH 43/67] build(deps): bump build-helper-maven-plugin from 3.3.0 to 3.4.0 Bumps [build-helper-maven-plugin](https://github.com/mojohaus/build-helper-maven-plugin) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/mojohaus/build-helper-maven-plugin/releases) - [Commits](https://github.com/mojohaus/build-helper-maven-plugin/compare/build-helper-maven-plugin-3.3.0...3.4.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:build-helper-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6abd25f8..fe3033f8 100644 --- a/pom.xml +++ b/pom.xml @@ -361,7 +361,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.3.0 + 3.4.0 generate-sources From e7de2ee6bf28f08584e53ce81df0421b81c446aa Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 16 May 2023 08:42:44 +0200 Subject: [PATCH 44/67] wip migrate to kotlin --- .../src/main/kotlin/process/OrderApproval.kt | 4 +- .../kotlin/itest/CamundaBpmDataITestBase.kt | 6 +- .../kotlin/itest/VariableMapAdapterITest.kt | 12 +- .../camunda/bpm/data/CamundaBpmData.java | 327 ------------------ .../bpm/data/builder/VariableMapBuilder.java | 79 ----- .../bpm/data/builder/package-info.java | 7 - .../bpm/data/factory/package-info.java | 7 - .../camunda/bpm/data/package-info.java | 7 - .../reader/CaseServiceVariableReader.java | 70 ---- .../data/reader/LockedExternalTaskReader.java | 64 ---- .../reader/RuntimeServiceVariableReader.java | 70 ---- .../reader/TaskServiceVariableReader.java | 71 ---- .../bpm/data/reader/VariableMapReader.java | 59 ---- .../bpm/data/reader/VariableReader.java | 97 ------ .../bpm/data/reader/VariableScopeReader.java | 64 ---- .../camunda/bpm/data/reader/package-info.java | 7 - .../writer/CaseServiceVariableWriter.java | 119 ------- .../bpm/data/writer/GlobalVariableWriter.java | 80 ----- .../writer/RuntimeServiceVariableWriter.java | 120 ------- .../writer/TaskServiceVariableWriter.java | 120 ------- .../bpm/data/writer/VariableMapWriter.java | 77 ----- .../bpm/data/writer/VariableScopeWriter.java | 117 ------- .../bpm/data/writer/VariableWriter.java | 12 - .../camunda/bpm/data/writer/package-info.java | 7 - .../camunda/bpm/data/CamundaBpmData.kt | 321 +++++++++++++++++ .../bpm/data/VariableFactoryFluentApi.kt | 18 +- .../bpm/data/builder/VariableMapBuilder.kt | 62 ++++ .../data/factory/BasicVariableFactory.java | 0 .../bpm/data/factory/ListVariableFactory.java | 0 .../bpm/data/factory/MapVariableFactory.java | 0 .../bpm/data/factory/SetVariableFactory.java | 0 .../bpm/data/factory/VariableFactory.java | 0 .../data/reader/CaseServiceVariableReader.kt | 46 +++ .../data/reader/LockedExternalTaskReader.kt | 38 ++ .../reader/RuntimeServiceVariableReader.kt | 41 +++ .../data/reader/TaskServiceVariableReader.kt | 41 +++ .../bpm/data/reader/VariableMapReader.kt | 39 +++ .../camunda/bpm/data/reader/VariableReader.kt | 91 +++++ .../bpm/data/reader/VariableScopeReader.kt | 38 ++ .../data/writer/CaseServiceVariableWriter.kt | 92 +++++ .../bpm/data/writer/GlobalVariableWriter.kt | 75 ++++ .../bpm/data/writer/LocalVariableWriter.kt} | 52 ++- .../writer/RuntimeServiceVariableWriter.kt | 96 +++++ .../data/writer/TaskServiceVariableWriter.kt | 92 +++++ .../bpm/data/writer/VariableMapWriter.kt | 54 +++ .../bpm/data/writer/VariableScopeWriter.kt | 87 +++++ .../camunda/bpm/data/writer/VariableWriter.kt | 8 + extension/core/src/main/kotlin/packages.md | 30 +- .../holunda/camunda/bpm/data/FluentApiTest.kt | 44 ++- .../holunda/camunda/bpm/data/acl/ACLTest.kt | 8 +- .../bpm/data/acl/AntiCorruptionLayerTest.kt | 4 +- 51 files changed, 1342 insertions(+), 1638 deletions(-) delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/CamundaBpmData.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/builder/VariableMapBuilder.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/builder/package-info.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/package-info.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/package-info.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableMapReader.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableReader.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableScopeReader.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/package-info.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableMapWriter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableWriter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/package-info.java create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmData.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/builder/VariableMapBuilder.kt rename extension/core/src/main/{java => kotlin}/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java (100%) rename extension/core/src/main/{java => kotlin}/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java (100%) rename extension/core/src/main/{java => kotlin}/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java (100%) rename extension/core/src/main/{java => kotlin}/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java (100%) rename extension/core/src/main/{java => kotlin}/io/holunda/camunda/bpm/data/factory/VariableFactory.java (100%) create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableMapReader.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableReader.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableScopeReader.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.kt rename extension/core/src/main/{java/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.java => kotlin/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.kt} (57%) create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableMapWriter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableWriter.kt diff --git a/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt b/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt index 03965d26..3bcae1fb 100644 --- a/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt +++ b/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt @@ -1,7 +1,7 @@ package io.holunda.camunda.bpm.data.example.kotlin.process -import io.holunda.camunda.bpm.data.CamundaBpmData.booleanVariable -import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable +import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.booleanVariable +import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.stringVariable import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.customVariable import io.holunda.camunda.bpm.data.example.kotlin.domain.Order import io.holunda.camunda.bpm.data.example.kotlin.domain.OrderPosition diff --git a/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt b/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt index e48de2e5..a67eb236 100644 --- a/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt +++ b/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt @@ -4,9 +4,13 @@ import com.fasterxml.jackson.annotation.JsonIgnore import com.tngtech.jgiven.base.ScenarioTestBase import com.tngtech.jgiven.integration.spring.EnableJGiven import com.tngtech.jgiven.integration.spring.junit5.SpringScenarioTest -import io.holunda.camunda.bpm.data.CamundaBpmData.* +import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.booleanVariable +import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.longVariable +import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.shortVariable import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.customVariable import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.dateVariable +import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.doubleVariable +import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.intVariable import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.listVariable import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.mapVariable import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.setVariable diff --git a/example/itest/src/test/kotlin/itest/VariableMapAdapterITest.kt b/example/itest/src/test/kotlin/itest/VariableMapAdapterITest.kt index cdd5505c..1ca9bf36 100644 --- a/example/itest/src/test/kotlin/itest/VariableMapAdapterITest.kt +++ b/example/itest/src/test/kotlin/itest/VariableMapAdapterITest.kt @@ -1,6 +1,10 @@ package io.holunda.camunda.bpm.data.itest -import io.holunda.camunda.bpm.data.CamundaBpmData.* +import io.holunda.camunda.bpm.data.CamundaBpmData.intVariable +import io.holunda.camunda.bpm.data.CamundaBpmData.listVariable +import io.holunda.camunda.bpm.data.CamundaBpmData.mapVariable +import io.holunda.camunda.bpm.data.CamundaBpmData.setVariable +import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable import io.holunda.camunda.bpm.data.adapter.VariableNotFoundException import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException import io.holunda.camunda.bpm.data.factory.VariableFactory @@ -220,7 +224,8 @@ class VariableMapAdapterITest : CamundaBpmDataITestBase() { val variables = createVariableMapUntyped() - val wrongBasicType: VariableFactory = intVariable(STRING_VAR.name) + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + val wrongBasicType: VariableFactory = intVariable(STRING_VAR.name) // wrong type assertThrows(WrongVariableTypeException::class.java) { @@ -233,7 +238,8 @@ class VariableMapAdapterITest : CamundaBpmDataITestBase() { val variables = createVariableMapUntyped() - val wrongBasicType: VariableFactory = intVariable(STRING_VAR.name) + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + val wrongBasicType: VariableFactory = intVariable(STRING_VAR.name) assertThrows(WrongVariableTypeException::class.java) { // wrong type diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/CamundaBpmData.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/CamundaBpmData.java deleted file mode 100644 index 8c6a707a..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/CamundaBpmData.java +++ /dev/null @@ -1,327 +0,0 @@ -package io.holunda.camunda.bpm.data; - -import io.holunda.camunda.bpm.data.builder.VariableMapBuilder; -import io.holunda.camunda.bpm.data.factory.BasicVariableFactory; -import io.holunda.camunda.bpm.data.factory.ListVariableFactory; -import io.holunda.camunda.bpm.data.factory.MapVariableFactory; -import io.holunda.camunda.bpm.data.factory.SetVariableFactory; -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import io.holunda.camunda.bpm.data.reader.*; -import io.holunda.camunda.bpm.data.writer.CaseServiceVariableWriter; -import io.holunda.camunda.bpm.data.writer.GlobalVariableWriter; -import io.holunda.camunda.bpm.data.writer.RuntimeServiceVariableWriter; -import io.holunda.camunda.bpm.data.writer.TaskServiceVariableWriter; -import io.holunda.camunda.bpm.data.writer.VariableMapWriter; -import io.holunda.camunda.bpm.data.writer.VariableScopeWriter; -import io.holunda.camunda.bpm.data.writer.VariableWriter; -import org.camunda.bpm.engine.CaseService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.TaskService; -import org.camunda.bpm.engine.delegate.VariableScope; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -/** - * Provides a collection of factory methods for creating variable factories. - */ -public class CamundaBpmData { - - /** - * Hide the instantiations. - */ - private CamundaBpmData() { - } - - /** - * Creates a string variable factory. - * - * @param variableName name of the variable. - * @return variable factory for string. - */ - @NotNull - public static VariableFactory stringVariable(@NotNull String variableName) { - return new BasicVariableFactory<>(variableName, String.class); - } - - /** - * Creates a date variable factory. - * - * @param variableName name of the variable. - * @return variable factory for date. - */ - @NotNull - public static VariableFactory dateVariable(@NotNull String variableName) { - return new BasicVariableFactory<>(variableName, Date.class); - } - - /** - * Creates an integer variable factory. - * - * @param variableName name of the variable. - * @return variable factory for integer. - */ - @NotNull - public static VariableFactory intVariable(@NotNull String variableName) { - return new BasicVariableFactory<>(variableName, Integer.class); - } - - /** - * Creates a long variable factory. - * - * @param variableName name of the variable. - * @return variable factory for long. - */ - @NotNull - public static VariableFactory longVariable(@NotNull String variableName) { - return new BasicVariableFactory<>(variableName, Long.class); - } - - /** - * Creates a short variable factory. - * - * @param variableName name of the variable. - * @return variable factory for short. - */ - @NotNull - public static VariableFactory shortVariable(@NotNull String variableName) { - return new BasicVariableFactory<>(variableName, Short.class); - } - - /** - * Creates a double variable factory. - * - * @param variableName name of the variable. - * @return variable factory for double. - */ - @NotNull - public static VariableFactory doubleVariable(@NotNull String variableName) { - return new BasicVariableFactory<>(variableName, Double.class); - } - - /** - * Creates a boolean variable factory. - * - * @param variableName name of the variable. - * @return variable factory for boolean. - */ - @NotNull - public static VariableFactory booleanVariable(@NotNull String variableName) { - return new BasicVariableFactory<>(variableName, Boolean.class); - } - - /** - * Creates an uuid variable factory. - * - * @param variableName name of the variable. - * @return variable factory for uuid. - */ - @NotNull - public static VariableFactory uuidVariable(@NotNull String variableName) { - return new BasicVariableFactory<>(variableName, UUID.class); - } - - /** - * Creates a variable factory for custom type. - * - * @param variableName name of the variable. - * @param clazz class of specifying the type. - * @param factory type. - * @return variable factory for given type. - */ - @NotNull - public static VariableFactory customVariable(@NotNull String variableName, @NotNull Class clazz) { - return new BasicVariableFactory<>(variableName, clazz); - } - - /** - * Creates a variable factory for list of custom type. - * - * @param variableName name of the variable. - * @param clazz class of specifying the member type. - * @param factory type. - * @return variable factory for given type. - */ - @NotNull - public static VariableFactory> listVariable(@NotNull String variableName, @NotNull Class clazz) { - return new ListVariableFactory<>(variableName, clazz); - } - - /** - * Creates a variable factory for set of custom type. - * - * @param variableName name of the variable. - * @param clazz class of specifying the member type. - * @param factory type. - * @return variable factory for given type. - */ - @NotNull - public static VariableFactory> setVariable(@NotNull String variableName, @NotNull Class clazz) { - return new SetVariableFactory<>(variableName, clazz); - } - - /** - * Creates a variable factory for map of custom key and custom value type. - * - * @param variableName name of the variable. - * @param keyClazz class of specifying the key member type. - * @param valueClazz class of specifying the value member type. - * @param factory key type. - * @param factory value type. - * @return variable factory for given type. - */ - @NotNull - public static VariableFactory> mapVariable(@NotNull String variableName, @NotNull Class keyClazz, - @NotNull Class valueClazz) { - return new MapVariableFactory<>(variableName, keyClazz, valueClazz); - } - - /** - * Creates a new variable map builder. - * - * @return new writer with empty variable map. - */ - public static VariableMapBuilder builder() { - return new VariableMapBuilder(); - } - - /** - * Creates a new variable map builder. - * - * @param variables pre-created, potentially non-empty variables. - * @return new writer - */ - @NotNull - public static GlobalVariableWriter writer(VariableMap variables) { - return new VariableMapWriter(variables); - } - - /** - * Creates a new variable scope writer. - * - * @param variableScope scope to work on (delegate execution or delegate task). - * @return new writer working on provided variable scope. - */ - @NotNull - public static VariableWriter writer(VariableScope variableScope) { - return new VariableScopeWriter(variableScope); - } - - /** - * Creates a new execution variable writer. - * - * @param runtimeService runtime service to use. - * @param executionId id of the execution. - * @return new writer working on provided process execution. - */ - @NotNull - public static VariableWriter writer(RuntimeService runtimeService, String executionId) { - return new RuntimeServiceVariableWriter(runtimeService, executionId); - } - - /** - * Creates a new task variable writer. - * - * @param taskService task service to use. - * @param taskId task id. - * @return new writer working on provided user task. - */ - @NotNull - public static VariableWriter writer(TaskService taskService, String taskId) { - return new TaskServiceVariableWriter(taskService, taskId); - } - - /** - * Creates a new caseExecution variable writer. - * - * @param caseService task service to use. - * @param caseExecutionId caseExecution id. - * @return new writer working on provided user task. - */ - @NotNull - public static VariableWriter writer(CaseService caseService, String caseExecutionId) { - return new CaseServiceVariableWriter(caseService, caseExecutionId); - } - - /** - * Creates a new task variable reader. - * - * @param taskService the Camunda task service - * @param taskId the id of the task to use - * @return variable reader working on task - */ - @NotNull - public static VariableReader reader(TaskService taskService, String taskId) { - return new TaskServiceVariableReader(taskService, taskId); - } - - /** - * Creates a new execution variable reader. - * - * @param runtimeService the Camunda runtime service - * @param executionId the executionId to use - * @return variable reader working on execution - */ - public static VariableReader reader(RuntimeService runtimeService, String executionId) { - return new RuntimeServiceVariableReader(runtimeService, executionId); - } - - /** - * Creates a new execution variable reader. - * - * @param caseService the Camunda case service - * @param caseExecutionId the caseExecutionId to use - * @return variable reader working on execution - */ - public static VariableReader reader(CaseService caseService, String caseExecutionId) { - return new CaseServiceVariableReader(caseService, caseExecutionId); - } - - /** - * Creates a new variableScope variable reader. - * - * @param variableScope the variable scope to use (DelegateExecution, DelegateTask) - * @return variable reader working on variableScope - */ - public static VariableReader reader(VariableScope variableScope) { - return new VariableScopeReader(variableScope); - } - - /** - * Creates a new variableMap variable reader. - * - * @param variableMap the variableMap to use - * @return variable reader working on variableMap - */ - public static VariableReader reader(VariableMap variableMap) { - return new VariableMapReader(variableMap); - } - - /** - * Creates a new processInstance variable reader. - * - * @see #reader(VariableMap) - * @param processInstance the processInstance with variables to read from - * @return variable reader working on the variableMap provided by instance - */ - public static VariableReader reader(ProcessInstanceWithVariables processInstance) { - return reader(processInstance.getVariables()); - } - - /** - * Creates a new extern variable reader. - * - * @param lockedExternalTask the external tasks to use - * @return variable reader working on external task - */ - public static VariableReader reader(LockedExternalTask lockedExternalTask) { - return new LockedExternalTaskReader(lockedExternalTask); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/builder/VariableMapBuilder.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/builder/VariableMapBuilder.java deleted file mode 100644 index 39c54723..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/builder/VariableMapBuilder.java +++ /dev/null @@ -1,79 +0,0 @@ -package io.holunda.camunda.bpm.data.builder; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import io.holunda.camunda.bpm.data.writer.VariableMapWriter; -import org.camunda.bpm.engine.variable.VariableMap; -import org.camunda.bpm.engine.variable.Variables; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.Objects; - -/** - * Builder to create {@link VariableMap} using {@link VariableFactory}. - */ -public class VariableMapBuilder { - - private final VariableMapWriter writer; - - /** - * Constructs a builder. - */ - public VariableMapBuilder() { - this.writer = new VariableMapWriter(Variables.createVariables()); - } - - /** - * Sets the value for the provided variable and returns the builder (fluently). - * - * @param variableFactory the variable - * @param value the value - * @param type of value - * @return current builder instance - */ - @NotNull - public VariableMapBuilder set(VariableFactory variableFactory, T value) { - writer.set(variableFactory, value); - return this; - } - - /** - * Sets the (transient) value for the provided variable and returns the builder (fluently). - * - * @param variableFactory the variable - * @param value the value - * @param isTransient if true, the variable is transient, default false. - * @param type of value - * @return current builder instance - */ - @NotNull - public VariableMapBuilder set(VariableFactory variableFactory, T value, boolean isTransient) { - writer.set(variableFactory, value, isTransient); - return this; - } - - /** - * Creates the variable map. - * - * @return instance of {@link VariableMap} containing set values - */ - @NotNull - public VariableMap build() { - return Variables.fromMap(Collections.unmodifiableMap(writer.variables())); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - VariableMapBuilder that = (VariableMapBuilder) o; - - return Objects.equals(writer, that.writer); - } - - @Override - public int hashCode() { - return writer != null ? writer.hashCode() : 0; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/builder/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/builder/package-info.java deleted file mode 100644 index dbc0b924..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/builder/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Writers are used to create multiple variables inside a variable map. - * - * @see io.holunda.camunda.bpm.data.CamundaBpmData#builder() methods. - * @since 0.0.5 - */ -package io.holunda.camunda.bpm.data.builder; diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/package-info.java deleted file mode 100644 index 1d505dbe..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Process Variable Factories are used to define process variables. - * - * @see io.holunda.camunda.bpm.data.factory.VariableFactory as the main starting point. - * @since 0.0.2 - */ -package io.holunda.camunda.bpm.data.factory; diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/package-info.java deleted file mode 100644 index 78d58027..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Top-level package of the library. - * - * @see io.holunda.camunda.bpm.data.CamundaBpmData as entry point for variable factory definition. - * @since 0.0.2 - */ -package io.holunda.camunda.bpm.data; diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.java deleted file mode 100644 index b172cd4c..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.java +++ /dev/null @@ -1,70 +0,0 @@ -package io.holunda.camunda.bpm.data.reader; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.CaseService; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.Optional; - -/** - * Allows reading multiple variable values from {@link CaseService#getVariable(String, String)}. - */ -public class CaseServiceVariableReader implements VariableReader { - - private final CaseService caseService; - private final String caseExecutionId; - - /** - * Constructs a reader operating on execution. - * - * @param caseService runtime service to use. - * @param caseExecutionId execution id. - */ - public CaseServiceVariableReader(CaseService caseService, String caseExecutionId) { - this.caseService = caseService; - this.caseExecutionId = caseExecutionId; - } - - @NotNull - @Override - public Optional getOptional(VariableFactory variableFactory) { - return variableFactory.from(caseService, caseExecutionId).getOptional(); - } - - @NotNull - @Override - public T get(VariableFactory variableFactory) { - return variableFactory.from(caseService, caseExecutionId).get(); - } - - @NotNull - @Override - public T getLocal(VariableFactory variableFactory) { - return variableFactory.from(caseService, caseExecutionId).getLocal(); - } - - @NotNull - @Override - public Optional getLocalOptional(VariableFactory variableFactory) { - return variableFactory.from(caseService, caseExecutionId).getLocalOptional(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CaseServiceVariableReader that = (CaseServiceVariableReader) o; - - if (!Objects.equals(caseService, that.caseService)) return false; - return Objects.equals(caseExecutionId, that.caseExecutionId); - } - - @Override - public int hashCode() { - int result = caseService != null ? caseService.hashCode() : 0; - result = 31 * result + (caseExecutionId != null ? caseExecutionId.hashCode() : 0); - return result; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.java deleted file mode 100644 index 8391a420..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.java +++ /dev/null @@ -1,64 +0,0 @@ -package io.holunda.camunda.bpm.data.reader; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.Optional; - -/** - * Allows reading multiple variable values from {@link LockedExternalTask}). - */ -public class LockedExternalTaskReader implements VariableReader { - - private final LockedExternalTask lockedExternalTask; - - /** - * Constructs a reader operating on external task. - * - * @param lockedExternalTask scope to operate on. - */ - public LockedExternalTaskReader(LockedExternalTask lockedExternalTask) { - this.lockedExternalTask = lockedExternalTask; - } - - @Override - @NotNull - public Optional getOptional(VariableFactory variableFactory) { - return variableFactory.from(lockedExternalTask).getOptional(); - } - - @Override - @NotNull - public T get(VariableFactory variableFactory) { - return variableFactory.from(lockedExternalTask).get(); - } - - @Override - @NotNull - public T getLocal(VariableFactory variableFactory) { - return variableFactory.from(lockedExternalTask).getLocal(); - } - - @Override - @NotNull - public Optional getLocalOptional(VariableFactory variableFactory) { - return variableFactory.from(lockedExternalTask).getLocalOptional(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - LockedExternalTaskReader that = (LockedExternalTaskReader) o; - - return Objects.equals(lockedExternalTask, that.lockedExternalTask); - } - - @Override - public int hashCode() { - return lockedExternalTask != null ? lockedExternalTask.hashCode() : 0; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.java deleted file mode 100644 index d5e5273e..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.java +++ /dev/null @@ -1,70 +0,0 @@ -package io.holunda.camunda.bpm.data.reader; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.RuntimeService; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.Optional; - -/** - * Allows reading multiple variable values from {@link RuntimeService#getVariable(String, String)}. - */ -public class RuntimeServiceVariableReader implements VariableReader { - - private final RuntimeService runtimeService; - private final String executionId; - - /** - * Constructs a reader operating on execution. - * - * @param runtimeService runtime service to use. - * @param executionId execution id. - */ - public RuntimeServiceVariableReader(RuntimeService runtimeService, String executionId) { - this.runtimeService = runtimeService; - this.executionId = executionId; - } - - @NotNull - @Override - public Optional getOptional(VariableFactory variableFactory) { - return variableFactory.from(runtimeService, executionId).getOptional(); - } - - @NotNull - @Override - public T get(VariableFactory variableFactory) { - return variableFactory.from(runtimeService, executionId).get(); - } - - @NotNull - @Override - public T getLocal(VariableFactory variableFactory) { - return variableFactory.from(runtimeService, executionId).getLocal(); - } - - @NotNull - @Override - public Optional getLocalOptional(VariableFactory variableFactory) { - return variableFactory.from(runtimeService, executionId).getLocalOptional(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - RuntimeServiceVariableReader that = (RuntimeServiceVariableReader) o; - - if (!Objects.equals(runtimeService, that.runtimeService)) return false; - return Objects.equals(executionId, that.executionId); - } - - @Override - public int hashCode() { - int result = runtimeService != null ? runtimeService.hashCode() : 0; - result = 31 * result + (executionId != null ? executionId.hashCode() : 0); - return result; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.java deleted file mode 100644 index 81d0eafe..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.java +++ /dev/null @@ -1,71 +0,0 @@ -package io.holunda.camunda.bpm.data.reader; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.TaskService; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.Optional; - -/** - * Allows reading multiple variable values from {@link TaskService#getVariable(String, String)}. - */ -public class TaskServiceVariableReader implements VariableReader { - - private final TaskService taskService; - private final String taskId; - - /** - * Constructs a reader operating on task service. - * - * @param taskService task service to operate on. - * @param taskId task id. - */ - public TaskServiceVariableReader(TaskService taskService, String taskId) { - this.taskService = taskService; - this.taskId = taskId; - } - - - @NotNull - @Override - public Optional getOptional(VariableFactory variableFactory) { - return variableFactory.from(taskService, taskId).getOptional(); - } - - @NotNull - @Override - public T get(VariableFactory variableFactory) { - return variableFactory.from(taskService, taskId).get(); - } - - @NotNull - @Override - public T getLocal(VariableFactory variableFactory) { - return variableFactory.from(taskService, taskId).getLocal(); - } - - @NotNull - @Override - public Optional getLocalOptional(VariableFactory variableFactory) { - return variableFactory.from(taskService, taskId).getLocalOptional(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TaskServiceVariableReader that = (TaskServiceVariableReader) o; - - if (!Objects.equals(taskService, that.taskService)) return false; - return Objects.equals(taskId, that.taskId); - } - - @Override - public int hashCode() { - int result = taskService != null ? taskService.hashCode() : 0; - result = 31 * result + (taskId != null ? taskId.hashCode() : 0); - return result; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableMapReader.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableMapReader.java deleted file mode 100644 index 405a6fc3..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableMapReader.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.holunda.camunda.bpm.data.reader; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.variable.VariableMap; - -import java.util.Objects; -import java.util.Optional; - -/** - * Allows reading multiple variable values from {@link VariableMap#getValue(String, Class)}. - */ -public class VariableMapReader implements VariableReader { - - private final VariableMap variableMap; - - /** - * Constructs the reader using the specified variable map. - * - * @param variableMap map to operate on. - */ - public VariableMapReader(VariableMap variableMap) { - this.variableMap = variableMap; - } - - @Override - public Optional getOptional(VariableFactory variableFactory) { - return variableFactory.from(variableMap).getOptional(); - } - - @Override - public T get(VariableFactory variableFactory) { - return variableFactory.from(variableMap).get(); - } - - @Override - public T getLocal(VariableFactory variableFactory) { - return variableFactory.from(variableMap).getLocal(); - } - - @Override - public Optional getLocalOptional(VariableFactory variableFactory) { - return variableFactory.from(variableMap).getLocalOptional(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - VariableMapReader that = (VariableMapReader) o; - - return Objects.equals(variableMap, that.variableMap); - } - - @Override - public int hashCode() { - return variableMap != null ? variableMap.hashCode() : 0; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableReader.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableReader.java deleted file mode 100644 index 9065beed..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableReader.java +++ /dev/null @@ -1,97 +0,0 @@ -package io.holunda.camunda.bpm.data.reader; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.jetbrains.annotations.NotNull; - -import java.util.Optional; - -/** - * Inverting calls to {@link io.holunda.camunda.bpm.data.adapter.ReadAdapter}. - */ -public interface VariableReader { - - /** - * Uses {@link ReadAdapter#getOptional()} to access variable value. - * - * @param variableFactory the variable to read - * @param type of value - * @return value of variable or empty() - */ - @NotNull Optional getOptional(VariableFactory variableFactory); - - /** - * Uses {@link ReadAdapter#get()} to access variable value. - * - * @param variableFactory the variable to read - * @param type of value - * @return value of variable - * @throws IllegalStateException if variable is not set - */ - @NotNull T get(VariableFactory variableFactory); - - /** - * Uses {@link ReadAdapter#getLocal()} to access variable value. - * - * @param variableFactory the variable to read - * @param type of value - * @return value of variable - * @throws IllegalStateException if variable is not set - */ - @NotNull T getLocal(VariableFactory variableFactory); - - /** - * Uses {@link ReadAdapter#getLocalOptional()} ()} to access variable value. - * - * @param variableFactory the variable to read - * @param type of value - * @return value of variable or empty() - */ - @NotNull Optional getLocalOptional(VariableFactory variableFactory); - - - /** - * Uses {@link ReadAdapter#getOptional()} to access variable value. If the optional is empty returns null - * - * @param variableFactory the variable to read - * @param type of value - * @return value of variable or null if the variable is not present or has value null. - */ - default T getOrNull(VariableFactory variableFactory) { - return getOptional(variableFactory).orElse(null); - } - - /** - * Reads a variable and returns a value if exists or returns the provided default. - * - * @param variableFactory the variable to read - * @param defaultValue the default value if the variable is not set - * @return value or default - */ - default T getOrDefault(VariableFactory variableFactory, T defaultValue) { - return getOptional(variableFactory).orElse(defaultValue); - } - - /** - * Uses {@link ReadAdapter#getLocalOptional()} to access variable value. If the optional is empty returns null - * - * @param variableFactory the variable to read - * @param type of value - * @return value of variable or null if the variable is not present or has value null. - */ - default T getLocalOrNull(VariableFactory variableFactory) { - return getLocalOptional(variableFactory).orElse(null); - } - - /** - * Reads a local variable and returns a value if exists or returns the provided default. - * - * @param variableFactory the variable to read - * @param defaultValue the default value if the variable is not set - * @return value or default - */ - default T getLocalOrDefault(VariableFactory variableFactory, T defaultValue) { - return getLocalOptional(variableFactory).orElse(defaultValue); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableScopeReader.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableScopeReader.java deleted file mode 100644 index 139db730..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/VariableScopeReader.java +++ /dev/null @@ -1,64 +0,0 @@ -package io.holunda.camunda.bpm.data.reader; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.delegate.VariableScope; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.Optional; - -/** - * Allows reading multiple variable values from {@link VariableScope} (such as {@link org.camunda.bpm.engine.delegate.DelegateExecution} and {@link org.camunda.bpm.engine.delegate.DelegateTask}). - */ -public class VariableScopeReader implements VariableReader { - - private final VariableScope variableScope; - - /** - * Constructs a reader operating on variable scope (e.g. DelegateExecution or DelegateTask). - * - * @param variableScope scope to operate on. - */ - public VariableScopeReader(VariableScope variableScope) { - this.variableScope = variableScope; - } - - @Override - @NotNull - public Optional getOptional(VariableFactory variableFactory) { - return variableFactory.from(variableScope).getOptional(); - } - - @Override - @NotNull - public T get(VariableFactory variableFactory) { - return variableFactory.from(variableScope).get(); - } - - @Override - @NotNull - public T getLocal(VariableFactory variableFactory) { - return variableFactory.from(variableScope).getLocal(); - } - - @Override - @NotNull - public Optional getLocalOptional(VariableFactory variableFactory) { - return variableFactory.from(variableScope).getLocalOptional(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - VariableScopeReader that = (VariableScopeReader) o; - - return Objects.equals(variableScope, that.variableScope); - } - - @Override - public int hashCode() { - return variableScope != null ? variableScope.hashCode() : 0; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/package-info.java deleted file mode 100644 index b13f67f6..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/reader/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Readers are used to interact with multiple variables in the same context. - * - * @see io.holunda.camunda.bpm.data.CamundaBpmData#reader() methods. - * @since 1.0.0 - */ -package io.holunda.camunda.bpm.data.reader; diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.java deleted file mode 100644 index ec72f289..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.java +++ /dev/null @@ -1,119 +0,0 @@ -package io.holunda.camunda.bpm.data.writer; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.CaseService; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.function.Function; - -/** - * Process execution builder allowing for fluent variable setting. - */ -public class CaseServiceVariableWriter implements VariableWriter { - - private final CaseService caseService; - private final String caseExecutionId; - - /** - * Creates a writer working on process execution. - */ - public CaseServiceVariableWriter(CaseService caseService, String caseExecutionId) { - this.caseService = caseService; - this.caseExecutionId = caseExecutionId; - } - - @Override - @NotNull - public VariableMap variables() { - return this.caseService.getVariablesTyped(this.caseExecutionId); - } - - @Override - @NotNull - public VariableMap variablesLocal() { - return this.caseService.getVariablesLocalTyped(this.caseExecutionId); - } - - @Override - @NotNull - public CaseServiceVariableWriter set(VariableFactory factory, T value) { - return this.set(factory, value, false); - } - - @Override - @NotNull - public CaseServiceVariableWriter set(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.caseService, this.caseExecutionId).set(value, isTransient); - return this; - } - - @Override - @NotNull - public CaseServiceVariableWriter setLocal(VariableFactory factory, T value) { - return this.setLocal(factory, value, false); - } - - @Override - @NotNull - public CaseServiceVariableWriter setLocal(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.caseService, this.caseExecutionId).setLocal(value, isTransient); - return this; - } - - @Override - public @NotNull CaseServiceVariableWriter updateLocal(VariableFactory factory, Function valueProcessor) { - return updateLocal(factory, valueProcessor, false); - } - - @Override - public @NotNull CaseServiceVariableWriter updateLocal(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.caseService, this.caseExecutionId).updateLocal(valueProcessor, isTransient); - return this; - } - - @Override - @NotNull - public CaseServiceVariableWriter remove(VariableFactory factory) { - factory.on(this.caseService, this.caseExecutionId).remove(); - return this; - } - - @Override - @NotNull - public CaseServiceVariableWriter removeLocal(VariableFactory factory) { - factory.on(this.caseService, this.caseExecutionId).removeLocal(); - return this; - } - - @Override - public @NotNull CaseServiceVariableWriter update(VariableFactory factory, Function valueProcessor) { - factory.on(this.caseService, this.caseExecutionId).update(valueProcessor); - return this; - } - - @Override - public @NotNull CaseServiceVariableWriter update(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.caseService, this.caseExecutionId).updateLocal(valueProcessor, isTransient); - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CaseServiceVariableWriter that = (CaseServiceVariableWriter) o; - - if (!Objects.equals(caseService, that.caseService)) return false; - return Objects.equals(caseExecutionId, that.caseExecutionId); - } - - @Override - public int hashCode() { - int result = caseService != null ? caseService.hashCode() : 0; - result = 31 * result + (caseExecutionId != null ? caseExecutionId.hashCode() : 0); - return result; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.java deleted file mode 100644 index 4010fa7b..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.java +++ /dev/null @@ -1,80 +0,0 @@ -package io.holunda.camunda.bpm.data.writer; - -import io.holunda.camunda.bpm.data.adapter.WriteAdapter; -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -/** - * Inverting calls to {@link io.holunda.camunda.bpm.data.adapter.WriteAdapter}. - * - * @param type of concrete Writer for fluent usage. - */ -public interface GlobalVariableWriter> { - - /** - * Sets the value for the provided variable and returns the builder (fluently). - * - * @param variableFactory the variable - * @param value the value - * @param type of value - * @return current writer instance - * @see io.holunda.camunda.bpm.data.adapter.WriteAdapter#set(Object) - */ - @NotNull S set(VariableFactory variableFactory, T value); - - /** - * Sets the (transient) value for the provided variable and returns the builder (fluently). - * - * @param variableFactory the variable - * @param value the value - * @param isTransient if true, the variable is transient, default false. - * @param type of value - * @return current writer instance - * @see io.holunda.camunda.bpm.data.adapter.WriteAdapter#set(Object, boolean) - */ - @NotNull S set(VariableFactory variableFactory, T value, boolean isTransient); - - /** - * Sets the global value for the provided variable and returns the builder (fluently). - * - * @param variableFactory the variable - * @param valueProcessor function updating the value based on the old value. - * @param type of value - * @return current writer instance - * @see WriteAdapter#setLocal(Object) - */ - @NotNull S update(VariableFactory variableFactory, Function valueProcessor); - - /** - * Updates the global (transient) value for the provided variable and returns the builder (fluently). - * - * @param variableFactory the variable - * @param valueProcessor function updating the value based on the old value. - * @param isTransient if true, the variable is transient - * @param type of value - * @return current writer instance - * @see WriteAdapter#setLocal(Object, boolean) - */ - @NotNull S update(VariableFactory variableFactory, Function valueProcessor, boolean isTransient); - /** - * Removes the value for the provided variable and returns the builder (fluently). - * - * @param variableFactory the variable - * @param type of value - * @return current writer instance - * @see WriteAdapter#remove() - */ - @NotNull S remove(VariableFactory variableFactory); - - /** - * Returns the resulting variables. - * - * @return variables. - */ - @NotNull - VariableMap variables(); - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.java deleted file mode 100644 index 3b24bb8f..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.java +++ /dev/null @@ -1,120 +0,0 @@ -package io.holunda.camunda.bpm.data.writer; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.function.Function; - -/** - * Process execution builder allowing for fluent variable setting. - */ -public class RuntimeServiceVariableWriter implements VariableWriter { - - private final RuntimeService runtimeService; - private final String executionId; - - /** - * Creates a writer working on process execution. - */ - public RuntimeServiceVariableWriter(RuntimeService runtimeService, String executionId) { - this.runtimeService = runtimeService; - this.executionId = executionId; - } - - @Override - @NotNull - public VariableMap variables() { - return this.runtimeService.getVariablesTyped(this.executionId); - } - - @Override - @NotNull - public VariableMap variablesLocal() { - return this.runtimeService.getVariablesLocalTyped(this.executionId); - } - - @Override - @NotNull - public RuntimeServiceVariableWriter set(VariableFactory factory, T value) { - return this.set(factory, value, false); - } - - @Override - @NotNull - public RuntimeServiceVariableWriter set(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.runtimeService, this.executionId).set(value, isTransient); - return this; - } - - @Override - @NotNull - public RuntimeServiceVariableWriter setLocal(VariableFactory factory, T value) { - return this.setLocal(factory, value, false); - } - - @Override - @NotNull - public RuntimeServiceVariableWriter setLocal(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.runtimeService, this.executionId).setLocal(value, isTransient); - return this; - } - - @Override - @NotNull - public RuntimeServiceVariableWriter remove(VariableFactory factory) { - factory.on(this.runtimeService, this.executionId).remove(); - return this; - } - - @Override - @NotNull - public RuntimeServiceVariableWriter removeLocal(VariableFactory factory) { - factory.on(this.runtimeService, this.executionId).removeLocal(); - return this; - } - - @Override - public @NotNull RuntimeServiceVariableWriter update(VariableFactory factory, Function valueProcessor) { - factory.on(this.runtimeService, this.executionId).update(valueProcessor); - return this; - } - - @Override - public @NotNull RuntimeServiceVariableWriter update(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.runtimeService, this.executionId).update(valueProcessor, isTransient); - return this; - } - - @Override - public @NotNull RuntimeServiceVariableWriter updateLocal(VariableFactory factory, Function valueProcessor) { - factory.on(this.runtimeService, this.executionId).updateLocal(valueProcessor); - return this; - } - - @Override - public @NotNull RuntimeServiceVariableWriter updateLocal(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.runtimeService, this.executionId).updateLocal(valueProcessor, isTransient); - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - RuntimeServiceVariableWriter that = (RuntimeServiceVariableWriter) o; - - if (!Objects.equals(runtimeService, that.runtimeService)) return false; - return Objects.equals(executionId, that.executionId); - } - - @Override - public int hashCode() { - int result = runtimeService != null ? runtimeService.hashCode() : 0; - result = 31 * result + (executionId != null ? executionId.hashCode() : 0); - return result; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.java deleted file mode 100644 index 4e8ecd81..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.java +++ /dev/null @@ -1,120 +0,0 @@ -package io.holunda.camunda.bpm.data.writer; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.TaskService; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.function.Function; - -/** - * User task builder allowing for fluent variable setting. - */ -public class TaskServiceVariableWriter implements VariableWriter { - - private final TaskService taskService; - private final String taskId; - - /** - * Creates a builder working on a user task. - */ - public TaskServiceVariableWriter(TaskService taskService, String taskId) { - this.taskService = taskService; - this.taskId = taskId; - } - - @Override - @NotNull - public VariableMap variables() { - return this.taskService.getVariablesTyped(this.taskId); - } - - @Override - @NotNull - public VariableMap variablesLocal() { - return this.taskService.getVariablesLocalTyped(this.taskId); - } - - @Override - @NotNull - public TaskServiceVariableWriter set(VariableFactory factory, T value) { - return this.set(factory, value, false); - } - - @Override - @NotNull - public TaskServiceVariableWriter set(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.taskService, this.taskId).set(value, isTransient); - return this; - } - - @Override - @NotNull - public TaskServiceVariableWriter setLocal(VariableFactory factory, T value) { - return this.setLocal(factory, value, false); - } - - @Override - @NotNull - public TaskServiceVariableWriter setLocal(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.taskService, this.taskId).setLocal(value, isTransient); - return this; - } - - @Override - @NotNull - public TaskServiceVariableWriter remove(VariableFactory factory) { - factory.on(this.taskService, this.taskId).remove(); - return this; - } - - @Override - @NotNull - public TaskServiceVariableWriter removeLocal(VariableFactory factory) { - factory.on(this.taskService, this.taskId).removeLocal(); - return this; - } - - @Override - public @NotNull TaskServiceVariableWriter update(VariableFactory factory, Function valueProcessor) { - factory.on(this.taskService, this.taskId).update(valueProcessor); - return this; - } - - @Override - public @NotNull TaskServiceVariableWriter update(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.taskService, this.taskId).update(valueProcessor, isTransient); - return this; - } - - @Override - public @NotNull TaskServiceVariableWriter updateLocal(VariableFactory factory, Function valueProcessor) { - factory.on(this.taskService, this.taskId).updateLocal(valueProcessor); - return this; - } - - @Override - public @NotNull TaskServiceVariableWriter updateLocal(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.taskService, this.taskId).updateLocal(valueProcessor, isTransient); - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TaskServiceVariableWriter that = (TaskServiceVariableWriter) o; - - if (!Objects.equals(taskService, that.taskService)) return false; - return Objects.equals(taskId, that.taskId); - } - - @Override - public int hashCode() { - int result = taskService != null ? taskService.hashCode() : 0; - result = 31 * result + (taskId != null ? taskId.hashCode() : 0); - return result; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableMapWriter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableMapWriter.java deleted file mode 100644 index b98cf3f6..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableMapWriter.java +++ /dev/null @@ -1,77 +0,0 @@ -package io.holunda.camunda.bpm.data.writer; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.function.Function; - -/** - * Variable map builder allowing for fluent variable setting. - */ -public class VariableMapWriter implements GlobalVariableWriter { - - private final VariableMap variables; - - /** - * Creates a builder with provided variable map. - * - * @param variables variables to work on. - */ - public VariableMapWriter(VariableMap variables) { - this.variables = variables; - } - - @Override - @NotNull - public VariableMapWriter set(VariableFactory factory, T value) { - return this.set(factory, value, false); - } - - @Override - @NotNull - public VariableMapWriter set(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.variables).set(value, isTransient); - return this; - } - - @Override - @NotNull - public VariableMapWriter remove(VariableFactory factory) { - factory.on(this.variables).remove(); - return this; - } - - @Override - public @NotNull VariableMapWriter update(VariableFactory factory, Function valueProcessor) { - factory.on(this.variables).update(valueProcessor); - return this; - } - - @Override - public @NotNull VariableMapWriter update(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.variables).update(valueProcessor, isTransient); - return this; - } - - @Override - @NotNull - public VariableMap variables() { - return variables; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - VariableMapWriter that = (VariableMapWriter) o; - return Objects.equals(variables, that.variables); - } - - @Override - public int hashCode() { - return variables != null ? variables.hashCode() : 0; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.java deleted file mode 100644 index 9db2bb7e..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.java +++ /dev/null @@ -1,117 +0,0 @@ -package io.holunda.camunda.bpm.data.writer; - -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.delegate.VariableScope; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.function.Function; - -/** - * Variable scope builder allowing for fluent variable setting. - */ -public class VariableScopeWriter implements VariableWriter { - - private final VariableScope scope; - - /** - * Creates a builder with provided variable map. - *

The provided variables are modified by reference.

- * - * @param variables variables to work on. - */ - public VariableScopeWriter(VariableScope variables) { - this.scope = variables; - } - - @Override - @NotNull - public VariableScopeWriter set(VariableFactory factory, T value) { - return this.set(factory, value, false); - } - - @Override - @NotNull - public VariableScopeWriter set(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.scope).set(value, isTransient); - return this; - } - - @Override - @NotNull - public VariableScopeWriter setLocal(VariableFactory factory, T value) { - return this.setLocal(factory, value, false); - } - - @Override - @NotNull - public VariableScopeWriter setLocal(VariableFactory factory, T value, boolean isTransient) { - factory.on(this.scope).setLocal(value, isTransient); - return this; - } - - @Override - public @NotNull VariableScopeWriter update(VariableFactory factory, Function valueProcessor) { - factory.on(this.scope).update(valueProcessor); - return this; - } - - @Override - public @NotNull VariableScopeWriter update(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.scope).update(valueProcessor, isTransient); - return this; - } - - @Override - public @NotNull VariableScopeWriter updateLocal(VariableFactory factory, Function valueProcessor) { - factory.on(this.scope).updateLocal(valueProcessor); - return this; - } - - @Override - public @NotNull VariableScopeWriter updateLocal(VariableFactory factory, Function valueProcessor, boolean isTransient) { - factory.on(this.scope).updateLocal(valueProcessor, isTransient); - return this; - } - - @Override - @NotNull - public VariableScopeWriter remove(VariableFactory factory) { - factory.on(this.scope).remove(); - return this; - } - - @Override - @NotNull - public VariableScopeWriter removeLocal(VariableFactory factory) { - factory.on(this.scope).removeLocal(); - return this; - } - - @Override - @NotNull - public VariableMap variables() { - return scope.getVariablesTyped(); - } - - @Override - @NotNull - public VariableMap variablesLocal() { - return scope.getVariablesLocalTyped(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - VariableScopeWriter that = (VariableScopeWriter) o; - return Objects.equals(scope, that.scope); - } - - @Override - public int hashCode() { - return scope != null ? scope.hashCode() : 0; - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableWriter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableWriter.java deleted file mode 100644 index 8faa5018..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/VariableWriter.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.holunda.camunda.bpm.data.writer; - -import io.holunda.camunda.bpm.data.adapter.WriteAdapter; - -/** - * Inverting calls to {@link WriteAdapter}. - * - * @param type of concrete Writer for fluent usage. - */ -public interface VariableWriter> extends LocalVariableWriter, GlobalVariableWriter { - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/package-info.java deleted file mode 100644 index 72ddbee5..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Writers are used to interact with multiple variables in the same context. - * - * @see io.holunda.camunda.bpm.data.CamundaBpmData#writer() methods. - * @since 0.0.5 - */ -package io.holunda.camunda.bpm.data.writer; diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmData.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmData.kt new file mode 100644 index 00000000..4e850fc1 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmData.kt @@ -0,0 +1,321 @@ + + +package io.holunda.camunda.bpm.data + +import io.holunda.camunda.bpm.data.builder.VariableMapBuilder +import io.holunda.camunda.bpm.data.factory.* +import io.holunda.camunda.bpm.data.reader.* +import io.holunda.camunda.bpm.data.writer.* +import org.camunda.bpm.engine.CaseService +import org.camunda.bpm.engine.RuntimeService +import org.camunda.bpm.engine.TaskService +import org.camunda.bpm.engine.delegate.VariableScope +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + + +/** + * Provides a collection of factory methods for creating variable factories. + */ +object CamundaBpmData { + /** + * Creates a string variable factory. + * + * @param variableName name of the variable. + * @return variable factory for string. + */ + @JvmStatic + fun stringVariable(variableName: String): VariableFactory { + return BasicVariableFactory(variableName, String::class.java) + } + + /** + * Creates a date variable factory. + * + * @param variableName name of the variable. + * @return variable factory for date. + */ + @JvmStatic + fun dateVariable(variableName: String): VariableFactory { + return BasicVariableFactory(variableName, Date::class.java) + } + + /** + * Creates an integer variable factory. + * + * @param variableName name of the variable. + * @return variable factory for integer. + */ + @JvmStatic + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + fun intVariable(variableName: String): VariableFactory { + return BasicVariableFactory(variableName, java.lang.Integer::class.java) + } + + /** + * Creates a long variable factory. + * + * @param variableName name of the variable. + * @return variable factory for long. + */ + @JvmStatic + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + fun longVariable(variableName: String): VariableFactory { + return BasicVariableFactory(variableName, java.lang.Long::class.java) + } + + /** + * Creates a short variable factory. + * + * @param variableName name of the variable. + * @return variable factory for short. + */ + @JvmStatic + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + fun shortVariable(variableName: String): VariableFactory { + return BasicVariableFactory(variableName, java.lang.Short::class.java) + } + + /** + * Creates a double variable factory. + * + * @param variableName name of the variable. + * @return variable factory for double. + */ + @JvmStatic + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + fun doubleVariable(variableName: String): VariableFactory { + return BasicVariableFactory(variableName, java.lang.Double::class.java) + } + + /** + * Creates a boolean variable factory. + * + * @param variableName name of the variable. + * @return variable factory for boolean. + */ + @JvmStatic + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + fun booleanVariable(variableName: String): VariableFactory { + return BasicVariableFactory(variableName, java.lang.Boolean::class.java) + } + + /** + * Creates an uuid variable factory. + * + * @param variableName name of the variable. + * @return variable factory for uuid. + */ + @JvmStatic + fun uuidVariable(variableName: String): VariableFactory { + return BasicVariableFactory(variableName, UUID::class.java) + } + + /** + * Creates a variable factory for custom type. + * + * @param variableName name of the variable. + * @param clazz class of specifying the type. + * @param factory type. + * @return variable factory for given type. + */ + @JvmStatic + fun customVariable(variableName: String, clazz: Class): VariableFactory { + return BasicVariableFactory(variableName, clazz) + } + + /** + * Creates a variable factory for list of custom type. + * + * @param variableName name of the variable. + * @param clazz class of specifying the member type. + * @param factory type. + * @return variable factory for given type. + */ + @JvmStatic + fun listVariable(variableName: String, clazz: Class): VariableFactory> { + return ListVariableFactory(variableName, clazz) + } + + /** + * Creates a variable factory for set of custom type. + * + * @param variableName name of the variable. + * @param clazz class of specifying the member type. + * @param factory type. + * @return variable factory for given type. + */ + @JvmStatic + fun setVariable(variableName: String, clazz: Class): VariableFactory> { + return SetVariableFactory(variableName, clazz) + } + + /** + * Creates a variable factory for map of custom key and custom value type. + * + * @param variableName name of the variable. + * @param keyClazz class of specifying the key member type. + * @param valueClazz class of specifying the value member type. + * @param factory key type. + * @param factory value type. + * @return variable factory for given type. + */ + @JvmStatic + fun mapVariable( + variableName: String, keyClazz: Class, + valueClazz: Class + ): VariableFactory> { + return MapVariableFactory(variableName, keyClazz, valueClazz) + } + + /** + * Creates a new variable map builder. + * + * @return new writer with empty variable map. + */ + @JvmStatic + fun builder(): VariableMapBuilder { + return VariableMapBuilder() + } + + /** + * Creates a new variable map builder. + * + * @param variables pre-created, potentially non-empty variables. + * @return new writer + */ + @JvmStatic + fun writer(variables: VariableMap): GlobalVariableWriter<*> { + return VariableMapWriter(variables) + } + + /** + * Creates a new variable scope writer. + * + * @param variableScope scope to work on (delegate execution or delegate task). + * @return new writer working on provided variable scope. + */ + @JvmStatic + fun writer(variableScope: VariableScope): VariableWriter<*> { + return VariableScopeWriter(variableScope) + } + + /** + * Creates a new execution variable writer. + * + * @param runtimeService runtime service to use. + * @param executionId id of the execution. + * @return new writer working on provided process execution. + */ + @JvmStatic + fun writer(runtimeService: RuntimeService, executionId: String): VariableWriter<*> { + return RuntimeServiceVariableWriter(runtimeService, executionId) + } + + /** + * Creates a new task variable writer. + * + * @param taskService task service to use. + * @param taskId task id. + * @return new writer working on provided user task. + */ + @JvmStatic + fun writer(taskService: TaskService, taskId: String): VariableWriter<*> { + return TaskServiceVariableWriter(taskService, taskId) + } + + /** + * Creates a new caseExecution variable writer. + * + * @param caseService task service to use. + * @param caseExecutionId caseExecution id. + * @return new writer working on provided user task. + */ + @JvmStatic + fun writer(caseService: CaseService, caseExecutionId: String): VariableWriter<*> { + return CaseServiceVariableWriter(caseService, caseExecutionId) + } + + /** + * Creates a new task variable reader. + * + * @param taskService the Camunda task service + * @param taskId the id of the task to use + * @return variable reader working on task + */ + @JvmStatic + fun reader(taskService: TaskService, taskId: String): VariableReader { + return TaskServiceVariableReader(taskService, taskId) + } + + /** + * Creates a new execution variable reader. + * + * @param runtimeService the Camunda runtime service + * @param executionId the executionId to use + * @return variable reader working on execution + */ + @JvmStatic + fun reader(runtimeService: RuntimeService, executionId: String): VariableReader { + return RuntimeServiceVariableReader(runtimeService, executionId) + } + + /** + * Creates a new execution variable reader. + * + * @param caseService the Camunda case service + * @param caseExecutionId the caseExecutionId to use + * @return variable reader working on execution + */ + @JvmStatic + fun reader(caseService: CaseService, caseExecutionId: String): VariableReader { + return CaseServiceVariableReader(caseService, caseExecutionId) + } + + /** + * Creates a new variableScope variable reader. + * + * @param variableScope the variable scope to use (DelegateExecution, DelegateTask) + * @return variable reader working on variableScope + */ + @JvmStatic + fun reader(variableScope: VariableScope): VariableReader { + return VariableScopeReader(variableScope) + } + + /** + * Creates a new variableMap variable reader. + * + * @param variableMap the variableMap to use + * @return variable reader working on variableMap + */ + @JvmStatic + fun reader(variableMap: VariableMap): VariableReader { + return VariableMapReader(variableMap) + } + + /** + * Creates a new processInstance variable reader. + * + * @see .reader + * @param processInstance the processInstance with variables to read from + * @return variable reader working on the variableMap provided by instance + */ + @JvmStatic + fun reader(processInstance: ProcessInstanceWithVariables): VariableReader { + return reader(processInstance.variables) + } + + /** + * Creates a new extern variable reader. + * + * @param lockedExternalTask the external tasks to use + * @return variable reader working on external task + */ + @JvmStatic + fun reader(lockedExternalTask: LockedExternalTask): VariableReader { + return LockedExternalTaskReader(lockedExternalTask) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt index ae5351dd..03c6ad02 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt @@ -126,34 +126,40 @@ fun VariableScope.updateLocal(factory: VariableFactory, valueProcessor: ( * Helper to access case service writer. * @param caseExecutionId id of the execution. */ -fun CaseService.writer(caseExecutionId: String) = CaseServiceVariableWriter(this, caseExecutionId) +fun CaseService.writer(caseExecutionId: String) = + CaseServiceVariableWriter(this, caseExecutionId) /** * Helper to access runtime service writer. * @param executionId id of the execution. */ -fun RuntimeService.writer(executionId: String) = RuntimeServiceVariableWriter(this, executionId) +fun RuntimeService.writer(executionId: String) = + RuntimeServiceVariableWriter(this, executionId) /** * Helper to access task service writer. * @param taskId id of the task. */ -fun TaskService.writer(taskId: String) = TaskServiceVariableWriter(this, taskId) +fun TaskService.writer(taskId: String) = + TaskServiceVariableWriter(this, taskId) /** * Helper to access case service reader. * @param caseExecutionId id of the execution. */ -fun CaseService.reader(caseExecutionId: String) = CaseServiceVariableReader(this, caseExecutionId) +fun CaseService.reader(caseExecutionId: String) = + CaseServiceVariableReader(this, caseExecutionId) /** * Helper to access runtime service reader. * @param executionId id of the execution. */ -fun RuntimeService.reader(executionId: String) = RuntimeServiceVariableReader(this, executionId) +fun RuntimeService.reader(executionId: String) = + RuntimeServiceVariableReader(this, executionId) /** * Helper to access task service reader. * @param taskId id of the task. */ -fun TaskService.reader(taskId: String) = TaskServiceVariableReader(this, taskId) +fun TaskService.reader(taskId: String) = + TaskServiceVariableReader(this, taskId) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/builder/VariableMapBuilder.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/builder/VariableMapBuilder.kt new file mode 100644 index 00000000..010b29c3 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/builder/VariableMapBuilder.kt @@ -0,0 +1,62 @@ +package io.holunda.camunda.bpm.data.builder + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import io.holunda.camunda.bpm.data.writer.VariableMapWriter +import org.camunda.bpm.engine.variable.VariableMap +import org.camunda.bpm.engine.variable.Variables +import java.util.* + +/** + * Builder to create [VariableMap] using [VariableFactory]. + */ +class VariableMapBuilder { + + private val writer: VariableMapWriter = VariableMapWriter(Variables.createVariables()) + + /** + * Sets the value for the provided variable and returns the builder (fluently). + * + * @param variableFactory the variable + * @param value the value + * @param type of value + * @return current builder instance + */ + fun set(variableFactory: VariableFactory, value: T): VariableMapBuilder { + writer.set(variableFactory, value) + return this + } + + /** + * Sets the (transient) value for the provided variable and returns the builder (fluently). + * + * @param variableFactory the variable + * @param value the value + * @param isTransient if true, the variable is transient, default false. + * @param type of value + * @return current builder instance + */ + fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): VariableMapBuilder { + writer.set(variableFactory, value, isTransient) + return this + } + + /** + * Creates the variable map. + * + * @return instance of [VariableMap] containing set values + */ + fun build(): VariableMap { + return Variables.fromMap(Collections.unmodifiableMap(writer.variables())) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as VariableMapBuilder + return writer == that.writer + } + + override fun hashCode(): Int { + return writer.hashCode() + } +} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java similarity index 100% rename from extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java rename to extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java similarity index 100% rename from extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java rename to extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java similarity index 100% rename from extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java rename to extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java similarity index 100% rename from extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java rename to extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/VariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/VariableFactory.java similarity index 100% rename from extension/core/src/main/java/io/holunda/camunda/bpm/data/factory/VariableFactory.java rename to extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/VariableFactory.java diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.kt new file mode 100644 index 00000000..04393ca3 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.kt @@ -0,0 +1,46 @@ +package io.holunda.camunda.bpm.data.reader + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.CaseService +import java.util.* + +/** + * Allows reading multiple variable values from [CaseService.getVariable]. + * @param caseService runtime service to use. + * @param caseExecutionId execution id. + * + */ +class CaseServiceVariableReader( + private val caseService: CaseService, + private val caseExecutionId: String +) : VariableReader { + + override fun getOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(caseService, caseExecutionId).optional + } + + override fun get(variableFactory: VariableFactory): T { + return variableFactory.from(caseService, caseExecutionId).get() + } + + override fun getLocal(variableFactory: VariableFactory): T { + return variableFactory.from(caseService, caseExecutionId).local + } + + override fun getLocalOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(caseService, caseExecutionId).localOptional + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as CaseServiceVariableReader + return if (caseService != that.caseService) false else caseExecutionId == that.caseExecutionId + } + + override fun hashCode(): Int { + var result = caseService.hashCode() + result = 31 * result + caseExecutionId.hashCode() + return result + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.kt new file mode 100644 index 00000000..371b7c76 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.kt @@ -0,0 +1,38 @@ +package io.holunda.camunda.bpm.data.reader + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import java.util.* + +/** + * Allows reading multiple variable values from [LockedExternalTask]). + * @param lockedExternalTask scope to operate on. + */ +class LockedExternalTaskReader(private val lockedExternalTask: LockedExternalTask) : VariableReader { + override fun getOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(lockedExternalTask).optional + } + + override fun get(variableFactory: VariableFactory): T { + return variableFactory.from(lockedExternalTask).get() + } + + override fun getLocal(variableFactory: VariableFactory): T { + return variableFactory.from(lockedExternalTask).local + } + + override fun getLocalOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(lockedExternalTask).localOptional + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as LockedExternalTaskReader + return lockedExternalTask == that.lockedExternalTask + } + + override fun hashCode(): Int { + return lockedExternalTask.hashCode() + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.kt new file mode 100644 index 00000000..2bcb3a38 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.kt @@ -0,0 +1,41 @@ +package io.holunda.camunda.bpm.data.reader + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.RuntimeService +import java.util.* + +/** + * Allows reading multiple variable values from [RuntimeService.getVariable]. + * @param runtimeService runtime service to use. + * @param executionId execution id. + */ +class RuntimeServiceVariableReader(private val runtimeService: RuntimeService, private val executionId: String) : VariableReader { + override fun getOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(runtimeService, executionId).optional + } + + override fun get(variableFactory: VariableFactory): T { + return variableFactory.from(runtimeService, executionId).get() + } + + override fun getLocal(variableFactory: VariableFactory): T { + return variableFactory.from(runtimeService, executionId).local + } + + override fun getLocalOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(runtimeService, executionId).localOptional + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as RuntimeServiceVariableReader + return if (runtimeService != that.runtimeService) false else executionId == that.executionId + } + + override fun hashCode(): Int { + var result = runtimeService.hashCode() + result = 31 * result + executionId.hashCode() + return result + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.kt new file mode 100644 index 00000000..1be6bc44 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.kt @@ -0,0 +1,41 @@ +package io.holunda.camunda.bpm.data.reader + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.TaskService +import java.util.* + +/** + * Allows reading multiple variable values from [TaskService.getVariable]. + * @param taskService task service to operate on. + * @param taskId task id. + */ +class TaskServiceVariableReader(private val taskService: TaskService, private val taskId: String) : VariableReader { + override fun getOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(taskService, taskId).optional + } + + override fun get(variableFactory: VariableFactory): T { + return variableFactory.from(taskService, taskId).get() + } + + override fun getLocal(variableFactory: VariableFactory): T { + return variableFactory.from(taskService, taskId).local + } + + override fun getLocalOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(taskService, taskId).localOptional + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as TaskServiceVariableReader + return if (taskService != that.taskService) false else taskId == that.taskId + } + + override fun hashCode(): Int { + var result = taskService.hashCode() + result = 31 * result + taskId.hashCode() + return result + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableMapReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableMapReader.kt new file mode 100644 index 00000000..b30584ad --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableMapReader.kt @@ -0,0 +1,39 @@ +package io.holunda.camunda.bpm.data.reader + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Allows reading multiple variable values from [VariableMap.getValue]. + * @param variableMap map to operate on. + */ +class VariableMapReader(private val variableMap: VariableMap) : VariableReader { + + override fun getOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(variableMap).optional + } + + override fun get(variableFactory: VariableFactory): T { + return variableFactory.from(variableMap).get() + } + + override fun getLocal(variableFactory: VariableFactory): T { + return variableFactory.from(variableMap).local + } + + override fun getLocalOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(variableMap).localOptional + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as VariableMapReader + return variableMap == that.variableMap + } + + override fun hashCode(): Int { + return variableMap.hashCode() + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableReader.kt new file mode 100644 index 00000000..e9e3434b --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableReader.kt @@ -0,0 +1,91 @@ +package io.holunda.camunda.bpm.data.reader + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import java.util.* + +/** + * Inverting calls to [io.holunda.camunda.bpm.data.adapter.ReadAdapter]. + */ +interface VariableReader { + /** + * Uses [io.holunda.camunda.bpm.data.adapter.ReadAdapter.getOptional] to access variable value. + * + * @param variableFactory the variable to read + * @param type of value + * @return value of variable or empty() + */ + fun getOptional(variableFactory: VariableFactory): Optional + + /** + * Uses [io.holunda.camunda.bpm.data.adapter.ReadAdapter.get] to access variable value. + * + * @param variableFactory the variable to read + * @param type of value + * @return value of variable + * @throws IllegalStateException if variable is not set + */ + fun get(variableFactory: VariableFactory): T + + /** + * Uses [io.holunda.camunda.bpm.data.adapter.ReadAdapter.getLocal] to access variable value. + * + * @param variableFactory the variable to read + * @param type of value + * @return value of variable + * @throws IllegalStateException if variable is not set + */ + fun getLocal(variableFactory: VariableFactory): T + + /** + * Uses [io.holunda.camunda.bpm.data.adapter.ReadAdapter.getLocalOptional] ()} to access variable value. + * + * @param variableFactory the variable to read + * @param type of value + * @return value of variable or empty() + */ + fun getLocalOptional(variableFactory: VariableFactory): Optional + + /** + * Uses [io.holunda.camunda.bpm.data.adapter.ReadAdapter.getOptional] to access variable value. If the optional is empty returns `null` + * + * @param variableFactory the variable to read + * @param type of value + * @return value of variable or `null` if the variable is not present or has value `null`. + */ + fun getOrNull(variableFactory: VariableFactory): T? { + return getOptional(variableFactory).orElse(null) + } + + /** + * Reads a variable and returns a value if exists or returns the provided default. + * + * @param variableFactory the variable to read + * @param defaultValue the default value if the variable is not set + * @return value or default + */ + fun getOrDefault(variableFactory: VariableFactory, defaultValue: T?): T? { + return getOptional(variableFactory).orElse(defaultValue) + } + + /** + * Uses [io.holunda.camunda.bpm.data.adapter.ReadAdapter.getLocalOptional] to access variable value. If the optional is empty returns `null` + * + * @param variableFactory the variable to read + * @param type of value + * @return value of variable or `null` if the variable is not present or has value `null`. + */ + fun getLocalOrNull(variableFactory: VariableFactory): T? { + return getLocalOptional(variableFactory).orElse(null) + } + + /** + * Reads a local variable and returns a value if exists or returns the provided default. + * + * @param variableFactory the variable to read + * @param defaultValue the default value if the variable is not set + * @return value or default + */ + fun getLocalOrDefault(variableFactory: VariableFactory, defaultValue: T): T { + return getLocalOptional(variableFactory).orElse(defaultValue) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableScopeReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableScopeReader.kt new file mode 100644 index 00000000..36b83917 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableScopeReader.kt @@ -0,0 +1,38 @@ +package io.holunda.camunda.bpm.data.reader + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.delegate.VariableScope +import java.util.* + +/** + * Allows reading multiple variable values from [VariableScope] (such as [org.camunda.bpm.engine.delegate.DelegateExecution] and [org.camunda.bpm.engine.delegate.DelegateTask]). + * @param variableScope scope to operate on. + */ +class VariableScopeReader(private val variableScope: VariableScope) : VariableReader { + override fun getOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(variableScope).optional + } + + override fun get(variableFactory: VariableFactory): T { + return variableFactory.from(variableScope).get() + } + + override fun getLocal(variableFactory: VariableFactory): T { + return variableFactory.from(variableScope).local + } + + override fun getLocalOptional(variableFactory: VariableFactory): Optional { + return variableFactory.from(variableScope).localOptional + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as VariableScopeReader + return variableScope == that.variableScope + } + + override fun hashCode(): Int { + return variableScope.hashCode() + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt new file mode 100644 index 00000000..57642213 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt @@ -0,0 +1,92 @@ +package io.holunda.camunda.bpm.data.writer + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.CaseService +import org.camunda.bpm.engine.variable.VariableMap +import java.util.function.Function + +/** + * Process execution builder allowing for fluent variable setting. + */ +class CaseServiceVariableWriter(private val caseService: CaseService, private val caseExecutionId: String) : + VariableWriter { + + override fun variables(): VariableMap { + return caseService.getVariablesTyped(caseExecutionId) + } + + override fun variablesLocal(): VariableMap { + return caseService.getVariablesLocalTyped(caseExecutionId) + } + + override fun set(variableFactory: VariableFactory, value: T): CaseServiceVariableWriter { + return this.set(variableFactory, value, false) + } + + override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): CaseServiceVariableWriter { + variableFactory.on(caseService, caseExecutionId)[value] = isTransient + return this + } + + override fun setLocal(variableFactory: VariableFactory, value: T): CaseServiceVariableWriter { + return this.setLocal(variableFactory, value, false) + } + + override fun setLocal(variableFactory: VariableFactory, value: T, isTransient: Boolean): CaseServiceVariableWriter { + variableFactory.on(caseService, caseExecutionId).setLocal(value, isTransient) + return this + } + + override fun updateLocal( + variableFactory: VariableFactory, + valueProcessor: Function + ): CaseServiceVariableWriter { + return updateLocal(variableFactory, valueProcessor, false) + } + + override fun updateLocal( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): CaseServiceVariableWriter { + variableFactory.on(caseService, caseExecutionId).updateLocal(valueProcessor, isTransient) + return this + } + + override fun remove(variableFactory: VariableFactory): CaseServiceVariableWriter { + variableFactory.on(caseService, caseExecutionId).remove() + return this + } + + override fun removeLocal(variableFactory: VariableFactory): CaseServiceVariableWriter { + variableFactory.on(caseService, caseExecutionId).removeLocal() + return this + } + + override fun update(variableFactory: VariableFactory, valueProcessor: Function): CaseServiceVariableWriter { + variableFactory.on(caseService, caseExecutionId).update(valueProcessor) + return this + } + + override fun update( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): CaseServiceVariableWriter { + variableFactory.on(caseService, caseExecutionId).updateLocal(valueProcessor, isTransient) + return this + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as CaseServiceVariableWriter + return if (caseService != that.caseService) false else caseExecutionId == that.caseExecutionId + } + + override fun hashCode(): Int { + var result = caseService.hashCode() + result = 31 * result + caseExecutionId.hashCode() + return result + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.kt new file mode 100644 index 00000000..dc856de5 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.kt @@ -0,0 +1,75 @@ +package io.holunda.camunda.bpm.data.writer + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.variable.VariableMap +import java.util.function.Function + +/** + * Inverting calls to [io.holunda.camunda.bpm.data.adapter.WriteAdapter]. + * + * @param type of concrete Writer for fluent usage. + */ +interface GlobalVariableWriter> { + /** + * Sets the value for the provided variable and returns the builder (fluently). + * + * @param variableFactory the variable + * @param value the value + * @param type of value + * @return current writer instance + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.set] + */ + operator fun set(variableFactory: VariableFactory, value: T): S + + /** + * Sets the (transient) value for the provided variable and returns the builder (fluently). + * + * @param variableFactory the variable + * @param value the value + * @param isTransient if true, the variable is transient, default false. + * @param type of value + * @return current writer instance + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.set] + */ + operator fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): S + + /** + * Sets the global value for the provided variable and returns the builder (fluently). + * + * @param variableFactory the variable + * @param valueProcessor function updating the value based on the old value. + * @param type of value + * @return current writer instance + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] + */ + fun update(variableFactory: VariableFactory, valueProcessor: Function): S + + /** + * Updates the global (transient) value for the provided variable and returns the builder (fluently). + * + * @param variableFactory the variable + * @param valueProcessor function updating the value based on the old value. + * @param isTransient if true, the variable is transient + * @param type of value + * @return current writer instance + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] + */ + fun update(variableFactory: VariableFactory, valueProcessor: Function, isTransient: Boolean): S + + /** + * Removes the value for the provided variable and returns the builder (fluently). + * + * @param variableFactory the variable + * @param type of value + * @return current writer instance + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.remove] + */ + fun remove(variableFactory: VariableFactory): S + + /** + * Returns the resulting variables. + * + * @return variables. + */ + fun variables(): VariableMap +} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.kt similarity index 57% rename from extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.java rename to extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.kt index 39ef1373..1b8ed27b 100644 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.java +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.kt @@ -1,19 +1,15 @@ -package io.holunda.camunda.bpm.data.writer; +package io.holunda.camunda.bpm.data.writer -import io.holunda.camunda.bpm.data.adapter.WriteAdapter; -import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.variable.VariableMap +import java.util.function.Function /** - * Inverting calls to {@link WriteAdapter}. + * Inverting calls to [io.holunda.camunda.bpm.data.adapter.WriteAdapter]. * * @param type of concrete Writer for fluent usage. - */ -public interface LocalVariableWriter> { - + */ +interface LocalVariableWriter> { /** * Sets the local value for the provided variable and returns the builder (fluently). * @@ -21,9 +17,9 @@ public interface LocalVariableWriter> { * @param value the value * @param type of value * @return current writer instance - * @see WriteAdapter#setLocal(Object) - */ - @NotNull S setLocal(VariableFactory variableFactory, T value); + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] + */ + fun setLocal(variableFactory: VariableFactory, value: T): S /** * Sets the local (transient) value for the provided variable and returns the builder (fluently). @@ -33,9 +29,9 @@ public interface LocalVariableWriter> { * @param isTransient if true, the variable is transient * @param type of value * @return current writer instance - * @see WriteAdapter#setLocal(Object, boolean) - */ - @NotNull S setLocal(VariableFactory variableFactory, T value, boolean isTransient); + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] + */ + fun setLocal(variableFactory: VariableFactory, value: T, isTransient: Boolean): S /** * Sets the local value for the provided variable and returns the builder (fluently). @@ -44,9 +40,9 @@ public interface LocalVariableWriter> { * @param valueProcessor function updating the value based on the old value. * @param type of value * @return current writer instance - * @see WriteAdapter#setLocal(Object) - */ - @NotNull S updateLocal(VariableFactory variableFactory, Function valueProcessor); + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] + */ + fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function): S /** * Updates the local (transient) value for the provided variable and returns the builder (fluently). @@ -56,9 +52,9 @@ public interface LocalVariableWriter> { * @param isTransient if true, the variable is transient * @param type of value * @return current writer instance - * @see WriteAdapter#setLocal(Object, boolean) - */ - @NotNull S updateLocal(VariableFactory variableFactory, Function valueProcessor, boolean isTransient); + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] + */ + fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function, isTransient: Boolean): S /** * Removes the local value for the provided variable and returns the builder (fluently). @@ -66,15 +62,13 @@ public interface LocalVariableWriter> { * @param variableFactory the variable * @param type of value * @return current writer instance - * @see WriteAdapter#removeLocal() - */ - @NotNull S removeLocal(VariableFactory variableFactory); + * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.removeLocal] + */ + fun removeLocal(variableFactory: VariableFactory): S /** * Returns the resulting local variables. - * * @return local variables. */ - @NotNull - VariableMap variablesLocal(); + fun variablesLocal(): VariableMap } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt new file mode 100644 index 00000000..15852b23 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt @@ -0,0 +1,96 @@ +package io.holunda.camunda.bpm.data.writer + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.RuntimeService +import org.camunda.bpm.engine.variable.VariableMap +import java.util.function.Function + +/** + * Process execution builder allowing for fluent variable setting. + */ +class RuntimeServiceVariableWriter(private val runtimeService: RuntimeService, private val executionId: String) : + VariableWriter { + override fun variables(): VariableMap { + return runtimeService.getVariablesTyped(executionId) + } + + override fun variablesLocal(): VariableMap { + return runtimeService.getVariablesLocalTyped(executionId) + } + + override fun set(variableFactory: VariableFactory, value: T): RuntimeServiceVariableWriter { + return this.set(variableFactory, value, false) + } + + override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): RuntimeServiceVariableWriter { + variableFactory.on(runtimeService, executionId)[value] = isTransient + return this + } + + override fun setLocal(variableFactory: VariableFactory, value: T): RuntimeServiceVariableWriter { + return this.setLocal(variableFactory, value, false) + } + + override fun setLocal( + variableFactory: VariableFactory, + value: T, + isTransient: Boolean + ): RuntimeServiceVariableWriter { + variableFactory.on(runtimeService, executionId).setLocal(value, isTransient) + return this + } + + override fun remove(variableFactory: VariableFactory): RuntimeServiceVariableWriter { + variableFactory.on(runtimeService, executionId).remove() + return this + } + + override fun removeLocal(variableFactory: VariableFactory): RuntimeServiceVariableWriter { + variableFactory.on(runtimeService, executionId).removeLocal() + return this + } + + override fun update(variableFactory: VariableFactory, valueProcessor: Function): RuntimeServiceVariableWriter { + variableFactory.on(runtimeService, executionId).update(valueProcessor) + return this + } + + override fun update( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): RuntimeServiceVariableWriter { + variableFactory.on(runtimeService, executionId).update(valueProcessor, isTransient) + return this + } + + override fun updateLocal( + variableFactory: VariableFactory, + valueProcessor: Function + ): RuntimeServiceVariableWriter { + variableFactory.on(runtimeService, executionId).updateLocal(valueProcessor) + return this + } + + override fun updateLocal( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): RuntimeServiceVariableWriter { + variableFactory.on(runtimeService, executionId).updateLocal(valueProcessor, isTransient) + return this + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as RuntimeServiceVariableWriter + return if (runtimeService != that.runtimeService) false else executionId == that.executionId + } + + override fun hashCode(): Int { + var result = runtimeService.hashCode() + result = 31 * result + executionId.hashCode() + return result + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt new file mode 100644 index 00000000..e4f9c84f --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt @@ -0,0 +1,92 @@ +package io.holunda.camunda.bpm.data.writer + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.TaskService +import org.camunda.bpm.engine.variable.VariableMap +import java.util.function.Function + +/** + * User task builder allowing for fluent variable setting. + */ +class TaskServiceVariableWriter(private val taskService: TaskService, private val taskId: String) : + VariableWriter { + override fun variables(): VariableMap { + return taskService.getVariablesTyped(taskId) + } + + override fun variablesLocal(): VariableMap { + return taskService.getVariablesLocalTyped(taskId) + } + + override fun set(variableFactory: VariableFactory, value: T): TaskServiceVariableWriter { + return this.set(variableFactory, value, false) + } + + override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): TaskServiceVariableWriter { + variableFactory.on(taskService, taskId)[value] = isTransient + return this + } + + override fun setLocal(variableFactory: VariableFactory, value: T): TaskServiceVariableWriter { + return this.setLocal(variableFactory, value, false) + } + + override fun setLocal(variableFactory: VariableFactory, value: T, isTransient: Boolean): TaskServiceVariableWriter { + variableFactory.on(taskService, taskId).setLocal(value, isTransient) + return this + } + + override fun remove(variableFactory: VariableFactory): TaskServiceVariableWriter { + variableFactory.on(taskService, taskId).remove() + return this + } + + override fun removeLocal(variableFactory: VariableFactory): TaskServiceVariableWriter { + variableFactory.on(taskService, taskId).removeLocal() + return this + } + + override fun update(variableFactory: VariableFactory, valueProcessor: Function): TaskServiceVariableWriter { + variableFactory.on(taskService, taskId).update(valueProcessor) + return this + } + + override fun update( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): TaskServiceVariableWriter { + variableFactory.on(taskService, taskId).update(valueProcessor, isTransient) + return this + } + + override fun updateLocal( + variableFactory: VariableFactory, + valueProcessor: Function + ): TaskServiceVariableWriter { + variableFactory.on(taskService, taskId).updateLocal(valueProcessor) + return this + } + + override fun updateLocal( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): TaskServiceVariableWriter { + variableFactory.on(taskService, taskId).updateLocal(valueProcessor, isTransient) + return this + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as TaskServiceVariableWriter + return if (taskService != that.taskService) false else taskId == that.taskId + } + + override fun hashCode(): Int { + var result = taskService.hashCode() + result = 31 * result + taskId.hashCode() + return result + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableMapWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableMapWriter.kt new file mode 100644 index 00000000..8bcda408 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableMapWriter.kt @@ -0,0 +1,54 @@ +package io.holunda.camunda.bpm.data.writer + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.variable.VariableMap +import java.util.function.Function + +/** + * Variable map builder allowing for fluent variable setting. + * @param variables variables to work on. + */ +class VariableMapWriter(private val variables: VariableMap) : GlobalVariableWriter { + override fun set(variableFactory: VariableFactory, value: T): VariableMapWriter { + return this.set(variableFactory, value, false) + } + + override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): VariableMapWriter { + variableFactory.on(variables)[value] = isTransient + return this + } + + override fun remove(variableFactory: VariableFactory): VariableMapWriter { + variableFactory.on(variables).remove() + return this + } + + override fun update(variableFactory: VariableFactory, valueProcessor: Function): VariableMapWriter { + variableFactory.on(variables).update(valueProcessor) + return this + } + + override fun update( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): VariableMapWriter { + variableFactory.on(variables).update(valueProcessor, isTransient) + return this + } + + override fun variables(): VariableMap { + return variables + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as VariableMapWriter + return variables == that.variables + } + + override fun hashCode(): Int { + return variables.hashCode() + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.kt new file mode 100644 index 00000000..c89b625c --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.kt @@ -0,0 +1,87 @@ +package io.holunda.camunda.bpm.data.writer + +import io.holunda.camunda.bpm.data.factory.VariableFactory +import org.camunda.bpm.engine.delegate.VariableScope +import org.camunda.bpm.engine.variable.VariableMap +import java.util.function.Function + +/** + * Variable scope builder allowing for fluent variable setting. + * @param scope variables to work on. + */ +class VariableScopeWriter(private val scope: VariableScope) : VariableWriter { + override fun set(variableFactory: VariableFactory, value: T): VariableScopeWriter { + return this.set(variableFactory, value, false) + } + + override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): VariableScopeWriter { + variableFactory.on(scope)[value] = isTransient + return this + } + + override fun setLocal(variableFactory: VariableFactory, value: T): VariableScopeWriter { + return this.setLocal(variableFactory, value, false) + } + + override fun setLocal(variableFactory: VariableFactory, value: T, isTransient: Boolean): VariableScopeWriter { + variableFactory.on(scope).setLocal(value, isTransient) + return this + } + + override fun update(variableFactory: VariableFactory, valueProcessor: Function): VariableScopeWriter { + variableFactory.on(scope).update(valueProcessor) + return this + } + + override fun update( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): VariableScopeWriter { + variableFactory.on(scope).update(valueProcessor, isTransient) + return this + } + + override fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function): VariableScopeWriter { + variableFactory.on(scope).updateLocal(valueProcessor) + return this + } + + override fun updateLocal( + variableFactory: VariableFactory, + valueProcessor: Function, + isTransient: Boolean + ): VariableScopeWriter { + variableFactory.on(scope).updateLocal(valueProcessor, isTransient) + return this + } + + override fun remove(variableFactory: VariableFactory): VariableScopeWriter { + variableFactory.on(scope).remove() + return this + } + + override fun removeLocal(variableFactory: VariableFactory): VariableScopeWriter { + variableFactory.on(scope).removeLocal() + return this + } + + override fun variables(): VariableMap { + return scope.variablesTyped + } + + override fun variablesLocal(): VariableMap { + return scope.variablesLocalTyped + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as VariableScopeWriter + return scope == that.scope + } + + override fun hashCode(): Int { + return scope.hashCode() + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableWriter.kt new file mode 100644 index 00000000..03594247 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableWriter.kt @@ -0,0 +1,8 @@ +package io.holunda.camunda.bpm.data.writer + +/** + * Inverting calls to [io.holunda.camunda.bpm.data.adapter.WriteAdapter]. + * + * @param type of concrete Writer for fluent usage. + */ +interface VariableWriter> : LocalVariableWriter, GlobalVariableWriter diff --git a/extension/core/src/main/kotlin/packages.md b/extension/core/src/main/kotlin/packages.md index 74608963..f211de2a 100644 --- a/extension/core/src/main/kotlin/packages.md +++ b/extension/core/src/main/kotlin/packages.md @@ -2,9 +2,27 @@ Top-level package of the library. -check [io.holunda.camunda.bpm.data.io.holunda.camunda.bpm.data.CamundaBpmDataKotlin] as entry point for variable factory definition. +check [io.holunda.camunda.bpm.data.CamundaBpmData] as entry point for variable factory definition in Java. +check [io.holunda.camunda.bpm.data.CamundaBpmDataKotlin] as entry point for variable factory definition in Kotlin. @since 0.0.2 +# Package io.holunda.camunda.bpm.data.acl + +Package providing resources for building of Anti-Corruption-Layer (ACL). +@since 1.0.0 +@see [io.holunda.camunda.bpm.data.acl.CamundaBpmDataACL] for more details. + +# Package io.holunda.camunda.bpm.data.builder + +Writers are used to create multiple variables inside a variable map. +@see [io.holunda.camunda.bpm.data.CamundaBpmData#builder()] methods. +@since 0.0.5 + +# Package io.holunda.camunda.bpm.data.factory + +Process Variable Factories are used to define process variables. +@see io.holunda.camunda.bpm.data.factory.VariableFactory as the main starting point. +@since 0.0.2 # Package io.holunda.camunda.bpm.data.guard @@ -12,10 +30,14 @@ Package providing resources for building Variable Guards. @since 0.0.4 check [io.holunda.camunda.bpm.data.guard.CamundaBpmDataGuards] for more details. -# Package io.holunda.camunda.bpm.data.acl +# Package io.holunda.camunda.bpm.data.reader -Package providing resources for building of Anti-Corruption-Layer (ACL). +Readers are used to interact with multiple variables in the same context. @since 1.0.0 -@see [io.holunda.camunda.bpm.data.acl.CamundaBpmDataACL] for more details. +@see [io.holunda.camunda.bpm.data.CamundaBpmData#reader()] methods. +# Package io.holunda.camunda.bpm.data.writer +Writers are used to interact with multiple variables in the same context. +@since 0.0.5 +@see [io.holunda.camunda.bpm.data.CamundaBpmData#writer()] methods. diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt index 40129a8a..f9d1fad7 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt @@ -97,13 +97,43 @@ class FluentApiTest { val runtime: RuntimeService = mock() val task: TaskService = mock() - assertThat(case.writer("case-id")).isEqualTo(CaseServiceVariableWriter(case, "case-id")) - assertThat(runtime.writer("id")).isEqualTo(RuntimeServiceVariableWriter(runtime, "id")) - assertThat(task.writer("task-id")).isEqualTo(TaskServiceVariableWriter(task, "task-id")) - - assertThat(case.reader("case-id")).isEqualTo(CaseServiceVariableReader(case, "case-id")) - assertThat(runtime.reader("id")).isEqualTo(RuntimeServiceVariableReader(runtime, "id")) - assertThat(task.reader("task-id")).isEqualTo(TaskServiceVariableReader(task, "task-id")) + assertThat(case.writer("case-id")).isEqualTo( + CaseServiceVariableWriter( + case, + "case-id" + ) + ) + assertThat(runtime.writer("id")).isEqualTo( + RuntimeServiceVariableWriter( + runtime, + "id" + ) + ) + assertThat(task.writer("task-id")).isEqualTo( + TaskServiceVariableWriter( + task, + "task-id" + ) + ) + + assertThat(case.reader("case-id")).isEqualTo( + CaseServiceVariableReader( + case, + "case-id" + ) + ) + assertThat(runtime.reader("id")).isEqualTo( + RuntimeServiceVariableReader( + runtime, + "id" + ) + ) + assertThat(task.reader("task-id")).isEqualTo( + TaskServiceVariableReader( + task, + "task-id" + ) + ) } } diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt index 6f326899..7efa480d 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt @@ -1,6 +1,7 @@ package io.holunda.camunda.bpm.data.acl import io.holunda.camunda.bpm.data.CamundaBpmData +import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin import io.holunda.camunda.bpm.data.acl.transform.VariableMapTransformer import io.holunda.camunda.bpm.data.guard.VariablesGuard import io.holunda.camunda.bpm.data.guard.condition.* @@ -10,7 +11,6 @@ import org.camunda.bpm.engine.RuntimeService import org.camunda.bpm.engine.TaskService import org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration import org.camunda.bpm.engine.test.Deployment -import org.camunda.bpm.engine.test.ProcessEngineRule import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.task import org.camunda.bpm.engine.test.junit5.ProcessEngineExtension @@ -103,9 +103,9 @@ class TransientVariableMappingListenerTest { companion object { - private val FOO = CamundaBpmData.stringVariable("foo") - private val BAZ = CamundaBpmData.longVariable("baz") - private val BAZ_INTERNAL = CamundaBpmData.longVariable("baz__int") + private val FOO = CamundaBpmDataKotlin.stringVariable("foo") + private val BAZ = CamundaBpmDataKotlin.longVariable("baz") + private val BAZ_INTERNAL = CamundaBpmDataKotlin.longVariable("baz__int") private val ACL_LR = CamundaBpmDataMapper.identityReplace("transient", true) diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt index 82b0464f..53979f32 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt @@ -1,6 +1,8 @@ package io.holunda.camunda.bpm.data.acl -import io.holunda.camunda.bpm.data.CamundaBpmData.* +import io.holunda.camunda.bpm.data.CamundaBpmData.builder +import io.holunda.camunda.bpm.data.CamundaBpmData.customVariable +import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable import io.holunda.camunda.bpm.data.acl.transform.IdentityVariableMapTransformer import io.holunda.camunda.bpm.data.acl.transform.VariableMapTransformer import io.holunda.camunda.bpm.data.guard.CamundaBpmDataGuards.exists From 73740033ae53bc8fc5e51893a1ebac91c48ba97b Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 16 May 2023 11:50:42 +0200 Subject: [PATCH 45/67] migrated the extension to kotlin --- .../kotlin/itest/CamundaBpmDataITestBase.kt | 56 +-- .../kotlin/itest/VariableMapAdapterITest.kt | 32 +- .../adapter/AbstractReadWriteAdapter.java | 75 ---- .../adapter/CollectionTypedValueUtil.java | 106 ------ .../adapter/VariableNotFoundException.java | 16 - .../bpm/data/adapter/WriteAdapter.java | 96 ------ .../adapter/WrongVariableTypeException.java | 15 - .../basic/AbstractBasicReadWriteAdapter.java | 58 ---- .../basic/ReadAdapterLockedExternalTask.java | 63 ---- .../basic/ReadWriteAdapterCaseService.java | 60 ---- .../basic/ReadWriteAdapterRuntimeService.java | 60 ---- .../basic/ReadWriteAdapterTaskService.java | 60 ---- .../basic/ReadWriteAdapterVariableMap.java | 57 ---- .../basic/ReadWriteAdapterVariableScope.java | 58 ---- .../bpm/data/adapter/basic/package-info.java | 7 - .../list/AbstractListReadWriteAdapter.java | 66 ---- .../ListReadAdapterLockedExternalTask.java | 98 ------ .../list/ListReadWriteAdapterCaseService.java | 61 ---- .../ListReadWriteAdapterRuntimeService.java | 61 ---- .../list/ListReadWriteAdapterTaskService.java | 62 ---- .../list/ListReadWriteAdapterVariableMap.java | 59 ---- .../ListReadWriteAdapterVariableScope.java | 59 ---- .../bpm/data/adapter/list/package-info.java | 7 - .../map/AbstractMapReadWriteAdapter.java | 76 ----- .../map/MapReadAdapterLockedExternalTask.java | 104 ------ .../map/MapReadWriteAdapterCaseService.java | 64 ---- .../MapReadWriteAdapterRuntimeService.java | 64 ---- .../map/MapReadWriteAdapterTaskService.java | 65 ---- .../map/MapReadWriteAdapterVariableMap.java | 61 ---- .../map/MapReadWriteAdapterVariableScope.java | 61 ---- .../bpm/data/adapter/map/package-info.java | 7 - .../bpm/data/adapter/package-info.java | 8 - .../set/AbstractSetReadWriteAdapter.java | 66 ---- .../set/SetReadAdapterLockedExternalTask.java | 98 ------ .../set/SetReadWriteAdapterCaseService.java | 62 ---- .../SetReadWriteAdapterRuntimeService.java | 62 ---- .../set/SetReadWriteAdapterTaskService.java | 62 ---- .../set/SetReadWriteAdapterVariableMap.java | 59 ---- .../set/SetReadWriteAdapterVariableScope.java | 59 ---- .../bpm/data/adapter/set/package-info.java | 7 - .../camunda/bpm/data/CamundaBpmData.kt | 2 +- .../bpm/data/VariableFactoryFluentApi.kt | 8 +- .../data/adapter/AbstractReadWriteAdapter.kt | 53 +++ .../data/adapter/CollectionTypedValueUtil.kt | 102 ++++++ .../camunda/bpm/data/adapter/ReadAdapter.kt} | 38 +-- .../bpm/data/adapter/ValueWrapperUtil.kt | 4 +- .../data/adapter/VariableNotFoundException.kt | 7 + .../camunda/bpm/data/adapter/WriteAdapter.kt | 94 +++++ .../adapter/WrongVariableTypeException.kt | 7 + .../basic/AbstractBasicReadWriteAdapter.kt | 44 +++ .../basic/ReadAdapterLockedExternalTask.kt | 48 +++ .../basic/ReadWriteAdapterCaseService.kt | 45 +++ .../basic/ReadWriteAdapterRuntimeService.kt | 44 +++ .../basic/ReadWriteAdapterTaskService.kt | 44 +++ .../basic/ReadWriteAdapterVariableMap.kt | 40 +++ .../basic/ReadWriteAdapterVariableScope.kt | 42 +++ .../list/AbstractListReadWriteAdapter.kt | 45 +++ .../list/ListReadAdapterLockedExternalTask.kt | 74 ++++ .../list/ListReadWriteAdapterCaseService.kt | 57 ++++ .../ListReadWriteAdapterRuntimeService.kt | 57 ++++ .../list/ListReadWriteAdapterTaskService.kt | 45 +++ .../list/ListReadWriteAdapterVariableMap.kt | 44 +++ .../list/ListReadWriteAdapterVariableScope.kt | 43 +++ .../map/AbstractMapReadWriteAdapter.kt | 55 +++ .../map/MapReadAdapterLockedExternalTask.kt | 82 +++++ .../map/MapReadWriteAdapterCaseService.kt | 59 ++++ .../map/MapReadWriteAdapterRuntimeService.kt | 59 ++++ .../map/MapReadWriteAdapterTaskService.kt | 47 +++ .../map/MapReadWriteAdapterVariableMap.kt | 45 +++ .../map/MapReadWriteAdapterVariableScope.kt | 45 +++ .../set/AbstractSetReadWriteAdapter.kt | 44 +++ .../set/SetReadAdapterLockedExternalTask.kt | 76 +++++ .../set/SetReadWriteAdapterCaseService.kt | 56 +++ .../set/SetReadWriteAdapterRuntimeService.kt | 50 +++ .../set/SetReadWriteAdapterTaskService.kt | 44 +++ .../set/SetReadWriteAdapterVariableMap.kt | 42 +++ .../set/SetReadWriteAdapterVariableScope.kt | 42 +++ .../data/factory/BasicVariableFactory.java | 323 ------------------ .../bpm/data/factory/BasicVariableFactory.kt | 268 +++++++++++++++ .../bpm/data/factory/ListVariableFactory.java | 129 ------- .../bpm/data/factory/ListVariableFactory.kt | 124 +++++++ .../bpm/data/factory/MapVariableFactory.java | 151 -------- .../bpm/data/factory/MapVariableFactory.kt | 149 ++++++++ .../bpm/data/factory/SetVariableFactory.java | 129 ------- .../bpm/data/factory/SetVariableFactory.kt | 106 ++++++ ...ariableFactory.java => VariableFactory.kt} | 46 +-- .../guard/condition/VariableGuardCondition.kt | 8 +- .../data/reader/CaseServiceVariableReader.kt | 10 +- .../data/reader/LockedExternalTaskReader.kt | 6 +- .../reader/RuntimeServiceVariableReader.kt | 10 +- .../data/reader/TaskServiceVariableReader.kt | 10 +- .../bpm/data/reader/VariableMapReader.kt | 6 +- .../camunda/bpm/data/reader/VariableReader.kt | 6 +- .../bpm/data/reader/VariableScopeReader.kt | 6 +- .../data/writer/CaseServiceVariableWriter.kt | 5 +- .../writer/RuntimeServiceVariableWriter.kt | 5 +- .../data/writer/TaskServiceVariableWriter.kt | 5 +- extension/core/src/main/kotlin/packages.md | 35 ++ 98 files changed, 2490 insertions(+), 3057 deletions(-) delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/VariableNotFoundException.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/WriteAdapter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/WrongVariableTypeException.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/package-info.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/package-info.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/package-info.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/package-info.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.java delete mode 100644 extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/package-info.java create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.kt rename extension/core/src/main/{java/io/holunda/camunda/bpm/data/adapter/ReadAdapter.java => kotlin/io/holunda/camunda/bpm/data/adapter/ReadAdapter.kt} (64%) create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/VariableNotFoundException.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WriteAdapter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WrongVariableTypeException.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.kt create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.kt delete mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.kt delete mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.kt delete mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.kt delete mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java create mode 100644 extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.kt rename extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/{VariableFactory.java => VariableFactory.kt} (61%) diff --git a/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt b/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt index a67eb236..1f7d6061 100644 --- a/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt +++ b/example/itest/src/test/kotlin/itest/CamundaBpmDataITestBase.kt @@ -222,20 +222,20 @@ abstract class CamundaBpmDataITestBase : SpringScenarioTest - optionalVars[STRING_VAR.name] = STRING_VAR.from(delegateExecution).optional - optionalVars[DATE_VAR.name] = DATE_VAR.from(delegateExecution).optional - optionalVars[SHORT_VAR.name] = SHORT_VAR.from(delegateExecution).optional - optionalVars[INT_VAR.name] = INT_VAR.from(delegateExecution).optional - optionalVars[LONG_VAR.name] = LONG_VAR.from(delegateExecution).optional - optionalVars[DOUBLE_VAR.name] = DOUBLE_VAR.from(delegateExecution).optional - optionalVars[BOOLEAN_VAR.name] = BOOLEAN_VAR.from(delegateExecution).optional - optionalVars[COMPLEX_VAR.name] = COMPLEX_VAR.from(delegateExecution).optional - optionalVars[LIST_STRING_VAR.name] = LIST_STRING_VAR.from(delegateExecution).optional - optionalVars[SET_STRING_VAR.name] = SET_STRING_VAR.from(delegateExecution).optional - optionalVars[MAP_STRING_LONG_VAR.name] = MAP_STRING_LONG_VAR.from(delegateExecution).optional - optionalVars[COMPLEX_SET_VAR.name] = COMPLEX_SET_VAR.from(delegateExecution).optional - optionalVars[COMPLEX_LIST_VAR.name] = COMPLEX_LIST_VAR.from(delegateExecution).optional - optionalVars[COMPLEX_MAP_VAR.name] = COMPLEX_MAP_VAR.from(delegateExecution).optional + optionalVars[STRING_VAR.name] = STRING_VAR.from(delegateExecution).getOptional() + optionalVars[DATE_VAR.name] = DATE_VAR.from(delegateExecution).getOptional() + optionalVars[SHORT_VAR.name] = SHORT_VAR.from(delegateExecution).getOptional() + optionalVars[INT_VAR.name] = INT_VAR.from(delegateExecution).getOptional() + optionalVars[LONG_VAR.name] = LONG_VAR.from(delegateExecution).getOptional() + optionalVars[DOUBLE_VAR.name] = DOUBLE_VAR.from(delegateExecution).getOptional() + optionalVars[BOOLEAN_VAR.name] = BOOLEAN_VAR.from(delegateExecution).getOptional() + optionalVars[COMPLEX_VAR.name] = COMPLEX_VAR.from(delegateExecution).getOptional() + optionalVars[LIST_STRING_VAR.name] = LIST_STRING_VAR.from(delegateExecution).getOptional() + optionalVars[SET_STRING_VAR.name] = SET_STRING_VAR.from(delegateExecution).getOptional() + optionalVars[MAP_STRING_LONG_VAR.name] = MAP_STRING_LONG_VAR.from(delegateExecution).getOptional() + optionalVars[COMPLEX_SET_VAR.name] = COMPLEX_SET_VAR.from(delegateExecution).getOptional() + optionalVars[COMPLEX_LIST_VAR.name] = COMPLEX_LIST_VAR.from(delegateExecution).getOptional() + optionalVars[COMPLEX_MAP_VAR.name] = COMPLEX_MAP_VAR.from(delegateExecution).getOptional() } @Bean @@ -270,20 +270,20 @@ abstract class CamundaBpmDataITestBase : SpringScenarioTest> = listVariable(LIST_STRING_VAR.name, Date::class.java) assertThrows(WrongVariableTypeException::class.java) { - wrongListTargetType.from(variables).optional + wrongListTargetType.from(variables).getOptional() } } @@ -317,7 +317,7 @@ class VariableMapAdapterITest : CamundaBpmDataITestBase() { assertThrows(WrongVariableTypeException::class.java) { // not a set - wrongSetType.from(variables).optional + wrongSetType.from(variables).getOptional() } } @@ -341,7 +341,7 @@ class VariableMapAdapterITest : CamundaBpmDataITestBase() { assertThrows(WrongVariableTypeException::class.java) { // wrong type of the set - wrongSetTargetType.from(variables).optional + wrongSetTargetType.from(variables).getOptional() } } @@ -367,7 +367,7 @@ class VariableMapAdapterITest : CamundaBpmDataITestBase() { assertThrows(WrongVariableTypeException::class.java) { // not a map - wrongMapType.from(variables).optional + wrongMapType.from(variables).getOptional() } } @@ -390,7 +390,7 @@ class VariableMapAdapterITest : CamundaBpmDataITestBase() { val wrongMapKeyType: VariableFactory> = mapVariable(MAP_STRING_LONG_VAR.name, Date::class.java, String::class.java) assertThrows(WrongVariableTypeException::class.java) { // wrong key type - wrongMapKeyType.from(variables).optional + wrongMapKeyType.from(variables).getOptional() } } @@ -414,7 +414,7 @@ class VariableMapAdapterITest : CamundaBpmDataITestBase() { assertThrows(WrongVariableTypeException::class.java) { // wrong value type - wrongMapValueType.from(variables).optional + wrongMapValueType.from(variables).getOptional() } } } diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.java deleted file mode 100644 index dc99cf9c..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.java +++ /dev/null @@ -1,75 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter; - -import java.util.function.Function; - -/** - * Abstract read write adapter. - * - * @param variable type. - */ -public abstract class AbstractReadWriteAdapter implements ReadAdapter, WriteAdapter { - - /** - * Variable name. - */ - protected final String variableName; - - /** - * Constructs the adapter. - * - * @param variableName variable name, - */ - public AbstractReadWriteAdapter(String variableName) { - this.variableName = variableName; - } - - @Override - public void set(T value) { - set(value, false); - } - - @Override - public void setLocal(T value) { - setLocal(value, false); - } - - @Override - public T get() { - return getOptional().orElseThrow(() -> new VariableNotFoundException("Couldn't find required variable '" + variableName + "'")); - } - - @Override - public T getLocal() { - return getLocalOptional().orElseThrow(() -> new VariableNotFoundException("Couldn't find required local variable '" + variableName + "'")); - } - - @Override - public void update(Function valueProcessor, boolean isTransient) { - T oldValue = get(); - T newValue = valueProcessor.apply(oldValue); - if (!oldValue.equals(newValue)) { - // touch only if the value changes - set(newValue, isTransient); - } - } - - @Override - public void updateLocal(Function valueProcessor, boolean isTransient) { - T oldValue = getLocal(); - T newValue = valueProcessor.apply(oldValue); - if (!oldValue.equals(newValue)) { - // touch only if the value changes - setLocal(newValue, isTransient); - } - } - - @Override - public void update(Function valueProcessor) { - update(valueProcessor, false); - } - - @Override - public void updateLocal(Function valueProcessor) { - updateLocal(valueProcessor, false); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.java deleted file mode 100644 index 0e409b29..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.java +++ /dev/null @@ -1,106 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.CollectionType; -import com.fasterxml.jackson.databind.type.MapType; -import org.camunda.bpm.engine.variable.impl.value.ObjectValueImpl; -import org.camunda.bpm.engine.variable.value.ObjectValue; -import org.camunda.bpm.engine.variable.value.TypedValue; - -import java.util.Collection; -import java.util.Map; - -/** - * Helper class to read values from collections. - */ -public class CollectionTypedValueUtil { - - /** - * Avoid instantiations. - */ - private CollectionTypedValueUtil() { - - } - /** - * Tries to read a collection type from a typed value containing the serialized json. - * - * @param typedValue value from camunda. - * @param variableName name of the variable. - * @param memberClazz clazz of the collection member. - * @param objectMapper jackson object mapper. - * @param collectionType constructed collection type. - * @param type of collection member. - * @param type of collection. - * @return collection of specified type or null. - */ - public static > C readFromTypedValue( - TypedValue typedValue, String variableName, Class memberClazz, ObjectMapper objectMapper, CollectionType collectionType) { - if (typedValue == null) { - return null; - } - if (typedValue instanceof ObjectValueImpl) { - final ObjectValue objectValue = (ObjectValueImpl) typedValue; - final String json = objectValue.getValueSerialized(); - try { - final C values = objectMapper.readValue(json, collectionType); - if (values.isEmpty()) { - return values; - } else { - if (memberClazz.isAssignableFrom(values.iterator().next().getClass())) { - return values; - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Wrong member type detected, expected " + memberClazz.getName() + ", but was not found in " + values); - } - } - } catch (JsonProcessingException jpe) { - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value from " + json); - } - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value from " + typedValue); - } - } - - /** - * Tries to read a collection type from a typed value containing the serialized json. - * - * @param typedValue value from camunda. - * @param variableName name of the variable. - * @param keyClazz clazz of the map key. - * @param valueClazz clazz of the map value. - * @param objectMapper jackson object mapper. - * @param mapType constructed map type. - * @param type of map key. - * @param type of myp value. - * @return map of specified types or null. - */ - public static Map readFromTypedValue( - TypedValue typedValue, String variableName, Class keyClazz, Class valueClazz, - ObjectMapper objectMapper, MapType mapType) { - if (typedValue == null) { - return null; - } - if (typedValue instanceof ObjectValueImpl) { - final ObjectValue objectValue = (ObjectValueImpl) typedValue; - final String json = objectValue.getValueSerialized(); - try { - final Map map = objectMapper.readValue(json, mapType); - if (map.isEmpty()) { - return map; - } else { - final Map.Entry entry = map.entrySet().iterator().next(); - if (valueClazz.isAssignableFrom(entry.getValue().getClass()) && keyClazz.isAssignableFrom(entry.getKey().getClass())) { - return map; - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Wrong map type detected, expected key " - + keyClazz.getName() + " and value " + valueClazz.getName() + ", but was not found in " + map); - } - } - } catch (JsonProcessingException jpe) { - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value from " + json); - } - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value from " + typedValue); - } - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/VariableNotFoundException.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/VariableNotFoundException.java deleted file mode 100644 index 6e1c971e..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/VariableNotFoundException.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter; - -/** - * Exception indicating that a variable is not found. - */ -public class VariableNotFoundException extends RuntimeException { - /** - * Constructs the exception. - * - * @param reason reason. - */ - public VariableNotFoundException(String reason) { - super(reason); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/WriteAdapter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/WriteAdapter.java deleted file mode 100644 index 1b1de0e8..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/WriteAdapter.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter; - -import org.camunda.bpm.engine.variable.value.TypedValue; - -import java.util.function.Function; - -/** - * Write adapter to write values. - * - * @param type of values to write. - */ -public interface WriteAdapter { - - /** - * Writes a value. - * - * @param value value to write. - */ - void set(T value); - - /** - * Writes a value as a transient variable. - * - * @param value value to write. - * @param isTransient allows to specify if the variable is transient. - */ - void set(T value, boolean isTransient); - - /** - * Writes a local variable. - * - * @param value value to write. - */ - void setLocal(T value); - - /** - * Writes a local variable. - * - * @param value value to write. - * @param isTransient allows to specify if the variable is transient. - */ - void setLocal(T value, boolean isTransient); - - /** - * Removes a variable from the scope. - */ - void remove(); - - /** - * Removes a local variable from the scope. - */ - void removeLocal(); - - /** - * Updates a variable using provided value processor. - *
If the value is unchanged, the variable is not touched. - * - * @param valueProcessor function updating the value based on the old value. - */ - void update(Function valueProcessor); - - /** - * Updates a local variable using provided value processor. - *
If the value is unchanged, the variable is not touched. - * - * @param valueProcessor function updating the value based on the old value. - */ - void updateLocal(Function valueProcessor); - - /** - * Updates a variable using provided value processor. - *
If the value is unchanged, the variable is not touched. - * - * @param valueProcessor function updating the value based on the old value. - * @param isTransient transient flag. - */ - void update(Function valueProcessor, boolean isTransient); - - /** - * Updates a local variable using provided value processor. - *
If the value is unchanged, the variable is not touched. - * - * @param valueProcessor function updating the value based on the old value. - * @param isTransient transient flag. - */ - void updateLocal(Function valueProcessor, boolean isTransient); - - /** - * Constructs typed value. - * - * @param value raw value. - * @param isTransient transient flag. - * @return typed value. - */ - TypedValue getTypedValue(Object value, boolean isTransient); -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/WrongVariableTypeException.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/WrongVariableTypeException.java deleted file mode 100644 index ee2fa07f..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/WrongVariableTypeException.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter; - -/** - * Exception indicating that a variable has a different type than requested. - */ -public class WrongVariableTypeException extends RuntimeException { - /** - * Constructs the exception. - * - * @param reason reason. - */ - public WrongVariableTypeException(String reason) { - super(reason); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.java deleted file mode 100644 index 53c9a3d0..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.basic; - -import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter; -import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil; -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; -import org.camunda.bpm.engine.variable.value.TypedValue; - -import java.util.UUID; - -/** - * Base class for all basic read-write-adapter. - * - * @param variable type. - */ -public abstract class AbstractBasicReadWriteAdapter extends AbstractReadWriteAdapter { - /** - * Variable type. - */ - protected final Class clazz; - - /** - * Constructs the adapter. - * - * @param variableName name of the variable. - * @param clazz variable type. - */ - public AbstractBasicReadWriteAdapter(String variableName, Class clazz) { - super(variableName); - this.clazz = clazz; - } - - /** - * Retrieves the value or null. - * - * @param value raw value. - * @return value or null. - */ - @SuppressWarnings("unchecked") - protected T getOrNull(Object value) { - - if (value == null) { - return null; - } - - if (clazz == UUID.class && String.class.isAssignableFrom(value.getClass())) { - return (T) UUID.fromString((String) value); - } - if (clazz.isAssignableFrom(value.getClass()) || ValueWrapperUtil.isAssignableFrom(clazz, value.getClass())) { - return (T) value; - } - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value of " + clazz + " from " + value); - } - - @Override - public TypedValue getTypedValue(Object value, boolean isTransient) { - return ValueWrapperUtil.getTypedValue(clazz, value, isTransient); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.java deleted file mode 100644 index 1455864e..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.basic; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; - -import java.util.Optional; - -/** - * Read-write adapter for external task. - * - * @param type of value. - */ -@SuppressWarnings("java:S1192") -public class ReadAdapterLockedExternalTask implements ReadAdapter { - - private final ReadAdapter readAdapter; - - public ReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, String variableName, Class clazz) { - readAdapter = new ReadWriteAdapterVariableMap<>(lockedExternalTask.getVariables(), variableName, clazz); - } - - @Override - public T get() { - return readAdapter.get(); - } - - @Override - @SuppressWarnings("unchecked") - public Optional getOptional() { - return readAdapter.getOptional(); - } - - @Override - public T getLocal() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public Optional getLocalOptional() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public T getOrDefault(T defaultValue) { - return readAdapter.getOrDefault(defaultValue); - } - - @Override - public T getLocalOrDefault(T defaultValue) { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public T getOrNull() { - return readAdapter.getOrNull(); - } - - @Override - public T getLocalOrNull() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.java deleted file mode 100644 index 6132bf0e..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.basic; - -import org.camunda.bpm.engine.CaseService; - -import java.util.Optional; - -/** - * Read write adapter for case service access. - * - * @param type of value. - */ -public class ReadWriteAdapterCaseService extends AbstractBasicReadWriteAdapter { - - private final CaseService caseService; - private final String caseExecutionId; - - /** - * Constructs the adapter. - * - * @param caseService case service to use. - * @param caseExecutionId id of the execution to read from and write to. - * @param variableName name of the variable. - * @param clazz class of the variable. - */ - public ReadWriteAdapterCaseService(CaseService caseService, String caseExecutionId, String variableName, Class clazz) { - super(variableName, clazz); - this.caseService = caseService; - this.caseExecutionId = caseExecutionId; - } - - @Override - public Optional getOptional() { - return Optional.ofNullable(getOrNull(caseService.getVariable(caseExecutionId, variableName))); - } - - @Override - public void set(T value, boolean isTransient) { - caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional getLocalOptional() { - return Optional.ofNullable(getOrNull(caseService.getVariableLocal(caseExecutionId, variableName))); - } - - @Override - public void setLocal(T value, boolean isTransient) { - caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - caseService.removeVariable(caseExecutionId, variableName); - } - - @Override - public void removeLocal() { - caseService.removeVariableLocal(caseExecutionId, variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.java deleted file mode 100644 index 25a7683a..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.basic; - -import org.camunda.bpm.engine.RuntimeService; - -import java.util.Optional; - -/** - * Read write adapter for runtime service access. - * - * @param type of value. - */ -public class ReadWriteAdapterRuntimeService extends AbstractBasicReadWriteAdapter { - - private final RuntimeService runtimeService; - private final String executionId; - - /** - * Constructs the adapter. - * - * @param runtimeService runtime service to use. - * @param executionId id of the execution to read from and write to. - * @param variableName name of the variable. - * @param clazz class of the variable. - */ - public ReadWriteAdapterRuntimeService(RuntimeService runtimeService, String executionId, String variableName, Class clazz) { - super(variableName, clazz); - this.runtimeService = runtimeService; - this.executionId = executionId; - } - - @Override - public Optional getOptional() { - return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName))); - } - - @Override - public void set(T value, boolean isTransient) { - runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional getLocalOptional() { - return Optional.ofNullable(getOrNull(runtimeService.getVariableLocal(executionId, variableName))); - } - - @Override - public void setLocal(T value, boolean isTransient) { - runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - runtimeService.removeVariable(executionId, variableName); - } - - @Override - public void removeLocal() { - runtimeService.removeVariableLocal(executionId, variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.java deleted file mode 100644 index 6e1dabb8..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.basic; - -import org.camunda.bpm.engine.TaskService; - -import java.util.Optional; - -/** - * Read write adapter for task service access. - * - * @param type of value. - */ -public class ReadWriteAdapterTaskService extends AbstractBasicReadWriteAdapter { - - private final TaskService taskService; - private final String taskId; - - /** - * Constructs the adapter. - * - * @param taskService task service to use. - * @param taskId id of the task to read from and write to. - * @param variableName name of the variable. - * @param clazz class of the variable. - */ - public ReadWriteAdapterTaskService(TaskService taskService, String taskId, String variableName, Class clazz) { - super(variableName, clazz); - this.taskService = taskService; - this.taskId = taskId; - } - - @Override - public Optional getOptional() { - return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))); - } - - @Override - public void set(T value, boolean isTransient) { - taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional getLocalOptional() { - return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))); - } - - @Override - public void setLocal(T value, boolean isTransient) { - taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - taskService.removeVariable(taskId, variableName); - } - - @Override - public void removeLocal() { - taskService.removeVariableLocal(taskId, variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.java deleted file mode 100644 index f73a7e43..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.basic; - -import org.camunda.bpm.engine.variable.VariableMap; - -import java.util.Optional; - -/** - * Read-write adapter for variable map. - * - * @param type of value. - */ -public class ReadWriteAdapterVariableMap extends AbstractBasicReadWriteAdapter { - - private final VariableMap variableMap; - - /** - * Constructs the adapter. - * - * @param variableMap variable map to access. - * @param variableName variable to access. - * @param clazz class of variable value. - */ - public ReadWriteAdapterVariableMap(VariableMap variableMap, String variableName, Class clazz) { - super(variableName, clazz); - this.variableMap = variableMap; - } - - @Override - public Optional getOptional() { - return Optional.ofNullable(getOrNull(variableMap.get(variableName))); - } - - @Override - public void set(T value, boolean isTransient) { - variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional getLocalOptional() { - throw new UnsupportedOperationException("Can't get a local variable on a variable map"); - } - - @Override - public void setLocal(T value, boolean isTransient) { - throw new UnsupportedOperationException("Can't set a local variable on a variable map"); - } - - @Override - public void remove() { - variableMap.remove(variableName); - } - - @Override - public void removeLocal() { - throw new UnsupportedOperationException("Can't set a local variable on a variable map"); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.java deleted file mode 100644 index 70a15887..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.basic; - -import org.camunda.bpm.engine.delegate.VariableScope; - -import java.util.Optional; - -/** - * Read-write adapter for variable scope. - * - * @param type of value. - */ -public class ReadWriteAdapterVariableScope extends AbstractBasicReadWriteAdapter { - - private final VariableScope variableScope; - - /** - * Constructs the adapter. - * - * @param variableScope variable scope to access. - * @param variableName variable to access. - * @param clazz class of variable value. - */ - public ReadWriteAdapterVariableScope(VariableScope variableScope, String variableName, Class clazz) { - super(variableName, clazz); - this.variableScope = variableScope; - } - - @Override - public void set(T value, boolean isTransient) { - variableScope.setVariable(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional getLocalOptional() { - return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))); - } - - @Override - public void setLocal(T value, boolean isTransient) { - variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional getOptional() { - return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))); - } - - @Override - public void remove() { - variableScope.removeVariable(variableName); - } - - @Override - public void removeLocal() { - variableScope.removeVariableLocal(variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/package-info.java deleted file mode 100644 index 20cbb819..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/basic/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Read/Write adapters for basic variable factory. - * - * @see io.holunda.camunda.bpm.data.factory.BasicVariableFactory for more details - * @since 0.0.2 - */ -package io.holunda.camunda.bpm.data.adapter.basic; diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.java deleted file mode 100644 index dfb9b84e..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.java +++ /dev/null @@ -1,66 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.list; - -import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter; -import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil; -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; -import org.camunda.bpm.engine.variable.value.TypedValue; - -import java.util.Collections; -import java.util.List; - -/** - * Base class for all list read-write adapter. - * - * @param member type. - */ -public abstract class AbstractListReadWriteAdapter extends AbstractReadWriteAdapter> { - - /** - * Member class. - */ - protected final Class memberClazz; - - /** - * Constructs the adapter. - * - * @param variableName name of variable. - * @param memberClazz member class. - */ - public AbstractListReadWriteAdapter(String variableName, Class memberClazz) { - super(variableName); - this.memberClazz = memberClazz; - } - - /** - * Read the value of null. - * - * @param value raw value. - * @return list or null. - */ - @SuppressWarnings("unchecked") - protected List getOrNull(Object value) { - if (value == null) { - return null; - } - - if (List.class.isAssignableFrom(value.getClass())) { - List valueAsList = (List) value; - if (valueAsList.isEmpty()) { - return Collections.emptyList(); - } else { - if (memberClazz.isAssignableFrom(valueAsList.iterator().next().getClass())) { - return (List) valueAsList; - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.getName() + ", but was not found in " + valueAsList); - } - } - } - - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value of type List from " + value); - } - - @Override - public TypedValue getTypedValue(Object value, boolean isTransient) { - return ValueWrapperUtil.getTypedValue(List.class, value, isTransient); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.java deleted file mode 100644 index efee4f18..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.java +++ /dev/null @@ -1,98 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.list; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.variable.Variables; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Read adapter for external task. - * - * @param type of value. - */ -@SuppressWarnings("unchecked") -public class ListReadAdapterLockedExternalTask implements ReadAdapter> { - - private final LockedExternalTask lockedExternalTask; - private final String variableName; - private final Class memberClazz; - - public ListReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, String variableName, Class memberClazz) { - this.lockedExternalTask = lockedExternalTask; - this.variableName = variableName; - this.memberClazz = memberClazz; - } - - @Override - public List get() { - return getOptional().get(); - } - - @Override - @SuppressWarnings("java:S3655") - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(getValue())); - } - - @Override - public List getLocal() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public Optional> getLocalOptional() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public List getOrDefault(List defaultValue) { - return getOptional().orElse(defaultValue); - } - - @Override - public List getLocalOrDefault(List defaultValue) { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public List getOrNull() { - return getOrNull(getValue()); - } - - @Override - public List getLocalOrNull() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @SuppressWarnings("Duplicates") - private List getOrNull(T value) { - if (value == null) { - return null; - } - - if (List.class.isAssignableFrom(value.getClass())) { - List valueAsList = (List) value; - if (valueAsList.isEmpty()) { - return Collections.emptyList(); - } else { - if (memberClazz.isAssignableFrom(valueAsList.iterator().next().getClass())) { - return (List) valueAsList; - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.getName() + ", but was not found in " + valueAsList); - } - } - } - - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value of type List from " + value); - } - - private T getValue() { - return (T) Optional.ofNullable(lockedExternalTask.getVariables()) - .orElse(Variables.createVariables()) - .get(variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.java deleted file mode 100644 index 7b846597..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.list; - -import org.camunda.bpm.engine.CaseService; - -import java.util.List; -import java.util.Optional; - -/** - * Read write adapter for case service access. - * - * @param type of value. - */ -public class ListReadWriteAdapterCaseService extends AbstractListReadWriteAdapter { - - private final CaseService caseService; - private final String caseExecutionId; - - /** - * Constructs the adapter. - * - * @param caseService case service to use. - * @param caseExecutionId id of the execution to read from and write to. - * @param variableName name of the variable. - * @param memberClazz class of the variable. - */ - public ListReadWriteAdapterCaseService(CaseService caseService, String caseExecutionId, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.caseService = caseService; - this.caseExecutionId = caseExecutionId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(caseService.getVariable(caseExecutionId, variableName))); - } - - @Override - public void set(List value, boolean isTransient) { - caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(caseService.getVariableLocal(caseExecutionId, variableName))); - } - - @Override - public void setLocal(List value, boolean isTransient) { - caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - caseService.removeVariable(caseExecutionId, variableName); - } - - @Override - public void removeLocal() { - caseService.removeVariableLocal(caseExecutionId, variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.java deleted file mode 100644 index 11904fe1..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.list; - -import org.camunda.bpm.engine.RuntimeService; - -import java.util.List; -import java.util.Optional; - -/** - * Read write adapter for runtime service access. - * - * @param type of value. - */ -public class ListReadWriteAdapterRuntimeService extends AbstractListReadWriteAdapter { - - private final RuntimeService runtimeService; - private final String executionId; - - /** - * Constructs the adapter. - * - * @param runtimeService runtime service to use. - * @param executionId id of the execution to read from and write to. - * @param variableName name of the variable. - * @param memberClazz class of the variable. - */ - public ListReadWriteAdapterRuntimeService(RuntimeService runtimeService, String executionId, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.runtimeService = runtimeService; - this.executionId = executionId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName))); - } - - @Override - public void set(List value, boolean isTransient) { - runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(runtimeService.getVariableLocal(executionId, variableName))); - } - - @Override - public void setLocal(List value, boolean isTransient) { - runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - runtimeService.removeVariable(executionId, variableName); - } - - @Override - public void removeLocal() { - runtimeService.removeVariableLocal(executionId, variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.java deleted file mode 100644 index f6df765b..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.list; - -import org.camunda.bpm.engine.TaskService; - -import java.util.List; -import java.util.Optional; - -/** - * Read write adapter for task service access. - * - * @param type of value. - */ -public class ListReadWriteAdapterTaskService extends AbstractListReadWriteAdapter { - - private final TaskService taskService; - private final String taskId; - - /** - * Constructs the adapter. - * - * @param taskService task service to use. - * @param taskId id of the task to read from and write to. - * @param variableName name of the variable. - * @param memberClazz class of the variable. - */ - public ListReadWriteAdapterTaskService(TaskService taskService, String taskId, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.taskService = taskService; - this.taskId = taskId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))); - } - - @Override - public void set(List value, boolean isTransient) { - taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))); - } - - @Override - public void setLocal(List value, boolean isTransient) { - taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - taskService.removeVariable(taskId, variableName); - } - - @Override - public void removeLocal() { - taskService.removeVariableLocal(taskId, variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.java deleted file mode 100644 index 16e48a53..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.list; - -import org.camunda.bpm.engine.variable.VariableMap; - -import java.util.List; -import java.util.Optional; - -/** - * Read-write adapter for variable map. - * - * @param type of value. - */ -public class ListReadWriteAdapterVariableMap extends AbstractListReadWriteAdapter { - - private final VariableMap variableMap; - - /** - * Constructs the adapter. - * - * @param variableMap variable map to access. - * @param variableName variable to access. - * @param memberClazz class of variable value. - */ - public ListReadWriteAdapterVariableMap(VariableMap variableMap, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.variableMap = variableMap; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(variableMap.get(variableName))); - } - - @Override - public void set(List value, boolean isTransient) { - variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - throw new UnsupportedOperationException("Can't get a local variable on a variable map"); - } - - @Override - public void setLocal(List value, boolean isTransient) { - throw new UnsupportedOperationException("Can't set a local variable on a variable map"); - } - - @Override - public void remove() { - variableMap.remove(variableName); - } - - @Override - public void removeLocal() { - throw new UnsupportedOperationException("Can't set a local variable on a variable map"); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.java deleted file mode 100644 index 675e42ed..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.list; - -import org.camunda.bpm.engine.delegate.VariableScope; - -import java.util.List; -import java.util.Optional; - -/** - * Read-write adapter for variable scope. - * - * @param type of value. - */ -public class ListReadWriteAdapterVariableScope extends AbstractListReadWriteAdapter { - - private final VariableScope variableScope; - - /** - * Constructs the adapter. - * - * @param variableScope variable scope to access. - * @param variableName variable to access. - * @param memberClazz class of member variable value. - */ - public ListReadWriteAdapterVariableScope(VariableScope variableScope, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.variableScope = variableScope; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))); - } - - @Override - public void set(List value, boolean isTransient) { - variableScope.setVariable(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))); - } - - @Override - public void setLocal(List value, boolean isTransient) { - variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - variableScope.removeVariable(variableName); - } - - @Override - public void removeLocal() { - variableScope.removeVariableLocal(variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/package-info.java deleted file mode 100644 index 4a592c9e..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Read/Write adapters for list variable factory. - * - * @see io.holunda.camunda.bpm.data.factory.ListVariableFactory for more details - * @since 0.0.2 - */ -package io.holunda.camunda.bpm.data.adapter.list; diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.java deleted file mode 100644 index acc31b55..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.map; - -import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter; -import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil; -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; -import org.camunda.bpm.engine.variable.value.TypedValue; - -import java.util.Collections; -import java.util.Map; - -/** - * Base class for all map type read write adapter. - * - * @param key type. - * @param value type. - */ -public abstract class AbstractMapReadWriteAdapter extends AbstractReadWriteAdapter> { - - /** - * Key type. - */ - protected final Class keyClazz; - /** - * Value type. - */ - protected final Class valueClazz; - - /** - * Constructs adapter. - * - * @param variableName name of the variable. - * @param keyClazz key class. - * @param valueClazz value class. - */ - public AbstractMapReadWriteAdapter(String variableName, Class keyClazz, Class valueClazz) { - super(variableName); - this.keyClazz = keyClazz; - this.valueClazz = valueClazz; - } - - /** - * Retrieves the value or null. - * - * @param value raw value. - * @return set or null. - */ - @SuppressWarnings("unchecked") - protected Map getOrNull(Object value) { - if (value == null) { - return null; - } - - if (Map.class.isAssignableFrom(value.getClass())) { - Map valueAsMap = (Map) value; - if (valueAsMap.isEmpty()) { - return Collections.emptyMap(); - } else { - Map.Entry entry = valueAsMap.entrySet().iterator().next(); - if (keyClazz.isAssignableFrom(entry.getKey().getClass()) && valueClazz.isAssignableFrom(entry.getValue().getClass())) { - return (Map) valueAsMap; - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Wrong map type detected, expected Map<" - + keyClazz.getName() + "," + valueClazz.getName() - + ", but was not found in " + valueAsMap); - } - } - } - - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value of type Map from " + value); - } - - @Override - public TypedValue getTypedValue(Object value, boolean isTransient) { - return ValueWrapperUtil.getTypedValue(Map.class, value, isTransient); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.java deleted file mode 100644 index 8bca8fd3..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.java +++ /dev/null @@ -1,104 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.map; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.variable.Variables; - -import java.util.Collections; -import java.util.Map; -import java.util.Optional; - -/** - * Read adapter for external task - * - * @param type of key. - * @param type of value. - */ -@SuppressWarnings("unchecked") -public class MapReadAdapterLockedExternalTask implements ReadAdapter> { - - private final LockedExternalTask lockedExternalTask; - private final String variableName; - private Class keyClazz; - private Class valueClazz; - - public MapReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, String variableName, Class keyClazz, Class valueClazz) { - this.lockedExternalTask = lockedExternalTask; - this.variableName = variableName; - this.keyClazz = keyClazz; - this.valueClazz = valueClazz; - } - - @Override - public Map get() { - return getOptional().get(); - } - - @Override - @SuppressWarnings("java:S3655") - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(getValue())); - } - - @Override - public Map getLocal() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public Optional> getLocalOptional() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public Map getOrDefault(Map defaultValue) { - return getOptional().orElse(defaultValue); - } - - @Override - public Map getLocalOrDefault(Map defaultValue) { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public Map getOrNull() { - return getOrNull(getValue()); - } - - @Override - public Map getLocalOrNull() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @SuppressWarnings("Duplicates") - private Map getOrNull(Object value) { - if (value == null) { - return null; - } - - if (Map.class.isAssignableFrom(value.getClass())) { - Map valueAsMap = (Map) value; - if (valueAsMap.isEmpty()) { - return Collections.emptyMap(); - } else { - Map.Entry entry = valueAsMap.entrySet().iterator().next(); - if (keyClazz.isAssignableFrom(entry.getKey().getClass()) && valueClazz.isAssignableFrom(entry.getValue().getClass())) { - return (Map) valueAsMap; - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Wrong map type detected, expected Map<" - + keyClazz.getName() + "," + valueClazz.getName() - + ", but was not found in " + valueAsMap); - } - } - } - - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value of type Map from " + value); - } - - private Object getValue() { - return Optional.ofNullable(lockedExternalTask.getVariables()) - .orElse(Variables.createVariables()) - .get(variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.java deleted file mode 100644 index 72161449..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.java +++ /dev/null @@ -1,64 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.map; - -import org.camunda.bpm.engine.CaseService; - -import java.util.Map; -import java.util.Optional; - -/** - * Read write adapter for case service access. - * - * @param type of key. - * @param type of value. - */ -public class MapReadWriteAdapterCaseService extends AbstractMapReadWriteAdapter { - - private final CaseService caseService; - private final String caseExecutionId; - - /** - * Constructs the adapter. - * - * @param caseService case service to use. - * @param caseExecutionId id of the execution to read from and write to. - * @param variableName name of the variable. - * @param keyClazz class of the key variable. - * @param valueClazz class of the value variable. - */ - public MapReadWriteAdapterCaseService( - CaseService caseService, String caseExecutionId, String variableName, Class keyClazz, Class valueClazz) { - super(variableName, keyClazz, valueClazz); - this.caseService = caseService; - this.caseExecutionId = caseExecutionId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(caseService.getVariable(caseExecutionId, variableName))); - } - - @Override - public void set(Map value, boolean isTransient) { - caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(caseService.getVariableLocal(caseExecutionId, variableName))); - } - - @Override - public void setLocal(Map value, boolean isTransient) { - caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - caseService.removeVariable(caseExecutionId, variableName); - } - - @Override - public void removeLocal() { - caseService.removeVariableLocal(caseExecutionId, variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.java deleted file mode 100644 index 7806a46d..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.java +++ /dev/null @@ -1,64 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.map; - -import org.camunda.bpm.engine.RuntimeService; - -import java.util.Map; -import java.util.Optional; - -/** - * Read write adapter for runtime service access. - * - * @param type of key. - * @param type of value. - */ -public class MapReadWriteAdapterRuntimeService extends AbstractMapReadWriteAdapter { - - private final RuntimeService runtimeService; - private final String executionId; - - /** - * Constructs the adapter. - * - * @param runtimeService runtime service to use. - * @param executionId id of the execution to read from and write to. - * @param variableName name of the variable. - * @param keyClazz class of the key variable. - * @param valueClazz class of the value variable. - */ - public MapReadWriteAdapterRuntimeService( - RuntimeService runtimeService, String executionId, String variableName, Class keyClazz, Class valueClazz) { - super(variableName, keyClazz, valueClazz); - this.runtimeService = runtimeService; - this.executionId = executionId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName))); - } - - @Override - public void set(Map value, boolean isTransient) { - runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(runtimeService.getVariableLocal(executionId, variableName))); - } - - @Override - public void setLocal(Map value, boolean isTransient) { - runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - runtimeService.removeVariable(executionId, variableName); - } - - @Override - public void removeLocal() { - runtimeService.removeVariableLocal(executionId, variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.java deleted file mode 100644 index 5bee832b..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.java +++ /dev/null @@ -1,65 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.map; - -import org.camunda.bpm.engine.TaskService; - -import java.util.Map; -import java.util.Optional; - -/** - * Read write adapter for task service access. - * - * @param type of key. - * @param type of value. - */ -public class MapReadWriteAdapterTaskService extends AbstractMapReadWriteAdapter { - - private final TaskService taskService; - private final String taskId; - - /** - * Constructs the adapter. - * - * @param taskService task service to use. - * @param taskId id of the task to read from and write to. - * @param variableName name of the variable. - * @param keyClazz class of the key of variable. - * @param valueClazz class of variable. - */ - public MapReadWriteAdapterTaskService( - TaskService taskService, String taskId, String variableName, Class keyClazz, Class valueClazz) { - super(variableName, keyClazz, valueClazz); - this.taskService = taskService; - this.taskId = taskId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))); - } - - @Override - public void set(Map value, boolean isTransient) { - taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))); - } - - @Override - public void setLocal(Map value, boolean isTransient) { - taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - taskService.removeVariable(taskId, variableName); - } - - @Override - public void removeLocal() { - taskService.removeVariableLocal(taskId, variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.java deleted file mode 100644 index 13edf5b9..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.map; - -import org.camunda.bpm.engine.variable.VariableMap; - -import java.util.Map; -import java.util.Optional; - -/** - * Read-write adapter for variable map. - * - * @param type of key. - * @param type of value. - */ -public class MapReadWriteAdapterVariableMap extends AbstractMapReadWriteAdapter { - - private final VariableMap variableMap; - - /** - * Constructs the adapter. - * - * @param variableMap variable map to access. - * @param variableName variable to access. - * @param keyClazz class of variable key. - * @param valueClazz class of variable value. - */ - public MapReadWriteAdapterVariableMap(VariableMap variableMap, String variableName, Class keyClazz, Class valueClazz) { - super(variableName, keyClazz, valueClazz); - this.variableMap = variableMap; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(variableMap.get(variableName))); - } - - @Override - public void set(Map value, boolean isTransient) { - variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - throw new UnsupportedOperationException("Can't get a local variable on a variable map"); - } - - @Override - public void setLocal(Map value, boolean isTransient) { - throw new UnsupportedOperationException("Can't set a local variable on a variable map"); - } - - @Override - public void remove() { - variableMap.remove(variableName); - } - - @Override - public void removeLocal() { - throw new UnsupportedOperationException("Can't set a local variable on a variable map"); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.java deleted file mode 100644 index c369fc76..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.map; - -import org.camunda.bpm.engine.delegate.VariableScope; - -import java.util.Map; -import java.util.Optional; - -/** - * Read-write adapter for variable scope. - * - * @param type of key. - * @param type of value. - */ -public class MapReadWriteAdapterVariableScope extends AbstractMapReadWriteAdapter { - - private final VariableScope variableScope; - - /** - * Constructs the adapter. - * - * @param variableScope variable scope to access. - * @param variableName variable to access. - * @param keyClazz class of variable key. - * @param valueClazz class of variable value. - */ - public MapReadWriteAdapterVariableScope(VariableScope variableScope, String variableName, Class keyClazz, Class valueClazz) { - super(variableName, keyClazz, valueClazz); - this.variableScope = variableScope; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))); - } - - @Override - public void set(Map value, boolean isTransient) { - variableScope.setVariable(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))); - } - - @Override - public void setLocal(Map value, boolean isTransient) { - variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - variableScope.removeVariable(variableName); - } - - @Override - public void removeLocal() { - variableScope.removeVariableLocal(variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/package-info.java deleted file mode 100644 index 42bcc4e9..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Read/Write adapters for map variable factory. - * - * @see io.holunda.camunda.bpm.data.factory.MapVariableFactory for more details - * @since 0.0.2 - */ -package io.holunda.camunda.bpm.data.adapter.map; diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/package-info.java deleted file mode 100644 index f4a6bb30..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Read and Write adapters for different factories to handle different contexts. - * - * @see io.holunda.camunda.bpm.data.adapter.ReadAdapter - * @see io.holunda.camunda.bpm.data.adapter.WriteAdapter - * @since 0.0.2 - */ -package io.holunda.camunda.bpm.data.adapter; diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.java deleted file mode 100644 index 345d2f78..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.java +++ /dev/null @@ -1,66 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.set; - -import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter; -import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil; -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; -import org.camunda.bpm.engine.variable.value.TypedValue; - -import java.util.Collections; -import java.util.Set; - -/** - * Base class for all set type read write adapter. - * - * @param member type. - */ -public abstract class AbstractSetReadWriteAdapter extends AbstractReadWriteAdapter> { - - /** - * Member type. - */ - protected final Class memberClazz; - - /** - * Constructs adapter. - * - * @param variableName name of the variable. - * @param memberClazz member class. - */ - public AbstractSetReadWriteAdapter(String variableName, Class memberClazz) { - super(variableName); - this.memberClazz = memberClazz; - } - - /** - * Retrieves the value or null. - * - * @param value raw value. - * @return set or null. - */ - @SuppressWarnings("unchecked") - protected Set getOrNull(Object value) { - if (value == null) { - return null; - } - - if (Set.class.isAssignableFrom(value.getClass())) { - Set valueAsList = (Set) value; - if (valueAsList.isEmpty()) { - return Collections.emptySet(); - } else { - if (memberClazz.isAssignableFrom(valueAsList.iterator().next().getClass())) { - return (Set) valueAsList; - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Wrong set type detected, expected " + memberClazz.getName() + ", but was not found in " + valueAsList); - } - } - } - - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value of type Set from " + value); - } - - @Override - public TypedValue getTypedValue(Object value, boolean isTransient) { - return ValueWrapperUtil.getTypedValue(Set.class, value, isTransient); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.java deleted file mode 100644 index 574b9ae8..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.java +++ /dev/null @@ -1,98 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.set; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.variable.Variables; - -import java.util.Collections; -import java.util.Optional; -import java.util.Set; - -/** - * Read adapter for external task. - * - * @param type of value. - */ -@SuppressWarnings("unchecked") -public class SetReadAdapterLockedExternalTask implements ReadAdapter> { - - private final LockedExternalTask lockedExternalTask; - private final String variableName; - private final Class memberClazz; - - public SetReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, String variableName, Class memberClazz) { - this.lockedExternalTask = lockedExternalTask; - this.variableName = variableName; - this.memberClazz = memberClazz; - } - - @Override - public Set get() { - return getOptional().get(); - } - - @Override - @SuppressWarnings("java:S3655") - public Optional> getOptional() { - return Optional.ofNullable(getOrNull()); - } - - @Override - public Set getLocal() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public Optional> getLocalOptional() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public Set getOrDefault(Set defaultValue) { - return getOptional().orElse(defaultValue); - } - - @Override - public Set getLocalOrDefault(Set defaultValue) { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @Override - public Set getOrNull() { - return getOrNull(getValue()); - } - - @Override - public Set getLocalOrNull() { - throw new UnsupportedOperationException("Can't get a local variable on an external task"); - } - - @SuppressWarnings("Duplicates") - private Set getOrNull(T value) { - if (value == null) { - return null; - } - - if (Set.class.isAssignableFrom(value.getClass())) { - Set valueAsSet = (Set) value; - if (valueAsSet.isEmpty()) { - return Collections.emptySet(); - } else { - if (memberClazz.isAssignableFrom(valueAsSet.iterator().next().getClass())) { - return (Set) valueAsSet; - } else { - throw new WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.getName() + ", but was not found in " + valueAsSet); - } - } - } - - throw new WrongVariableTypeException("Error reading " + variableName + ": Couldn't read value of type List from " + value); - } - - private T getValue() { - return (T) Optional.ofNullable(lockedExternalTask.getVariables()) - .orElse(Variables.createVariables()) - .get(variableName); - } -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.java deleted file mode 100644 index df4c38b9..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.set; - -import org.camunda.bpm.engine.CaseService; - -import java.util.Optional; -import java.util.Set; - -/** - * Read write adapter for runtime service access. - * - * @param type of value. - */ -public class SetReadWriteAdapterCaseService extends AbstractSetReadWriteAdapter { - - private final CaseService caseService; - private final String caseExecutionId; - - /** - * Constructs the adapter. - * - * @param caseService case service to use. - * @param caseExecutionId id of the execution to read from and write to. - * @param variableName name of the variable. - * @param memberClazz class of the variable. - */ - public SetReadWriteAdapterCaseService(CaseService caseService, String caseExecutionId, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.caseService = caseService; - this.caseExecutionId = caseExecutionId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(caseService.getVariable(caseExecutionId, variableName))); - } - - @Override - public void set(Set value, boolean isTransient) { - caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(caseService.getVariableLocal(caseExecutionId, variableName))); - } - - @Override - public void setLocal(Set value, boolean isTransient) { - caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - caseService.removeVariable(caseExecutionId, variableName); - } - - @Override - public void removeLocal() { - caseService.removeVariableLocal(caseExecutionId, variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.java deleted file mode 100644 index 6b73061f..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.set; - -import org.camunda.bpm.engine.RuntimeService; - -import java.util.Optional; -import java.util.Set; - -/** - * Read write adapter for runtime service access. - * - * @param type of value. - */ -public class SetReadWriteAdapterRuntimeService extends AbstractSetReadWriteAdapter { - - private final RuntimeService runtimeService; - private final String executionId; - - /** - * Constructs the adapter. - * - * @param runtimeService runtime service to use. - * @param executionId id of the execution to read from and write to. - * @param variableName name of the variable. - * @param memberClazz class of the variable. - */ - public SetReadWriteAdapterRuntimeService(RuntimeService runtimeService, String executionId, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.runtimeService = runtimeService; - this.executionId = executionId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName))); - } - - @Override - public void set(Set value, boolean isTransient) { - runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(runtimeService.getVariableLocal(executionId, variableName))); - } - - @Override - public void setLocal(Set value, boolean isTransient) { - runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - runtimeService.removeVariable(executionId, variableName); - } - - @Override - public void removeLocal() { - runtimeService.removeVariableLocal(executionId, variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.java deleted file mode 100644 index 02620781..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.set; - -import org.camunda.bpm.engine.TaskService; - -import java.util.Optional; -import java.util.Set; - -/** - * Read write adapter for task service access. - * - * @param type of value. - */ -public class SetReadWriteAdapterTaskService extends AbstractSetReadWriteAdapter { - - private final TaskService taskService; - private final String taskId; - - /** - * Constructs the adapter. - * - * @param taskService task service to use. - * @param taskId id of the task to read from and write to. - * @param variableName name of the variable. - * @param memberClazz class of the variable. - */ - public SetReadWriteAdapterTaskService(TaskService taskService, String taskId, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.taskService = taskService; - this.taskId = taskId; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))); - } - - @Override - public void set(Set value, boolean isTransient) { - taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))); - } - - @Override - public void setLocal(Set value, boolean isTransient) { - taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - taskService.removeVariable(taskId, variableName); - } - - @Override - public void removeLocal() { - taskService.removeVariableLocal(taskId, variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.java deleted file mode 100644 index 47cd63b6..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.set; - -import org.camunda.bpm.engine.variable.VariableMap; - -import java.util.Optional; -import java.util.Set; - -/** - * Read-write adapter for variable map. - * - * @param type of value. - */ -public class SetReadWriteAdapterVariableMap extends AbstractSetReadWriteAdapter { - - private final VariableMap variableMap; - - /** - * Constructs the adapter. - * - * @param variableMap variable map to access. - * @param variableName variable to access. - * @param memberClazz class of variable value. - */ - public SetReadWriteAdapterVariableMap(VariableMap variableMap, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.variableMap = variableMap; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(variableMap.get(variableName))); - } - - @Override - public void set(Set value, boolean isTransient) { - variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - throw new UnsupportedOperationException("Can't get a local variable on a variable map"); - } - - @Override - public void setLocal(Set value, boolean isTransient) { - throw new UnsupportedOperationException("Can't set a local variable on a variable map"); - } - - @Override - public void remove() { - variableMap.remove(variableName); - } - - @Override - public void removeLocal() { - throw new UnsupportedOperationException("Can't set a local variable on a variable map"); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.java deleted file mode 100644 index 2d880221..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.holunda.camunda.bpm.data.adapter.set; - -import org.camunda.bpm.engine.delegate.VariableScope; - -import java.util.Optional; -import java.util.Set; - -/** - * Read-write adapter for variable scope. - * - * @param type of value. - */ -public class SetReadWriteAdapterVariableScope extends AbstractSetReadWriteAdapter { - - private final VariableScope variableScope; - - /** - * Constructs the adapter. - * - * @param variableScope variable scope to access. - * @param variableName variable to access. - * @param memberClazz class of member variable value. - */ - public SetReadWriteAdapterVariableScope(VariableScope variableScope, String variableName, Class memberClazz) { - super(variableName, memberClazz); - this.variableScope = variableScope; - } - - @Override - public Optional> getOptional() { - return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))); - } - - @Override - public void set(Set value, boolean isTransient) { - variableScope.setVariable(variableName, getTypedValue(value, isTransient)); - } - - @Override - public Optional> getLocalOptional() { - return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))); - } - - @Override - public void setLocal(Set value, boolean isTransient) { - variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)); - } - - @Override - public void remove() { - variableScope.removeVariable(variableName); - } - - @Override - public void removeLocal() { - variableScope.removeVariableLocal(variableName); - } - -} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/package-info.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/package-info.java deleted file mode 100644 index 86da78a3..00000000 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Read/Write adapters for set variable factory. - * - * @see io.holunda.camunda.bpm.data.factory.SetVariableFactory for more details - * @since 0.0.2 - */ -package io.holunda.camunda.bpm.data.adapter.set; diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmData.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmData.kt index 4e850fc1..935147d6 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmData.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/CamundaBpmData.kt @@ -122,7 +122,7 @@ object CamundaBpmData { * @return variable factory for given type. */ @JvmStatic - fun customVariable(variableName: String, clazz: Class): VariableFactory { + fun customVariable(variableName: String, clazz: Class): VariableFactory { return BasicVariableFactory(variableName, clazz) } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt index 03c6ad02..0a3d6848 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt @@ -18,7 +18,7 @@ import java.util.* * Getter from local scope. * @param factory factory defining the variable. */ -fun VariableMap.getOptional(factory: VariableFactory): Optional = factory.from(this).optional +fun VariableMap.getOptional(factory: VariableFactory): Optional = factory.from(this).getOptional() /** * Fluent setter. @@ -52,19 +52,19 @@ fun VariableMap.update(factory: VariableFactory, valueProcessor: (T) -> T * Getter from local scope. * @param factory factory defining the variable. */ -fun VariableScope.getOptional(factory: VariableFactory): Optional = factory.from(this).optional +fun VariableScope.getOptional(factory: VariableFactory): Optional = factory.from(this).getOptional() /** * Getter from local scope. * @param factory factory defining the variable. */ -fun VariableScope.getLocal(factory: VariableFactory): T = factory.from(this).local +fun VariableScope.getLocal(factory: VariableFactory): T = factory.from(this).getLocal() /** * Getter from local scope. * @param factory factory defining the variable. */ -fun VariableScope.getLocalOptional(factory: VariableFactory): Optional = factory.from(this).localOptional +fun VariableScope.getLocalOptional(factory: VariableFactory): Optional = factory.from(this).getLocalOptional() /** * Fluent setter. diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.kt new file mode 100644 index 00000000..3b9b1019 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.kt @@ -0,0 +1,53 @@ +package io.holunda.camunda.bpm.data.adapter + +import java.util.function.Function + +/** + * Abstract read write adapter. + * + * @param [T] variable type. + * @param variableName variable name, + */ +abstract class AbstractReadWriteAdapter(protected val variableName: String) : ReadAdapter, WriteAdapter { + override fun set(value: T) { + set(value, false) + } + + override fun setLocal(value: T) { + setLocal(value, false) + } + + override fun get(): T { + return getOptional().orElseThrow { VariableNotFoundException("Couldn't find required variable '$variableName'") } + } + + override fun getLocal(): T { + return getLocalOptional().orElseThrow { VariableNotFoundException("Couldn't find required local variable '$variableName'") } + } + + override fun update(valueProcessor: Function, isTransient: Boolean) { + val oldValue = get() + val newValue = valueProcessor.apply(oldValue) + if (oldValue != newValue) { + // touch only if the value changes + set(newValue, isTransient) + } + } + + override fun updateLocal(valueProcessor: Function, isTransient: Boolean) { + val oldValue = getLocal() + val newValue = valueProcessor.apply(oldValue) + if (oldValue != newValue) { + // touch only if the value changes + setLocal(newValue, isTransient) + } + } + + override fun update(valueProcessor: Function) { + update(valueProcessor, false) + } + + override fun updateLocal(valueProcessor: Function) { + updateLocal(valueProcessor, false) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.kt new file mode 100644 index 00000000..f25aa014 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.kt @@ -0,0 +1,102 @@ +package io.holunda.camunda.bpm.data.adapter + +import com.fasterxml.jackson.core.JsonProcessingException +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.type.CollectionType +import com.fasterxml.jackson.databind.type.MapType +import org.camunda.bpm.engine.variable.impl.value.ObjectValueImpl +import org.camunda.bpm.engine.variable.value.TypedValue + +/** + * Helper class to read values from collections. + */ +object CollectionTypedValueUtil { + /** + * Tries to read a collection type from a typed value containing the serialized json. + * + * @param typedValue value from camunda. + * @param variableName name of the variable. + * @param memberClazz clazz of the collection member. + * @param objectMapper jackson object mapper. + * @param collectionType constructed collection type. + * @param [T] type of collection member. + * @param [C] type of collection. + * @return collection of specified type or null. + */ + fun ?> readFromTypedValue( + typedValue: TypedValue?, + variableName: String, + memberClazz: Class, + objectMapper: ObjectMapper, + collectionType: CollectionType? + ): C? { + if (typedValue == null) { + return null + } + return if (typedValue is ObjectValueImpl) { + val json = typedValue.valueSerialized + try { + val values = objectMapper.readValue(json, collectionType) + if (values!!.isEmpty()) { + values + } else { + val value: T = values.iterator().next() + if (memberClazz.isAssignableFrom(value!!::class.java)) { + values + } else { + throw WrongVariableTypeException("Error reading " + variableName + ": Wrong member type detected, expected " + memberClazz.name + ", but was not found in " + values) + } + } + } catch (jpe: JsonProcessingException) { + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value from $json") + } + } else { + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value from $typedValue") + } + } + + /** + * Tries to read a collection type from a typed value containing the serialized json. + * + * @param typedValue value from camunda. + * @param variableName name of the variable. + * @param keyClazz clazz of the map key. + * @param valueClazz clazz of the map value. + * @param objectMapper jackson object mapper. + * @param mapType constructed map type. + * @param [K] type of map key. + * @param [V] type of myp value. + * @return map of specified types or null. + */ + fun readFromTypedValue( + typedValue: TypedValue?, variableName: String, keyClazz: Class, valueClazz: Class, + objectMapper: ObjectMapper, mapType: MapType? + ): Map? { + if (typedValue == null) { + return null + } + return if (typedValue is ObjectValueImpl) { + val json = typedValue.valueSerialized + try { + val map = objectMapper.readValue>(json, mapType) + if (map.isEmpty()) { + map + } else { + val (key, value) = map.entries.iterator().next() + if (valueClazz.isAssignableFrom(value!!::class.java) && keyClazz.isAssignableFrom(key!!::class.java)) { + map + } else { + throw WrongVariableTypeException( + "Error reading " + variableName + ": Wrong map type detected, expected key " + + keyClazz.name + " and value " + valueClazz.name + ", but was not found in " + map + ) + } + } + } catch (jpe: JsonProcessingException) { + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value from $json") + } + } else { + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value from $typedValue") + } + } +} diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/ReadAdapter.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/ReadAdapter.kt similarity index 64% rename from extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/ReadAdapter.java rename to extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/ReadAdapter.kt index 22aa9def..9bc66677 100644 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/ReadAdapter.java +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/ReadAdapter.kt @@ -1,28 +1,28 @@ -package io.holunda.camunda.bpm.data.adapter; +package io.holunda.camunda.bpm.data.adapter -import java.util.Optional; +import java.util.* /** * Adapter to read variables. * - * @param type of value. + * @param [T] type of value. */ -public interface ReadAdapter { - +interface ReadAdapter { /** * Reads a variable. * * @return value. * @exception VariableNotFoundException if the required variable is missing or can't be read. */ - T get(); + fun get(): T /** * Reads a variable and returns a value if exists or an empty. * * @return optional. */ - Optional getOptional(); + + fun getOptional(): Optional /** * Reads a local variable. @@ -30,14 +30,14 @@ public interface ReadAdapter { * @return value. * @exception VariableNotFoundException if the required variable is missing or can't be read. */ - T getLocal(); + fun getLocal(): T /** * Reads a local variable and returns a value if exists or an empty. * * @return optional. */ - Optional getLocalOptional(); + fun getLocalOptional(): Optional /** * Reads a variable and returns a value if exists or default. @@ -45,8 +45,8 @@ public interface ReadAdapter { * @param defaultValue the default value if the variable is not set * @return value or default */ - default T getOrDefault(T defaultValue) { - return getOptional().orElse(defaultValue); + fun getOrDefault(defaultValue: T): T { + return getOptional().orElse(defaultValue) } /** @@ -55,25 +55,25 @@ default T getOrDefault(T defaultValue) { * @param defaultValue the default value if the variable is not set * @return value or default */ - default T getLocalOrDefault(T defaultValue) { - return getLocalOptional().orElse(defaultValue); + fun getLocalOrDefault(defaultValue: T): T { + return getLocalOptional().orElse(defaultValue) } /** * Reads a variable and returns a value if exists or null. * - * @return value or null> + * @return value or `null` */ - default T getOrNull() { - return getOptional().orElse(null); + fun getOrNull(): T? { + return getOptional().orElse(null) } /** * Reads a local variable and returns a value if exists or null. * - * @return value or null> + * @return value or `null` */ - default T getLocalOrNull() { - return getLocalOptional().orElse(null); + fun getLocalOrNull(): T? { + return getLocalOptional().orElse(null) } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtil.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtil.kt index 5418e966..d1faddb0 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtil.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtil.kt @@ -17,10 +17,10 @@ object ValueWrapperUtil { * @param clazz class of value. * @param value value to encapsulate. * @param isTransient transient flag. - * @param type of value. + * @param [T] type of value. * @return typed value. * @throws IllegalArgumentException if value and clazz are incompatible. - */ + */ @JvmStatic fun getTypedValue(clazz: Class, value: Any?, isTransient: Boolean): TypedValue { require( diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/VariableNotFoundException.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/VariableNotFoundException.kt new file mode 100644 index 00000000..0d23b1e9 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/VariableNotFoundException.kt @@ -0,0 +1,7 @@ +package io.holunda.camunda.bpm.data.adapter + +/** + * Exception indicating that a variable is not found. + * @param reason reason. + */ +class VariableNotFoundException(reason: String?) : RuntimeException(reason) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WriteAdapter.kt new file mode 100644 index 00000000..0260f9a9 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WriteAdapter.kt @@ -0,0 +1,94 @@ +package io.holunda.camunda.bpm.data.adapter + +import org.camunda.bpm.engine.variable.value.TypedValue +import java.util.function.Function + +/** + * Write adapter to write values. + * + * @param [T] type of values to write. + */ +interface WriteAdapter { + /** + * Writes a value. + * + * @param value value to write. + */ + fun set(value: T) + + /** + * Writes a value as a transient variable. + * + * @param value value to write. + * @param isTransient allows to specify if the variable is transient. + */ + operator fun set(value: T, isTransient: Boolean) + + /** + * Writes a local variable. + * + * @param value value to write. + */ + fun setLocal(value: T) + + /** + * Writes a local variable. + * + * @param value value to write. + * @param isTransient allows to specify if the variable is transient. + */ + fun setLocal(value: T, isTransient: Boolean) + + /** + * Removes a variable from the scope. + */ + fun remove() + + /** + * Removes a local variable from the scope. + */ + fun removeLocal() + + /** + * Updates a variable using provided value processor. + * If the value is unchanged, the variable is not touched. + * + * @param valueProcessor function updating the value based on the old value. + */ + fun update(valueProcessor: Function) + + /** + * Updates a local variable using provided value processor. + * If the value is unchanged, the variable is not touched. + * + * @param valueProcessor function updating the value based on the old value. + */ + fun updateLocal(valueProcessor: Function) + + /** + * Updates a variable using provided value processor. + *

If the value is unchanged, the variable is not touched. + * + * @param valueProcessor function updating the value based on the old value. + * @param isTransient transient flag. + */ + fun update(valueProcessor: Function, isTransient: Boolean) + + /** + * Updates a local variable using provided value processor. + *

If the value is unchanged, the variable is not touched. + * + * @param valueProcessor function updating the value based on the old value. + * @param isTransient transient flag. + */ + fun updateLocal(valueProcessor: Function, isTransient: Boolean) + + /** + * Constructs typed value. + * + * @param value raw value. + * @param isTransient transient flag. + * @return typed value. + */ + fun getTypedValue(value: Any?, isTransient: Boolean): TypedValue +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WrongVariableTypeException.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WrongVariableTypeException.kt new file mode 100644 index 00000000..408ed9f1 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WrongVariableTypeException.kt @@ -0,0 +1,7 @@ +package io.holunda.camunda.bpm.data.adapter + +/** + * Exception indicating that a variable has a different type than requested. + * @param reason reason. + */ +class WrongVariableTypeException(reason: String?) : RuntimeException(reason) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.kt new file mode 100644 index 00000000..a070553d --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.kt @@ -0,0 +1,44 @@ +package io.holunda.camunda.bpm.data.adapter.basic + +import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter +import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil.getTypedValue +import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil.isAssignableFrom +import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException +import org.camunda.bpm.engine.variable.value.TypedValue +import java.util.* + +/** + * Base class for all basic read-write-adapter. + * + * @param [T] variable type. + * @param variableName name of the variable. + * @param clazz variable type. + */ +abstract class AbstractBasicReadWriteAdapter( + variableName: String, + protected val clazz: Class +) : AbstractReadWriteAdapter(variableName) { + /** + * Retrieves the value or null. + * + * @param value raw value. + * @return value or null. + */ + @Suppress("UNCHECKED_CAST") + protected fun getOrNull(value: Any?): T? { + if (value == null) { + return null + } + if (clazz == UUID::class.java && String::class.java.isAssignableFrom(value.javaClass)) { + return UUID.fromString(value as String?) as T + } + if (clazz.isAssignableFrom(value.javaClass) || isAssignableFrom(clazz, value.javaClass)) { + return value as T + } + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of $clazz from $value") + } + + override fun getTypedValue(value: Any?, isTransient: Boolean): TypedValue { + return getTypedValue(clazz, value, isTransient) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt new file mode 100644 index 00000000..cb45ccc5 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt @@ -0,0 +1,48 @@ +package io.holunda.camunda.bpm.data.adapter.basic + +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import java.util.* + +/** + * Read-write adapter for external task. + * + * @param [T] type of value. + */ +class ReadAdapterLockedExternalTask(lockedExternalTask: LockedExternalTask, variableName: String, clazz: Class) : + ReadAdapter +{ + private val readAdapter: ReadAdapter = ReadWriteAdapterVariableMap(lockedExternalTask.variables, variableName, clazz) + + override fun get(): T { + return readAdapter.get() + } + + override fun getOptional(): Optional { + return readAdapter.getOptional() + } + + override fun getLocal(): T { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getLocalOptional(): Optional { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getOrDefault(defaultValue: T): T { + return readAdapter.getOrDefault(defaultValue) + } + + override fun getLocalOrDefault(defaultValue: T): T { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getOrNull(): T? { + return readAdapter.getOrNull() + } + + override fun getLocalOrNull(): T { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.kt new file mode 100644 index 00000000..d3dc6c18 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.kt @@ -0,0 +1,45 @@ +package io.holunda.camunda.bpm.data.adapter.basic + +import org.camunda.bpm.engine.CaseService +import java.util.* + +/** + * Read write adapter for case service access. + * + * @param [T] type of value. + * @param caseService case service to use. + * @param caseExecutionId id of the execution to read from and write to. + * @param variableName name of the variable. + * @param clazz class of the variable. + */ +class ReadWriteAdapterCaseService( + private val caseService: CaseService, + private val caseExecutionId: String, + variableName: String, + clazz: Class +) : AbstractBasicReadWriteAdapter(variableName, clazz) { + + override fun getOptional(): Optional { + return Optional.ofNullable(getOrNull(caseService.getVariable(caseExecutionId, variableName))) + } + + override fun set(value: T, isTransient: Boolean) { + caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional { + return Optional.ofNullable(getOrNull(caseService.getVariableLocal(caseExecutionId, variableName))) + } + + override fun setLocal(value: T, isTransient: Boolean) { + caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + caseService.removeVariable(caseExecutionId, variableName) + } + + override fun removeLocal() { + caseService.removeVariableLocal(caseExecutionId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.kt new file mode 100644 index 00000000..5f17a126 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.kt @@ -0,0 +1,44 @@ +package io.holunda.camunda.bpm.data.adapter.basic + +import org.camunda.bpm.engine.RuntimeService +import java.util.* + +/** + * Read write adapter for runtime service access. + * + * @param [T] type of value. + * @param runtimeService runtime service to use. + * @param executionId id of the execution to read from and write to. + * @param variableName name of the variable. + * @param clazz class of the variable. + */ +class ReadWriteAdapterRuntimeService( + private val runtimeService: RuntimeService, + private val executionId: String, + variableName: String, + clazz: Class +) : AbstractBasicReadWriteAdapter(variableName, clazz) { + override fun getOptional(): Optional { + return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName))) + } + + override fun set(value: T, isTransient: Boolean) { + runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional { + return Optional.ofNullable(getOrNull(runtimeService.getVariableLocal(executionId, variableName))) + } + + override fun setLocal(value: T, isTransient: Boolean) { + runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + runtimeService.removeVariable(executionId, variableName) + } + + override fun removeLocal() { + runtimeService.removeVariableLocal(executionId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.kt new file mode 100644 index 00000000..3956a5d3 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.kt @@ -0,0 +1,44 @@ +package io.holunda.camunda.bpm.data.adapter.basic + +import org.camunda.bpm.engine.TaskService +import java.util.* + +/** + * Read write adapter for task service access. + * + * @param [T] type of value. + * @param taskService task service to use. + * @param taskId id of the task to read from and write to. + * @param variableName name of the variable. + * @param clazz class of the variable. + */ +class ReadWriteAdapterTaskService( + private val taskService: TaskService, + private val taskId: String, + variableName: String, + clazz: Class +) : AbstractBasicReadWriteAdapter(variableName, clazz) { + override fun getOptional(): Optional { + return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))) + } + + override fun set(value: T, isTransient: Boolean) { + taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional { + return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))) + } + + override fun setLocal(value: T, isTransient: Boolean) { + taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + taskService.removeVariable(taskId, variableName) + } + + override fun removeLocal() { + taskService.removeVariableLocal(taskId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.kt new file mode 100644 index 00000000..1de360b5 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.kt @@ -0,0 +1,40 @@ +package io.holunda.camunda.bpm.data.adapter.basic + +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Read-write adapter for variable map. + * + * @param [T] type of value. + * @param variableMap variable map to access. + * @param variableName variable to access. + * @param clazz class of variable value. + */ +class ReadWriteAdapterVariableMap(private val variableMap: VariableMap, variableName: String, clazz: Class) : + AbstractBasicReadWriteAdapter(variableName, clazz) { + + override fun getOptional(): Optional { + return Optional.ofNullable(getOrNull(variableMap[variableName])) + } + + override fun set(value: T, isTransient: Boolean) { + variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional { + throw UnsupportedOperationException("Can't get a local variable on a variable map") + } + + override fun setLocal(value: T, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a local variable on a variable map") + } + + override fun remove() { + variableMap.remove(variableName) + } + + override fun removeLocal() { + throw UnsupportedOperationException("Can't set a local variable on a variable map") + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.kt new file mode 100644 index 00000000..41ad85f7 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.kt @@ -0,0 +1,42 @@ +package io.holunda.camunda.bpm.data.adapter.basic + +import org.camunda.bpm.engine.delegate.VariableScope +import java.util.* + +/** + * Read-write adapter for variable scope. + * + * @param [T] type of value. + * @param variableScope variable scope to access. + * @param variableName variable to access. + * @param clazz class of variable value. + */ +class ReadWriteAdapterVariableScope( + private val variableScope: VariableScope, + variableName: String, + clazz: Class +) : AbstractBasicReadWriteAdapter(variableName, clazz) { + override fun set(value: T, isTransient: Boolean) { + variableScope.setVariable(variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional { + return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))) + } + + override fun setLocal(value: T, isTransient: Boolean) { + variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)) + } + + override fun getOptional(): Optional { + return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))) + } + + override fun remove() { + variableScope.removeVariable(variableName) + } + + override fun removeLocal() { + variableScope.removeVariableLocal(variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.kt new file mode 100644 index 00000000..5492b042 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.kt @@ -0,0 +1,45 @@ +package io.holunda.camunda.bpm.data.adapter.list + +import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter +import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil.getTypedValue +import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException +import org.camunda.bpm.engine.variable.value.TypedValue + +/** + * Base class for all list read-write adapter. + * + * @param [T] member type. + * @param variableName name of variable. + * @param memberClazz member class. + */ +abstract class AbstractListReadWriteAdapter(variableName: String, protected val memberClazz: Class) : + AbstractReadWriteAdapter>(variableName) { + /** + * Read the value of null. + * + * @param value raw value. + * @return list or null. + */ + protected fun getOrNull(value: Any?): List? { + if (value == null) { + return null + } + if (MutableList::class.java.isAssignableFrom(value.javaClass)) { + val valueAsList = value as List<*> + return if (valueAsList.isEmpty()) { + emptyList() + } else { + if (memberClazz.isAssignableFrom(valueAsList.iterator().next()!!.javaClass)) { + valueAsList as List + } else { + throw WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.name + ", but was not found in " + valueAsList) + } + } + } + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type List from $value") + } + + override fun getTypedValue(value: Any?, isTransient: Boolean): TypedValue { + return getTypedValue>(MutableList::class.java, value, isTransient) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt new file mode 100644 index 00000000..bd710428 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt @@ -0,0 +1,74 @@ +package io.holunda.camunda.bpm.data.adapter.list + +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.Variables +import java.util.* + +/** + * Read adapter for external task. + * + * @param [T] type of value. + */ +class ListReadAdapterLockedExternalTask( + private val lockedExternalTask: LockedExternalTask, + private val variableName: String, + private val memberClazz: Class +) : ReadAdapter> { + + override fun get(): List { + return getOptional().get() + } + + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(value)) + } + + override fun getLocal(): List { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getLocalOptional(): Optional> { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getOrDefault(defaultValue: List): List { + return getOptional().orElse(defaultValue) + } + + override fun getLocalOrDefault(defaultValue: List): List { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getOrNull(): List? { + return getOrNull(value) + } + + override fun getLocalOrNull(): List { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + private fun getOrNull(value: T?): List? { + if (value == null) { + return null + } + if (MutableList::class.java.isAssignableFrom(value.javaClass)) { + val valueAsList = value as List<*> + return if (valueAsList.isEmpty()) { + emptyList() + } else { + if (memberClazz.isAssignableFrom(valueAsList.iterator().next()!!.javaClass)) { + valueAsList as List + } else { + throw WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.name + ", but was not found in " + valueAsList) + } + } + } + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type List from $value") + } + + private val value: T? + get() = Optional.ofNullable(lockedExternalTask.variables) + .orElse(Variables.createVariables())[variableName] as T? +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.kt new file mode 100644 index 00000000..ae25bd67 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.kt @@ -0,0 +1,57 @@ +package io.holunda.camunda.bpm.data.adapter.list + +import org.camunda.bpm.engine.CaseService +import java.util.* + +/** + * Read write adapter for case service access. + * + * @param [T] type of value. + * @param caseService case service to use. + * @param caseExecutionId id of the execution to read from and write to. + * @param variableName name of the variable. + * @param memberClazz class of the variable. + */ +class ListReadWriteAdapterCaseService( + private val caseService: CaseService, + private val caseExecutionId: String, + variableName: String, + memberClazz: Class +) : AbstractListReadWriteAdapter(variableName, memberClazz) { + + override fun getOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + caseService.getVariable( + caseExecutionId, variableName + ) + ) + ) + } + + override fun set(value: List, isTransient: Boolean) { + caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + caseService.getVariableLocal( + caseExecutionId, variableName + ) + ) + ) + } + + override fun setLocal(value: List, isTransient: Boolean) { + caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + caseService.removeVariable(caseExecutionId, variableName) + } + + override fun removeLocal() { + caseService.removeVariableLocal(caseExecutionId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.kt new file mode 100644 index 00000000..40ff1d66 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.kt @@ -0,0 +1,57 @@ +package io.holunda.camunda.bpm.data.adapter.list + +import org.camunda.bpm.engine.RuntimeService +import java.util.* + +/** + * Read write adapter for runtime service access. + * + * @param [T] type of value. + * @param runtimeService runtime service to use. + * @param executionId id of the execution to read from and write to. + * @param variableName name of the variable. + * @param memberClazz class of the variable. + */ +class ListReadWriteAdapterRuntimeService( + private val runtimeService: RuntimeService, + private val executionId: String, + variableName: String, + memberClazz: Class +) : AbstractListReadWriteAdapter(variableName, memberClazz) { + + override fun getOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + runtimeService.getVariable( + executionId, variableName + ) + ) + ) + } + + override fun set(value: List, isTransient: Boolean) { + runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + runtimeService.getVariableLocal( + executionId, variableName + ) + ) + ) + } + + override fun setLocal(value: List, isTransient: Boolean) { + runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + runtimeService.removeVariable(executionId, variableName) + } + + override fun removeLocal() { + runtimeService.removeVariableLocal(executionId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.kt new file mode 100644 index 00000000..dc010e49 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.kt @@ -0,0 +1,45 @@ +package io.holunda.camunda.bpm.data.adapter.list + +import org.camunda.bpm.engine.TaskService +import java.util.* + +/** + * Read write adapter for task service access. + * + * @param [T] type of value. + * @param taskService task service to use. + * @param taskId id of the task to read from and write to. + * @param variableName name of the variable. + * @param memberClazz class of the variable. + */ +class ListReadWriteAdapterTaskService( + private val taskService: TaskService, + private val taskId: String, + variableName: String, + memberClazz: Class +) : AbstractListReadWriteAdapter(variableName, memberClazz) { + + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))) + } + + override fun set(value: List, isTransient: Boolean) { + taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))) + } + + override fun setLocal(value: List, isTransient: Boolean) { + taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + taskService.removeVariable(taskId, variableName) + } + + override fun removeLocal() { + taskService.removeVariableLocal(taskId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.kt new file mode 100644 index 00000000..4f78d152 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.kt @@ -0,0 +1,44 @@ +package io.holunda.camunda.bpm.data.adapter.list + +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Read-write adapter for variable map. + * + * @param type of value. + * @param variableMap variable map to access. + * @param variableName variable to access. + * @param memberClazz class of variable value. + */ +class ListReadWriteAdapterVariableMap( + private val variableMap: VariableMap, + variableName: String, + memberClazz: Class +) : AbstractListReadWriteAdapter( + variableName, memberClazz +) { + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableMap[variableName])) + } + + override fun set(value: List, isTransient: Boolean) { + variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + throw UnsupportedOperationException("Can't get a local variable on a variable map") + } + + override fun setLocal(value: List, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a local variable on a variable map") + } + + override fun remove() { + variableMap.remove(variableName) + } + + override fun removeLocal() { + throw UnsupportedOperationException("Can't set a local variable on a variable map") + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.kt new file mode 100644 index 00000000..ef6e5a25 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.kt @@ -0,0 +1,43 @@ +package io.holunda.camunda.bpm.data.adapter.list + +import org.camunda.bpm.engine.delegate.VariableScope +import java.util.* + +/** + * Read-write adapter for variable scope. + * + * @param [T] type of value. + * @param variableScope variable scope to access. + * @param variableName variable to access. + * @param memberClazz class of member variable value. + */ +class ListReadWriteAdapterVariableScope( + private val variableScope: VariableScope, + variableName: String, + memberClazz: Class +) : AbstractListReadWriteAdapter(variableName, memberClazz) { + + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))) + } + + override fun set(value: List, isTransient: Boolean) { + variableScope.setVariable(variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))) + } + + override fun setLocal(value: List, isTransient: Boolean) { + variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + variableScope.removeVariable(variableName) + } + + override fun removeLocal() { + variableScope.removeVariableLocal(variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.kt new file mode 100644 index 00000000..1d1f3b9e --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.kt @@ -0,0 +1,55 @@ +package io.holunda.camunda.bpm.data.adapter.map + +import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter +import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil.getTypedValue +import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException +import org.camunda.bpm.engine.variable.value.TypedValue + +/** + * Base class for all map type read write adapter. + * + * @param [K] key type. + * @param [V] value type. + * @param variableName name of the variable. + * @param keyClazz key class. + * @param valueClazz value class. + */ +abstract class AbstractMapReadWriteAdapter( + variableName: String, + protected val keyClazz: Class, + protected val valueClazz: Class +) : AbstractReadWriteAdapter>(variableName) { + /** + * Retrieves the value or null. + * + * @param value raw value. + * @return set or null. + */ + protected fun getOrNull(value: Any?): Map? { + if (value == null) { + return null + } + if (MutableMap::class.java.isAssignableFrom(value.javaClass)) { + val valueAsMap = value as Map<*, *> + return if (valueAsMap.isEmpty()) { + emptyMap() + } else { + val (key, value1) = valueAsMap.entries.iterator().next() + if (keyClazz.isAssignableFrom(key!!.javaClass) && valueClazz.isAssignableFrom(value1!!.javaClass)) { + valueAsMap as Map + } else { + throw WrongVariableTypeException( + "Error reading " + variableName + ": Wrong map type detected, expected Map<" + + keyClazz.name + "," + valueClazz.name + + ", but was not found in " + valueAsMap + ) + } + } + } + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type Map from $value") + } + + override fun getTypedValue(value: Any?, isTransient: Boolean): TypedValue { + return getTypedValue>(MutableMap::class.java, value, isTransient) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt new file mode 100644 index 00000000..cb512388 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt @@ -0,0 +1,82 @@ +package io.holunda.camunda.bpm.data.adapter.map + +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.Variables +import java.util.* + +/** + * Read adapter for external task + * + * @param type of key. + * @param type of value. + * @param lockedExternalTask external task. + * @param variableName name of the variable. + */ +class MapReadAdapterLockedExternalTask( + private val lockedExternalTask: LockedExternalTask, + private val variableName: String, + private val keyClazz: Class, + private val valueClazz: Class +) : ReadAdapter> { + override fun get(): Map { + return getOptional().get() + } + + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(value)) + } + + override fun getLocal(): Map { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getLocalOptional(): Optional> { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getOrDefault(defaultValue: Map): Map { + return getOptional().orElse(defaultValue) + } + + override fun getLocalOrDefault(defaultValue: Map): Map { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getOrNull(): Map? { + return getOrNull(value) + } + + override fun getLocalOrNull(): Map { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + private fun getOrNull(value: Any?): Map? { + if (value == null) { + return null + } + if (MutableMap::class.java.isAssignableFrom(value.javaClass)) { + val valueAsMap = value as Map<*, *> + return if (valueAsMap.isEmpty()) { + emptyMap() + } else { + val (key, value1) = valueAsMap.entries.iterator().next() + if (keyClazz.isAssignableFrom(key!!.javaClass) && valueClazz.isAssignableFrom(value1!!.javaClass)) { + valueAsMap as Map + } else { + throw WrongVariableTypeException( + "Error reading " + variableName + ": Wrong map type detected, expected Map<" + + keyClazz.name + "," + valueClazz.name + + ", but was not found in " + valueAsMap + ) + } + } + } + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type Map from $value") + } + + private val value: Any? + get() = Optional.ofNullable(lockedExternalTask.variables) + .orElse(Variables.createVariables())[variableName] +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.kt new file mode 100644 index 00000000..03835702 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.kt @@ -0,0 +1,59 @@ +package io.holunda.camunda.bpm.data.adapter.map + +import org.camunda.bpm.engine.CaseService +import java.util.* + +/** + * Read write adapter for case service access. + * + * @param [K] type of key. + * @param [V] type of value. + * @param caseService case service to use. + * @param caseExecutionId id of the execution to read from and write to. + * @param variableName name of the variable. + * @param keyClazz class of the key variable. + * @param valueClazz class of the value variable. + */ +class MapReadWriteAdapterCaseService( + private val caseService: CaseService, + private val caseExecutionId: String, + variableName: String, + keyClazz: Class, + valueClazz: Class +) : AbstractMapReadWriteAdapter(variableName, keyClazz, valueClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + caseService.getVariable( + caseExecutionId, variableName + ) + ) + ) + } + + override fun set(value: Map, isTransient: Boolean) { + caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + caseService.getVariableLocal( + caseExecutionId, variableName + ) + ) + ) + } + + override fun setLocal(value: Map, isTransient: Boolean) { + caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + caseService.removeVariable(caseExecutionId, variableName) + } + + override fun removeLocal() { + caseService.removeVariableLocal(caseExecutionId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.kt new file mode 100644 index 00000000..4864a0f5 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.kt @@ -0,0 +1,59 @@ +package io.holunda.camunda.bpm.data.adapter.map + +import org.camunda.bpm.engine.RuntimeService +import java.util.* + +/** + * Read write adapter for runtime service access. + * + * @param [K] type of key. + * @param [V] type of value. + * @param runtimeService runtime service to use. + * @param executionId id of the execution to read from and write to. + * @param variableName name of the variable. + * @param keyClazz class of the key variable. + * @param valueClazz class of the value variable. + */ +class MapReadWriteAdapterRuntimeService( + private val runtimeService: RuntimeService, + private val executionId: String, + variableName: String, + keyClazz: Class, + valueClazz: Class +) : AbstractMapReadWriteAdapter(variableName, keyClazz, valueClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + runtimeService.getVariable( + executionId, variableName + ) + ) + ) + } + + override fun set(value: Map, isTransient: Boolean) { + runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + runtimeService.getVariableLocal( + executionId, variableName + ) + ) + ) + } + + override fun setLocal(value: Map, isTransient: Boolean) { + runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + runtimeService.removeVariable(executionId, variableName) + } + + override fun removeLocal() { + runtimeService.removeVariableLocal(executionId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.kt new file mode 100644 index 00000000..748ae68b --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.kt @@ -0,0 +1,47 @@ +package io.holunda.camunda.bpm.data.adapter.map + +import org.camunda.bpm.engine.TaskService +import java.util.* + +/** + * Read write adapter for task service access. + * + * @param [K] type of key. + * @param [V] type of value. + * @param taskService task service to use. + * @param taskId id of the task to read from and write to. + * @param variableName name of the variable. + * @param keyClazz class of the key of variable. + * @param valueClazz class of variable. + */ +class MapReadWriteAdapterTaskService( + private val taskService: TaskService, + private val taskId: String, + variableName: String, + keyClazz: Class, + valueClazz: Class +) : AbstractMapReadWriteAdapter(variableName, keyClazz, valueClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))) + } + + override fun set(value: Map, isTransient: Boolean) { + taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))) + } + + override fun setLocal(value: Map, isTransient: Boolean) { + taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + taskService.removeVariable(taskId, variableName) + } + + override fun removeLocal() { + taskService.removeVariableLocal(taskId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.kt new file mode 100644 index 00000000..1fdb56cd --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.kt @@ -0,0 +1,45 @@ +package io.holunda.camunda.bpm.data.adapter.map + +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Read-write adapter for variable map. + * + * @param [K] type of key. + * @param [V] type of value. + * @param variableMap variable map to access. + * @param variableName variable to access. + * @param keyClazz class of variable key. + * @param valueClazz class of variable value. + */ +class MapReadWriteAdapterVariableMap( + private val variableMap: VariableMap, + variableName: String, + keyClazz: Class, + valueClazz: Class +) : AbstractMapReadWriteAdapter(variableName, keyClazz, valueClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableMap[variableName])) + } + + override fun set(value: Map, isTransient: Boolean) { + variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + throw UnsupportedOperationException("Can't get a local variable on a variable map") + } + + override fun setLocal(value: Map, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a local variable on a variable map") + } + + override fun remove() { + variableMap.remove(variableName) + } + + override fun removeLocal() { + throw UnsupportedOperationException("Can't set a local variable on a variable map") + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.kt new file mode 100644 index 00000000..0644e255 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.kt @@ -0,0 +1,45 @@ +package io.holunda.camunda.bpm.data.adapter.map + +import org.camunda.bpm.engine.delegate.VariableScope +import java.util.* + +/** + * Read-write adapter for variable scope. + * + * @param [K] type of key. + * @param [V] type of value. + * @param variableScope variable scope to access. + * @param variableName variable to access. + * @param keyClazz class of variable key. + * @param valueClazz class of variable value. + */ +class MapReadWriteAdapterVariableScope( + private val variableScope: VariableScope, + variableName: String, + keyClazz: Class, + valueClazz: Class +) : AbstractMapReadWriteAdapter(variableName, keyClazz, valueClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))) + } + + override fun set(value: Map, isTransient: Boolean) { + variableScope.setVariable(variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))) + } + + override fun setLocal(value: Map, isTransient: Boolean) { + variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + variableScope.removeVariable(variableName) + } + + override fun removeLocal() { + variableScope.removeVariableLocal(variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.kt new file mode 100644 index 00000000..29883218 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.kt @@ -0,0 +1,44 @@ +package io.holunda.camunda.bpm.data.adapter.set + +import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter +import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil.getTypedValue +import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException +import org.camunda.bpm.engine.variable.value.TypedValue + +/** + * Base class for all set type read write adapter. + * + * @param [T] member type. + * @param variableName name of the variable. + * @param memberClazz member class. + */ +abstract class AbstractSetReadWriteAdapter(variableName: String, protected val memberClazz: Class) : AbstractReadWriteAdapter>(variableName) { + /** + * Retrieves the value or null. + * + * @param value raw value. + * @return set or null. + */ + protected fun getOrNull(value: Any?): Set? { + if (value == null) { + return null + } + if (MutableSet::class.java.isAssignableFrom(value.javaClass)) { + val valueAsList = value as Set<*> + return if (valueAsList.isEmpty()) { + emptySet() + } else { + if (memberClazz.isAssignableFrom(valueAsList.iterator().next()!!.javaClass)) { + valueAsList as Set + } else { + throw WrongVariableTypeException("Error reading " + variableName + ": Wrong set type detected, expected " + memberClazz.name + ", but was not found in " + valueAsList) + } + } + } + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type Set from $value") + } + + override fun getTypedValue(value: Any?, isTransient: Boolean): TypedValue { + return getTypedValue>(MutableSet::class.java, value, isTransient) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt new file mode 100644 index 00000000..28c92707 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt @@ -0,0 +1,76 @@ +package io.holunda.camunda.bpm.data.adapter.set + +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.Variables +import java.util.* + +/** + * Read adapter for external task. + * + * @param [T] type of value. + * @param lockedExternalTask locked external client + * @param variableName name of the variable. + * @param memberClazz class of the variable. + */ +class SetReadAdapterLockedExternalTask( + private val lockedExternalTask: LockedExternalTask, + private val variableName: String, + private val memberClazz: Class +) : ReadAdapter> { + override fun get(): Set { + return getOptional().get() + } + + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull()) + } + + override fun getLocal(): Set { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getLocalOptional(): Optional> { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getOrDefault(defaultValue: Set): Set { + return getOptional().orElse(defaultValue) + } + + override fun getLocalOrDefault(defaultValue: Set): Set { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getOrNull(): Set? { + return getOrNull(value) + } + + override fun getLocalOrNull(): Set { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + private fun getOrNull(value: T?): Set? { + if (value == null) { + return null + } + if (MutableSet::class.java.isAssignableFrom(value.javaClass)) { + val valueAsSet = value as Set<*> + return if (valueAsSet.isEmpty()) { + emptySet() + } else { + if (memberClazz.isAssignableFrom(valueAsSet.iterator().next()!!.javaClass)) { + valueAsSet as Set + } else { + throw WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.name + ", but was not found in " + valueAsSet) + } + } + } + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type List from $value") + } + + private val value: T? + get() = Optional.ofNullable(lockedExternalTask.variables) + .orElse(Variables.createVariables())[variableName] as T? +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.kt new file mode 100644 index 00000000..58f90690 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.kt @@ -0,0 +1,56 @@ +package io.holunda.camunda.bpm.data.adapter.set + +import org.camunda.bpm.engine.CaseService +import java.util.* + +/** + * Read write adapter for runtime service access. + * + * @param [T] type of value. + * @param caseService case service to use. + * @param caseExecutionId id of the execution to read from and write to. + * @param variableName name of the variable. + * @param memberClazz class of the variable. + */ +class SetReadWriteAdapterCaseService( + private val caseService: CaseService, + private val caseExecutionId: String, + variableName: String, + memberClazz: Class +) : AbstractSetReadWriteAdapter(variableName, memberClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + caseService.getVariable( + caseExecutionId, variableName + ) + ) + ) + } + + override fun set(value: Set, isTransient: Boolean) { + caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + caseService.getVariableLocal( + caseExecutionId, variableName + ) + ) + ) + } + + override fun setLocal(value: Set, isTransient: Boolean) { + caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + caseService.removeVariable(caseExecutionId, variableName) + } + + override fun removeLocal() { + caseService.removeVariableLocal(caseExecutionId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.kt new file mode 100644 index 00000000..d19933b8 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.kt @@ -0,0 +1,50 @@ +package io.holunda.camunda.bpm.data.adapter.set + +import org.camunda.bpm.engine.RuntimeService +import java.util.* + +/** + * Read write adapter for runtime service access. + * + * @param [T] type of value. + * @param runtimeService runtime service to use. + * @param executionId id of the execution to read from and write to. + * @param variableName name of the variable. + * @param memberClazz class of the variable. + */ +class SetReadWriteAdapterRuntimeService( + private val runtimeService: RuntimeService, + private val executionId: String, + variableName: String, + memberClazz: Class +) : AbstractSetReadWriteAdapter(variableName, memberClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName))) + } + + override fun set(value: Set, isTransient: Boolean) { + runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + runtimeService.getVariableLocal( + executionId, variableName + ) + ) + ) + } + + override fun setLocal(value: Set, isTransient: Boolean) { + runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + runtimeService.removeVariable(executionId, variableName) + } + + override fun removeLocal() { + runtimeService.removeVariableLocal(executionId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.kt new file mode 100644 index 00000000..35ef79dd --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.kt @@ -0,0 +1,44 @@ +package io.holunda.camunda.bpm.data.adapter.set + +import org.camunda.bpm.engine.TaskService +import java.util.* + +/** + * Read write adapter for task service access. + * + * @param [T] type of value. + * @param taskService task service to use. + * @param taskId id of the task to read from and write to. + * @param variableName name of the variable. + * @param memberClazz class of the variable. + */ +class SetReadWriteAdapterTaskService( + private val taskService: TaskService, + private val taskId: String, + variableName: String, + memberClazz: Class +) : AbstractSetReadWriteAdapter(variableName, memberClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))) + } + + override fun set(value: Set, isTransient: Boolean) { + taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))) + } + + override fun setLocal(value: Set, isTransient: Boolean) { + taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + taskService.removeVariable(taskId, variableName) + } + + override fun removeLocal() { + taskService.removeVariableLocal(taskId, variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.kt new file mode 100644 index 00000000..01f533b8 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.kt @@ -0,0 +1,42 @@ +package io.holunda.camunda.bpm.data.adapter.set + +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Read-write adapter for variable map. + * + * @param [T] type of value. + * @param variableMap variable map to access. + * @param variableName variable to access. + * @param memberClazz class of variable value. + */ +class SetReadWriteAdapterVariableMap( + private val variableMap: VariableMap, + variableName: String, + memberClazz: Class +) : AbstractSetReadWriteAdapter(variableName, memberClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableMap[variableName])) + } + + override fun set(value: Set, isTransient: Boolean) { + variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + throw UnsupportedOperationException("Can't get a local variable on a variable map") + } + + override fun setLocal(value: Set, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a local variable on a variable map") + } + + override fun remove() { + variableMap.remove(variableName) + } + + override fun removeLocal() { + throw UnsupportedOperationException("Can't set a local variable on a variable map") + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.kt new file mode 100644 index 00000000..6887940c --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.kt @@ -0,0 +1,42 @@ +package io.holunda.camunda.bpm.data.adapter.set + +import org.camunda.bpm.engine.delegate.VariableScope +import java.util.* + +/** + * Read-write adapter for variable scope. + * + * @param [T] type of value. + * @param variableScope variable scope to access. + * @param variableName variable to access. + * @param memberClazz class of member variable value. + */ +class SetReadWriteAdapterVariableScope( + private val variableScope: VariableScope, + variableName: String, + memberClazz: Class +) : AbstractSetReadWriteAdapter(variableName, memberClazz) { + override fun getOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))) + } + + override fun set(value: Set, isTransient: Boolean) { + variableScope.setVariable(variableName, getTypedValue(value, isTransient)) + } + + override fun getLocalOptional(): Optional> { + return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))) + } + + override fun setLocal(value: Set, isTransient: Boolean) { + variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)) + } + + override fun remove() { + variableScope.removeVariable(variableName) + } + + override fun removeLocal() { + variableScope.removeVariableLocal(variableName) + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java deleted file mode 100644 index e5be4858..00000000 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.java +++ /dev/null @@ -1,323 +0,0 @@ -package io.holunda.camunda.bpm.data.factory; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.adapter.WriteAdapter; -import io.holunda.camunda.bpm.data.adapter.basic.ReadAdapterLockedExternalTask; -import io.holunda.camunda.bpm.data.adapter.basic.ReadWriteAdapterCaseService; -import io.holunda.camunda.bpm.data.adapter.basic.ReadWriteAdapterRuntimeService; -import io.holunda.camunda.bpm.data.adapter.basic.ReadWriteAdapterTaskService; -import io.holunda.camunda.bpm.data.adapter.basic.ReadWriteAdapterVariableMap; -import io.holunda.camunda.bpm.data.adapter.basic.ReadWriteAdapterVariableScope; -import org.camunda.bpm.engine.CaseService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.TaskService; -import org.camunda.bpm.engine.delegate.VariableScope; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; - -/** - * Variable factory of a base type(non parametrized). - * - * @param type of the factory. - */ -public class BasicVariableFactory implements VariableFactory { - - @NotNull - private final String name; - - @NotNull - private final Class clazz; - - /** - * Creates variable factory for a given type and name. - * - * @param name name of the variable. - * @param clazz class of the type. - */ - public BasicVariableFactory(@NotNull String name, @NotNull Class clazz) { - this.name = name; - this.clazz = clazz; - } - - @Override - public WriteAdapter on(VariableScope variableScope) { - return new ReadWriteAdapterVariableScope<>(variableScope, name, clazz); - } - - @Override - public ReadAdapter from(VariableScope variableScope) { - return new ReadWriteAdapterVariableScope<>(variableScope, name, clazz); - } - - @Override - public WriteAdapter on(VariableMap variableMap) { - return new ReadWriteAdapterVariableMap<>(variableMap, name, clazz); - } - - @Override - public ReadAdapter from(VariableMap variableMap) { - return new ReadWriteAdapterVariableMap<>(variableMap, name, clazz); - } - - @Override - public WriteAdapter on(RuntimeService runtimeService, String executionId) { - return new ReadWriteAdapterRuntimeService<>(runtimeService, executionId, name, clazz); - } - - @Override - public ReadAdapter from(RuntimeService runtimeService, String executionId) { - return new ReadWriteAdapterRuntimeService<>(runtimeService, executionId, name, clazz); - } - - @Override - public WriteAdapter on(TaskService taskService, String taskId) { - return new ReadWriteAdapterTaskService<>(taskService, taskId, name, clazz); - } - - @Override - public ReadAdapter from(TaskService taskService, String taskId) { - return new ReadWriteAdapterTaskService<>(taskService, taskId, name, clazz); - } - - @Override - public WriteAdapter on(CaseService caseService, String caseExecutionId) { - return new ReadWriteAdapterCaseService<>(caseService, caseExecutionId, name, clazz); - } - - @Override - public ReadAdapter from(CaseService caseService, String caseExecutionId) { - return new ReadWriteAdapterCaseService<>(caseService, caseExecutionId, name, clazz); - } - - @Override - public ReadAdapter from(LockedExternalTask lockedExternalTask) { - return new ReadAdapterLockedExternalTask<>(lockedExternalTask, name, clazz); - } - - /** - * Creates a reusable adapter builder using a runtime service. - * - * @param runtimeService runtime service to operate on. - * @return adapter builder. - */ - public BasicRuntimeServiceAdapterBuilder using(RuntimeService runtimeService) { - return new BasicRuntimeServiceAdapterBuilder<>(this, runtimeService); - } - - /** - * Creates a reusable adapter builder using a task service. - * - * @param taskService task service to operate on. - * @return adapter builder. - */ - public BasicTaskServiceAdapterBuilder using(TaskService taskService) { - return new BasicTaskServiceAdapterBuilder<>(this, taskService); - } - - /** - * Creates a reusable adapter builder using a case service. - * - * @param caseService case service to operate on. - * @return adapter builder. - */ - public BasicCaseServiceAdapterBuilder using(CaseService caseService) { - return new BasicCaseServiceAdapterBuilder<>(this, caseService); - } - - @Override - @NotNull - public String getName() { - return this.name; - } - - /** - * Retrieves the variable class. - * - * @return class of the variable. - */ - @NotNull - public Class getVariableClass() { - return clazz; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - BasicVariableFactory that = (BasicVariableFactory) o; - return name.equals(that.name) && - clazz.equals(that.clazz); - } - - @Override - public int hashCode() { - return Objects.hash(name, clazz); - } - - @Override - public String toString() { - return "BasicVariableFactory{" + - "name='" + name + '\'' + - ", clazz=" + clazz + - '}'; - } - - /** - * Creates a builder to encapsulate the runtime service access. - * - * @param type of builder. - */ - public static class BasicRuntimeServiceAdapterBuilder { - - private final RuntimeService runtimeService; - private final BasicVariableFactory basicVariableFactory; - - /** - * Constructs the builder. - * - * @param basicVariableFactory variable factory to use. - * @param runtimeService task service to build adapter with. - */ - public BasicRuntimeServiceAdapterBuilder(BasicVariableFactory basicVariableFactory, RuntimeService runtimeService) { - this.runtimeService = runtimeService; - this.basicVariableFactory = basicVariableFactory; - } - - private ReadWriteAdapterRuntimeService readWriteAdapter(String executionId) { - return new ReadWriteAdapterRuntimeService<>( - runtimeService, - executionId, - basicVariableFactory.getName(), - basicVariableFactory.getVariableClass() - ); - } - - /** - * Creates a write adapter on execution. - * - * @param executionId id identifying execution. - * @return write adapter - */ - public WriteAdapter on(String executionId) { - return readWriteAdapter(executionId); - } - - /** - * Creates a read adapter on execution. - * - * @param executionId id identifying execution. - * @return read adapter. - */ - public ReadAdapter from(String executionId) { - return readWriteAdapter(executionId); - } - } - - /** - * Creates a builder to encapsulate the task service access. - * - * @param type of builder. - */ - public static class BasicTaskServiceAdapterBuilder { - - private final TaskService taskService; - private final BasicVariableFactory basicVariableFactory; - - /** - * Constructs the builder. - * - * @param basicVariableFactory variable factory to use. - * @param taskService task service to build adapter with. - */ - public BasicTaskServiceAdapterBuilder(BasicVariableFactory basicVariableFactory, TaskService taskService) { - this.taskService = taskService; - this.basicVariableFactory = basicVariableFactory; - } - - private ReadWriteAdapterTaskService readWriteAdapter(String taskId) { - return new ReadWriteAdapterTaskService<>( - taskService, - taskId, - basicVariableFactory.getName(), - basicVariableFactory.getVariableClass() - ); - } - - /** - * Creates a write adapter on task. - * - * @param taskId id identifying task. - * @return write adapter - */ - public WriteAdapter on(String taskId) { - return readWriteAdapter(taskId); - } - - /** - * Creates a read adapter on task. - * - * @param taskId id identifying task. - * @return read adapter. - */ - public ReadAdapter from(String taskId) { - return readWriteAdapter(taskId); - } - } - - - /** - * Creates a builder to encapsulate the case service access. - * - * @param type of builder. - */ - public static class BasicCaseServiceAdapterBuilder { - - private final CaseService caseService; - private final BasicVariableFactory basicVariableFactory; - - /** - * Constructs the builder. - * - * @param basicVariableFactory variable factory to use. - * @param caseService task service to build adapter with. - */ - public BasicCaseServiceAdapterBuilder(BasicVariableFactory basicVariableFactory, CaseService caseService) { - this.caseService = caseService; - this.basicVariableFactory = basicVariableFactory; - } - - private ReadWriteAdapterCaseService readWriteAdapter(String caseExecutionId) { - return new ReadWriteAdapterCaseService<>( - caseService, - caseExecutionId, - basicVariableFactory.getName(), - basicVariableFactory.getVariableClass() - ); - } - - /** - * Creates a write adapter on caseExecution. - * - * @param caseExecutionId id identifying caseExecution. - * @return write adapter - */ - public WriteAdapter on(String caseExecutionId) { - return readWriteAdapter(caseExecutionId); - } - - /** - * Creates a read adapter on caseExecution. - * - * @param caseExecutionId id identifying caseExecution. - * @return read adapter. - */ - public ReadAdapter from(String caseExecutionId) { - return readWriteAdapter(caseExecutionId); - } - } -} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.kt new file mode 100644 index 00000000..36e3bba0 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/BasicVariableFactory.kt @@ -0,0 +1,268 @@ +package io.holunda.camunda.bpm.data.factory + +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import io.holunda.camunda.bpm.data.adapter.WriteAdapter +import io.holunda.camunda.bpm.data.adapter.basic.* +import org.camunda.bpm.engine.CaseService +import org.camunda.bpm.engine.RuntimeService +import org.camunda.bpm.engine.TaskService +import org.camunda.bpm.engine.delegate.VariableScope +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Variable factory of a base type(non parametrized). + * + * @param [T] type of the factory. + * @param name name of the variable. + * @param variableClass class of the type. + */ +class BasicVariableFactory( + override val name: String, + val variableClass: Class +) : VariableFactory { + + override fun on(variableScope: VariableScope): WriteAdapter { + return ReadWriteAdapterVariableScope(variableScope, name, variableClass) + } + + override fun from(variableScope: VariableScope): ReadAdapter { + return ReadWriteAdapterVariableScope(variableScope, name, variableClass) + } + + override fun on(variableMap: VariableMap): WriteAdapter { + return ReadWriteAdapterVariableMap(variableMap, name, variableClass) + } + + override fun from(variableMap: VariableMap): ReadAdapter { + return ReadWriteAdapterVariableMap(variableMap, name, variableClass) + } + + override fun on(runtimeService: RuntimeService, executionId: String): WriteAdapter { + return ReadWriteAdapterRuntimeService( + runtimeService, + executionId, + name, + variableClass + ) + } + + override fun from(runtimeService: RuntimeService, executionId: String): ReadAdapter { + return ReadWriteAdapterRuntimeService( + runtimeService, + executionId, + name, + variableClass + ) + } + + override fun on(taskService: TaskService, taskId: String): WriteAdapter { + return ReadWriteAdapterTaskService( + taskService, + taskId, + name, + variableClass + ) + } + + override fun from(taskService: TaskService, taskId: String): ReadAdapter { + return ReadWriteAdapterTaskService( + taskService, + taskId, + name, + variableClass + ) + } + + override fun on(caseService: CaseService, caseExecutionId: String): WriteAdapter { + return ReadWriteAdapterCaseService( + caseService, + caseExecutionId, + name, + variableClass + ) + } + + override fun from(caseService: CaseService, caseExecutionId: String): ReadAdapter { + return ReadWriteAdapterCaseService( + caseService, + caseExecutionId, + name, + variableClass + ) + } + + override fun from(lockedExternalTask: LockedExternalTask): ReadAdapter { + return ReadAdapterLockedExternalTask( + lockedExternalTask, + name, + variableClass + ) + } + + /** + * Creates a reusable adapter builder using a runtime service. + * + * @param runtimeService runtime service to operate on. + * @return adapter builder. + */ + fun using(runtimeService: RuntimeService): BasicRuntimeServiceAdapterBuilder { + return BasicRuntimeServiceAdapterBuilder(this, runtimeService) + } + + /** + * Creates a reusable adapter builder using a task service. + * + * @param taskService task service to operate on. + * @return adapter builder. + */ + fun using(taskService: TaskService): BasicTaskServiceAdapterBuilder { + return BasicTaskServiceAdapterBuilder(this, taskService) + } + + /** + * Creates a reusable adapter builder using a case service. + * + * @param caseService case service to operate on. + * @return adapter builder. + */ + fun using(caseService: CaseService): BasicCaseServiceAdapterBuilder { + return BasicCaseServiceAdapterBuilder(this, caseService) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as BasicVariableFactory<*> + return name == that.name && variableClass == that.variableClass + } + + override fun hashCode(): Int { + return Objects.hash(name, variableClass) + } + + override fun toString(): String { + return "BasicVariableFactory{" + + "name='" + name + '\'' + + ", clazz=" + variableClass + + '}' + } + + /** + * Creates a builder to encapsulate the runtime service access. + * + * @param [T] type of builder. + * @param basicVariableFactory variable factory to use. + * @param runtimeService task service to build adapter with. + */ + class BasicRuntimeServiceAdapterBuilder( + private val basicVariableFactory: BasicVariableFactory, + private val runtimeService: RuntimeService + ) { + private fun readWriteAdapter(executionId: String): ReadWriteAdapterRuntimeService { + return ReadWriteAdapterRuntimeService( + runtimeService, + executionId, + basicVariableFactory.name, + basicVariableFactory.variableClass + ) + } + + /** + * Creates a write adapter on execution. + * + * @param executionId id identifying execution. + * @return write adapter + */ + fun on(executionId: String): WriteAdapter { + return readWriteAdapter(executionId) + } + + /** + * Creates a read adapter on execution. + * + * @param executionId id identifying execution. + * @return read adapter. + */ + fun from(executionId: String): ReadAdapter { + return readWriteAdapter(executionId) + } + } + + /** + * Creates a builder to encapsulate the task service access. + * + * @param [T] type of builder. + * @param basicVariableFactory variable factory to use. + * @param taskService task service to build adapter with. + */ + class BasicTaskServiceAdapterBuilder(private val basicVariableFactory: BasicVariableFactory, private val taskService: TaskService) { + private fun readWriteAdapter(taskId: String): ReadWriteAdapterTaskService { + return ReadWriteAdapterTaskService( + taskService, + taskId, + basicVariableFactory.name, + basicVariableFactory.variableClass + ) + } + + /** + * Creates a write adapter on task. + * + * @param taskId id identifying task. + * @return write adapter + */ + fun on(taskId: String): WriteAdapter { + return readWriteAdapter(taskId) + } + + /** + * Creates a read adapter on task. + * + * @param taskId id identifying task. + * @return read adapter. + */ + fun from(taskId: String): ReadAdapter { + return readWriteAdapter(taskId) + } + } + + /** + * Creates a builder to encapsulate the case service access. + * + * @param [T] type of builder. + * @param basicVariableFactory variable factory to use. + * @param caseService task service to build adapter with. + */ + class BasicCaseServiceAdapterBuilder(private val basicVariableFactory: BasicVariableFactory, private val caseService: CaseService) { + private fun readWriteAdapter(caseExecutionId: String): ReadWriteAdapterCaseService { + return ReadWriteAdapterCaseService( + caseService, + caseExecutionId, + basicVariableFactory.name, + basicVariableFactory.variableClass + ) + } + + /** + * Creates a write adapter on caseExecution. + * + * @param caseExecutionId id identifying caseExecution. + * @return write adapter + */ + fun on(caseExecutionId: String): WriteAdapter { + return readWriteAdapter(caseExecutionId) + } + + /** + * Creates a read adapter on caseExecution. + * + * @param caseExecutionId id identifying caseExecution. + * @return read adapter. + */ + fun from(caseExecutionId: String): ReadAdapter { + return readWriteAdapter(caseExecutionId) + } + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java deleted file mode 100644 index acbc9bff..00000000 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.java +++ /dev/null @@ -1,129 +0,0 @@ -package io.holunda.camunda.bpm.data.factory; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.adapter.WriteAdapter; -import io.holunda.camunda.bpm.data.adapter.list.ListReadAdapterLockedExternalTask; -import io.holunda.camunda.bpm.data.adapter.list.ListReadWriteAdapterCaseService; -import io.holunda.camunda.bpm.data.adapter.list.ListReadWriteAdapterRuntimeService; -import io.holunda.camunda.bpm.data.adapter.list.ListReadWriteAdapterTaskService; -import io.holunda.camunda.bpm.data.adapter.list.ListReadWriteAdapterVariableMap; -import io.holunda.camunda.bpm.data.adapter.list.ListReadWriteAdapterVariableScope; -import org.camunda.bpm.engine.CaseService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.TaskService; -import org.camunda.bpm.engine.delegate.VariableScope; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Objects; - -/** - * Variable factory of a base parametrized list type. - * - * @param member type of the factory. - */ -public class ListVariableFactory implements VariableFactory> { - - @NotNull - private final String name; - - @NotNull - private final Class memberClazz; - - public ListVariableFactory(@NotNull String name, @NotNull Class memberClazz) { - this.name = name; - this.memberClazz = memberClazz; - } - - @Override - public WriteAdapter> on(VariableScope variableScope) { - return new ListReadWriteAdapterVariableScope<>(variableScope, name, memberClazz); - } - - @Override - public ReadAdapter> from(VariableScope variableScope) { - return new ListReadWriteAdapterVariableScope<>(variableScope, name, memberClazz); - } - - @Override - public WriteAdapter> on(VariableMap variableMap) { - return new ListReadWriteAdapterVariableMap<>(variableMap, name, memberClazz); - } - - @Override - public ReadAdapter> from(VariableMap variableMap) { - return new ListReadWriteAdapterVariableMap<>(variableMap, name, memberClazz); - } - - @Override - public WriteAdapter> on(RuntimeService runtimeService, String executionId) { - return new ListReadWriteAdapterRuntimeService<>(runtimeService, executionId, name, memberClazz); - } - - @Override - public ReadAdapter> from(RuntimeService runtimeService, String executionId) { - return new ListReadWriteAdapterRuntimeService<>(runtimeService, executionId, name, memberClazz); - } - - @Override - public WriteAdapter> on(TaskService taskService, String taskId) { - return new ListReadWriteAdapterTaskService<>(taskService, taskId, name, memberClazz); - } - - @Override - public ReadAdapter> from(TaskService taskService, String taskId) { - return new ListReadWriteAdapterTaskService<>(taskService, taskId, name, memberClazz); - } - - @Override - public WriteAdapter> on(CaseService caseService, String caseExecutionId) { - return new ListReadWriteAdapterCaseService<>(caseService, caseExecutionId, name, memberClazz); - } - - @Override - public ReadAdapter> from(CaseService caseService, String caseExecutionId) { - return new ListReadWriteAdapterCaseService<>(caseService, caseExecutionId, name, memberClazz); - } - - @Override - public ReadAdapter> from(LockedExternalTask lockedExternalTask) { - return new ListReadAdapterLockedExternalTask<>(lockedExternalTask, name, memberClazz); - } - - @Override - @NotNull - public String getName() { - return name; - } - - @NotNull - public Class getMemberClass() { - return memberClazz; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ListVariableFactory that = (ListVariableFactory) o; - return name.equals(that.name) && - memberClazz.equals(that.memberClazz); - } - - @Override - public int hashCode() { - return Objects.hash(name, memberClazz); - } - - @Override - public String toString() { - return "ListVariableFactory{" + - "name='" + name + '\'' + - ", memberClazz=" + memberClazz + - '}'; - } -} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.kt new file mode 100644 index 00000000..9837354e --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/ListVariableFactory.kt @@ -0,0 +1,124 @@ +package io.holunda.camunda.bpm.data.factory + +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import io.holunda.camunda.bpm.data.adapter.WriteAdapter +import io.holunda.camunda.bpm.data.adapter.list.* +import org.camunda.bpm.engine.CaseService +import org.camunda.bpm.engine.RuntimeService +import org.camunda.bpm.engine.TaskService +import org.camunda.bpm.engine.delegate.VariableScope +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Variable factory of a base parametrized list type. + * + * @param [T] member type of the factory. + */ +class ListVariableFactory(override val name: String, val memberClass: Class) : VariableFactory> { + + override fun on(variableScope: VariableScope): WriteAdapter> { + return ListReadWriteAdapterVariableScope( + variableScope, + name, + memberClass + ) + } + + override fun from(variableScope: VariableScope): ReadAdapter> { + return ListReadWriteAdapterVariableScope( + variableScope, + name, + memberClass + ) + } + + override fun on(variableMap: VariableMap): WriteAdapter> { + return ListReadWriteAdapterVariableMap(variableMap, name, memberClass) + } + + override fun from(variableMap: VariableMap): ReadAdapter> { + return ListReadWriteAdapterVariableMap(variableMap, name, memberClass) + } + + override fun on(runtimeService: RuntimeService, executionId: String): WriteAdapter> { + return ListReadWriteAdapterRuntimeService( + runtimeService, + executionId, + name, + memberClass + ) + } + + override fun from(runtimeService: RuntimeService, executionId: String): ReadAdapter> { + return ListReadWriteAdapterRuntimeService( + runtimeService, + executionId, + name, + memberClass + ) + } + + override fun on(taskService: TaskService, taskId: String): WriteAdapter> { + return ListReadWriteAdapterTaskService( + taskService, + taskId, + name, + memberClass + ) + } + + override fun from(taskService: TaskService, taskId: String): ReadAdapter> { + return ListReadWriteAdapterTaskService( + taskService, + taskId, + name, + memberClass + ) + } + + override fun on(caseService: CaseService, caseExecutionId: String): WriteAdapter> { + return ListReadWriteAdapterCaseService( + caseService, + caseExecutionId, + name, + memberClass + ) + } + + override fun from(caseService: CaseService, caseExecutionId: String): ReadAdapter> { + return ListReadWriteAdapterCaseService( + caseService, + caseExecutionId, + name, + memberClass + ) + } + + override fun from(lockedExternalTask: LockedExternalTask): ReadAdapter> { + return ListReadAdapterLockedExternalTask( + lockedExternalTask, + name, + memberClass + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as ListVariableFactory<*> + return name == that.name && memberClass == that.memberClass + } + + override fun hashCode(): Int { + return Objects.hash(name, memberClass) + } + + override fun toString(): String { + return "ListVariableFactory{" + + "name='" + name + '\'' + + ", memberClazz=" + memberClass + + '}' + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java deleted file mode 100644 index 64d0bda4..00000000 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.java +++ /dev/null @@ -1,151 +0,0 @@ -package io.holunda.camunda.bpm.data.factory; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.adapter.WriteAdapter; -import io.holunda.camunda.bpm.data.adapter.map.MapReadAdapterLockedExternalTask; -import io.holunda.camunda.bpm.data.adapter.map.MapReadWriteAdapterCaseService; -import io.holunda.camunda.bpm.data.adapter.map.MapReadWriteAdapterRuntimeService; -import io.holunda.camunda.bpm.data.adapter.map.MapReadWriteAdapterTaskService; -import io.holunda.camunda.bpm.data.adapter.map.MapReadWriteAdapterVariableMap; -import io.holunda.camunda.bpm.data.adapter.map.MapReadWriteAdapterVariableScope; -import org.camunda.bpm.engine.CaseService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.TaskService; -import org.camunda.bpm.engine.delegate.VariableScope; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Map; -import java.util.Objects; - -/** - * Variable factory of a base parametrized map type. - * - * @param member key type of the factory. - * @param member value type of the factory. - */ -public class MapVariableFactory implements VariableFactory> { - - @NotNull - private final String name; - - @NotNull - private final Class keyClazz; - - @NotNull - private final Class valueClazz; - - public MapVariableFactory(@NotNull String name, @NotNull Class keyClazz, @NotNull Class valueClazz) { - this.name = name; - this.keyClazz = keyClazz; - this.valueClazz = valueClazz; - } - - @Override - public WriteAdapter> on(VariableScope variableScope) { - return new MapReadWriteAdapterVariableScope<>(variableScope, name, keyClazz, valueClazz); - } - - @Override - public ReadAdapter> from(VariableScope variableScope) { - return new MapReadWriteAdapterVariableScope<>(variableScope, name, keyClazz, valueClazz); - } - - @Override - public WriteAdapter> on(VariableMap variableMap) { - return new MapReadWriteAdapterVariableMap<>(variableMap, name, keyClazz, valueClazz); - } - - @Override - public ReadAdapter> from(VariableMap variableMap) { - return new MapReadWriteAdapterVariableMap<>(variableMap, name, keyClazz, valueClazz); - } - - @Override - public WriteAdapter> on(RuntimeService runtimeService, String executionId) { - return new MapReadWriteAdapterRuntimeService<>(runtimeService, executionId, name, keyClazz, valueClazz); - } - - @Override - public ReadAdapter> from(RuntimeService runtimeService, String executionId) { - return new MapReadWriteAdapterRuntimeService<>(runtimeService, executionId, name, keyClazz, valueClazz); - } - - @Override - public WriteAdapter> on(TaskService taskService, String taskId) { - return new MapReadWriteAdapterTaskService<>(taskService, taskId, name, keyClazz, valueClazz); - } - - @Override - public ReadAdapter> from(TaskService taskService, String taskId) { - return new MapReadWriteAdapterTaskService<>(taskService, taskId, name, keyClazz, valueClazz); - } - - @Override - public WriteAdapter> on(CaseService caseService, String caseExecutionId) { - return new MapReadWriteAdapterCaseService<>(caseService, caseExecutionId, name, keyClazz, valueClazz); - } - - @Override - public ReadAdapter> from(CaseService caseService, String caseExecutionId) { - return new MapReadWriteAdapterCaseService<>(caseService, caseExecutionId, name, keyClazz, valueClazz); - } - - @Override - public ReadAdapter> from(LockedExternalTask lockedExternalTask) { - return new MapReadAdapterLockedExternalTask<>(lockedExternalTask, name, keyClazz, valueClazz); - } - - @Override - @NotNull - public String getName() { - return name; - } - - /** - * Retrieves key type. - * - * @return key type. - */ - @NotNull - public Class getKeyClass() { - return keyClazz; - } - - /** - * Retrieves value type. - * - * @return value type. - */ - @NotNull - public Class getValueClass() { - return valueClazz; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - MapVariableFactory that = (MapVariableFactory) o; - return name.equals(that.name) && - keyClazz.equals(that.keyClazz) && - valueClazz.equals(that.valueClazz); - } - - @Override - public int hashCode() { - return Objects.hash(name, keyClazz, valueClazz); - } - - @Override - public String toString() { - return "MapVariableFactory{" + - "name='" + name + '\'' + - ", keyClazz=" + keyClazz + - ", valueClazz=" + valueClazz + - '}'; - } -} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.kt new file mode 100644 index 00000000..5aebad68 --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/MapVariableFactory.kt @@ -0,0 +1,149 @@ +package io.holunda.camunda.bpm.data.factory + +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import io.holunda.camunda.bpm.data.adapter.WriteAdapter +import io.holunda.camunda.bpm.data.adapter.map.* +import org.camunda.bpm.engine.CaseService +import org.camunda.bpm.engine.RuntimeService +import org.camunda.bpm.engine.TaskService +import org.camunda.bpm.engine.delegate.VariableScope +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Variable factory of a base parametrized map type. + * + * @param [K]> member key type of the factory. + * @param [V] member value type of the factory. + */ +class MapVariableFactory( + override val name: String, + val keyClass: Class, + val valueClass: Class +) : VariableFactory> { + + override fun on(variableScope: VariableScope): WriteAdapter> { + return MapReadWriteAdapterVariableScope( + variableScope, + name, + keyClass, + valueClass + ) + } + + override fun from(variableScope: VariableScope): ReadAdapter> { + return MapReadWriteAdapterVariableScope( + variableScope, + name, + keyClass, + valueClass + ) + } + + override fun on(variableMap: VariableMap): WriteAdapter> { + return MapReadWriteAdapterVariableMap( + variableMap, + name, + keyClass, + valueClass + ) + } + + override fun from(variableMap: VariableMap): ReadAdapter> { + return MapReadWriteAdapterVariableMap( + variableMap, + name, + keyClass, + valueClass + ) + } + + override fun on(runtimeService: RuntimeService, executionId: String): WriteAdapter> { + return MapReadWriteAdapterRuntimeService( + runtimeService, + executionId, + name, + keyClass, + valueClass + ) + } + + override fun from(runtimeService: RuntimeService, executionId: String): ReadAdapter> { + return MapReadWriteAdapterRuntimeService( + runtimeService, + executionId, + name, + keyClass, + valueClass + ) + } + + override fun on(taskService: TaskService, taskId: String): WriteAdapter> { + return MapReadWriteAdapterTaskService( + taskService, + taskId, + name, + keyClass, + valueClass + ) + } + + override fun from(taskService: TaskService, taskId: String): ReadAdapter> { + return MapReadWriteAdapterTaskService( + taskService, + taskId, + name, + keyClass, + valueClass + ) + } + + override fun on(caseService: CaseService, caseExecutionId: String): WriteAdapter> { + return MapReadWriteAdapterCaseService( + caseService, + caseExecutionId, + name, + keyClass, + valueClass + ) + } + + override fun from(caseService: CaseService, caseExecutionId: String): ReadAdapter> { + return MapReadWriteAdapterCaseService( + caseService, + caseExecutionId, + name, + keyClass, + valueClass + ) + } + + override fun from(lockedExternalTask: LockedExternalTask): ReadAdapter> { + return MapReadAdapterLockedExternalTask( + lockedExternalTask, + name, + keyClass, + valueClass + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as MapVariableFactory<*, *> + return name == that.name && keyClass == that.keyClass && valueClass == that.valueClass + } + + override fun hashCode(): Int { + return Objects.hash(name, keyClass, valueClass) + } + + override fun toString(): String { + return "MapVariableFactory{" + + "name='" + name + '\'' + + ", keyClazz=" + keyClass + + ", valueClazz=" + valueClass + + '}' + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java deleted file mode 100644 index d7a79ea0..00000000 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.java +++ /dev/null @@ -1,129 +0,0 @@ -package io.holunda.camunda.bpm.data.factory; - -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.adapter.WriteAdapter; -import io.holunda.camunda.bpm.data.adapter.set.SetReadAdapterLockedExternalTask; -import io.holunda.camunda.bpm.data.adapter.set.SetReadWriteAdapterCaseService; -import io.holunda.camunda.bpm.data.adapter.set.SetReadWriteAdapterRuntimeService; -import io.holunda.camunda.bpm.data.adapter.set.SetReadWriteAdapterTaskService; -import io.holunda.camunda.bpm.data.adapter.set.SetReadWriteAdapterVariableMap; -import io.holunda.camunda.bpm.data.adapter.set.SetReadWriteAdapterVariableScope; -import org.camunda.bpm.engine.CaseService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.TaskService; -import org.camunda.bpm.engine.delegate.VariableScope; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.variable.VariableMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; -import java.util.Set; - -/** - * Variable factory of a base parametrized set type. - * - * @param member type of the factory. - */ -public class SetVariableFactory implements VariableFactory> { - - @NotNull - private final String name; - - @NotNull - private final Class memberClazz; - - public SetVariableFactory(@NotNull String name, @NotNull Class memberClazz) { - this.name = name; - this.memberClazz = memberClazz; - } - - @Override - public WriteAdapter> on(VariableScope variableScope) { - return new SetReadWriteAdapterVariableScope<>(variableScope, name, memberClazz); - } - - @Override - public ReadAdapter> from(VariableScope variableScope) { - return new SetReadWriteAdapterVariableScope<>(variableScope, name, memberClazz); - } - - @Override - public WriteAdapter> on(VariableMap variableMap) { - return new SetReadWriteAdapterVariableMap<>(variableMap, name, memberClazz); - } - - @Override - public ReadAdapter> from(VariableMap variableMap) { - return new SetReadWriteAdapterVariableMap<>(variableMap, name, memberClazz); - } - - @Override - public WriteAdapter> on(RuntimeService runtimeService, String executionId) { - return new SetReadWriteAdapterRuntimeService<>(runtimeService, executionId, name, memberClazz); - } - - @Override - public ReadAdapter> from(RuntimeService runtimeService, String executionId) { - return new SetReadWriteAdapterRuntimeService<>(runtimeService, executionId, name, memberClazz); - } - - @Override - public WriteAdapter> on(TaskService taskService, String taskId) { - return new SetReadWriteAdapterTaskService<>(taskService, taskId, name, memberClazz); - } - - @Override - public ReadAdapter> from(TaskService taskService, String taskId) { - return new SetReadWriteAdapterTaskService<>(taskService, taskId, name, memberClazz); - } - - @Override - public WriteAdapter> on(CaseService caseService, String caseExecutionId) { - return new SetReadWriteAdapterCaseService<>(caseService, caseExecutionId, name, memberClazz); - } - - @Override - public ReadAdapter> from(CaseService caseService, String caseExecutionId) { - return new SetReadWriteAdapterCaseService<>(caseService, caseExecutionId, name, memberClazz); - } - - @Override - public ReadAdapter> from(LockedExternalTask lockedExternalTask) { - return new SetReadAdapterLockedExternalTask<>(lockedExternalTask, name, memberClazz); - } - - @Override - @NotNull - public String getName() { - return name; - } - - @NotNull - public Class getMemberClass() { - return memberClazz; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - SetVariableFactory that = (SetVariableFactory) o; - return name.equals(that.name) && - memberClazz.equals(that.memberClazz); - } - - @Override - public int hashCode() { - return Objects.hash(name, memberClazz); - } - - @Override - public String toString() { - return "SetVariableFactory{" + - "name='" + name + '\'' + - ", memberClazz=" + memberClazz + - '}'; - } -} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.kt new file mode 100644 index 00000000..a338d8ed --- /dev/null +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/SetVariableFactory.kt @@ -0,0 +1,106 @@ +package io.holunda.camunda.bpm.data.factory + +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import io.holunda.camunda.bpm.data.adapter.WriteAdapter +import io.holunda.camunda.bpm.data.adapter.set.* +import org.camunda.bpm.engine.CaseService +import org.camunda.bpm.engine.RuntimeService +import org.camunda.bpm.engine.TaskService +import org.camunda.bpm.engine.delegate.VariableScope +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.VariableMap +import java.util.* + +/** + * Variable factory of a base parametrized set type. + * + * @param [T] member type of the factory. + */ +class SetVariableFactory(override val name: String, val memberClass: Class) : VariableFactory> { + + override fun on(variableScope: VariableScope): WriteAdapter> { + return SetReadWriteAdapterVariableScope(variableScope, name, memberClass) + } + + override fun from(variableScope: VariableScope): ReadAdapter> { + return SetReadWriteAdapterVariableScope(variableScope, name, memberClass) + } + + override fun on(variableMap: VariableMap): WriteAdapter> { + return SetReadWriteAdapterVariableMap(variableMap, name, memberClass) + } + + override fun from(variableMap: VariableMap): ReadAdapter> { + return SetReadWriteAdapterVariableMap(variableMap, name, memberClass) + } + + override fun on(runtimeService: RuntimeService, executionId: String): WriteAdapter> { + return SetReadWriteAdapterRuntimeService( + runtimeService, + executionId, + name, + memberClass + ) + } + + override fun from(runtimeService: RuntimeService, executionId: String): ReadAdapter> { + return SetReadWriteAdapterRuntimeService( + runtimeService, + executionId, + name, + memberClass + ) + } + + override fun on(taskService: TaskService, taskId: String): WriteAdapter> { + return SetReadWriteAdapterTaskService(taskService, taskId, name, memberClass) + } + + override fun from(taskService: TaskService, taskId: String): ReadAdapter> { + return SetReadWriteAdapterTaskService(taskService, taskId, name, memberClass) + } + + override fun on(caseService: CaseService, caseExecutionId: String): WriteAdapter> { + return SetReadWriteAdapterCaseService( + caseService, + caseExecutionId, + name, + memberClass + ) + } + + override fun from(caseService: CaseService, caseExecutionId: String): ReadAdapter> { + return SetReadWriteAdapterCaseService( + caseService, + caseExecutionId, + name, + memberClass + ) + } + + override fun from(lockedExternalTask: LockedExternalTask): ReadAdapter> { + return SetReadAdapterLockedExternalTask( + lockedExternalTask, + name, + memberClass + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val that = other as SetVariableFactory<*> + return name == that.name && memberClass == that.memberClass + } + + override fun hashCode(): Int { + return Objects.hash(name, memberClass) + } + + override fun toString(): String { + return "SetVariableFactory{" + + "name='" + name + '\'' + + ", memberClazz=" + memberClass + + '}' + } +} diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/VariableFactory.java b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/VariableFactory.kt similarity index 61% rename from extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/VariableFactory.java rename to extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/VariableFactory.kt index 96ac45ba..403210f8 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/VariableFactory.java +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/factory/VariableFactory.kt @@ -1,27 +1,27 @@ -package io.holunda.camunda.bpm.data.factory; +package io.holunda.camunda.bpm.data.factory -import io.holunda.camunda.bpm.data.adapter.ReadAdapter; -import io.holunda.camunda.bpm.data.adapter.WriteAdapter; -import org.camunda.bpm.engine.CaseService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.TaskService; -import org.camunda.bpm.engine.delegate.VariableScope; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; -import org.camunda.bpm.engine.variable.VariableMap; +import io.holunda.camunda.bpm.data.adapter.ReadAdapter +import io.holunda.camunda.bpm.data.adapter.WriteAdapter +import org.camunda.bpm.engine.CaseService +import org.camunda.bpm.engine.RuntimeService +import org.camunda.bpm.engine.TaskService +import org.camunda.bpm.engine.delegate.VariableScope +import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.VariableMap /** * Typed variable factory. * - * @param type of the factory. + * @param [T] type of the factory. */ -public interface VariableFactory { +interface VariableFactory { /** * Creates a write adapter for variable scope. * * @param variableScope underlying scope to work on. * @return write adapter. */ - WriteAdapter on(VariableScope variableScope); + fun on(variableScope: VariableScope): WriteAdapter /** * Creates a read adapter on variable scope. @@ -29,7 +29,7 @@ public interface VariableFactory { * @param variableScope underlying scope to work on. * @return read adapter. */ - ReadAdapter from(VariableScope variableScope); + fun from(variableScope: VariableScope): ReadAdapter /** * Creates a write adapter for variable map. @@ -37,7 +37,7 @@ public interface VariableFactory { * @param variableMap underlying scope to work on. * @return write adapter. */ - WriteAdapter on(VariableMap variableMap); + fun on(variableMap: VariableMap): WriteAdapter /** * Creates a read adapter on variable scope. @@ -45,7 +45,7 @@ public interface VariableFactory { * @param variableMap underlying map to work on. * @return read adapter. */ - ReadAdapter from(VariableMap variableMap); + fun from(variableMap: VariableMap): ReadAdapter /** * Creates a write adapter on execution. @@ -54,7 +54,7 @@ public interface VariableFactory { * @param executionId id identifying execution. * @return write adapter */ - WriteAdapter on(RuntimeService runtimeService, String executionId); + fun on(runtimeService: RuntimeService, executionId: String): WriteAdapter /** * Creates a read adapter on execution. @@ -63,7 +63,7 @@ public interface VariableFactory { * @param executionId id identifying execution. * @return read adapter. */ - ReadAdapter from(RuntimeService runtimeService, String executionId); + fun from(runtimeService: RuntimeService, executionId: String): ReadAdapter /** * Creates a write adapter on task. @@ -72,7 +72,7 @@ public interface VariableFactory { * @param taskId id identifying task. * @return write adapter */ - WriteAdapter on(TaskService taskService, String taskId); + fun on(taskService: TaskService, taskId: String): WriteAdapter /** * Creates a read adapter on task. @@ -81,7 +81,7 @@ public interface VariableFactory { * @param taskId id identifying task. * @return read adapter. */ - ReadAdapter from(TaskService taskService, String taskId); + fun from(taskService: TaskService, taskId: String): ReadAdapter /** * Creates a write adapter on task. @@ -90,7 +90,7 @@ public interface VariableFactory { * @param caseExecutionId id identifying case execution. * @return write adapter */ - WriteAdapter on(CaseService caseService, String caseExecutionId); + fun on(caseService: CaseService, caseExecutionId: String): WriteAdapter /** * Creates a read adapter on task. @@ -99,7 +99,7 @@ public interface VariableFactory { * @param caseExecutionId id identifying case execution. * @return read adapter. */ - ReadAdapter from(CaseService caseService, String caseExecutionId); + fun from(caseService: CaseService, caseExecutionId: String): ReadAdapter /** * Creates a read adapter on external task. @@ -107,12 +107,12 @@ public interface VariableFactory { * @param lockedExternalTask underlying external task to work on. * @return read adapter. */ - ReadAdapter from(LockedExternalTask lockedExternalTask); + fun from(lockedExternalTask: LockedExternalTask): ReadAdapter /** * Retrieves the variable name. * * @return name of the variable. */ - String getName(); + val name: String } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/guard/condition/VariableGuardCondition.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/guard/condition/VariableGuardCondition.kt index 3fa15246..56d7fae6 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/guard/condition/VariableGuardCondition.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/guard/condition/VariableGuardCondition.kt @@ -42,7 +42,7 @@ abstract class VariableGuardCondition( * @return list of guard violations */ fun evaluate(variableMap: VariableMap): List> { - return evaluate(if (local) variableFactory.from(variableMap).localOptional else variableFactory.from(variableMap).optional) + return evaluate(if (local) variableFactory.from(variableMap).getLocalOptional() else variableFactory.from(variableMap).getOptional()) } /** @@ -51,7 +51,7 @@ abstract class VariableGuardCondition( * @return list of guard violations */ fun evaluate(variableScope: VariableScope): List> { - return evaluate(if (local) variableFactory.from(variableScope).localOptional else variableFactory.from(variableScope).optional) + return evaluate(if (local) variableFactory.from(variableScope).getLocalOptional() else variableFactory.from(variableScope).getOptional()) } /** @@ -61,7 +61,7 @@ abstract class VariableGuardCondition( * @return list of guard violations */ fun evaluate(taskService: TaskService, taskId: String): List> { - return evaluate(if (local) variableFactory.from(taskService, taskId).localOptional else variableFactory.from(taskService, taskId).optional) + return evaluate(if (local) variableFactory.from(taskService, taskId).getLocalOptional() else variableFactory.from(taskService, taskId).getOptional()) } /** @@ -71,7 +71,7 @@ abstract class VariableGuardCondition( * @return list of guard violations */ fun evaluate(runtimeService: RuntimeService, executionId: String): List> { - return evaluate(if (local) variableFactory.from(runtimeService, executionId).localOptional else variableFactory.from(runtimeService, executionId).optional) + return evaluate(if (local) variableFactory.from(runtimeService, executionId).getLocalOptional() else variableFactory.from(runtimeService, executionId).getOptional()) } override fun equals(other: Any?): Boolean { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.kt index 04393ca3..4fd4b7f2 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/CaseServiceVariableReader.kt @@ -16,7 +16,7 @@ class CaseServiceVariableReader( ) : VariableReader { override fun getOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(caseService, caseExecutionId).optional + return variableFactory.from(caseService, caseExecutionId).getOptional() } override fun get(variableFactory: VariableFactory): T { @@ -24,11 +24,11 @@ class CaseServiceVariableReader( } override fun getLocal(variableFactory: VariableFactory): T { - return variableFactory.from(caseService, caseExecutionId).local + return variableFactory.from(caseService, caseExecutionId).getLocal() } override fun getLocalOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(caseService, caseExecutionId).localOptional + return variableFactory.from(caseService, caseExecutionId).getLocalOptional() } override fun equals(other: Any?): Boolean { @@ -39,8 +39,6 @@ class CaseServiceVariableReader( } override fun hashCode(): Int { - var result = caseService.hashCode() - result = 31 * result + caseExecutionId.hashCode() - return result + return Objects.hash(caseService, caseExecutionId) } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.kt index 371b7c76..8972f73a 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReader.kt @@ -10,7 +10,7 @@ import java.util.* */ class LockedExternalTaskReader(private val lockedExternalTask: LockedExternalTask) : VariableReader { override fun getOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(lockedExternalTask).optional + return variableFactory.from(lockedExternalTask).getOptional() } override fun get(variableFactory: VariableFactory): T { @@ -18,11 +18,11 @@ class LockedExternalTaskReader(private val lockedExternalTask: LockedExternalTas } override fun getLocal(variableFactory: VariableFactory): T { - return variableFactory.from(lockedExternalTask).local + return variableFactory.from(lockedExternalTask).getLocal() } override fun getLocalOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(lockedExternalTask).localOptional + return variableFactory.from(lockedExternalTask).getLocalOptional() } override fun equals(other: Any?): Boolean { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.kt index 2bcb3a38..4d312d75 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/RuntimeServiceVariableReader.kt @@ -11,7 +11,7 @@ import java.util.* */ class RuntimeServiceVariableReader(private val runtimeService: RuntimeService, private val executionId: String) : VariableReader { override fun getOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(runtimeService, executionId).optional + return variableFactory.from(runtimeService, executionId).getOptional() } override fun get(variableFactory: VariableFactory): T { @@ -19,11 +19,11 @@ class RuntimeServiceVariableReader(private val runtimeService: RuntimeService, p } override fun getLocal(variableFactory: VariableFactory): T { - return variableFactory.from(runtimeService, executionId).local + return variableFactory.from(runtimeService, executionId).getLocal() } override fun getLocalOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(runtimeService, executionId).localOptional + return variableFactory.from(runtimeService, executionId).getLocalOptional() } override fun equals(other: Any?): Boolean { @@ -34,8 +34,6 @@ class RuntimeServiceVariableReader(private val runtimeService: RuntimeService, p } override fun hashCode(): Int { - var result = runtimeService.hashCode() - result = 31 * result + executionId.hashCode() - return result + return Objects.hash(runtimeService, executionId) } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.kt index 1be6bc44..9eba1cd3 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/TaskServiceVariableReader.kt @@ -11,7 +11,7 @@ import java.util.* */ class TaskServiceVariableReader(private val taskService: TaskService, private val taskId: String) : VariableReader { override fun getOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(taskService, taskId).optional + return variableFactory.from(taskService, taskId).getOptional() } override fun get(variableFactory: VariableFactory): T { @@ -19,11 +19,11 @@ class TaskServiceVariableReader(private val taskService: TaskService, private va } override fun getLocal(variableFactory: VariableFactory): T { - return variableFactory.from(taskService, taskId).local + return variableFactory.from(taskService, taskId).getLocal() } override fun getLocalOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(taskService, taskId).localOptional + return variableFactory.from(taskService, taskId).getLocalOptional() } override fun equals(other: Any?): Boolean { @@ -34,8 +34,6 @@ class TaskServiceVariableReader(private val taskService: TaskService, private va } override fun hashCode(): Int { - var result = taskService.hashCode() - result = 31 * result + taskId.hashCode() - return result + return Objects.hash(taskService, taskId) } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableMapReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableMapReader.kt index b30584ad..0cb91d48 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableMapReader.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableMapReader.kt @@ -11,7 +11,7 @@ import java.util.* class VariableMapReader(private val variableMap: VariableMap) : VariableReader { override fun getOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(variableMap).optional + return variableFactory.from(variableMap).getOptional() } override fun get(variableFactory: VariableFactory): T { @@ -19,11 +19,11 @@ class VariableMapReader(private val variableMap: VariableMap) : VariableReader { } override fun getLocal(variableFactory: VariableFactory): T { - return variableFactory.from(variableMap).local + return variableFactory.from(variableMap).getLocal() } override fun getLocalOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(variableMap).localOptional + return variableFactory.from(variableMap).getLocalOptional() } override fun equals(other: Any?): Boolean { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableReader.kt index e9e3434b..66ae6c56 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableReader.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableReader.kt @@ -52,7 +52,7 @@ interface VariableReader { * @param type of value * @return value of variable or `null` if the variable is not present or has value `null`. */ - fun getOrNull(variableFactory: VariableFactory): T? { + fun getOrNull(variableFactory: VariableFactory): T? { return getOptional(variableFactory).orElse(null) } @@ -63,7 +63,7 @@ interface VariableReader { * @param defaultValue the default value if the variable is not set * @return value or default */ - fun getOrDefault(variableFactory: VariableFactory, defaultValue: T?): T? { + fun getOrDefault(variableFactory: VariableFactory, defaultValue: T?): T? { return getOptional(variableFactory).orElse(defaultValue) } @@ -74,7 +74,7 @@ interface VariableReader { * @param type of value * @return value of variable or `null` if the variable is not present or has value `null`. */ - fun getLocalOrNull(variableFactory: VariableFactory): T? { + fun getLocalOrNull(variableFactory: VariableFactory): T? { return getLocalOptional(variableFactory).orElse(null) } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableScopeReader.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableScopeReader.kt index 36b83917..4c08d244 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableScopeReader.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/reader/VariableScopeReader.kt @@ -10,7 +10,7 @@ import java.util.* */ class VariableScopeReader(private val variableScope: VariableScope) : VariableReader { override fun getOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(variableScope).optional + return variableFactory.from(variableScope).getOptional() } override fun get(variableFactory: VariableFactory): T { @@ -18,11 +18,11 @@ class VariableScopeReader(private val variableScope: VariableScope) : VariableRe } override fun getLocal(variableFactory: VariableFactory): T { - return variableFactory.from(variableScope).local + return variableFactory.from(variableScope).getLocal() } override fun getLocalOptional(variableFactory: VariableFactory): Optional { - return variableFactory.from(variableScope).localOptional + return variableFactory.from(variableScope).getLocalOptional() } override fun equals(other: Any?): Boolean { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt index 57642213..93a16b30 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt @@ -3,6 +3,7 @@ package io.holunda.camunda.bpm.data.writer import io.holunda.camunda.bpm.data.factory.VariableFactory import org.camunda.bpm.engine.CaseService import org.camunda.bpm.engine.variable.VariableMap +import java.util.* import java.util.function.Function /** @@ -85,8 +86,6 @@ class CaseServiceVariableWriter(private val caseService: CaseService, private va } override fun hashCode(): Int { - var result = caseService.hashCode() - result = 31 * result + caseExecutionId.hashCode() - return result + return Objects.hash(caseService, caseExecutionId) } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt index 15852b23..7a9a8273 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt @@ -3,6 +3,7 @@ package io.holunda.camunda.bpm.data.writer import io.holunda.camunda.bpm.data.factory.VariableFactory import org.camunda.bpm.engine.RuntimeService import org.camunda.bpm.engine.variable.VariableMap +import java.util.* import java.util.function.Function /** @@ -89,8 +90,6 @@ class RuntimeServiceVariableWriter(private val runtimeService: RuntimeService, p } override fun hashCode(): Int { - var result = runtimeService.hashCode() - result = 31 * result + executionId.hashCode() - return result + return Objects.hash(runtimeService, executionId) } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt index e4f9c84f..db814221 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt @@ -3,6 +3,7 @@ package io.holunda.camunda.bpm.data.writer import io.holunda.camunda.bpm.data.factory.VariableFactory import org.camunda.bpm.engine.TaskService import org.camunda.bpm.engine.variable.VariableMap +import java.util.* import java.util.function.Function /** @@ -85,8 +86,6 @@ class TaskServiceVariableWriter(private val taskService: TaskService, private va } override fun hashCode(): Int { - var result = taskService.hashCode() - result = 31 * result + taskId.hashCode() - return result + return Objects.hash(taskService, taskId) } } diff --git a/extension/core/src/main/kotlin/packages.md b/extension/core/src/main/kotlin/packages.md index f211de2a..12fa19cd 100644 --- a/extension/core/src/main/kotlin/packages.md +++ b/extension/core/src/main/kotlin/packages.md @@ -12,6 +12,41 @@ Package providing resources for building of Anti-Corruption-Layer (ACL). @since 1.0.0 @see [io.holunda.camunda.bpm.data.acl.CamundaBpmDataACL] for more details. +# Package io.holunda.camunda.bpm.data.adapter + +Read and Write adapters for different factories to handle different contexts. +@see [io.holunda.camunda.bpm.data.adapter.ReadAdapter] +@see [io.holunda.camunda.bpm.data.adapter.WriteAdapter] +@since 0.0.2 + +# Package io.holunda.camunda.bpm.data.adapter.basic + +Read/Write adapters for basic variable factory. + +@see [io.holunda.camunda.bpm.data.factory.BasicVariableFactory] for more details +@since 0.0.2 + + +# Package io.holunda.camunda.bpm.data.adapter.list + +Read/Write adapters for list variable factory. + +@see [io.holunda.camunda.bpm.data.factory.ListVariableFactory] for more details +@since 0.0.2 + +# Package io.holunda.camunda.bpm.data.adapter.map + +Read/Write adapters for map variable factory. + +@see [io.holunda.camunda.bpm.data.factory.MapVariableFactory] for more details +@since 0.0.2 + +# Package io.holunda.camunda.bpm.data.adapter.set + +Read/Write adapters for set variable factory. +@see [io.holunda.camunda.bpm.data.factory.SetVariableFactory] for more details +@since 0.0.2 + # Package io.holunda.camunda.bpm.data.builder Writers are used to create multiple variables inside a variable map. From 395d7327cd4ec4467956f4228e4145a78cfdbbe3 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 16 May 2023 12:56:23 +0200 Subject: [PATCH 46/67] rebuild lockedExternalTask adapters to use the abstract implementation --- .../basic/AbstractBasicReadWriteAdapter.kt | 47 ++++---- .../basic/ReadAdapterLockedExternalTask.kt | 44 ++++--- .../list/AbstractListReadWriteAdapter.kt | 1 + .../list/ListReadAdapterLockedExternalTask.kt | 109 ++++++++---------- .../map/AbstractMapReadWriteAdapter.kt | 1 + .../map/MapReadAdapterLockedExternalTask.kt | 74 +++++------- .../set/AbstractSetReadWriteAdapter.kt | 3 +- .../set/SetReadAdapterLockedExternalTask.kt | 59 ++++------ 8 files changed, 158 insertions(+), 180 deletions(-) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.kt index a070553d..f9e46da7 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/AbstractBasicReadWriteAdapter.kt @@ -15,30 +15,31 @@ import java.util.* * @param clazz variable type. */ abstract class AbstractBasicReadWriteAdapter( - variableName: String, - protected val clazz: Class + variableName: String, + protected val clazz: Class ) : AbstractReadWriteAdapter(variableName) { - /** - * Retrieves the value or null. - * - * @param value raw value. - * @return value or null. - */ - @Suppress("UNCHECKED_CAST") - protected fun getOrNull(value: Any?): T? { - if (value == null) { - return null - } - if (clazz == UUID::class.java && String::class.java.isAssignableFrom(value.javaClass)) { - return UUID.fromString(value as String?) as T - } - if (clazz.isAssignableFrom(value.javaClass) || isAssignableFrom(clazz, value.javaClass)) { - return value as T - } - throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of $clazz from $value") + /** + * Retrieves the value or null. + * + * @param value raw value. + * @return value or null. + */ + protected fun getOrNull(value: Any?): T? { + if (value == null) { + return null } - - override fun getTypedValue(value: Any?, isTransient: Boolean): TypedValue { - return getTypedValue(clazz, value, isTransient) + if (clazz == UUID::class.java && String::class.java.isAssignableFrom(value.javaClass)) { + @Suppress("UNCHECKED_CAST") + return UUID.fromString(value as String?) as T + } + if (clazz.isAssignableFrom(value.javaClass) || isAssignableFrom(clazz, value.javaClass)) { + @Suppress("UNCHECKED_CAST") + return value as T } + throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of $clazz from $value") + } + + override fun getTypedValue(value: Any?, isTransient: Boolean): TypedValue { + return getTypedValue(clazz, value, isTransient) + } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt index cb45ccc5..ebdea13f 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt @@ -1,7 +1,7 @@ package io.holunda.camunda.bpm.data.adapter.basic -import io.holunda.camunda.bpm.data.adapter.ReadAdapter import org.camunda.bpm.engine.externaltask.LockedExternalTask +import org.camunda.bpm.engine.variable.Variables import java.util.* /** @@ -9,17 +9,29 @@ import java.util.* * * @param [T] type of value. */ -class ReadAdapterLockedExternalTask(lockedExternalTask: LockedExternalTask, variableName: String, clazz: Class) : - ReadAdapter -{ - private val readAdapter: ReadAdapter = ReadWriteAdapterVariableMap(lockedExternalTask.variables, variableName, clazz) +class ReadAdapterLockedExternalTask( + private val lockedExternalTask: LockedExternalTask, + variableName: String, + clazz: Class +) : AbstractBasicReadWriteAdapter(variableName, clazz) { + private val value: Any? + get() = Optional.ofNullable(lockedExternalTask.variables) + .orElse(Variables.createVariables())[variableName] - override fun get(): T { - return readAdapter.get() + override fun getOptional(): Optional { + return Optional.ofNullable( + getOrNull( + value + ) + ) } - override fun getOptional(): Optional { - return readAdapter.getOptional() + override fun set(value: T, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a variable on an external task") + } + + override fun setLocal(value: T, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a local variable on an external task") } override fun getLocal(): T { @@ -30,19 +42,19 @@ class ReadAdapterLockedExternalTask(lockedExternalTask: LockedExternalT throw UnsupportedOperationException("Can't get a local variable on an external task") } - override fun getOrDefault(defaultValue: T): T { - return readAdapter.getOrDefault(defaultValue) + override fun getLocalOrDefault(defaultValue: T): T { + throw UnsupportedOperationException("Can't get a local variable on an external task") } - override fun getLocalOrDefault(defaultValue: T): T { + override fun getLocalOrNull(): T { throw UnsupportedOperationException("Can't get a local variable on an external task") } - override fun getOrNull(): T? { - return readAdapter.getOrNull() + override fun remove() { + throw UnsupportedOperationException("Can't remove a variable on an external task") } - override fun getLocalOrNull(): T { - throw UnsupportedOperationException("Can't get a local variable on an external task") + override fun removeLocal() { + throw UnsupportedOperationException("Can't remove a local variable on an external task") } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.kt index 5492b042..697c58d9 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/AbstractListReadWriteAdapter.kt @@ -30,6 +30,7 @@ abstract class AbstractListReadWriteAdapter(variableName: String, protected v emptyList() } else { if (memberClazz.isAssignableFrom(valueAsList.iterator().next()!!.javaClass)) { + @Suppress("UNCHECKED_CAST") valueAsList as List } else { throw WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.name + ", but was not found in " + valueAsList) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt index bd710428..8bf961d7 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt @@ -1,7 +1,5 @@ package io.holunda.camunda.bpm.data.adapter.list -import io.holunda.camunda.bpm.data.adapter.ReadAdapter -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException import org.camunda.bpm.engine.externaltask.LockedExternalTask import org.camunda.bpm.engine.variable.Variables import java.util.* @@ -12,63 +10,52 @@ import java.util.* * @param [T] type of value. */ class ListReadAdapterLockedExternalTask( - private val lockedExternalTask: LockedExternalTask, - private val variableName: String, - private val memberClazz: Class -) : ReadAdapter> { - - override fun get(): List { - return getOptional().get() - } - - override fun getOptional(): Optional> { - return Optional.ofNullable(getOrNull(value)) - } - - override fun getLocal(): List { - throw UnsupportedOperationException("Can't get a local variable on an external task") - } - - override fun getLocalOptional(): Optional> { - throw UnsupportedOperationException("Can't get a local variable on an external task") - } - - override fun getOrDefault(defaultValue: List): List { - return getOptional().orElse(defaultValue) - } - - override fun getLocalOrDefault(defaultValue: List): List { - throw UnsupportedOperationException("Can't get a local variable on an external task") - } - - override fun getOrNull(): List? { - return getOrNull(value) - } - - override fun getLocalOrNull(): List { - throw UnsupportedOperationException("Can't get a local variable on an external task") - } - - private fun getOrNull(value: T?): List? { - if (value == null) { - return null - } - if (MutableList::class.java.isAssignableFrom(value.javaClass)) { - val valueAsList = value as List<*> - return if (valueAsList.isEmpty()) { - emptyList() - } else { - if (memberClazz.isAssignableFrom(valueAsList.iterator().next()!!.javaClass)) { - valueAsList as List - } else { - throw WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.name + ", but was not found in " + valueAsList) - } - } - } - throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type List from $value") - } - - private val value: T? - get() = Optional.ofNullable(lockedExternalTask.variables) - .orElse(Variables.createVariables())[variableName] as T? + private val lockedExternalTask: LockedExternalTask, + variableName: String, + memberClazz: Class +) : AbstractListReadWriteAdapter(variableName, memberClazz) { + + private val value: Any? + get() = Optional.ofNullable(lockedExternalTask.variables) + .orElse(Variables.createVariables())[variableName] + + override fun getOptional(): Optional> { + return Optional.ofNullable( + getOrNull( + value + ) + ) + } + + override fun set(value: List, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a variable on an external task") + } + + override fun setLocal(value: List, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a local variable on an external task") + } + + override fun getLocal(): List { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getLocalOptional(): Optional> { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getLocalOrDefault(defaultValue: List): List { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun getLocalOrNull(): List { + throw UnsupportedOperationException("Can't get a local variable on an external task") + } + + override fun remove() { + throw UnsupportedOperationException("Can't remove a variable on an external task") + } + + override fun removeLocal() { + throw UnsupportedOperationException("Can't remove a local variable on an external task") + } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.kt index 1d1f3b9e..d2b1c498 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/AbstractMapReadWriteAdapter.kt @@ -36,6 +36,7 @@ abstract class AbstractMapReadWriteAdapter( } else { val (key, value1) = valueAsMap.entries.iterator().next() if (keyClazz.isAssignableFrom(key!!.javaClass) && valueClazz.isAssignableFrom(value1!!.javaClass)) { + @Suppress("UNCHECKED_CAST") valueAsMap as Map } else { throw WrongVariableTypeException( diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt index cb512388..b98f4807 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt @@ -1,7 +1,5 @@ package io.holunda.camunda.bpm.data.adapter.map -import io.holunda.camunda.bpm.data.adapter.ReadAdapter -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException import org.camunda.bpm.engine.externaltask.LockedExternalTask import org.camunda.bpm.engine.variable.Variables import java.util.* @@ -9,23 +7,28 @@ import java.util.* /** * Read adapter for external task * - * @param type of key. - * @param type of value. + * @param [K] type of key. + * @param [V] type of value. * @param lockedExternalTask external task. * @param variableName name of the variable. - */ + */ class MapReadAdapterLockedExternalTask( private val lockedExternalTask: LockedExternalTask, - private val variableName: String, - private val keyClazz: Class, - private val valueClazz: Class -) : ReadAdapter> { - override fun get(): Map { - return getOptional().get() - } + variableName: String, + keyClazz: Class, + valueClazz: Class +) : AbstractMapReadWriteAdapter(variableName, keyClazz, valueClazz) { + + private val value: Any? + get() = Optional.ofNullable(lockedExternalTask.variables) + .orElse(Variables.createVariables())[variableName] override fun getOptional(): Optional> { - return Optional.ofNullable(getOrNull(value)) + return Optional.ofNullable( + getOrNull( + value + ) + ) } override fun getLocal(): Map { @@ -36,47 +39,28 @@ class MapReadAdapterLockedExternalTask( throw UnsupportedOperationException("Can't get a local variable on an external task") } - override fun getOrDefault(defaultValue: Map): Map { - return getOptional().orElse(defaultValue) + override fun getLocalOrDefault(defaultValue: Map): Map { + throw UnsupportedOperationException("Can't get a local variable on an external task") } - override fun getLocalOrDefault(defaultValue: Map): Map { + override fun getLocalOrNull(): Map { throw UnsupportedOperationException("Can't get a local variable on an external task") } - override fun getOrNull(): Map? { - return getOrNull(value) + override fun remove() { + throw UnsupportedOperationException("Can't remove a variable on an external task") } - override fun getLocalOrNull(): Map { - throw UnsupportedOperationException("Can't get a local variable on an external task") + override fun removeLocal() { + throw UnsupportedOperationException("Can't remove a local variable on an external task") } - private fun getOrNull(value: Any?): Map? { - if (value == null) { - return null - } - if (MutableMap::class.java.isAssignableFrom(value.javaClass)) { - val valueAsMap = value as Map<*, *> - return if (valueAsMap.isEmpty()) { - emptyMap() - } else { - val (key, value1) = valueAsMap.entries.iterator().next() - if (keyClazz.isAssignableFrom(key!!.javaClass) && valueClazz.isAssignableFrom(value1!!.javaClass)) { - valueAsMap as Map - } else { - throw WrongVariableTypeException( - "Error reading " + variableName + ": Wrong map type detected, expected Map<" - + keyClazz.name + "," + valueClazz.name - + ", but was not found in " + valueAsMap - ) - } - } - } - throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type Map from $value") + override fun set(value: Map, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a variable on an external task") + } + + override fun setLocal(value: Map, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a local variable on an external task") } - private val value: Any? - get() = Optional.ofNullable(lockedExternalTask.variables) - .orElse(Variables.createVariables())[variableName] } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.kt index 29883218..bdbfb7c9 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/AbstractSetReadWriteAdapter.kt @@ -29,7 +29,8 @@ abstract class AbstractSetReadWriteAdapter(variableName: String, protected va emptySet() } else { if (memberClazz.isAssignableFrom(valueAsList.iterator().next()!!.javaClass)) { - valueAsList as Set + @Suppress("UNCHECKED_CAST") + valueAsList as Set } else { throw WrongVariableTypeException("Error reading " + variableName + ": Wrong set type detected, expected " + memberClazz.name + ", but was not found in " + valueAsList) } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt index 28c92707..423fa0a5 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt @@ -1,7 +1,5 @@ package io.holunda.camunda.bpm.data.adapter.set -import io.holunda.camunda.bpm.data.adapter.ReadAdapter -import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException import org.camunda.bpm.engine.externaltask.LockedExternalTask import org.camunda.bpm.engine.variable.Variables import java.util.* @@ -15,16 +13,26 @@ import java.util.* * @param memberClazz class of the variable. */ class SetReadAdapterLockedExternalTask( - private val lockedExternalTask: LockedExternalTask, - private val variableName: String, - private val memberClazz: Class -) : ReadAdapter> { - override fun get(): Set { - return getOptional().get() - } + private val lockedExternalTask: LockedExternalTask, variableName: String, memberClazz: Class +) : AbstractSetReadWriteAdapter(variableName, memberClazz) { + + private val value: Any? + get() = Optional.ofNullable(lockedExternalTask.variables).orElse(Variables.createVariables())[variableName] override fun getOptional(): Optional> { - return Optional.ofNullable(getOrNull()) + return Optional.ofNullable( + getOrNull( + value + ) + ) + } + + override fun set(value: Set, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a variable on an external task") + } + + override fun setLocal(value: Set, isTransient: Boolean) { + throw UnsupportedOperationException("Can't set a local variable on an external task") } override fun getLocal(): Set { @@ -43,34 +51,17 @@ class SetReadAdapterLockedExternalTask( throw UnsupportedOperationException("Can't get a local variable on an external task") } - override fun getOrNull(): Set? { - return getOrNull(value) - } - override fun getLocalOrNull(): Set { throw UnsupportedOperationException("Can't get a local variable on an external task") } - private fun getOrNull(value: T?): Set? { - if (value == null) { - return null - } - if (MutableSet::class.java.isAssignableFrom(value.javaClass)) { - val valueAsSet = value as Set<*> - return if (valueAsSet.isEmpty()) { - emptySet() - } else { - if (memberClazz.isAssignableFrom(valueAsSet.iterator().next()!!.javaClass)) { - valueAsSet as Set - } else { - throw WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.name + ", but was not found in " + valueAsSet) - } - } - } - throw WrongVariableTypeException("Error reading $variableName: Couldn't read value of type List from $value") + override fun remove() { + throw UnsupportedOperationException("Can't remove a variable on an external task") } - private val value: T? - get() = Optional.ofNullable(lockedExternalTask.variables) - .orElse(Variables.createVariables())[variableName] as T? + override fun removeLocal() { + throw UnsupportedOperationException("Can't remove a local variable on an external task") + } + + } From 85f2e868a1eba78e311db4ab5e82ddc2ff59c564 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 May 2023 01:59:08 +0000 Subject: [PATCH 47/67] build(deps): bump maven-source-plugin from 3.2.1 to 3.3.0 Bumps [maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.2.1 to 3.3.0. - [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.2.1...maven-source-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-source-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84d1dcaf..833a2ca0 100644 --- a/pom.xml +++ b/pom.xml @@ -381,7 +381,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.0 attach-sources From 2172b977a7981da4a264688f636b18ac8627df52 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Mon, 22 May 2023 14:36:42 +0200 Subject: [PATCH 48/67] removed null-errors from Java converted file --- .../bpm/data/adapter/CollectionTypedValueUtil.kt | 14 +++++++------- .../bpm/data/adapter/ValueWrapperUtilTest.java | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.kt index f25aa014..42d97ec1 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/CollectionTypedValueUtil.kt @@ -23,12 +23,12 @@ object CollectionTypedValueUtil { * @param [C] type of collection. * @return collection of specified type or null. */ - fun ?> readFromTypedValue( + fun > readFromTypedValue( typedValue: TypedValue?, variableName: String, memberClazz: Class, objectMapper: ObjectMapper, - collectionType: CollectionType? + collectionType: CollectionType ): C? { if (typedValue == null) { return null @@ -37,11 +37,11 @@ object CollectionTypedValueUtil { val json = typedValue.valueSerialized try { val values = objectMapper.readValue(json, collectionType) - if (values!!.isEmpty()) { + if (values.isEmpty()) { values } else { val value: T = values.iterator().next() - if (memberClazz.isAssignableFrom(value!!::class.java)) { + if (memberClazz.isAssignableFrom(value::class.java)) { values } else { throw WrongVariableTypeException("Error reading " + variableName + ": Wrong member type detected, expected " + memberClazz.name + ", but was not found in " + values) @@ -68,9 +68,9 @@ object CollectionTypedValueUtil { * @param [V] type of myp value. * @return map of specified types or null. */ - fun readFromTypedValue( + fun readFromTypedValue( typedValue: TypedValue?, variableName: String, keyClazz: Class, valueClazz: Class, - objectMapper: ObjectMapper, mapType: MapType? + objectMapper: ObjectMapper, mapType: MapType ): Map? { if (typedValue == null) { return null @@ -83,7 +83,7 @@ object CollectionTypedValueUtil { map } else { val (key, value) = map.entries.iterator().next() - if (valueClazz.isAssignableFrom(value!!::class.java) && keyClazz.isAssignableFrom(key!!::class.java)) { + if (valueClazz.isAssignableFrom(value::class.java) && keyClazz.isAssignableFrom(key::class.java)) { map } else { throw WrongVariableTypeException( diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtilTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtilTest.java index 9d1ec67b..2ff1746b 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtilTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/adapter/ValueWrapperUtilTest.java @@ -5,6 +5,7 @@ import java.time.Instant; import java.util.Date; +import java.util.UUID; import org.camunda.bpm.engine.variable.type.PrimitiveValueType; import org.camunda.bpm.engine.variable.value.BooleanValue; @@ -150,6 +151,14 @@ public void shouldReturnStringValue() { assertThat(stringValue.getType()).isExactlyInstanceOf(PrimitiveValueType.STRING.getClass()); assertThat(stringValue.getValue()).isNull(); assertThat(stringValue.isTransient()).isTrue(); + + UUID uuid = UUID.randomUUID(); + stringValue = ValueWrapperUtil.getTypedValue(UUID.class, uuid, true); + assertThat(stringValue).isInstanceOf(StringValue.class); + assertThat(stringValue.getType()).isExactlyInstanceOf(PrimitiveValueType.STRING.getClass()); + assertThat(stringValue.getValue()).isEqualTo(uuid.toString()); + assertThat(stringValue.isTransient()).isTrue(); + } @Test From 3bf31b1ac78274260a48f92e93eebb22263322fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 01:57:36 +0000 Subject: [PATCH 49/67] build(deps): bump gitflow-maven-plugin from 1.19.0 to 1.20.0 Bumps [gitflow-maven-plugin](https://github.com/aleksandr-m/gitflow-maven-plugin) from 1.19.0 to 1.20.0. - [Release notes](https://github.com/aleksandr-m/gitflow-maven-plugin/releases) - [Changelog](https://github.com/aleksandr-m/gitflow-maven-plugin/blob/master/CHANGELOG.md) - [Commits](https://github.com/aleksandr-m/gitflow-maven-plugin/compare/v1.19.0...v1.20.0) --- updated-dependencies: - dependency-name: com.amashchenko.maven.plugin:gitflow-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 833a2ca0..16f29408 100644 --- a/pom.xml +++ b/pom.xml @@ -401,7 +401,7 @@ com.amashchenko.maven.plugin gitflow-maven-plugin - 1.19.0 + 1.20.0 master From 15c7f08bb724c719bb7f819a429445b11e817bfd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 01:58:02 +0000 Subject: [PATCH 50/67] build(deps): bump mockito-kotlin from 4.1.0 to 5.0.0 Bumps [mockito-kotlin](https://github.com/mockito/mockito-kotlin) from 4.1.0 to 5.0.0. - [Release notes](https://github.com/mockito/mockito-kotlin/releases) - [Commits](https://github.com/mockito/mockito-kotlin/compare/4.1.0...5.0.0) --- updated-dependencies: - dependency-name: org.mockito.kotlin:mockito-kotlin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 833a2ca0..9a1ebda9 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ true 3.0.5 - 4.1.0 + 5.0.0 6.19.0 **/*ITest.* From c47c32b9a0cae4ee65e40f6ebeef1a86ec999aff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:57:36 +0000 Subject: [PATCH 51/67] build(deps): bump dokka-maven-plugin from 1.8.10 to 1.8.20 Bumps [dokka-maven-plugin](https://github.com/Kotlin/dokka) from 1.8.10 to 1.8.20. - [Release notes](https://github.com/Kotlin/dokka/releases) - [Commits](https://github.com/Kotlin/dokka/compare/v1.8.10...v1.8.20) --- updated-dependencies: - dependency-name: org.jetbrains.dokka:dokka-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16f29408..938a6fb5 100644 --- a/pom.xml +++ b/pom.xml @@ -327,7 +327,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.8.10 + 1.8.20 attach-javadocs From b199dfa5f2a6ba3aaa3b76110d24fb8d68eb113d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:58:13 +0000 Subject: [PATCH 52/67] build(deps): bump maven-failsafe-plugin from 3.1.0 to 3.1.2 Bumps [maven-failsafe-plugin](https://github.com/apache/maven-surefire) from 3.1.0 to 3.1.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.0...surefire-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16f29408..04cdd6e6 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.0 + 3.1.2 From 3daa3f673506e0bb5fc248e6b533a6bc39a2bd2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 01:58:12 +0000 Subject: [PATCH 53/67] build(deps): bump maven-surefire-plugin from 3.1.0 to 3.1.2 Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.1.0 to 3.1.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.0...surefire-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0b34b71c..455ab245 100644 --- a/pom.xml +++ b/pom.xml @@ -298,7 +298,7 @@ maven-surefire-plugin - 3.1.0 + 3.1.2 false kill From d1825cc0c44c5c1b6584883090d650483ab02a42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Jun 2023 01:59:53 +0000 Subject: [PATCH 54/67] build(deps): bump kotlin.version from 1.8.21 to 1.8.22 Bumps `kotlin.version` from 1.8.21 to 1.8.22. Updates `kotlin-bom` from 1.8.21 to 1.8.22 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.22/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.21...v1.8.22) Updates `kotlin-maven-allopen` from 1.8.21 to 1.8.22 Updates `kotlin-maven-noarg` from 1.8.21 to 1.8.22 Updates `kotlin-maven-plugin` from 1.8.21 to 1.8.22 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-noarg dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 455ab245..1d192f0b 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 1.18.1 ${camunda.version.ce} - 1.8.21 + 1.8.22 1.2.5 true From b183a4f6bcf3dd69ec3c37c5fe465a8dfcba7ff7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Jun 2023 01:57:35 +0000 Subject: [PATCH 55/67] build(deps): bump maven-clean-plugin from 3.2.0 to 3.3.1 Bumps [maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.2.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-clean-plugin/releases) - [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.2.0...maven-clean-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-clean-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1d192f0b..8fc21cee 100644 --- a/pom.xml +++ b/pom.xml @@ -156,7 +156,7 @@ org.apache.maven.plugins maven-clean-plugin - 3.2.0 + 3.3.1 From 170a8ae9b136e1fe0fff8857d9117fe4c6392d67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 01:51:38 +0000 Subject: [PATCH 56/67] build(deps): bump kotlin.version from 1.8.22 to 1.9.0 Bumps `kotlin.version` from 1.8.22 to 1.9.0. Updates `kotlin-bom` from 1.8.22 to 1.9.0 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.0) Updates `kotlin-maven-allopen` from 1.8.22 to 1.9.0 Updates `kotlin-maven-noarg` from 1.8.22 to 1.9.0 Updates `kotlin-maven-plugin` from 1.8.22 to 1.9.0 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-noarg dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8fc21cee..df96b9c3 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 1.18.1 ${camunda.version.ce} - 1.8.22 + 1.9.0 1.2.5 true From 227dc083f4d507a04f38812f38c63a2b8e2b102a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jul 2023 01:15:09 +0000 Subject: [PATCH 57/67] build(deps): bump camunda-spin-bom from 1.18.1 to 1.20.0 Bumps [camunda-spin-bom](https://github.com/camunda/camunda-spin) from 1.18.1 to 1.20.0. - [Release notes](https://github.com/camunda/camunda-spin/releases) - [Commits](https://github.com/camunda/camunda-spin/compare/1.18.1...1.20.0) --- updated-dependencies: - dependency-name: org.camunda.spin:camunda-spin-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index df96b9c3..27c0a78e 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 7.18.0-ee 2.7.5 - 1.18.1 + 1.20.0 ${camunda.version.ce} 1.9.0 From 44464854ac52b30cd0dc4a8c0cfb6a1bff68592a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 01:28:35 +0000 Subject: [PATCH 58/67] build(deps): bump org.mockito.kotlin:mockito-kotlin from 5.0.0 to 5.1.0 Bumps [org.mockito.kotlin:mockito-kotlin](https://github.com/mockito/mockito-kotlin) from 5.0.0 to 5.1.0. - [Release notes](https://github.com/mockito/mockito-kotlin/releases) - [Commits](https://github.com/mockito/mockito-kotlin/compare/5.0.0...5.1.0) --- updated-dependencies: - dependency-name: org.mockito.kotlin:mockito-kotlin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75b2fbd4..de6889ec 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ true 3.0.5 - 5.0.0 + 5.1.0 6.19.0 **/*ITest.* From afa5d52f0e24ea7d664e89c727d9e655791fda2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Aug 2023 01:10:23 +0000 Subject: [PATCH 59/67] build(deps): bump org.camunda.spin:camunda-spin-bom Bumps [org.camunda.spin:camunda-spin-bom](https://github.com/camunda/camunda-spin) from 1.20.0 to 1.21.0. - [Release notes](https://github.com/camunda/camunda-spin/releases) - [Commits](https://github.com/camunda/camunda-spin/compare/1.20.0...1.21.0) --- updated-dependencies: - dependency-name: org.camunda.spin:camunda-spin-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75b2fbd4..09439473 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 7.18.0-ee 2.7.5 - 1.20.0 + 1.21.0 ${camunda.version.ce} 1.9.0 From 61a5f9875e61979e58da7f922e90489d4706d6ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Aug 2023 01:06:43 +0000 Subject: [PATCH 60/67] build(deps): bump org.apache.maven.plugins:maven-enforcer-plugin Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.3.0...enforcer-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75b2fbd4..7ddfee1f 100644 --- a/pom.xml +++ b/pom.xml @@ -484,7 +484,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.3.0 + 3.4.0 enforce-maven From 0d5c97919e5bfb3a7e192d71523966d9ffcab4df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 01:43:34 +0000 Subject: [PATCH 61/67] build(deps): bump kotlin.version from 1.9.0 to 1.9.10 Bumps `kotlin.version` from 1.9.0 to 1.9.10. Updates `org.jetbrains.kotlin:kotlin-bom` from 1.9.0 to 1.9.10 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.9.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.0...v1.9.10) Updates `org.jetbrains.kotlin:kotlin-maven-allopen` from 1.9.0 to 1.9.10 Updates `org.jetbrains.kotlin:kotlin-maven-noarg` from 1.9.0 to 1.9.10 Updates `org.jetbrains.kotlin:kotlin-maven-plugin` from 1.9.0 to 1.9.10 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-noarg dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75b2fbd4..a1613f94 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 1.20.0 ${camunda.version.ce} - 1.9.0 + 1.9.10 1.2.5 true From 45d62b9c309566e87cab3c022a2d549d825780bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 01:34:54 +0000 Subject: [PATCH 62/67] build(deps): bump org.jetbrains.dokka:dokka-maven-plugin Bumps [org.jetbrains.dokka:dokka-maven-plugin](https://github.com/Kotlin/dokka) from 1.8.20 to 1.9.0. - [Release notes](https://github.com/Kotlin/dokka/releases) - [Commits](https://github.com/Kotlin/dokka/commits) --- updated-dependencies: - dependency-name: org.jetbrains.dokka:dokka-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6007f22..4720a82f 100644 --- a/pom.xml +++ b/pom.xml @@ -327,7 +327,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.8.20 + 1.9.0 attach-javadocs From a5c4556618f147f6c2553563c0d2eb4e07652a94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 01:28:11 +0000 Subject: [PATCH 63/67] build(deps): bump jgiven.version from 1.2.5 to 1.3.0 Bumps `jgiven.version` from 1.2.5 to 1.3.0. Updates `com.tngtech.jgiven:jgiven-junit5` from 1.2.5 to 1.3.0 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.5...v1.3.0) Updates `com.tngtech.jgiven:jgiven-spring-junit5` from 1.2.5 to 1.3.0 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.5...v1.3.0) Updates `com.tngtech.jgiven:jgiven-spring` from 1.2.5 to 1.3.0 Updates `com.tngtech.jgiven:jgiven-html5-report` from 1.2.5 to 1.3.0 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.5...v1.3.0) Updates `com.tngtech.jgiven:jgiven-maven-plugin` from 1.2.5 to 1.3.0 - [Release notes](https://github.com/TNG/jgiven/releases) - [Changelog](https://github.com/TNG/JGiven/blob/master/CHANGELOG.md) - [Commits](https://github.com/TNG/jgiven/compare/v1.2.5...v1.3.0) --- updated-dependencies: - dependency-name: com.tngtech.jgiven:jgiven-junit5 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.tngtech.jgiven:jgiven-spring-junit5 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.tngtech.jgiven:jgiven-spring dependency-type: direct:development update-type: version-update:semver-minor - dependency-name: com.tngtech.jgiven:jgiven-html5-report dependency-type: direct:development update-type: version-update:semver-minor - dependency-name: com.tngtech.jgiven:jgiven-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4720a82f..80ba64f8 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ ${camunda.version.ce} 1.9.10 - 1.2.5 + 1.3.0 true 3.0.5 From 71c87b9667db779cbedb309b545034e02785f474 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 01:28:33 +0000 Subject: [PATCH 64/67] build(deps): bump org.apache.maven.plugins:maven-enforcer-plugin Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.4.0...enforcer-3.4.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4720a82f..54a6a3c7 100644 --- a/pom.xml +++ b/pom.xml @@ -484,7 +484,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.0 + 3.4.1 enforce-maven From 8961b5f75c3dcd9fa5d2928c7909c8eadbf770f0 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 6 Oct 2023 13:17:54 +0200 Subject: [PATCH 65/67] remove dependency to camunda-mockito, fix #389 --- docs/user-guide/features.md | 8 - example/example-java/pom.xml | 5 - .../rest/ApproveOrderTaskControllerTest.java | 68 --- example/example-kotlin/pom.xml | 5 - .../process/OrderApprovalDelegateTests.kt | 77 --- example/itest/pom.xml | 5 - .../itest/src/test/kotlin/SmartUpdateTest.kt | 42 -- extension/c7/pom.xml | 5 - extension/core/pom.xml | 5 - .../camunda/bpm/data/CamundaBpmDataTest.java | 1 - .../bpm/data/DelegateExecutionFake.java | 273 +++++++++ .../camunda/bpm/data/DelegateFake.java | 33 + .../camunda/bpm/data/DelegateTaskFake.java | 575 ++++++++++++++++++ .../camunda/bpm/data/VariableScopeFake.java | 81 +++ .../data/reader/VariableScopeReaderTest.java | 2 +- .../data/writer/VariableScopeWriterTest.java | 2 +- .../holunda/camunda/bpm/data/FluentApiTest.kt | 1 - .../camunda/bpm/data/NullableMapTest.kt | 8 +- .../camunda/bpm/data/VariablesGuardTest.kt | 38 +- .../holunda/camunda/bpm/data/acl/ACLTest.kt | 6 +- .../bpm/data/acl/AntiCorruptionLayerTest.kt | 4 +- .../integration/GuardExecutionListenerTest.kt | 8 +- .../integration/GuardTaskListenerTest.kt | 2 +- pom.xml | 25 +- 24 files changed, 1012 insertions(+), 267 deletions(-) delete mode 100644 example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java delete mode 100644 example/example-kotlin/src/test/kotlin/process/OrderApprovalDelegateTests.kt delete mode 100644 example/itest/src/test/kotlin/SmartUpdateTest.kt create mode 100644 extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateExecutionFake.java create mode 100644 extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateFake.java create mode 100644 extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateTaskFake.java create mode 100644 extension/core/src/test/java/io/holunda/camunda/bpm/data/VariableScopeFake.java diff --git a/docs/user-guide/features.md b/docs/user-guide/features.md index 1aea3017..2b33a26a 100644 --- a/docs/user-guide/features.md +++ b/docs/user-guide/features.md @@ -29,11 +29,3 @@ - Task listener to handle `VariableGuard`-based conditions and `VariableMapTransformer`-based modifications. - Factory methods to create `AntiCorruptionLayer` with a `VariableGuard` (see `CamundaBpmDataACL`) - Factory methods to create `AntiCorruptionLayer` without a `VariableGuard` (see `CamundaBpmDataMapper`) - -* Testing variable access and mocking `RuntimeService`, `TaskService` and `CaseService` (will be moved to [camunda-platform-7-mockito](https://github.com/camunda-community-hub/camunda-platform-7-mockito)) - - Builder to create Mockito-based behaviour of `RuntimeService` accessing variables. - - Builder to create Mockito-based behaviour of `TaskServiceService` accessing variables. - - Builder to create Mockito-based behaviour of `CaseServiceService` accessing variables. - - Verifier to check correct access to variables in `RuntimeService` - - Verifier to check correct access to variables in `TaskService` - - Verifier to check correct access to variables in `CaseService` diff --git a/example/example-java/pom.xml b/example/example-java/pom.xml index 687920a6..4fc3eeef 100644 --- a/example/example-java/pom.xml +++ b/example/example-java/pom.xml @@ -100,11 +100,6 @@
- - org.camunda.community.mockito - camunda-platform-7-mockito - test - org.springframework.boot spring-boot-starter-test diff --git a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java b/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java deleted file mode 100644 index 6755db7a..00000000 --- a/example/example-java/src/test/java/io/holunda/camunda/bpm/data/example/rest/ApproveOrderTaskControllerTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.holunda.camunda.bpm.data.example.rest; - -import io.holunda.camunda.bpm.data.example.domain.Order; -import org.camunda.bpm.engine.TaskService; -import org.camunda.community.mockito.service.TaskServiceStubBuilder; -import org.camunda.community.mockito.verify.TaskServiceVerification; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.UUID; - -import static io.holunda.camunda.bpm.data.CamundaBpmData.builder; -import static io.holunda.camunda.bpm.data.example.process.OrderApproval.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; - -/** - * Demonstrates the usage of Task Service Variable Mock Builder and Task Service Verifier. - */ -public class ApproveOrderTaskControllerTest { - - private final static Order order = new Order("ORDER-ID-1", new Date(), new ArrayList<>()); - private final TaskService taskService = mock(TaskService.class); - private final TaskServiceVerification verifier = new TaskServiceVerification(taskService); - private final ApproveOrderTaskController controller = new ApproveOrderTaskController(taskService); - private String taskId; - - @BeforeEach - public void prepareTest() { - reset(taskService); - taskId = UUID.randomUUID().toString(); - } - - @Test - public void testLoadTask() { - // given - new TaskServiceStubBuilder(taskService) - .defineAndInitialize(ORDER, order) - .defineAndInitialize(ORDER_TOTAL, BigDecimal.ZERO) - .build(); - // when - ResponseEntity responseEntity = controller.loadTask(taskId); - // then - assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(responseEntity.getBody()).isEqualTo(new ApproveTaskDto(order, BigDecimal.ZERO)); - verifier.verifyGet(ORDER, taskId); - verifier.verifyGet(ORDER_TOTAL, taskId); - verifier.verifyNoMoreInteractions(); - } - - @Test - public void testCompleteTask() { - // when - ApproveTaskCompleteDto response = new ApproveTaskCompleteDto(true); - ResponseEntity responseEntity = controller.completeTask(taskId, response); - // then - assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); - verifier.verifyComplete(builder().set(ORDER_APPROVED, response.getApproved()).build(), taskId); - verifier.verifyNoMoreInteractions(); - } - -} diff --git a/example/example-kotlin/pom.xml b/example/example-kotlin/pom.xml index d118ca15..18e55394 100644 --- a/example/example-kotlin/pom.xml +++ b/example/example-kotlin/pom.xml @@ -121,11 +121,6 @@ spring-boot-starter-test test - - org.camunda.community.mockito - camunda-platform-7-mockito - test -
diff --git a/example/example-kotlin/src/test/kotlin/process/OrderApprovalDelegateTests.kt b/example/example-kotlin/src/test/kotlin/process/OrderApprovalDelegateTests.kt deleted file mode 100644 index e4c7a641..00000000 --- a/example/example-kotlin/src/test/kotlin/process/OrderApprovalDelegateTests.kt +++ /dev/null @@ -1,77 +0,0 @@ -package io.holunda.camunda.bpm.data.example.kotlin.process - -import io.holunda.camunda.bpm.data.CamundaBpmData.builder -import io.holunda.camunda.bpm.data.CamundaBpmData.reader -import io.holunda.camunda.bpm.data.example.kotlin.domain.OrderPosition -import io.holunda.camunda.bpm.data.example.kotlin.process.OrderApproval.Variables.ORDER_POSITION -import io.holunda.camunda.bpm.data.example.kotlin.process.OrderApproval.Variables.ORDER_TOTAL -import org.assertj.core.api.Assertions.assertThat -import org.camunda.community.mockito.CamundaMockito.delegateExecutionFake -import org.junit.jupiter.api.Test -import java.math.BigDecimal - -/** - * Class collecting delegate tests of the approval process. - */ -class OrderApprovalDelegateTests { - - /** - * Start with empty total and add position total from one position stored locally. - */ - @Test - fun `should calculate order position for empty total`() { - - // GIVEN - val execution = delegateExecutionFake() - .withVariables( - builder() - .set(ORDER_TOTAL, BigDecimal.valueOf(0.0)) - .build() - ).withVariablesLocal( - builder() - .set(ORDER_POSITION, OrderPosition("position 1", BigDecimal.valueOf(10.10), 1)) - .build() - ) - - // WHEN - OrderApproval().calculateOrderPositions().execute(execution) - - // THEN - val newTotal = reader(execution).get(ORDER_TOTAL) - assertThat(newTotal).isEqualTo(BigDecimal.valueOf(10.10)) - } - - /** - * Start with non-empty total and add several position totals from two positions stored locally. - */ - @Test - fun `should calculate order positions for existing total`() { - - // GIVEN - val execution = delegateExecutionFake() - .withVariables( - builder() - .set(ORDER_TOTAL, BigDecimal.valueOf(12.99)) - .build() - ).withVariablesLocal( - builder() - .set(ORDER_POSITION, OrderPosition("position 1", BigDecimal.valueOf(10.10), 1)) - .build() - ) - - // WHEN - // position 1 - OrderApproval().calculateOrderPositions().execute(execution) - // position 2 - OrderApproval().calculateOrderPositions().execute( - execution.withVariablesLocal( - builder().set(ORDER_POSITION, OrderPosition("position 2", BigDecimal.valueOf(5.05), 2)).build() - ) - ) - - // THEN - assertThat(ORDER_TOTAL.from(execution).get()).isEqualTo(BigDecimal.valueOf(33.19)) - } - -} - diff --git a/example/itest/pom.xml b/example/itest/pom.xml index 327a4ff8..d53e7196 100644 --- a/example/itest/pom.xml +++ b/example/itest/pom.xml @@ -121,11 +121,6 @@ jgiven-spring-junit5 test
- - org.camunda.community.mockito - camunda-platform-7-mockito - test -
diff --git a/example/itest/src/test/kotlin/SmartUpdateTest.kt b/example/itest/src/test/kotlin/SmartUpdateTest.kt deleted file mode 100644 index ed4c2cde..00000000 --- a/example/itest/src/test/kotlin/SmartUpdateTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package io.holunda.camunda.bpm.data - -import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable -import io.holunda.camunda.bpm.data.factory.VariableFactory -import org.camunda.bpm.engine.RuntimeService -import org.camunda.community.mockito.service.RuntimeServiceStubBuilder -import org.camunda.community.mockito.verify.RuntimeServiceVerification -import org.junit.jupiter.api.Test -import org.mockito.kotlin.mock -import java.util.* - -/** - * Test to verify that update is not touching a variable is the value has not changed. - */ -class SmartUpdateTest { - - companion object { - val MY_VAR: VariableFactory = stringVariable("myVar") - } - - @Test - fun should_not_touch_global() { - val execId = UUID.randomUUID().toString() - val runtime: RuntimeService = mock() - val verifier = RuntimeServiceVerification(runtime) - RuntimeServiceStubBuilder(runtime).defineAndInitialize(MY_VAR, "value").build() - MY_VAR.on(runtime, execId).update { "value" } - verifier.verifyGet(MY_VAR, execId) - verifier.verifyNoMoreInteractions() - } - - @Test - fun should_not_touch_local() { - val execId = UUID.randomUUID().toString() - val runtime: RuntimeService = mock() - val verifier = RuntimeServiceVerification(runtime) - RuntimeServiceStubBuilder(runtime).defineAndInitializeLocal(MY_VAR, "value").build() - MY_VAR.on(runtime, execId).updateLocal { "value" } - verifier.verifyGetLocal(MY_VAR, execId) - verifier.verifyNoMoreInteractions() - } -} diff --git a/extension/c7/pom.xml b/extension/c7/pom.xml index 97690757..2fb70cfb 100644 --- a/extension/c7/pom.xml +++ b/extension/c7/pom.xml @@ -103,11 +103,6 @@ jackson-module-kotlin test
- - org.camunda.community.mockito - camunda-platform-7-mockito - test - diff --git a/extension/core/pom.xml b/extension/core/pom.xml index 68d919b7..ef16fc0c 100644 --- a/extension/core/pom.xml +++ b/extension/core/pom.xml @@ -122,11 +122,6 @@ jackson-module-kotlin test
- - org.camunda.community.mockito - camunda-platform-7-mockito - test - diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/CamundaBpmDataTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/CamundaBpmDataTest.java index 1aeb2323..356b17eb 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/CamundaBpmDataTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/CamundaBpmDataTest.java @@ -23,7 +23,6 @@ import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables; -import org.camunda.community.mockito.delegate.DelegateExecutionFake; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateExecutionFake.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateExecutionFake.java new file mode 100644 index 00000000..c2d643c2 --- /dev/null +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateExecutionFake.java @@ -0,0 +1,273 @@ +package io.holunda.camunda.bpm.data; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.runtime.Incident; +import org.camunda.bpm.model.bpmn.BpmnModelInstance; +import org.camunda.bpm.model.bpmn.instance.FlowElement; +import org.mockito.Mockito; + +import java.util.HashMap; +import java.util.Map; + +import static org.mockito.Answers.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.when; + +/** + * Copy of the fake to avoid dependency to camunda-platform-7-mockito (to avoid cyclic dependency graph). + */ +@SuppressWarnings({"WeakerAccess","UnusedReturnValue", "unused"}) +public class DelegateExecutionFake extends DelegateFake implements DelegateExecution { + + private static final long serialVersionUID = -8413557219169444178L; + private String processInstanceId; + private String processBusinessKey; + private String processDefinitionId; + private String parentId; + private String currentActivityId; + private String currentActivityName; + private String activityInstanceId; + private String parentActivityInstanceId; + private String currentTransitionId; + private DelegateExecution processInstance; + private DelegateExecution superExecution; + private boolean canceled; + private String tenantId; + private String id; + private String eventName; + private String businessKey; + private final FlowElement flowElement = Mockito.mock(FlowElement.class, RETURNS_DEEP_STUBS); + + private final Map incidents = new HashMap<>(); + + public DelegateExecutionFake() { + this(null); + } + + public DelegateExecutionFake(final String id) { + withId(id); + } + + public static DelegateExecutionFake of() { + return new DelegateExecutionFake(); + } + + @Override + public String getProcessInstanceId() { + return processInstanceId; + } + public DelegateExecutionFake withProcessInstanceId(final String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + @Override + public String getProcessBusinessKey() { + return processBusinessKey; + } + + @Override + public void setProcessBusinessKey(String processBusinessKey) { + withProcessBusinessKey(processBusinessKey); + } + + public DelegateExecutionFake withProcessBusinessKey(final String processBusinessKey) { + this.processBusinessKey = processBusinessKey; + return this; + } + + @Override + public String getProcessDefinitionId() { + return processDefinitionId; + } + public DelegateExecutionFake withProcessDefinitionId(final String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + return this; + } + + @Override + public String getParentId() { + return parentId; + } + public DelegateExecutionFake withParentId(final String parentId) { + this.parentId = parentId; + return this; + } + + @Override + public String getCurrentActivityId() { + return currentActivityId; + } + public DelegateExecutionFake withCurrentActivityId(final String currentActivityId) { + this.currentActivityId = currentActivityId; + return this; + } + + @Override + public String getCurrentActivityName() { + return currentActivityName; + } + public DelegateExecutionFake withCurrentActivityName(final String currentActivityName) { + this.currentActivityName = currentActivityName; + return this; + } + + @Override + public String getActivityInstanceId() { + return activityInstanceId; + } + public DelegateExecutionFake withActivityInstanceId(final String activityInstanceId) { + this.activityInstanceId = activityInstanceId; + return this; + } + + @Override + public String getParentActivityInstanceId() { + return parentActivityInstanceId; + } + public DelegateExecutionFake withParentActivityInstanceId(final String parentActivityInstanceId) { + this.parentActivityInstanceId = parentActivityInstanceId; + return this; + } + + @Override + public String getCurrentTransitionId() { + return currentTransitionId; + } + public DelegateExecutionFake withCurrentTransitionId(final String currentTransitionId) { + this.currentTransitionId = currentTransitionId; + return this; + } + + @Override + public DelegateExecution getProcessInstance() { + return processInstance; + } + public DelegateExecutionFake withProcessInstance(final DelegateExecution processInstance) { + this.processInstance = processInstance; + return this; + } + + @Override + public DelegateExecution getSuperExecution() { + return superExecution; + } + public DelegateExecutionFake withSuperExecution(final DelegateExecution superExecution) { + this.superExecution = superExecution; + return this; + } + + @Override + public boolean isCanceled() { + return canceled; + } + public DelegateExecutionFake withCanceled(final boolean canceled) { + this.canceled = canceled; + return this; + } + + @Override + public String getTenantId() { + return tenantId; + } + public DelegateExecutionFake withTenantId(final String tenantId) { + this.tenantId = tenantId; + return this; + } + + @Override + public void setVariable(final String variableName, final Object value, final String activityId) { + setVariable(variableName, value); + } + + @Override + public Incident createIncident(final String incidentType, final String configuration) { + return createIncident(incidentType, configuration, null); + } + + @Override + public Incident createIncident(final String incidentType, final String configuration, final String message) { + return null; + } + + @Override + public void resolveIncident(final String incidentId) { + incidents.remove(incidentId); + } + + @Override + public String getId() { + return id; + } + public DelegateExecutionFake withId(final String id) { + this.id = id; + return this; + } + + @Override + public String getEventName() { + return eventName; + } + public DelegateExecutionFake withEventName(final String eventName) { + this.eventName = eventName; + return this; + } + + @Override + public String getBusinessKey() { + return businessKey; + } + public DelegateExecutionFake withBusinessKey(final String businessKey) { + this.businessKey = businessKey; + return this; + } + + @Override + public BpmnModelInstance getBpmnModelInstance() { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public FlowElement getBpmnModelElementInstance() { + return flowElement; + } + + public DelegateExecutionFake withBpmnModelElementInstanceType(String type) { + when(flowElement.getElementType().getTypeName()).thenReturn(type); + return this; + } + + + public Map getIncidents() { + return incidents; + } + + public static class ProcessInstanceNotSetException extends IllegalStateException { + private static final long serialVersionUID = 1739284977147050452L; + // empty + } + + @Override public String toString() { + return "DelegateExecutionFake{" + + "processInstanceId='" + processInstanceId + '\'' + + ", processEngine='" + getProcessEngine() + '\'' + + ", processEngineServices=" + getProcessEngineServices() + + ", processBusinessKey='" + processBusinessKey + '\'' + + ", processDefinitionId='" + processDefinitionId + '\'' + + ", parentId='" + parentId + '\'' + + ", currentActivityId='" + currentActivityId + '\'' + + ", currentActivityName='" + currentActivityName + '\'' + + ", activityInstanceId='" + activityInstanceId + '\'' + + ", parentActivityInstanceId='" + parentActivityInstanceId + '\'' + + ", currentTransitionId='" + currentTransitionId + '\'' + + ", processInstance=" + processInstance + + ", superExecution=" + superExecution + + ", canceled=" + canceled + + ", tenantId='" + tenantId + '\'' + + ", id='" + id + '\'' + + ", eventName='" + eventName + '\'' + + ", businessKey='" + businessKey + '\'' + + ", incidents=" + incidents + + '}'; + } +} diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateFake.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateFake.java new file mode 100644 index 00000000..99926f83 --- /dev/null +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateFake.java @@ -0,0 +1,33 @@ +package io.holunda.camunda.bpm.data; + +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.delegate.ProcessEngineServicesAware; + +/** + * Copy of the fake to avoid dependency to camunda-platform-7-mockito (to avoid cyclic dependency graph). + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +abstract class DelegateFake extends VariableScopeFake implements ProcessEngineServicesAware { + + + @Override + public ProcessEngineServices getProcessEngineServices() { + return null; + } + + public T withProcessEngineServices(ProcessEngineServices processEngineServices) { + return (T) this; + } + + + @Override + public ProcessEngine getProcessEngine() { + return null; + } + + public T withProcessEngine(ProcessEngine processEngine) { + return (T) this; + } + +} diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateTaskFake.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateTaskFake.java new file mode 100644 index 00000000..6369d3dd --- /dev/null +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/DelegateTaskFake.java @@ -0,0 +1,575 @@ +package io.holunda.camunda.bpm.data; + +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.delegate.DelegateCaseExecution; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.DelegateTask; +import org.camunda.bpm.engine.task.IdentityLink; +import org.camunda.bpm.model.bpmn.BpmnModelInstance; +import org.camunda.bpm.model.bpmn.instance.UserTask; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.StringJoiner; +import java.util.UUID; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import static org.camunda.bpm.engine.task.IdentityLinkType.CANDIDATE; + +/** + * Copy of the fake to avoid dependency to camunda-platform-7-mockito (to avoid cyclic dependency graph). + */ +@SuppressWarnings({ "WeakerAccess", "UnusedReturnValue", "unused" }) +public class DelegateTaskFake extends DelegateFake implements DelegateTask, Serializable { + + public static Set candidateUserIds(DelegateTask task) { + return userIds(task, CANDIDATE); + } + + public static Set candidateGroupIds(DelegateTask task) { + return groupIds(task, CANDIDATE); + } + + public static Set userIds(DelegateTask task) { + return userIds(task, null); + } + + public static Set userIds(DelegateTask task, String type) { + return linkIds(task, IdentityLink::getUserId, type); + } + + public static Set groupIds(DelegateTask task) { + return groupIds(task, null); + } + + public static Set groupIds(DelegateTask task, String type) { + return linkIds(task, IdentityLink::getGroupId, type); + } + + private static Set linkIds(DelegateTask task, Function extract, String type) { + return Optional.ofNullable(task.getCandidates()).orElseGet(HashSet::new) + .stream() + .filter(link -> type == null || type.equals(link.getType())) + .map(extract) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + } + + private static Predicate isUserLink = link -> link.getUserId() != null; + private static Predicate isGroupLink = link -> link.getGroupId() != null; + + private final Logger log = LoggerFactory.getLogger(this.getClass()); + private String id; + + private final Set candidates = new LinkedHashSet<>(); + + private String name; + private String description; + private int priority; + private String processInstanceId; + private String executionId; + private String processDefinitionId; + private String caseInstanceId; + private String caseExecutionId; + private String caseDefinitionId; + private Date createTime; + private Date lastUpdated; + private String taskDefinitionKey; + private String eventName; + private String owner; + private String assignee; + private Date dueDate; + private Date followUpDate; + private String deleteReason; + private String tenantId; + private boolean completed; + private ProcessEngine processEngine; + private ProcessEngineServices processEngineServices; + private DelegateExecution delegateExecution; + private DelegateCaseExecution delegateCaseExecution; + + public DelegateTaskFake() { + this(null); + } + + public DelegateTaskFake(final String id) { + withId(id); + } + + @Override + public String getId() { + return id; + } + + public DelegateTaskFake withId(String id) { + this.id = id; + return this; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = name; + } + + public DelegateTaskFake withName(String name) { + setName(name); + return this; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public void setDescription(String description) { + this.description = description; + } + + public DelegateTaskFake withDescription(String description) { + setDescription(description); + return this; + } + + @Override + public int getPriority() { + return priority; + } + + @Override + public void setPriority(int priority) { + this.priority = priority; + } + + public DelegateTaskFake withPriority(int priority) { + setPriority(priority); + return this; + } + + @Override + public String getProcessInstanceId() { + return valueFromCaseOrProcessExecution( + DelegateExecution::getProcessInstanceId, + c -> null, + processInstanceId + ); + } + + public DelegateTaskFake withProcessInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + + @Override + public String getProcessDefinitionId() { + return Optional.ofNullable(delegateExecution) + .map(DelegateExecution::getProcessDefinitionId) + .orElse(processDefinitionId); + } + + public DelegateTaskFake withProcessDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + return this; + } + + @Override + public String getCaseInstanceId() { + return Optional.ofNullable(delegateCaseExecution) + .map(DelegateCaseExecution::getCaseInstanceId) + .orElse(caseInstanceId); + } + + public DelegateTaskFake withCaseInstanceId(String caseInstanceId) { + this.caseInstanceId = caseInstanceId; + return this; + } + + @Override + public String getCaseExecutionId() { + return Optional.ofNullable(delegateCaseExecution) + .map(DelegateCaseExecution::getId) + .orElse(caseExecutionId); + } + + public DelegateTaskFake withCaseExecutionId(String caseExecutionId) { + this.caseExecutionId = caseExecutionId; + return this; + } + + @Override + public String getCaseDefinitionId() { + return Optional.ofNullable(delegateCaseExecution) + .map(DelegateCaseExecution::getCaseDefinitionId) + .orElse(caseDefinitionId); + } + + public DelegateTaskFake withCaseDefinitionId(String caseDefinitionId) { + this.caseDefinitionId = caseDefinitionId; + return this; + } + + @Override + public Date getCreateTime() { + return createTime; + } + + public DelegateTaskFake withCreateTime(Date createTime) { + this.createTime = createTime; + return this; + } + + @Override + public Date getLastUpdated() { + return null; + } + + public DelegateTaskFake withLastUpdated(Date lastUpdated) { + this.lastUpdated = lastUpdated; + return this; + } + + @Override + public String getTaskDefinitionKey() { + return taskDefinitionKey; + } + + public DelegateTaskFake withTaskDefinitionKey(String taskDefinitionKey) { + this.taskDefinitionKey = taskDefinitionKey; + return this; + } + + @Override + public DelegateExecution getExecution() { + return delegateExecution; + } + + /** + * Tries to cast execution to fake. + * + * @return delegate execution fake + */ + public DelegateExecutionFake getExecutionFake() { + return (DelegateExecutionFake) getExecution(); + } + + @Override + public String getExecutionId() { + return Optional.ofNullable(delegateExecution).map(DelegateExecution::getId).orElse(executionId); + } + + public DelegateTaskFake withExecutionId(String executionId) { + this.executionId = executionId; + return this; + } + + public DelegateTaskFake withExecution(DelegateExecution execution) { + this.delegateExecution = execution; + + return this; + } + + @Override + public DelegateCaseExecution getCaseExecution() { + return delegateCaseExecution; + } + + public DelegateTaskFake withCaseExecution(DelegateCaseExecution caseExecution) { + this.delegateCaseExecution = caseExecution; + + return this; + } + + @Override + public String getEventName() { + return eventName; + } + + public DelegateTaskFake withEventName(String eventName) { + this.eventName = eventName; + return this; + } + + private IdentityLink identityLink(String userId, String groupId, String type) { + return new IdentityLink() { + @Override + public String getId() { + return UUID.randomUUID().toString(); + } + + @Override + public String getType() { + return type; + } + + @Override + public String getUserId() { + return userId; + } + + @Override + public String getGroupId() { + return groupId; + } + + @Override + public String getTaskId() { + return getId(); + } + + @Override + public String getProcessDefId() { + return getProcessDefinitionId(); + } + + @Override + public String getTenantId() { + return valueFromCaseOrProcessExecution( + DelegateExecution::getTenantId, + DelegateCaseExecution::getTenantId, + tenantId + ); + } + + @Override + public String toString() { + return new StringJoiner(", ", IdentityLink.class.getSimpleName() + "[", "]") + .add("userId=" + getUserId()) + .add("groupId=" + getGroupId()) + .add("type=" + getType()) + .toString(); + } + }; + } + + @Override + public void addCandidateUser(String userId) { + addUserIdentityLink(userId, CANDIDATE); + } + + @Override + public void addCandidateUsers(Collection candidateUsers) { + candidateUsers.forEach(this::addCandidateUser); + } + + @Override + public void addCandidateGroup(String groupId) { + addGroupIdentityLink(groupId, CANDIDATE); + } + + @Override + public void addCandidateGroups(Collection candidateGroups) { + candidateGroups.forEach(this::addCandidateGroup); + } + + + @Override + public void addUserIdentityLink(String userId, String type) { + candidates.add(identityLink(userId, null, type)); + } + + @Override + public void addGroupIdentityLink(String groupId, String type) { + candidates.add(identityLink(null, groupId, type)); + } + + @Override + public void deleteCandidateUser(String userId) { + deleteUserIdentityLink(userId, CANDIDATE); + } + + @Override + public void deleteCandidateGroup(String groupId) { + deleteGroupIdentityLink(groupId, CANDIDATE); + } + + @Override + public void deleteUserIdentityLink(String userId, String type) { + candidates.removeIf(identityLink -> type.equals(identityLink.getType()) && identityLink.getUserId() != null && userId.equals( + identityLink.getUserId())); + } + + @Override + public void deleteGroupIdentityLink(String groupId, String type) { + candidates.removeIf(identityLink -> type.equals(identityLink.getType()) && identityLink.getGroupId() != null && groupId.equals( + identityLink.getGroupId())); + } + + @Override + public Set getCandidates() { + return candidates; + } + + @Override + public String getOwner() { + return owner; + } + + @Override + public void setOwner(String owner) { + this.owner = owner; + } + + @Override + public String getAssignee() { + return assignee; + } + + @Override + public void setAssignee(String assignee) { + this.assignee = assignee; + } + + public DelegateTaskFake withAssignee(String assignee) { + setAssignee(assignee); + return this; + } + + @Override + public Date getDueDate() { + return dueDate; + } + + @Override + public void setDueDate(Date dueDate) { + this.dueDate = dueDate; + } + + @Override + public String getDeleteReason() { + return deleteReason; + } + + public DelegateTaskFake withDeleteReason(String deleteReason) { + this.deleteReason = deleteReason; + return this; + } + + + @Override + public BpmnModelInstance getBpmnModelInstance() { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public UserTask getBpmnModelElementInstance() { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public String getTenantId() { + return valueFromCaseOrProcessExecution( + DelegateExecution::getTenantId, + DelegateCaseExecution::getTenantId, + tenantId + ); + } + + @Override + public Date getFollowUpDate() { + return followUpDate; + } + + @Override + public void setFollowUpDate(Date followUpDate) { + this.followUpDate = followUpDate; + } + + public DelegateTaskFake withFollowUpDate(Date followUpDate) { + setFollowUpDate(followUpDate); + return this; + } + + public DelegateTaskFake withTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + @Override + public void complete() { + log.info("task completed!"); + this.completed = true; + } + + public boolean isCompleted() { + return completed; + } + + @Override + public ProcessEngineServices getProcessEngineServices() { + return valueFromCaseOrProcessExecution( + DelegateExecution::getProcessEngineServices, + DelegateCaseExecution::getProcessEngineServices, + null + ); + } + + @Override + public ProcessEngine getProcessEngine() { + return valueFromCaseOrProcessExecution( + DelegateExecution::getProcessEngine, + DelegateCaseExecution::getProcessEngine, + null + ); + } + + private T valueFromCaseOrProcessExecution( + Function fromProcess, + Function fromCase, + T fromTask) { + + return Optional.ofNullable(delegateExecution) + .map(fromProcess) + .orElse(Optional.ofNullable(delegateCaseExecution) + .map(fromCase) + .orElse(fromTask) + ); + } + + @Override + public String toString() { + return "DelegateTaskFake{" + + "id='" + id + '\'' + + ", candidates=" + candidates + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", priority=" + priority + + ", processInstanceId='" + processInstanceId + '\'' + + ", executionId='" + executionId + '\'' + + ", processDefinitionId='" + processDefinitionId + '\'' + + ", caseInstanceId='" + caseInstanceId + '\'' + + ", caseExecutionId='" + caseExecutionId + '\'' + + ", caseDefinitionId='" + caseDefinitionId + '\'' + + ", createTime=" + createTime + + ", lastUpdated=" + lastUpdated + + ", taskDefinitionKey='" + taskDefinitionKey + '\'' + + ", eventName='" + eventName + '\'' + + ", owner='" + owner + '\'' + + ", assignee='" + assignee + '\'' + + ", dueDate=" + dueDate + + ", deleteReason='" + deleteReason + '\'' + + ", tenantId='" + tenantId + '\'' + + ", completed=" + completed + + ", processEngine='" + getProcessEngine() + '\'' + + ", processEngineServices=" + getProcessEngineServices() + + ", delegateExecution=" + delegateExecution + + ", delegateCaseExecution=" + delegateCaseExecution + + '}'; + } +} diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/VariableScopeFake.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/VariableScopeFake.java new file mode 100644 index 00000000..f1ed83ca --- /dev/null +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/VariableScopeFake.java @@ -0,0 +1,81 @@ +package io.holunda.camunda.bpm.data; + +import io.holunda.camunda.bpm.data.factory.VariableFactory; +import org.camunda.bpm.engine.delegate.VariableScope; +import org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance; +import org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope; +import org.camunda.bpm.engine.impl.core.variable.scope.SimpleVariableInstance; +import org.camunda.bpm.engine.impl.core.variable.scope.VariableInstanceFactory; +import org.camunda.bpm.engine.impl.core.variable.scope.VariableInstanceLifecycleListener; +import org.camunda.bpm.engine.impl.core.variable.scope.VariableStore; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Copy of the fake to avoid dependency to camunda-platform-7-mockito (to avoid cyclic dependency graph). + */ +@SuppressWarnings({ "unchecked", "rawtypes" }) +public abstract class VariableScopeFake extends AbstractVariableScope implements VariableScope { + + protected VariableStore variableStore = new VariableStore<>(); + protected VariableInstanceFactory variableInstanceFactory = (name, value, isTransient) -> new SimpleVariableInstance( + name, + value); + + @Override + protected VariableStore getVariableStore() { + return variableStore; + } + + @Override + protected VariableInstanceFactory getVariableInstanceFactory() { + return variableInstanceFactory; + } + + @Override + public String getVariableScopeKey() { + return "fake"; + } + + @Override + protected List> getVariableInstanceLifecycleListeners() { + return Collections.EMPTY_LIST; + } + + @Override + public AbstractVariableScope getParentVariableScope() { + return null; + } + + public T withVariable(String variableName, Object value) { + setVariable(variableName, value); + return (T) this; + } + + public T withVariableLocal(String variableName, Object value) { + setVariableLocal(variableName, value); + return (T) this; + } + + public T withVariable(VariableFactory variable, V value) { + variable.on(this).set(value); + return (T) this; + } + + public T withVariableLocal(VariableFactory variable, V value) { + variable.on(this).setLocal(value); + return (T) this; + } + + public T withVariables(Map variables) { + setVariables(variables); + return (T) this; + } + + public T withVariablesLocal(Map variables) { + setVariablesLocal(variables); + return (T) this; + } +} diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableScopeReaderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableScopeReaderTest.java index a521d1b0..f8351d81 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableScopeReaderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/VariableScopeReaderTest.java @@ -1,9 +1,9 @@ package io.holunda.camunda.bpm.data.reader; import io.holunda.camunda.bpm.data.CamundaBpmData; +import io.holunda.camunda.bpm.data.DelegateExecutionFake; import io.holunda.camunda.bpm.data.factory.VariableFactory; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.community.mockito.delegate.DelegateExecutionFake; import org.junit.jupiter.api.Test; import static io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable; diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriterTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriterTest.java index 5f7111f8..de49d1e9 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriterTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/writer/VariableScopeWriterTest.java @@ -1,8 +1,8 @@ package io.holunda.camunda.bpm.data.writer; import io.holunda.camunda.bpm.data.CamundaBpmData; +import io.holunda.camunda.bpm.data.DelegateExecutionFake; import io.holunda.camunda.bpm.data.factory.VariableFactory; -import org.camunda.community.mockito.delegate.DelegateExecutionFake; import org.junit.jupiter.api.Test; import static io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable; diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt index f9d1fad7..7525c90e 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt @@ -14,7 +14,6 @@ import org.camunda.bpm.engine.RuntimeService import org.camunda.bpm.engine.TaskService import org.camunda.bpm.engine.variable.Variables.createVariables import org.camunda.bpm.engine.variable.Variables.stringValue -import org.camunda.community.mockito.delegate.DelegateExecutionFake import org.junit.jupiter.api.Test import java.util.* diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/NullableMapTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/NullableMapTest.kt index 718df0f3..f1bbe146 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/NullableMapTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/NullableMapTest.kt @@ -6,7 +6,7 @@ import io.holunda.camunda.bpm.data.NullableMapTest.TestVariables.NO_NULL_MAP import io.holunda.camunda.bpm.data.NullableMapTest.TestVariables.NULL_MAP import io.holunda.camunda.bpm.data.factory.VariableFactory import org.assertj.core.api.Assertions.assertThat -import org.camunda.community.mockito.CamundaMockito.delegateExecutionFake +import org.camunda.bpm.engine.variable.Variables.createVariables import org.junit.jupiter.api.Test internal class NullableMapTest { @@ -19,7 +19,9 @@ internal class NullableMapTest { @Test fun `test null values map as no null value map`() { val data = mapOf("first" to 1, "second" to null, "last" to "string") - val mockExecution = delegateExecutionFake().withVariable(NO_NULL_MAP.name, data) + val mockExecution = DelegateExecutionFake().withVariables(createVariables().apply { + putValue(NO_NULL_MAP.name, data) + }) // NO_NULL_MAP.on(mockExecution).set(data) // won't compile, wrong type val map: Map = NO_NULL_MAP.from(mockExecution).get() val second = map.getValue("second") @@ -30,7 +32,7 @@ internal class NullableMapTest { @Test fun `test null values map`() { val data = mapOf("first" to 1, "second" to null, "last" to "string") - val mockExecution = delegateExecutionFake() + val mockExecution = DelegateExecutionFake() NULL_MAP.on(mockExecution).set(data) // val result: Map = NULL_MAP.from(mockExecution).get() // no assignable val result: Map = NULL_MAP.from(mockExecution).get() diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/VariablesGuardTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/VariablesGuardTest.kt index c70914e9..5da7567e 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/VariablesGuardTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/VariablesGuardTest.kt @@ -9,7 +9,7 @@ import io.holunda.camunda.bpm.data.guard.VariablesGuard import io.holunda.camunda.bpm.data.guard.VariablesGuard.Companion.ALL import io.holunda.camunda.bpm.data.guard.VariablesGuard.Companion.ONE_OF import org.assertj.core.api.Assertions.assertThat -import org.camunda.community.mockito.delegate.DelegateExecutionFake +import org.camunda.bpm.engine.variable.Variables import org.junit.jupiter.api.Test import java.util.* @@ -54,15 +54,27 @@ class VariablesGuardTest { @Test fun shouldEvaluateOneOf() { val executionWithBoth = DelegateExecutionFake() - .withVariable(FOO.name, "foo") - .withVariable(BAR.name, "bar") - + .withVariables( + Variables.createVariables().apply { + putValue(FOO.name, "foo") + putValue(BAR.name, "bar") + } + ) val executionWithBAR = DelegateExecutionFake() - .withVariable(BAR.name, "bar") + .withVariables( + Variables.createVariables().apply { + putValue(BAR.name, "bar") + } + ) + val executionWithFOO = DelegateExecutionFake() - .withVariable(FOO.name, "foo") + .withVariables( + Variables.createVariables().apply { + putValue(FOO.name, "foo") + } + ) val emptyExecution = DelegateExecutionFake() @@ -81,11 +93,19 @@ class VariablesGuardTest { @Test fun shouldEvaluateAll() { val executionWithBoth = DelegateExecutionFake() - .withVariable(FOO.name, "foo") - .withVariable(BAR.name, "bar") + .withVariables( + Variables.createVariables().apply { + putValue(FOO.name, "foo") + putValue(BAR.name, "bar") + } + ) val executionWithFOO = DelegateExecutionFake() - .withVariable(FOO.name, "foo") + .withVariables( + Variables.createVariables().apply { + putValue(FOO.name, "foo") + } + ) val emptyExecution = DelegateExecutionFake() diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt index 7efa480d..52c9a363 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/ACLTest.kt @@ -15,8 +15,8 @@ import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.task import org.camunda.bpm.engine.test.junit5.ProcessEngineExtension import org.camunda.bpm.engine.test.mock.MockExpressionManager +import org.camunda.bpm.engine.test.mock.Mocks import org.camunda.bpm.engine.variable.VariableMap -import org.camunda.community.mockito.CamundaMockito.registerInstance import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -47,7 +47,7 @@ class TransientVariableMappingListenerTest { fun `ACL signal sub-process with variables does not set variables on processInstance`() { // given - registerInstance("mapper", ACL_LR.getExecutionListener()) + Mocks.register("mapper", ACL_LR.getExecutionListener()) val processInstance = camunda.runtimeService.startProcessInstanceByKey( "eventBasedSubprocess_with_transientMapping" @@ -72,7 +72,7 @@ class TransientVariableMappingListenerTest { fun `ACL signal sub-process with variables passes guard sets does not set variables on process instance`() { // given - registerInstance("mapper", ACL_GTLR.getExecutionListener()) + Mocks.register("mapper", ACL_GTLR.getExecutionListener()) val processInstance = camunda.runtimeService.startProcessInstanceByKey( "eventBasedSubprocess_with_transientMapping" diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt index 53979f32..5e71a784 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/acl/AntiCorruptionLayerTest.kt @@ -3,6 +3,8 @@ package io.holunda.camunda.bpm.data.acl import io.holunda.camunda.bpm.data.CamundaBpmData.builder import io.holunda.camunda.bpm.data.CamundaBpmData.customVariable import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable +import io.holunda.camunda.bpm.data.DelegateExecutionFake +import io.holunda.camunda.bpm.data.DelegateTaskFake import io.holunda.camunda.bpm.data.acl.transform.IdentityVariableMapTransformer import io.holunda.camunda.bpm.data.acl.transform.VariableMapTransformer import io.holunda.camunda.bpm.data.guard.CamundaBpmDataGuards.exists @@ -16,8 +18,6 @@ import org.camunda.bpm.engine.impl.context.Context import org.camunda.bpm.engine.test.mock.MockExpressionManager import org.camunda.bpm.engine.variable.VariableMap import org.camunda.bpm.engine.variable.value.ObjectValue -import org.camunda.community.mockito.delegate.DelegateExecutionFake -import org.camunda.community.mockito.delegate.DelegateTaskFake import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardExecutionListenerTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardExecutionListenerTest.kt index 74e16b25..fc0e001a 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardExecutionListenerTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardExecutionListenerTest.kt @@ -1,11 +1,11 @@ package io.holunda.camunda.bpm.data.guard.integration import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable +import io.holunda.camunda.bpm.data.DelegateExecutionFake import io.holunda.camunda.bpm.data.guard.VariablesGuard import io.holunda.camunda.bpm.data.guard.condition.exists import io.holunda.camunda.bpm.data.guard.condition.hasValue import org.assertj.core.api.Assertions.assertThat -import org.camunda.community.mockito.delegate.DelegateExecutionFake import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -15,7 +15,7 @@ class GuardExecutionListenerTest { @Test fun `should do nothing`() { - val execution = DelegateExecutionFake().withId("4711").withCurrentActivityName("some") + val execution = DelegateExecutionFake.of().withId("4711").withCurrentActivityName("some") ORDER_REFERENCE.on(execution).set("1") val listener = createListener(true) @@ -27,7 +27,7 @@ class GuardExecutionListenerTest { @Test fun `should not throw exception if disabled `() { - val execution = DelegateExecutionFake().withId("4711").withCurrentActivityName("some") + val execution = DelegateExecutionFake.of().withId("4711").withCurrentActivityName("some") ORDER_REFERENCE.on(execution).set("2") val listener = createListener(false) @@ -39,7 +39,7 @@ class GuardExecutionListenerTest { @Test fun `should throw exception if enabled `() { - val execution = DelegateExecutionFake().withId("4711").withCurrentActivityName("some") + val execution = DelegateExecutionFake.of().withId("4711").withCurrentActivityName("some") ORDER_REFERENCE.on(execution).set("2") val listener = createListener(true) diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardTaskListenerTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardTaskListenerTest.kt index 01250ec3..0fdf41f8 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardTaskListenerTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/guard/integration/GuardTaskListenerTest.kt @@ -1,11 +1,11 @@ package io.holunda.camunda.bpm.data.guard.integration import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable +import io.holunda.camunda.bpm.data.DelegateTaskFake import io.holunda.camunda.bpm.data.guard.VariablesGuard import io.holunda.camunda.bpm.data.guard.condition.exists import io.holunda.camunda.bpm.data.guard.condition.hasValue import org.assertj.core.api.Assertions.assertThat -import org.camunda.community.mockito.delegate.DelegateTaskFake import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/pom.xml b/pom.xml index 515ed226..689e53a5 100644 --- a/pom.xml +++ b/pom.xml @@ -19,9 +19,9 @@ ${java.version} 7.19.0 - 7.18.0-ee + 7.19.0-ee - 2.7.5 + 2.7.6 1.21.0 ${camunda.version.ce} @@ -86,23 +86,6 @@ pom ${spin.version} - - - org.camunda.community.mockito - camunda-platform-7-mockito - ${camunda-platform-7-mockito.version} - test - - - io.holunda.data - camunda-bpm-data - - - io.holunda.data - camunda-bpm-data-test - - - org.camunda.bpm.springboot camunda-bpm-spring-boot-starter-test @@ -186,8 +169,8 @@ org.jetbrains.kotlin ${kotlin.version} - 1.5 - 1.5 + 1.9 + 1.9 -Xinline-classes From 84d9e594b1dcec7995c835cae301b112654adb38 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 6 Oct 2023 13:25:09 +0200 Subject: [PATCH 66/67] Update versions for release --- example/coverage-report-aggregator/pom.xml | 2 +- example/example-java/pom.xml | 2 +- example/example-kotlin/pom.xml | 2 +- example/example-no-engine/pom.xml | 2 +- example/itest/pom.xml | 2 +- example/pom.xml | 2 +- example/spin-type-detector/pom.xml | 2 +- extension/c7/pom.xml | 2 +- extension/core/pom.xml | 2 +- pom.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/example/coverage-report-aggregator/pom.xml b/example/coverage-report-aggregator/pom.xml index f016fae4..a046c084 100644 --- a/example/coverage-report-aggregator/pom.xml +++ b/example/coverage-report-aggregator/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT camunda-bpm-data-coverage-report diff --git a/example/example-java/pom.xml b/example/example-java/pom.xml index 4fc3eeef..10f333f2 100644 --- a/example/example-java/pom.xml +++ b/example/example-java/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT camunda-bpm-data-example-java diff --git a/example/example-kotlin/pom.xml b/example/example-kotlin/pom.xml index 18e55394..32624c7c 100644 --- a/example/example-kotlin/pom.xml +++ b/example/example-kotlin/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT camunda-bpm-data-example-kotlin diff --git a/example/example-no-engine/pom.xml b/example/example-no-engine/pom.xml index aea1b3be..7bf60f1a 100644 --- a/example/example-no-engine/pom.xml +++ b/example/example-no-engine/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT camunda-bpm-data-example-no-engine diff --git a/example/itest/pom.xml b/example/itest/pom.xml index d53e7196..2a355a5c 100644 --- a/example/itest/pom.xml +++ b/example/itest/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT camunda-bpm-data-integration-test diff --git a/example/pom.xml b/example/pom.xml index 8eae69ce..688be2b1 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT io.holunda.data.example diff --git a/example/spin-type-detector/pom.xml b/example/spin-type-detector/pom.xml index 2f0479e1..2138e7ff 100644 --- a/example/spin-type-detector/pom.xml +++ b/example/spin-type-detector/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT camunda-bpm-data-spin-type-detector diff --git a/extension/c7/pom.xml b/extension/c7/pom.xml index 2fb70cfb..d438e84d 100644 --- a/extension/c7/pom.xml +++ b/extension/c7/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT ../../pom.xml diff --git a/extension/core/pom.xml b/extension/core/pom.xml index ef16fc0c..5b1f1abe 100644 --- a/extension/core/pom.xml +++ b/extension/core/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 689e53a5..f2326044 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.9-SNAPSHOT + 1.3.0-SNAPSHOT ${project.artifactId} Camunda BPM Data https://github.com/holunda-io/camunda-bpm-data/ From 37459a4772d3ab67fb27735948ccf94e3fdc272b Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 6 Oct 2023 13:30:15 +0200 Subject: [PATCH 67/67] Update for next development version --- example/coverage-report-aggregator/pom.xml | 2 +- example/example-java/pom.xml | 2 +- example/example-kotlin/pom.xml | 2 +- example/example-no-engine/pom.xml | 2 +- example/itest/pom.xml | 2 +- example/pom.xml | 2 +- example/spin-type-detector/pom.xml | 2 +- extension/c7/pom.xml | 2 +- extension/core/pom.xml | 2 +- pom.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/example/coverage-report-aggregator/pom.xml b/example/coverage-report-aggregator/pom.xml index a046c084..62ead905 100644 --- a/example/coverage-report-aggregator/pom.xml +++ b/example/coverage-report-aggregator/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.3.0-SNAPSHOT + 1.3.0 camunda-bpm-data-coverage-report diff --git a/example/example-java/pom.xml b/example/example-java/pom.xml index 10f333f2..add495e9 100644 --- a/example/example-java/pom.xml +++ b/example/example-java/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.3.0-SNAPSHOT + 1.3.0 camunda-bpm-data-example-java diff --git a/example/example-kotlin/pom.xml b/example/example-kotlin/pom.xml index 32624c7c..e4d47a56 100644 --- a/example/example-kotlin/pom.xml +++ b/example/example-kotlin/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.3.0-SNAPSHOT + 1.3.0 camunda-bpm-data-example-kotlin diff --git a/example/example-no-engine/pom.xml b/example/example-no-engine/pom.xml index 7bf60f1a..35f7b21a 100644 --- a/example/example-no-engine/pom.xml +++ b/example/example-no-engine/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.3.0-SNAPSHOT + 1.3.0 camunda-bpm-data-example-no-engine diff --git a/example/itest/pom.xml b/example/itest/pom.xml index 2a355a5c..7729ca28 100644 --- a/example/itest/pom.xml +++ b/example/itest/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.3.0-SNAPSHOT + 1.3.0 camunda-bpm-data-integration-test diff --git a/example/pom.xml b/example/pom.xml index 688be2b1..36b84db0 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.3.0-SNAPSHOT + 1.3.0 io.holunda.data.example diff --git a/example/spin-type-detector/pom.xml b/example/spin-type-detector/pom.xml index 2138e7ff..4b3b22bb 100644 --- a/example/spin-type-detector/pom.xml +++ b/example/spin-type-detector/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.3.0-SNAPSHOT + 1.3.0 camunda-bpm-data-spin-type-detector diff --git a/extension/c7/pom.xml b/extension/c7/pom.xml index d438e84d..b37c3a2e 100644 --- a/extension/c7/pom.xml +++ b/extension/c7/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.3.0-SNAPSHOT + 1.3.0 ../../pom.xml diff --git a/extension/core/pom.xml b/extension/core/pom.xml index 5b1f1abe..168bb09d 100644 --- a/extension/core/pom.xml +++ b/extension/core/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.3.0-SNAPSHOT + 1.3.0 ../../pom.xml diff --git a/pom.xml b/pom.xml index f2326044..c260f5e6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.holunda.data camunda-bpm-data-parent - 1.3.0-SNAPSHOT + 1.3.0 ${project.artifactId} Camunda BPM Data https://github.com/holunda-io/camunda-bpm-data/