Skip to content

Commit

Permalink
Merge branch 'release/1.21.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jangalinski committed Jun 26, 2024
2 parents 6e68013 + 0413021 commit bf6832c
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 94 deletions.
126 changes: 61 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Camunda specific stages and scenarios for the BDD testing tool JGiven written in Kotlin.

[![stable](https://img.shields.io/badge/lifecycle-STABLE-green.svg)](https://github.com/holisticon#open-source-lifecycle)
[![Camunda 7.20](https://img.shields.io/badge/Camunda%20Version-7.20-orange.svg)]([https://github.com/holisticon#open-source-lifecycle](https://docs.camunda.org/manual/7.20/))
[![Development braches](https://github.com/holunda-io/camunda-bpm-jgiven/workflows/Development%20braches/badge.svg)](https://github.com/holunda-io/camunda-bpm-jgiven/workflows)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.holunda.testing/camunda-bpm-jgiven/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.holunda.testing/camunda-bpm-jgiven)

Expand All @@ -28,7 +29,7 @@ Add the following dependency to your Maven pom:
<dependency>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven</artifactId>
<version>0.4.0</version>
<version>1.20.0</version>
<scope>test</scope>
</dependency>
```
Expand All @@ -39,17 +40,18 @@ Stages contain assert and action methods and may be subclassed. This library pro
`ProcessStage` for building your process testing stages. Here is how the test then looks like
(written in Kotlin):

### JUnit4
### JUnit5

```kotlin
@Deployment(resources = [ApprovalProcessBean.RESOURCE])
open class ApprovalProcessTest : ScenarioTest<ApprovalProcessActionStage, ApprovalProcessActionStage, ApprovalProcessThenStage>() {
internal class ApprovalProcessTest :
ScenarioTest<ApprovalProcessActionStage, ApprovalProcessActionStage, ApprovalProcessThenStage>() {

@get: Rule
val rule: ProcessEngineRule = StandaloneInMemoryTestConfiguration().rule()
@RegisterExtension
val extension = TestProcessEngine.DEFAULT

@ScenarioState
val camunda = rule.processEngine
val camunda = extension.processEngine

@Test
fun`should automatically approve`() {
Expand Down Expand Up @@ -77,49 +79,46 @@ open class ApprovalProcessTest : ScenarioTest<ApprovalProcessActionStage, Approv
}
```

If you want to collect process test coverage during the test run, make sure to replace your rule declaration by the following:
Here is the corresponding stage, providing the steps used in the test:

```kotlin
companion object {
@get: ClassRule
@JvmStatic
val processEngineRule: ProcessEngineRule = TestCoverageProcessEngineRuleBuilder.create().build()
}

@get:Rule
val rule: ProcessEngineRule = processEngineRule

```
class ApprovalProcessActionStage : ProcessStage<ApprovalProcessActionStage, ApprovalProcessBean>() {

and add the following content into your `camunda.cfg.xml`:
@BeforeStage
fun `automock all delegates`() {
CamundaMockito.registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY)
CamundaMockito.registerJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST)
CamundaMockito.registerJavaDelegateMock(ApprovalProcessBean.Expressions.LOAD_APPROVAL_REQUEST)
}

```xml
<?xml version="1.0" encoding="UTF-8"?>
fun process_is_started_for_request(approvalRequestId: String) = step {
processInstanceSupplier = ApprovalProcessBean(camunda.processEngine)
processInstanceSupplier.start(approvalRequestId)
assertThat(processInstanceSupplier.processInstance).isNotNull
assertThat(processInstanceSupplier.processInstance).isStarted
}

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
fun approval_strategy_can_be_applied(approvalStrategy: String) = step {
getJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY).onExecutionSetVariables(Variables.putValue(APPROVAL_STRATEGY, approvalStrategy))
}

<bean id="processEngineConfiguration"
class="org.camunda.community.process_test_coverage.engine.platform7.ProcessCoverageInMemProcessEngineConfiguration">
<property name="history" value="full"/>
</bean>
</beans>
fun automatic_approval_returns(approvalDecision: String) = step {
getJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST).onExecutionSetVariables(Variables.putValue(APPROVAL_DECISION, approvalDecision))
}
}
```


### JUnit5
### JUnit4

```kotlin
@Deployment(resources = [ApprovalProcessBean.RESOURCE])
internal class ApprovalProcessTest :
ScenarioTest<ApprovalProcessActionStage, ApprovalProcessActionStage, ApprovalProcessThenStage>() {
open class ApprovalProcessTest : ScenarioTest<ApprovalProcessActionStage, ApprovalProcessActionStage, ApprovalProcessThenStage>() {

@RegisterExtension
val extension = TestProcessEngine.DEFAULT
@get: Rule
val rule: ProcessEngineRule = StandaloneInMemoryTestConfiguration().rule()

@ScenarioState
val camunda = extension.processEngine
val camunda = rule.processEngine

@Test
fun`should automatically approve`() {
Expand Down Expand Up @@ -147,35 +146,37 @@ internal class ApprovalProcessTest :
}
```

Here is the corresponding stage, providing the steps used in the test:
If you want to collect process test coverage during the test run, make sure to replace your rule declaration by the following:

```kotlin
class ApprovalProcessActionStage : ProcessStage<ApprovalProcessActionStage, ApprovalProcessBean>() {
companion object {
@get: ClassRule
@JvmStatic
val processEngineRule: ProcessEngineRule = TestCoverageProcessEngineRuleBuilder.create().build()
}

@BeforeStage
fun `automock all delegates`() {
CamundaMockito.registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY)
CamundaMockito.registerJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST)
CamundaMockito.registerJavaDelegateMock(ApprovalProcessBean.Expressions.LOAD_APPROVAL_REQUEST)
}
@get:Rule
val rule: ProcessEngineRule = processEngineRule

fun process_is_started_for_request(approvalRequestId: String) = step {
processInstanceSupplier = ApprovalProcessBean(camunda.processEngine)
processInstanceSupplier.start(approvalRequestId)
assertThat(processInstanceSupplier.processInstance).isNotNull
assertThat(processInstanceSupplier.processInstance).isStarted
}
```

fun approval_strategy_can_be_applied(approvalStrategy: String) = step {
getJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY).onExecutionSetVariables(Variables.putValue(APPROVAL_STRATEGY, approvalStrategy))
}
and add the following content into your `camunda.cfg.xml`:

fun automatic_approval_returns(approvalDecision: String) = step {
getJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST).onExecutionSetVariables(Variables.putValue(APPROVAL_DECISION, approvalDecision))
}
}
```xml
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="processEngineConfiguration"
class="org.camunda.community.process_test_coverage.engine.platform7.ProcessCoverageInMemProcessEngineConfiguration">
<property name="history" value="full"/>
</bean>
</beans>
```


The resulting report:

![JGiven Process Report](docs/report.png)
Expand All @@ -185,7 +186,10 @@ Interested? Check out the examples.

## License

APACHE 2.0
This library is developed under

[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](/LICENSE)


## Contribution

Expand All @@ -201,11 +205,3 @@ If you have permissions to release, make sure all branches are fetched and run:
from cli. This will update the poms of `develop` and `master` branches
and start GitHub actions producing a new release.


### Current maintainers

* [Simon Zambrovski](https://github.com/zambrovski)
* [Simon Sprünker](https://github.com/srsp)
* [Jan Galinski](https://github.com/jangalinski)
* [Andre Hegerath](https://github.com/a-hegerath)
* [Stefan Zilske](https://github.com/stefanzilske)
2 changes: 1 addition & 1 deletion examples/basic-junit4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven-examples</artifactId>
<version>1.20.0</version>
<version>1.21.0</version>
</parent>

<artifactId>camunda-bpm-jgiven-examples-basic-junit4</artifactId>
Expand Down
5 changes: 2 additions & 3 deletions examples/basic-junit5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven-examples</artifactId>
<version>1.20.0</version>
<version>1.21.0</version>
</parent>

<artifactId>camunda-bpm-jgiven-examples-basic-junit5</artifactId>
Expand Down Expand Up @@ -41,9 +41,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.extension</groupId>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bpm-junit5</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl
import org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin
import org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration
import org.camunda.bpm.engine.impl.history.HistoryLevel
import org.camunda.bpm.engine.test.junit5.ProcessEngineExtension
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.*
Expand Down
8 changes: 4 additions & 4 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<parent>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven-parent</artifactId>
<version>1.20.0</version>
<version>1.21.0</version>
</parent>

<artifactId>camunda-bpm-jgiven-examples</artifactId>
<packaging>pom</packaging>

<properties>
<spring-boot.version>3.1.4</spring-boot.version>
<camunda-process-test-coverage.version>2.2.0</camunda-process-test-coverage.version>
<camunda-platform-7-mockito.version>6.19.1</camunda-platform-7-mockito.version>
<spring-boot.version>3.2.5</spring-boot.version>
<camunda-process-test-coverage.version>2.6.0</camunda-process-test-coverage.version>
<camunda-platform-7-mockito.version>7.21.0</camunda-platform-7-mockito.version>
<junit.version>4.13.2</junit.version>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven-parent</artifactId>
<version>1.20.0</version>
<version>1.21.0</version>
</parent>

<artifactId>camunda-bpm-jgiven</artifactId>
Expand Down
Loading

0 comments on commit bf6832c

Please sign in to comment.