From f082252e25f00c764847fa5d1284d7df6dcdffe5 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 22 Nov 2022 14:52:14 +0100 Subject: [PATCH 01/28] Update for next development version --- examples/basic-junit5/pom.xml | 2 +- examples/basic/pom.xml | 2 +- examples/pom.xml | 2 +- extension/pom.xml | 2 +- pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/basic-junit5/pom.xml b/examples/basic-junit5/pom.xml index a421ada..ed66ad6 100644 --- a/examples/basic-junit5/pom.xml +++ b/examples/basic-junit5/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-examples - 0.4.0 + 0.4.1-SNAPSHOT camunda-bpm-jgiven-examples-basic-junit5 diff --git a/examples/basic/pom.xml b/examples/basic/pom.xml index 59fc6e5..6813924 100644 --- a/examples/basic/pom.xml +++ b/examples/basic/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-examples - 0.4.0 + 0.4.1-SNAPSHOT camunda-bpm-jgiven-examples-basic diff --git a/examples/pom.xml b/examples/pom.xml index 22bb59c..5b52eea 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-parent - 0.4.0 + 0.4.1-SNAPSHOT camunda-bpm-jgiven-examples diff --git a/extension/pom.xml b/extension/pom.xml index 9580916..c30180b 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-parent - 0.4.0 + 0.4.1-SNAPSHOT camunda-bpm-jgiven diff --git a/pom.xml b/pom.xml index 6714f9c..d8ac745 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.holunda.testing camunda-bpm-jgiven-parent - 0.4.0 + 0.4.1-SNAPSHOT pom From 103cf41e7233b0aedc18fc1948ae3d0d3a685c2b Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 22 Nov 2022 15:21:05 +0100 Subject: [PATCH 02/28] update docs and GH files --- .github/workflows/default.yml | 14 ++++---------- .github/workflows/master.yml | 19 +++++++------------ README.md | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 9533dd1..ab1fcab 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -17,20 +17,14 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 - - - name: Cache .m2 - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven + uses: actions/checkout@v3 - name: Set up JDK - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.jdk }} + distribution: zulu + cache: maven - name: Prepare Maven Wrapper run: chmod +x ./mvnw diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 9b710ec..6b61ed6 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -10,27 +10,22 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v1 - - - name: Cache .m2 - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven + uses: actions/checkout@v3 # Get GPG private key into GPG - name: Import GPG Owner Trust run: echo ${{ secrets.GPG_OWNERTRUST }} | base64 --decode | gpg --import-ownertrust + - name: Import GPG key run: echo ${{ secrets.GPG_SECRET_KEYS }} | base64 --decode | gpg --import --no-tty --batch --yes # Setup JDK and Maven - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 11.0.5 + distribution: zulu + cache: maven server-id: ossrh server-username: OSS_CENTRAL_USERNAME # env variable for Maven Central server-password: OSS_CENTRAL_PASSWORD # env variable for Maven Central @@ -44,5 +39,5 @@ 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 }}" diff --git a/README.md b/README.md index c69da6e..2b6bfd3 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Add the following dependency to your Maven pom: io.holunda.testing camunda-bpm-jgiven - 0.2.0 + 0.4.0 test ``` @@ -77,6 +77,37 @@ open class ApprovalProcessTest : ScenarioTest + + + + + + + +``` + + ### JUnit5 ```kotlin From 48f81a5247638bb5ecc83d19235b6f2b6d499a22 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 22 Nov 2022 15:38:08 +0100 Subject: [PATCH 03/28] chore: reactivate junit5 tests --- examples/basic-junit5/pom.xml | 7 ++++++- .../examples/basic/junit5/ApprovalProcessTest.kt | 3 --- pom.xml | 12 ++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/basic-junit5/pom.xml b/examples/basic-junit5/pom.xml index ed66ad6..902d681 100644 --- a/examples/basic-junit5/pom.xml +++ b/examples/basic-junit5/pom.xml @@ -21,6 +21,11 @@ com.h2database h2 + + org.junit.jupiter + junit-jupiter + test + org.camunda.community.mockito camunda-platform-7-mockito @@ -48,7 +53,7 @@ org.camunda.community.process_test_coverage - camunda-process-test-coverage-junit4-platform-7 + camunda-process-test-coverage-junit5-platform-7 ${camunda-process-test-coverage.version} test diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessTest.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessTest.kt index 8b3d6c2..0400106 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessTest.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessTest.kt @@ -11,14 +11,11 @@ import io.toolisticon.testing.jgiven.THEN import io.toolisticon.testing.jgiven.WHEN import org.camunda.bpm.engine.test.Deployment import org.camunda.bpm.engine.variable.Variables.putValue -import org.camunda.bpm.extension.junit5.test.ProcessEngineExtension import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.api.extension.RegisterExtension import java.time.Period import java.util.* -@ExtendWith(ProcessEngineExtension::class) @Deployment(resources = [ApprovalProcessBean.RESOURCE]) internal class ApprovalProcessTest : ScenarioTest() { diff --git a/pom.xml b/pom.xml index d8ac745..ab33d08 100644 --- a/pom.xml +++ b/pom.xml @@ -179,6 +179,18 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.2 + + org.apache.maven.plugins From bae351652a0430073cc6a6c48cf6bf550cc47ce3 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 22 Nov 2022 15:38:46 +0100 Subject: [PATCH 04/28] update readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 2b6bfd3..2faca00 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,6 @@ and add the following content into your `camunda.cfg.xml`: ### JUnit5 ```kotlin -@ExtendWith(ProcessEngineExtension::class) @Deployment(resources = [ApprovalProcessBean.RESOURCE]) internal class ApprovalProcessTest : ScenarioTest() { From 5fed4364d689b2a5fbcad5bb99a14fc56f802dd6 Mon Sep 17 00:00:00 2001 From: Jan Rohwer Date: Thu, 24 Nov 2022 08:45:53 +0100 Subject: [PATCH 05/28] feat: #139 add process test coverage to junit5 test setup --- .../testing/examples/basic/junit5/ApprovalProcessTest.kt | 7 +++++-- .../testing/examples/basic/junit5/TestProcessEngine.kt | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessTest.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessTest.kt index 0400106..fc9402f 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessTest.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessTest.kt @@ -20,8 +20,11 @@ import java.util.* internal class ApprovalProcessTest : ScenarioTest() { - @RegisterExtension - val extension = TestProcessEngine.DEFAULT + companion object { + @JvmField + @RegisterExtension + val extension = TestProcessEngine.DEFAULT + } @ScenarioState val camunda = extension.processEngine diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt index cd62f9f..21f2bbb 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt @@ -10,6 +10,8 @@ import org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration import org.camunda.bpm.engine.impl.history.HistoryLevel import org.camunda.bpm.engine.test.mock.MockExpressionManager import org.camunda.bpm.extension.junit5.test.ProcessEngineExtension +import org.camunda.community.process_test_coverage.engine.platform7.ProcessCoverageConfigurator +import org.camunda.community.process_test_coverage.junit5.platform7.ProcessEngineCoverageExtension import java.util.* import java.util.function.Consumer import java.util.stream.Collectors @@ -72,12 +74,9 @@ enum class TestProcessEngine { return this } - fun engine(): ProcessEngineImpl { - return configuration.buildProcessEngine() as ProcessEngineImpl - } - fun extension(): ProcessEngineExtension { - return ProcessEngineExtension.builder().useProcessEngine(engine()).build() + ProcessCoverageConfigurator.initializeProcessCoverageExtensions(configuration) + return ProcessEngineCoverageExtension.builder(configuration).build() } companion object { From 5a06c56b55490f5f28b7327c1b7157f784fb0d9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Nov 2022 23:02:43 +0000 Subject: [PATCH 06/28] chore(deps): bump kotlin.version from 1.7.21 to 1.7.22 Bumps `kotlin.version` from 1.7.21 to 1.7.22. Updates `kotlin-bom` from 1.7.21 to 1.7.22 - [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.7.21...v1.7.22) Updates `kotlin-maven-allopen` from 1.7.21 to 1.7.22 Updates `kotlin-maven-noarg` from 1.7.21 to 1.7.22 Updates `kotlin-maven-plugin` from 1.7.21 to 1.7.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 ab33d08..1a71364 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.2.4.0 11 - 1.7.21 + 1.7.22 true ${java.version} ${java.version} From a108bfeb81023a5242a7f82723e82e71ff74e71c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 23:00:49 +0000 Subject: [PATCH 07/28] chore(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] --- examples/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pom.xml b/examples/pom.xml index 5b52eea..7cf0319 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -15,7 +15,7 @@ 2.7.5 2.0.0 - 6.17.1 + 6.18.0 From 8be7d53b49a622a41bdef391911446d23e0d02dc Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 14 Dec 2022 11:00:05 +0100 Subject: [PATCH 08/28] fixing codacy --- .codacy.yaml | 9 + .../basic/junit5/TestProcessEngine.kt | 219 ++++++++++-------- .../examples/basic/ApprovalProcessBean.kt | 28 ++- .../jgiven/formatter/EntryRowFormatter.kt | 59 +++++ .../jgiven/formatter/VarargsFormatter.kt | 2 +- .../jgiven/formatter/VariableMapFormat.kt | 84 ------- .../formatter/VariableMapTableFormatter.kt | 34 +++ 7 files changed, 257 insertions(+), 178 deletions(-) create mode 100644 .codacy.yaml create mode 100644 extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/EntryRowFormatter.kt create mode 100644 extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VariableMapTableFormatter.kt diff --git a/.codacy.yaml b/.codacy.yaml new file mode 100644 index 0000000..27e0105 --- /dev/null +++ b/.codacy.yaml @@ -0,0 +1,9 @@ +--- +engines: + duplications: + exclude_paths: + - "**/src/test/kotlin/**" +exclude_paths: + - "README.md" + - ".github/**" + - "docs/**" diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt index cd62f9f..5a45cba 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt @@ -15,112 +15,147 @@ import java.util.function.Consumer import java.util.stream.Collectors import java.util.stream.Stream - +/** + * Test engine setup. + */ enum class TestProcessEngine { - ; - - class Builder internal constructor() { - private val configuration: ProcessEngineConfigurationImpl - - init { - configuration = StandaloneInMemProcessEngineConfiguration() - configuration.historyLevel = HistoryLevel.HISTORY_LEVEL_FULL - configuration.databaseSchemaUpdate = ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE - configuration.isJobExecutorActivate = false - configuration.isDbMetricsReporterActivate = false - configuration.expressionManager = MockExpressionManager() - configuration.isTelemetryReporterActivate = false - configuration.isInitializeTelemetry = false - } - - fun preInit(preInit: Consumer): Builder { - plugin(createPlugin(preInit, null, null)) - return this - } + ; + + class Builder internal constructor() { + private val configuration: ProcessEngineConfigurationImpl + + init { + configuration = StandaloneInMemProcessEngineConfiguration() + configuration.historyLevel = HistoryLevel.HISTORY_LEVEL_FULL + configuration.databaseSchemaUpdate = ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE + configuration.isJobExecutorActivate = false + configuration.isDbMetricsReporterActivate = false + configuration.expressionManager = MockExpressionManager() + configuration.isTelemetryReporterActivate = false + configuration.isInitializeTelemetry = false + } - fun postInit(postInit: Consumer): Builder { - plugin(createPlugin(null, postInit, null)) - return this - } + /** + * Function to register pre-init hooks. + */ + fun preInit(preInit: Consumer): Builder { + plugin(createPlugin(preInit, null, null)) + return this + } - fun postProcessEngineBuild(postProcessEngineBuild: Consumer): Builder { - plugin(createPlugin(null, null, postProcessEngineBuild)) - return this - } + /** + * Function to register post-init hooks. + */ + fun postInit(postInit: Consumer): Builder { + plugin(createPlugin(null, postInit, null)) + return this + } - fun withDefaultSerializationFormat(defaultSerializationFormat: String): Builder { - configuration.defaultSerializationFormat = defaultSerializationFormat - return this - } + /** + * Function to register post engine build hooks. + */ + fun postProcessEngineBuild(postProcessEngineBuild: Consumer): Builder { + plugin(createPlugin(null, null, postProcessEngineBuild)) + return this + } - fun plugin(plugin: ProcessEnginePlugin): Builder { - configuration.processEnginePlugins.add(plugin) - return this - } + /** + * Set serialization format. + */ + fun withDefaultSerializationFormat(defaultSerializationFormat: String): Builder { + configuration.defaultSerializationFormat = defaultSerializationFormat + return this + } - fun withH2MemNameDefault(): Builder { - return withH2MemName("camunda") - } + /** + * Adds an engine core plugin. + */ + fun plugin(plugin: ProcessEnginePlugin): Builder { + configuration.processEnginePlugins.add(plugin) + return this + } - fun withH2MemName(databaseName: String): Builder { - preInit { - it.jdbcUrl = String.format( - "jdbc:h2:mem:%s;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE", - databaseName - ) - } - return this - } + /** + * Sets default name for H" DB. + */ + fun withH2MemNameDefault(): Builder { + return withH2MemName("camunda") + } - fun engine(): ProcessEngineImpl { - return configuration.buildProcessEngine() as ProcessEngineImpl - } + /** + * Sets name of the Camunda H2 DB. + */ + fun withH2MemName(databaseName: String): Builder { + preInit { + it.jdbcUrl = String.format( + "jdbc:h2:mem:%s;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE", + databaseName + ) + } + return this + } - fun extension(): ProcessEngineExtension { - return ProcessEngineExtension.builder().useProcessEngine(engine()).build() - } + /** + * Retrieves the engine. + */ + fun engine(): ProcessEngineImpl { + return configuration.buildProcessEngine() as ProcessEngineImpl + } - companion object { - private fun createPlugin( - preInit: Consumer?, - postInit: Consumer?, - postProcessEngineBuild: Consumer? - ): ProcessEnginePlugin { - return object : AbstractProcessEnginePlugin() { - override fun preInit(processEngineConfiguration: ProcessEngineConfigurationImpl) { - preInit?.accept(processEngineConfiguration) - } - - override fun postInit(processEngineConfiguration: ProcessEngineConfigurationImpl) { - postInit?.accept(processEngineConfiguration) - } - - override fun postProcessEngineBuild(processEngine: ProcessEngine) { - postProcessEngineBuild?.accept(processEngine) - } - - override fun toString(): String { - return Stream.of(preInit, postInit, postProcessEngineBuild).map(Objects::nonNull) - .map { obj: Any -> obj.toString() } - .collect(Collectors.joining("-")) - } - } - } - } + /** + * Builds the JUnit5 extension. + */ + fun extension(): ProcessEngineExtension { + return ProcessEngineExtension.builder().useProcessEngine(engine()).build() } companion object { - // util class, final, no instance - val DEFAULT = builder() - .withDefaultSerializationFormat("application/json") - .extension() - - fun builder(): Builder { - return Builder() + private fun createPlugin( + preInit: Consumer?, + postInit: Consumer?, + postProcessEngineBuild: Consumer? + ): ProcessEnginePlugin { + return object : AbstractProcessEnginePlugin() { + override fun preInit(processEngineConfiguration: ProcessEngineConfigurationImpl) { + preInit?.accept(processEngineConfiguration) + } + + override fun postInit(processEngineConfiguration: ProcessEngineConfigurationImpl) { + postInit?.accept(processEngineConfiguration) + } + + override fun postProcessEngineBuild(processEngine: ProcessEngine) { + postProcessEngineBuild?.accept(processEngine) + } + + override fun toString(): String { + return Stream.of(preInit, postInit, postProcessEngineBuild).map(Objects::nonNull) + .map { obj: Any -> obj.toString() } + .collect(Collectors.joining("-")) + } } + } + } + } + + companion object { + // util class, final, no instance + val DEFAULT = builder() + .withDefaultSerializationFormat("application/json") + .extension() + + /** + * Creates the builder. + */ + fun builder(): Builder { + return Builder() + } - fun extension(): ProcessEngineExtension { - return builder().extension() - } + /** + * Creates the extension. + */ + fun extension(): ProcessEngineExtension { + return builder().extension() } + } } diff --git a/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/ApprovalProcessBean.kt b/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/ApprovalProcessBean.kt index 6b3ef0f..42d5675 100644 --- a/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/ApprovalProcessBean.kt +++ b/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/ApprovalProcessBean.kt @@ -4,7 +4,12 @@ import org.camunda.bpm.engine.ProcessEngine import org.camunda.bpm.engine.runtime.ProcessInstance import java.util.function.Supplier -class ApprovalProcessBean(private val processEngine: ProcessEngine) : Supplier { +/** + * Process backing bean. + */ +class ApprovalProcessBean( + private val processEngine: ProcessEngine +) : Supplier { companion object { const val KEY = "approval" @@ -15,6 +20,9 @@ class ApprovalProcessBean(private val processEngine: ProcessEngine) : Supplier

Map.Entry + * @param tableAnnotation for column setup. + */ +class EntryRowFormatter(private val tableAnnotation: Table) : RowFormatter() { + + /* + * Object formatter. + */ + private val formatter: ObjectFormatter = DefaultFormatter.INSTANCE + + override fun header(): MutableList { + return tableAnnotation.columnTitles.toMutableList() + } + + override fun formatRow(row: Any?): MutableList { + val columns = mutableListOf() + if (row is Map.Entry<*, *>) { + columns.add(formatter.format(row.key)) + val value = row.value + if (value is TypedValue) { + columns.add(formatter.format(value.value)) + columns.add(formatter.format(value.isTransient)) + } else { + columns.add(formatter.format(value)) + columns.add("n/a") + } + } else { + columns.add(formatter.format(row)) + } + return columns + } + + /** + * Factory. + */ + class Factory : RowFormatterFactory { + override fun create( + parameterType: Class<*>, + parameterName: String, + tableAnnotation: Table, + annotations: Array, + configuration: FormatterConfiguration, + objectFormatter: ObjectFormatter<*> + ): RowFormatter { + return EntryRowFormatter(tableAnnotation) + } + } +} \ No newline at end of file diff --git a/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VarargsFormatter.kt b/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VarargsFormatter.kt index af4949c..8dfd916 100644 --- a/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VarargsFormatter.kt +++ b/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VarargsFormatter.kt @@ -9,7 +9,7 @@ import com.tngtech.jgiven.format.PrintfFormatter */ open class VarargsFormatter : ArgumentFormatter { - /** + /* * Formatter. */ private val printfFormatter = PrintfFormatter() diff --git a/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VariableMapFormat.kt b/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VariableMapFormat.kt index ab63be6..981bdd6 100644 --- a/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VariableMapFormat.kt +++ b/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VariableMapFormat.kt @@ -1,16 +1,6 @@ package io.holunda.camunda.bpm.extension.jgiven.formatter import com.tngtech.jgiven.annotation.Table -import com.tngtech.jgiven.config.FormatterConfiguration -import com.tngtech.jgiven.format.DefaultFormatter -import com.tngtech.jgiven.format.ObjectFormatter -import com.tngtech.jgiven.format.table.DefaultTableFormatter -import com.tngtech.jgiven.format.table.RowFormatter -import com.tngtech.jgiven.format.table.RowFormatterFactory -import com.tngtech.jgiven.format.table.TableFormatterFactory -import com.tngtech.jgiven.report.model.DataTable -import org.camunda.bpm.engine.variable.VariableMap -import org.camunda.bpm.engine.variable.value.TypedValue /** @@ -27,77 +17,3 @@ import org.camunda.bpm.engine.variable.value.TypedValue @Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FIELD) annotation class VariableMapFormat -/** - * Formatter for process variables. - * @param formatterConfiguration config. - * @param objectFormatter formatter for single objects. - */ -class VariableMapTableFormatter(formatterConfiguration: FormatterConfiguration, objectFormatter: ObjectFormatter<*>) : - DefaultTableFormatter(formatterConfiguration, objectFormatter) { - - // FIXME: if we use meta-annotation, specify it here. - override fun format(argument: Any, tableAnnotation: Table, parameterName: String, vararg allAnnotations: Annotation): DataTable { - return if (argument is VariableMap) { - super.format(argument.entries, tableAnnotation, parameterName, *allAnnotations) - } else { - super.format(argument, tableAnnotation, parameterName, *allAnnotations) - } - } - - /** - * Factory. - */ - class Factory : TableFormatterFactory { - override fun create(formatterConfiguration: FormatterConfiguration, objectFormatter: ObjectFormatter<*>) = VariableMapTableFormatter(formatterConfiguration, objectFormatter) - } -} - -/** - * Formatter for single row, which is Map.Entry - * @param tableAnnotation for column setup. - */ -class EntryRowFormatter(private val tableAnnotation: Table) : RowFormatter() { - - /** - * Object formatter. - */ - private val formatter: ObjectFormatter = DefaultFormatter.INSTANCE - - override fun header(): MutableList { - return tableAnnotation.columnTitles.toMutableList() - } - - override fun formatRow(row: Any?): MutableList { - val columns = mutableListOf() - if (row is Map.Entry<*, *>) { - columns.add(formatter.format(row.key)) - val value = row.value - if (value is TypedValue) { - columns.add(formatter.format(value.value)) - columns.add(formatter.format(value.isTransient)) - } else { - columns.add(formatter.format(value)) - columns.add("n/a") - } - } else { - columns.add(formatter.format(row)) - } - return columns - } - - /** - * Factory. - */ - class Factory : RowFormatterFactory { - override fun create( - parameterType: Class<*>, - parameterName: String, - tableAnnotation: Table, - annotations: Array, - configuration: FormatterConfiguration, - objectFormatter: ObjectFormatter<*> - ): RowFormatter { - return EntryRowFormatter(tableAnnotation) - } - } -} diff --git a/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VariableMapTableFormatter.kt b/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VariableMapTableFormatter.kt new file mode 100644 index 0000000..bbea6ef --- /dev/null +++ b/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/formatter/VariableMapTableFormatter.kt @@ -0,0 +1,34 @@ +package io.holunda.camunda.bpm.extension.jgiven.formatter + +import com.tngtech.jgiven.annotation.Table +import com.tngtech.jgiven.config.FormatterConfiguration +import com.tngtech.jgiven.format.ObjectFormatter +import com.tngtech.jgiven.format.table.DefaultTableFormatter +import com.tngtech.jgiven.format.table.TableFormatterFactory +import com.tngtech.jgiven.report.model.DataTable +import org.camunda.bpm.engine.variable.VariableMap + +/** + * Formatter for process variables. + * @param formatterConfiguration config. + * @param objectFormatter formatter for single objects. + */ +class VariableMapTableFormatter(formatterConfiguration: FormatterConfiguration, objectFormatter: ObjectFormatter<*>) : + DefaultTableFormatter(formatterConfiguration, objectFormatter) { + + // FIXME: if we use meta-annotation, specify it here. + override fun format(argument: Any, tableAnnotation: Table, parameterName: String, vararg allAnnotations: Annotation): DataTable { + return if (argument is VariableMap) { + super.format(argument.entries, tableAnnotation, parameterName, *allAnnotations) + } else { + super.format(argument, tableAnnotation, parameterName, *allAnnotations) + } + } + + /** + * Factory. + */ + class Factory : TableFormatterFactory { + override fun create(formatterConfiguration: FormatterConfiguration, objectFormatter: ObjectFormatter<*>) = VariableMapTableFormatter(formatterConfiguration, objectFormatter) + } +} \ No newline at end of file From dd62b63518f4cbe8b8eec37ee2d47ecebe106ebd Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 14 Dec 2022 11:16:02 +0100 Subject: [PATCH 09/28] more comments --- .codacy.yaml | 4 --- .../examples/basic/ApprovalProcessBean.kt | 28 ++++++++++++++++++- .../examples/basic/BasicProcessApplication.kt | 6 ++++ .../basic/junit5/ApprovalProcessStages.kt | 18 ++++++++++++ .../basic/junit5/TestProcessEngine.kt | 3 ++ .../examples/basic/BasicProcessApplication.kt | 6 ++++ .../examples/basic/ApprovalProcessStages.kt | 18 ++++++++++++ 7 files changed, 78 insertions(+), 5 deletions(-) diff --git a/.codacy.yaml b/.codacy.yaml index 27e0105..d5ed4eb 100644 --- a/.codacy.yaml +++ b/.codacy.yaml @@ -1,8 +1,4 @@ --- -engines: - duplications: - exclude_paths: - - "**/src/test/kotlin/**" exclude_paths: - "README.md" - ".github/**" diff --git a/examples/basic-junit5/src/main/kotlin/io/holunda/testing/examples/basic/ApprovalProcessBean.kt b/examples/basic-junit5/src/main/kotlin/io/holunda/testing/examples/basic/ApprovalProcessBean.kt index 6b3ef0f..3b8a834 100644 --- a/examples/basic-junit5/src/main/kotlin/io/holunda/testing/examples/basic/ApprovalProcessBean.kt +++ b/examples/basic-junit5/src/main/kotlin/io/holunda/testing/examples/basic/ApprovalProcessBean.kt @@ -4,7 +4,12 @@ import org.camunda.bpm.engine.ProcessEngine import org.camunda.bpm.engine.runtime.ProcessInstance import java.util.function.Supplier -class ApprovalProcessBean(private val processEngine: ProcessEngine) : Supplier { +/** + * Process backing bean. + */ +class ApprovalProcessBean( + private val processEngine: ProcessEngine +) : Supplier { companion object { const val KEY = "approval" @@ -15,6 +20,9 @@ class ApprovalProcessBean(private val processEngine: ProcessEngine) : Supplier

) = runApplication(*args).let { Unit } +/** + * Main application class. + */ @EnableProcessApplication class BasicProcessApplication { diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt index 50e95eb..5d83d24 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt @@ -21,9 +21,15 @@ import org.camunda.bpm.engine.variable.Variables.putValue import org.camunda.community.mockito.DelegateExpressions.getJavaDelegateMock import org.camunda.community.mockito.DelegateExpressions.registerJavaDelegateMock +/** + * Process stage. + */ @JGivenProcessStage class ApprovalProcessActionStage : ProcessStage() { + /** + * mocks all expressions (delegates) of the process. + */ @BeforeStage fun mock_all_delegates() { registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY) @@ -32,6 +38,9 @@ class ApprovalProcessActionStage : ProcessStage() diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt index 5a45cba..feff07e 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt @@ -21,6 +21,9 @@ import java.util.stream.Stream enum class TestProcessEngine { ; + /** + * Creates the builder. + */ class Builder internal constructor() { private val configuration: ProcessEngineConfigurationImpl diff --git a/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt b/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt index 0d23fb6..aec6e91 100644 --- a/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt +++ b/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt @@ -8,8 +8,14 @@ import org.springframework.context.annotation.Bean import java.time.temporal.ChronoUnit import java.util.* +/** + * Starts the application. + */ fun main(args: Array) = runApplication(*args).let { Unit } +/** + * Main application class. + */ @EnableProcessApplication class BasicProcessApplication { diff --git a/examples/basic/src/test/kotlin/io/holunda/testing/examples/basic/ApprovalProcessStages.kt b/examples/basic/src/test/kotlin/io/holunda/testing/examples/basic/ApprovalProcessStages.kt index 8e3a4b7..13b10fa 100644 --- a/examples/basic/src/test/kotlin/io/holunda/testing/examples/basic/ApprovalProcessStages.kt +++ b/examples/basic/src/test/kotlin/io/holunda/testing/examples/basic/ApprovalProcessStages.kt @@ -19,9 +19,15 @@ import org.camunda.bpm.engine.variable.Variables.putValue import org.camunda.community.mockito.DelegateExpressions.getJavaDelegateMock import org.camunda.community.mockito.DelegateExpressions.registerJavaDelegateMock +/** + * Action stage for the test. + */ @JGivenProcessStage class ApprovalProcessActionStage : ProcessStage() { + /** + * Mocks registration. + */ @BeforeStage fun mock_all_delegates() { registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY) @@ -30,6 +36,9 @@ class ApprovalProcessActionStage : ProcessStage() From 782101ff19bd38d6e888aa8fc6f50096801c08e9 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 14 Dec 2022 11:27:51 +0100 Subject: [PATCH 10/28] integrate codacy push --- .github/workflows/default.yml | 5 +++++ .github/workflows/master.yml | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index ab1fcab..5e460a6 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -32,3 +32,8 @@ jobs: - name: Build with Maven run: ./mvnw clean verify -U -B -T4 + - 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}}" diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 6b61ed6..ea4fed0 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -41,3 +41,9 @@ jobs: env: 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 9e6f7f69486acfa88fede40c64303061aba1ca8f Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 14 Dec 2022 11:43:44 +0100 Subject: [PATCH 11/28] remove upload --- .github/workflows/default.yml | 10 +++++----- .github/workflows/master.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 5e460a6..8ab6d85 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -32,8 +32,8 @@ jobs: - name: Build with Maven run: ./mvnw clean verify -U -B -T4 - - 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}}" +# - 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}}" diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index ea4fed0..a355ad1 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -42,8 +42,8 @@ jobs: 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}}" +# - 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 298be296b8873c6a8334ca9683e158e9f129dabe Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 14 Dec 2022 11:54:40 +0100 Subject: [PATCH 12/28] codacy improves --- .codacy.yaml | 6 +++++- .../testing/examples/basic/BasicProcessApplication.kt | 3 +++ .../testing/examples/basic/BasicProcessApplication.kt | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.codacy.yaml b/.codacy.yaml index d5ed4eb..9d437b7 100644 --- a/.codacy.yaml +++ b/.codacy.yaml @@ -1,5 +1,9 @@ --- +engines: + duplications: + exclude_paths: + - "**/src/test/kotlin/**" exclude_paths: - "README.md" - ".github/**" - - "docs/**" + - "docs/**" \ No newline at end of file diff --git a/examples/basic-junit5/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt b/examples/basic-junit5/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt index aec6e91..58ac779 100644 --- a/examples/basic-junit5/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt +++ b/examples/basic-junit5/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt @@ -19,6 +19,9 @@ fun main(args: Array) = runApplication(*args).l @EnableProcessApplication class BasicProcessApplication { + /** + * Listener setting follow-up date. + */ @Bean(APPROVE_REQUEST_TASK_LISTENER) fun approveRequestTaskListener() = TaskListener { it.followUpDate = Date.from(it.createTime.toInstant().plus(1, ChronoUnit.DAYS)) diff --git a/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt b/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt index aec6e91..58ac779 100644 --- a/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt +++ b/examples/basic/src/main/kotlin/io/holunda/testing/examples/basic/BasicProcessApplication.kt @@ -19,6 +19,9 @@ fun main(args: Array) = runApplication(*args).l @EnableProcessApplication class BasicProcessApplication { + /** + * Listener setting follow-up date. + */ @Bean(APPROVE_REQUEST_TASK_LISTENER) fun approveRequestTaskListener() = TaskListener { it.followUpDate = Date.from(it.createTime.toInstant().plus(1, ChronoUnit.DAYS)) From 42193516714c46762b411b038e2f5657e6393f01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:01:26 +0000 Subject: [PATCH 13/28] chore(deps): bump assertj-core from 3.23.1 to 3.24.0 Bumps assertj-core from 3.23.1 to 3.24.0. --- updated-dependencies: - dependency-name: org.assertj:assertj-core 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 1a71364..47d6cfc 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 7.18.0 1.2.4 4.13.2 - 3.23.1 + 3.24.0 1.2.4.0 11 From d0b7fa8cacf5e5600513caca088c25857022a195 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jan 2023 23:02:01 +0000 Subject: [PATCH 14/28] chore(deps): bump assertj-core from 3.24.0 to 3.24.1 Bumps assertj-core from 3.24.0 to 3.24.1. --- updated-dependencies: - dependency-name: org.assertj:assertj-core 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 47d6cfc..744a9f9 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 7.18.0 1.2.4 4.13.2 - 3.24.0 + 3.24.1 1.2.4.0 11 From 424e215d564127914fce24147afdc569606be204 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 23:01:08 +0000 Subject: [PATCH 15/28] chore(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 744a9f9..af13cc5 100644 --- a/pom.xml +++ b/pom.xml @@ -113,7 +113,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.1.0 + 3.2.1 enforce-maven From b095b522bf8a853dc3f35e48c8d7ac5820c3cae2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 23:02:15 +0000 Subject: [PATCH 16/28] chore(deps): bump kotlin.version from 1.7.22 to 1.8.10 Bumps `kotlin.version` from 1.7.22 to 1.8.10. Updates `kotlin-bom` from 1.7.22 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.22...v1.8.10) Updates `kotlin-maven-allopen` from 1.7.22 to 1.8.10 Updates `kotlin-maven-noarg` from 1.7.22 to 1.8.10 Updates `kotlin-maven-plugin` from 1.7.22 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 af13cc5..7543236 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.2.4.0 11 - 1.7.22 + 1.8.10 true ${java.version} ${java.version} From d256295c4610dd7856c94651fc573ae6366c8724 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Feb 2023 23:56:52 +0000 Subject: [PATCH 17/28] chore(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 af13cc5..999b844 100644 --- a/pom.xml +++ b/pom.xml @@ -380,7 +380,7 @@ maven-deploy-plugin - 3.0.0 + 3.1.0 true From 9cb771a6dd61af20c119c15344e6859b590d3935 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Feb 2023 23:57:03 +0000 Subject: [PATCH 18/28] chore(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-junit` 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-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-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) Updates `jgiven-core` 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-junit dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.tngtech.jgiven:jgiven-junit5 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.tngtech.jgiven:jgiven-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.tngtech.jgiven:jgiven-core 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 999b844..4557c3a 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 7.18.0 - 1.2.4 + 1.2.5 4.13.2 3.24.1 1.2.4.0 From 8c2f505cfb678ab1069876771b0303197a21699b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Feb 2023 23:57:09 +0000 Subject: [PATCH 19/28] chore(deps): bump jgiven-kotlin from 1.2.4.0 to 1.2.5.0 Bumps [jgiven-kotlin](https://github.com/toolisticon/jgiven-kotlin) from 1.2.4.0 to 1.2.5.0. - [Release notes](https://github.com/toolisticon/jgiven-kotlin/releases) - [Commits](https://github.com/toolisticon/jgiven-kotlin/compare/1.2.4.0...1.2.5.0) --- updated-dependencies: - dependency-name: io.toolisticon.testing:jgiven-kotlin 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 999b844..f1dd2f6 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 1.2.4 4.13.2 3.24.1 - 1.2.4.0 + 1.2.5.0 11 1.7.22 From 37f04fe1a5bc7f72e8fe2616cd27978915f2c29d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:22:23 +0000 Subject: [PATCH 20/28] chore(deps): bump assertj-core from 3.24.1 to 3.24.2 Bumps assertj-core from 3.24.1 to 3.24.2. --- updated-dependencies: - dependency-name: org.assertj:assertj-core 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 3052f7f..f2dba3f 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 7.18.0 1.2.5 4.13.2 - 3.24.1 + 3.24.2 1.2.5.0 11 From 3f2a61b11be68ffb15655d39762c5fa70b058b8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:58:27 +0000 Subject: [PATCH 21/28] chore(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 f2dba3f..327d1f7 100644 --- a/pom.xml +++ b/pom.xml @@ -145,7 +145,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.11.0 UTF-8 ${java.version} From 4befba3506c162a1732a0a36869305d53f34bf99 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Mar 2023 23:57:08 +0000 Subject: [PATCH 22/28] chore(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 327d1f7..90b59e6 100644 --- a/pom.xml +++ b/pom.xml @@ -301,7 +301,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.7.20 + 1.8.10 test From d11197243e2167c92533dec667609066d9db7051 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 23:56:43 +0000 Subject: [PATCH 23/28] chore(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 90b59e6..ec75e4e 100644 --- a/pom.xml +++ b/pom.xml @@ -182,7 +182,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.0.0 From cafac181a98d960f32fda49d267b6f34fb1762f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 23:56:56 +0000 Subject: [PATCH 24/28] chore(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 90b59e6..cffbdba 100644 --- a/pom.xml +++ b/pom.xml @@ -188,7 +188,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.22.2 + 3.0.0 From d89804a09f849abf4c8d2fd89ff6f0a9770f684d Mon Sep 17 00:00:00 2001 From: Jan Galinski Date: Thu, 16 Mar 2023 10:50:22 +0100 Subject: [PATCH 25/28] maven 3.8.7, fixes #163 --- .mvn/wrapper/maven-wrapper.properties | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 6c8c0e0..7d02699 100755 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,18 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 2034eb44916e085b2bc83688390110c8a630eaff Mon Sep 17 00:00:00 2001 From: Jan Galinski Date: Thu, 16 Mar 2023 12:05:26 +0100 Subject: [PATCH 26/28] pass lackedExternalTask lambda to step, fixes #162 --- README.md | 4 +- .../src/main/resources/approval.bpmn | 2 +- .../basic/junit5/ApprovalProcessStages.kt | 5 +- .../basic/junit5/ApprovalProcessTest.kt | 65 +++++++++++++++++-- .../basic/junit5/TestProcessEngine.kt | 39 +++++------ .../bpm/extension/jgiven/ProcessStage.kt | 29 +++++---- 6 files changed, 99 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 2faca00..40b197d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ open class ApprovalProcessTest : ScenarioTest - + \ No newline at end of file diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt index 5d83d24..cbb6834 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt @@ -60,7 +60,10 @@ class ApprovalProcessActionStage : ProcessStage = mutableListOf()) : (LockedExternalTask) -> Unit{ + override fun invoke(task: LockedExternalTask) { + camunda.externalTaskService.complete(task.id, workerName, putValue(ApprovalProcessBean.Variables.APPROVAL_DECISION, Expressions.ApprovalDecision.APPROVE)) + activities.add(task.activityId) + } + + + } + + val worker = DummyWorker(workerName = "dummyWorker", topicName = "approve-request") + + val approvalRequestId = UUID.randomUUID().toString() + + GIVEN + .process_is_deployed(ApprovalProcessBean.KEY) + .AND + .process_is_started_for_request(approvalRequestId) + .AND + .approval_strategy_can_be_applied(Expressions.ApprovalStrategy.AUTOMATIC) + .AND + .process_continues() + + // not jgiven, but let's check here if the custom worker lambda works + assertThat(worker.activities).isEmpty() + + WHEN + .external_task_is_completed( + workerName = worker.workerName, + topicName = worker.topicName, + isAsyncAfter = false, + variables = createVariables(), + worker = worker + ) + + THEN + .process_is_finished() + .AND + .process_has_passed(Elements.SERVICE_AUTO_APPROVE, Elements.END_APPROVED) + + // not jgiven, but let's check here if the custom worker lambda works + assertThat(worker.activities).containsExactly("service_auto_approve_request") + } + @Test - internal fun `should automatically reject`() { + fun `should automatically reject`() { val approvalRequestId = UUID.randomUUID().toString() @@ -120,7 +171,7 @@ internal class ApprovalProcessTest : } @Test - internal fun `should manually reject`() { + fun `should manually reject`() { val approvalRequestId = UUID.randomUUID().toString() @@ -153,7 +204,7 @@ internal class ApprovalProcessTest : } @Test - internal fun `should manually approve`() { + fun `should manually approve`() { val approvalRequestId = UUID.randomUUID().toString() diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt index 0431eb0..be96eb4 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt @@ -20,8 +20,7 @@ import java.util.stream.Stream /** * Test engine setup. */ -enum class TestProcessEngine { - ; +object TestProcessEngine { /** * Creates the builder. @@ -111,8 +110,8 @@ enum class TestProcessEngine { * Builds the JUnit5 extension. */ fun extension(): ProcessEngineExtension { - ProcessCoverageConfigurator.initializeProcessCoverageExtensions(configuration) - return ProcessEngineCoverageExtension.builder(configuration).build() + ProcessCoverageConfigurator.initializeProcessCoverageExtensions(configuration) + return ProcessEngineCoverageExtension.builder(configuration).build() } companion object { @@ -144,24 +143,22 @@ enum class TestProcessEngine { } } - companion object { - // util class, final, no instance - val DEFAULT = builder() - .withDefaultSerializationFormat("application/json") - .extension() + // util class, final, no instance + val DEFAULT = builder() + .withDefaultSerializationFormat("application/json") + .extension() - /** - * Creates the builder. - */ - fun builder(): Builder { - return Builder() - } + /** + * Creates the builder. + */ + fun builder(): Builder { + return Builder() + } - /** - * Creates the extension. - */ - fun extension(): ProcessEngineExtension { - return builder().extension() - } + /** + * Creates the extension. + */ + fun extension(): ProcessEngineExtension { + return builder().extension() } } diff --git a/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/ProcessStage.kt b/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/ProcessStage.kt index 455c8dc..872c82f 100644 --- a/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/ProcessStage.kt +++ b/extension/src/main/kotlin/io/holunda/camunda/bpm/extension/jgiven/ProcessStage.kt @@ -8,6 +8,7 @@ import io.holunda.camunda.bpm.extension.jgiven.formatter.VariableMapFormat import io.toolisticon.testing.jgiven.step import org.assertj.core.api.Assertions.* import org.camunda.bpm.engine.ProcessEngine +import org.camunda.bpm.engine.externaltask.LockedExternalTask import org.camunda.bpm.engine.impl.persistence.entity.TimerEntity import org.camunda.bpm.engine.impl.util.ClockUtil import org.camunda.bpm.engine.runtime.ProcessInstance @@ -55,6 +56,7 @@ annotation class JGivenProcessStage @JGivenProcessStage class ProcessStage, PROCESS_BEAN : Supplier> : Stage() { + /** * Process engine to work on. */ @@ -398,7 +400,8 @@ class ProcessStage, PROCESS_BEAN : Suppl .singleResult() }.filterIsInstance() - assertThat(timerJobs).`as`("Expected one instance waiting in $timerActivityId, but found ${timerJobs.size}.").hasSize(1) + assertThat(timerJobs).`as`("Expected one instance waiting in $timerActivityId, but found ${timerJobs.size}.") + .hasSize(1) assertThat(timerJobs[0]).hasDueDate(truncatedToMinutes) } @@ -421,7 +424,8 @@ class ProcessStage, PROCESS_BEAN : Suppl .jobDefinitionId(jobDefinition.id) .singleResult() }.filterIsInstance() - assertThat(timerJobs).`as`("Expected one instance waiting in $timerActivityId, but found ${timerJobs.size}.").hasSize(1) + assertThat(timerJobs).`as`("Expected one instance waiting in $timerActivityId, but found ${timerJobs.size}.") + .hasSize(1) job_is_executed(timerActivityId) } @@ -450,9 +454,7 @@ class ProcessStage, PROCESS_BEAN : Suppl fun external_task_is_completed( @Quoted topicName: String, @VariableMapFormat variables: VariableMap = createVariables() - ): SELF = step { - external_task_is_completed(topicName, variables, false) - } + ): SELF = external_task_is_completed(topicName = topicName, variables = variables, isAsyncAfter = false) /** * Completes external task. @@ -464,20 +466,21 @@ class ProcessStage, PROCESS_BEAN : Suppl @As("external task on topic \$topicName is completed with variables \$variables") fun external_task_is_completed( @Quoted topicName: String, + @Quoted workerName: String = "test-worker", @VariableMapFormat variables: VariableMap = createVariables(), - isAsyncAfter: Boolean = false + @Hidden isAsyncAfter: Boolean = false, + @Hidden worker: (LockedExternalTask) -> Unit = { + camunda + .externalTaskService + .complete(it.id, workerName, variables) + } ): SELF = step { camunda .externalTaskService - .fetchAndLock(10, "test-worker") + .fetchAndLock(10, workerName) .topic(topicName, 1_000) .execute() - .forEach { - camunda - .externalTaskService - .complete(it.id, "test-worker", variables) - - } + .forEach(worker) if (isAsyncAfter) { process_continues() From 616daa5c55ba8529dfb2ea1f80d337409e18d32e Mon Sep 17 00:00:00 2001 From: Jan Galinski Date: Thu, 16 Mar 2023 13:34:11 +0100 Subject: [PATCH 27/28] process does not wait in, fixes #165 --- .../basic/junit5/ApprovalProcessStages.kt | 6 +- .../basic/junit5/ApprovalProcessTest.kt | 19 ++-- .../examples/basic/ApprovalProcessStages.kt | 5 +- .../bpm/extension/jgiven/ProcessStage.kt | 98 +++++++++++++++---- 4 files changed, 99 insertions(+), 29 deletions(-) diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt index cbb6834..f6ee3df 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/ApprovalProcessStages.kt @@ -53,7 +53,7 @@ class ApprovalProcessActionStage : ProcessStage = mutableListOf()) : (LockedExternalTask) -> Unit{ + class DummyWorker( + val workerName: String, + val topicName: String, + val activities: MutableList = mutableListOf() + ) : (LockedExternalTask) -> Unit { override fun invoke(task: LockedExternalTask) { - camunda.externalTaskService.complete(task.id, workerName, putValue(ApprovalProcessBean.Variables.APPROVAL_DECISION, Expressions.ApprovalDecision.APPROVE)) + camunda.externalTaskService.complete( + task.id, + workerName, + putValue(ApprovalProcessBean.Variables.APPROVAL_DECISION, Expressions.ApprovalDecision.APPROVE) + ) activities.add(task.activityId) } @@ -128,11 +136,10 @@ internal class ApprovalProcessTest : assertThat(worker.activities).isEmpty() WHEN - .external_task_is_completed( + .external_task_is_completed_by_worker( workerName = worker.workerName, topicName = worker.topicName, isAsyncAfter = false, - variables = createVariables(), worker = worker ) diff --git a/examples/basic/src/test/kotlin/io/holunda/testing/examples/basic/ApprovalProcessStages.kt b/examples/basic/src/test/kotlin/io/holunda/testing/examples/basic/ApprovalProcessStages.kt index 13b10fa..99c9a35 100644 --- a/examples/basic/src/test/kotlin/io/holunda/testing/examples/basic/ApprovalProcessStages.kt +++ b/examples/basic/src/test/kotlin/io/holunda/testing/examples/basic/ApprovalProcessStages.kt @@ -58,7 +58,10 @@ class ApprovalProcessActionStage : ProcessStage, PROCESS_BEAN : Suppl assertThat(processInstanceSupplier.get()).isWaitingAt(activityId) } + /** + * Checks if the process instance is _not_ waiting in an activity with specified id. + * @param activityId definition id. + * @return fluent stage. + */ + @As("process does not wait in $") + fun process_does_not_wait_in(@Quoted activityId: String): SELF = step { + assertThat(processInstanceSupplier.get()).isNotWaitingAt(activityId) + } + /** * Checks if the process instance is waiting in all activities with specified ids. * @param activityId definition id. @@ -444,6 +455,38 @@ class ProcessStage, PROCESS_BEAN : Suppl assertThat(externalTasks).isNotEmpty } + + /** + * Completes external task. + * + * @param topicName name of the topic. + * @param workerName optional, defaults to `test-worker` + * @param variables variables to set on completion, optional, defaults to empty map. + * @param isAsyncAfter executes the async job after completion, optional, defaults to `false`. + * @return fluent stage. + */ + private fun externalTaskIsCompleted( + topicName: String, + workerName: String = "test-worker", + variables: VariableMap = createVariables(), + isAsyncAfter: Boolean = false, + worker: (LockedExternalTask) -> Unit = defaultExternalTaskWorker( + workerName = workerName, + variables = variables + ) + ): SELF = step { + camunda + .externalTaskService + .fetchAndLock(10, workerName) + .topic(topicName, 1_000) + .execute() + .forEach(worker) + + if (isAsyncAfter) { + process_continues() + } + } + /** * Completes external task. If the task is marked as async-after, the process will not continue. * @param topicName name of the topic. @@ -454,7 +497,10 @@ class ProcessStage, PROCESS_BEAN : Suppl fun external_task_is_completed( @Quoted topicName: String, @VariableMapFormat variables: VariableMap = createVariables() - ): SELF = external_task_is_completed(topicName = topicName, variables = variables, isAsyncAfter = false) + ): SELF = externalTaskIsCompleted( + topicName = topicName, + variables = variables + ) /** * Completes external task. @@ -466,26 +512,33 @@ class ProcessStage, PROCESS_BEAN : Suppl @As("external task on topic \$topicName is completed with variables \$variables") fun external_task_is_completed( @Quoted topicName: String, - @Quoted workerName: String = "test-worker", @VariableMapFormat variables: VariableMap = createVariables(), - @Hidden isAsyncAfter: Boolean = false, - @Hidden worker: (LockedExternalTask) -> Unit = { - camunda - .externalTaskService - .complete(it.id, workerName, variables) - } - ): SELF = step { - camunda - .externalTaskService - .fetchAndLock(10, workerName) - .topic(topicName, 1_000) - .execute() - .forEach(worker) + @Hidden isAsyncAfter: Boolean = false + ): SELF = externalTaskIsCompleted(topicName = topicName, variables = variables, isAsyncAfter = isAsyncAfter) - if (isAsyncAfter) { - process_continues() - } - } + + /** + * Completes external task. + * + * @param topicName name of the topic. + * @param workerName optional, defaults to `test-worker` + * @param isAsyncAfter executes the async job after completion, optional, defaults to `false`. + * @param worker lambda with custom completion + * @return fluent stage. + */ + @As("external task on topic \$topicName is completed by worker \$workerName") + @JvmOverloads + fun external_task_is_completed_by_worker( + @Quoted topicName: String, + @Quoted workerName: String = "test-worker", + @Hidden isAsyncAfter: Boolean = false, + @Hidden worker: (LockedExternalTask) -> Unit + ): SELF = externalTaskIsCompleted( + topicName = topicName, + workerName = workerName, + isAsyncAfter = isAsyncAfter, + worker = worker + ) /** * Correlates message. @@ -511,4 +564,11 @@ class ProcessStage, PROCESS_BEAN : Suppl .correlate() } + internal fun defaultExternalTaskWorker( + externalTaskService: ExternalTaskService = camunda.externalTaskService, + workerName: String, + variables: VariableMap + ): (LockedExternalTask) -> Unit = { + externalTaskService.complete(it.id, workerName, variables) + } } From 504002145a5b36d7e48280303f7b1dd066a4eeba Mon Sep 17 00:00:00 2001 From: Jan Galinski Date: Thu, 16 Mar 2023 13:36:14 +0100 Subject: [PATCH 28/28] Update for next development version --- examples/basic-junit5/pom.xml | 2 +- examples/basic/pom.xml | 2 +- examples/pom.xml | 2 +- extension/pom.xml | 2 +- pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/basic-junit5/pom.xml b/examples/basic-junit5/pom.xml index 902d681..50726c4 100644 --- a/examples/basic-junit5/pom.xml +++ b/examples/basic-junit5/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-examples - 0.4.1-SNAPSHOT + 0.4.1 camunda-bpm-jgiven-examples-basic-junit5 diff --git a/examples/basic/pom.xml b/examples/basic/pom.xml index 6813924..ead58fe 100644 --- a/examples/basic/pom.xml +++ b/examples/basic/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-examples - 0.4.1-SNAPSHOT + 0.4.1 camunda-bpm-jgiven-examples-basic diff --git a/examples/pom.xml b/examples/pom.xml index 7cf0319..d9a0009 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-parent - 0.4.1-SNAPSHOT + 0.4.1 camunda-bpm-jgiven-examples diff --git a/extension/pom.xml b/extension/pom.xml index c30180b..99c0ca2 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-parent - 0.4.1-SNAPSHOT + 0.4.1 camunda-bpm-jgiven diff --git a/pom.xml b/pom.xml index f1c8051..cb097b9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.holunda.testing camunda-bpm-jgiven-parent - 0.4.1-SNAPSHOT + 0.4.1 pom