forked from camunda/camunda-bpm-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to CAM-11955
- Loading branch information
Showing
108 changed files
with
982 additions
and
813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Camunda Platform Assert | ||
|
||
**Camunda Platform Assert** makes it easy to assert the status of your BPMN processes and CMMN cases when driving them forward in your typical unit test methods. Simply write code like | ||
|
||
```groovy | ||
assertThat(instance).isWaitingAt("UserTask_InformCustomer"); | ||
assertThat(task).hasCandidateGroup("Sales").isNotAssigned(); | ||
``` | ||
|
||
Furthermore a set of static helper methods is provided to make it easier to drive through a process. Based on the [80/20 principle](https://en.wikipedia.org/wiki/Pareto_principle) the library reaches out to make those things simple you need really often. You will e.g. often have a single open task instance in your process instance. Then just write | ||
|
||
```groovy | ||
complete(task(instance), withVariables("approved", true)); | ||
``` | ||
|
||
## Compatibility | ||
|
||
Camunda Platform Assert works with the corresponding version of Camunda Platform (i.e., Camunda Platform Assert 7.17.0 is compatible to Camunda Platform 7.17.0). The compatibility between earlier versions are as shown [in the documentation](https://docs.camunda.org/manual/latest/user-guide/testing/#assertions-version-compatibility). | ||
Camunda Platform Assert works with multiple Java versions (1.8+). All of this is continuously verified by executing around 500 test cases. | ||
|
||
## Get started | ||
|
||
1. Add a maven test dependency to your project: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.camunda.bpm</groupId> | ||
<artifactId>camunda-bpm-assert</artifactId> | ||
<version>${camunda.platform.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
``` | ||
|
||
Additionally, [AssertJ](https://assertj.github.io/doc/) needs to be provided as a dependency with a version that is compatible with the one documented in the [compatibility matrix](https://docs.camunda.org/manual/latest/user-guide/testing/#assertions-version-compatibility). | ||
|
||
Please note that if you use [Spring Boot](https://spring.io/projects/spring-boot) or the [Camunda Spring Boot Starter](https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/) in your project, AssertJ is already included in your project's setup. | ||
|
||
2. Add a static import to your test class | ||
|
||
Create your test case just as described in the [Camunda Platform Testing Guide](https://docs.camunda.org/manual/latest/user-guide/testing/) and add Camunda Platform Assert by statically importing it in your test class: | ||
|
||
```groovy | ||
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*; | ||
``` | ||
|
||
3. Start using the assertions in your test methods | ||
|
||
You now have access to all the Camunda Platform assertions. Assuming you want to assert that your process instance is actually started, waiting at a specific user task and that task should yet be unassigned, but waiting to be assigned to a user of a specific group, just write: | ||
|
||
```groovy | ||
assertThat(processInstance).isStarted() | ||
.task().hasDefinitionKey("edit") | ||
.hasCandidateGroup("human-resources") | ||
.isNotAssigned(); | ||
``` | ||
|
||
In case you want to combine Camunda Platform Assert with the assertions provided by AssertJ, your imports should look like this: | ||
```groovy | ||
import static org.assertj.core.api.Assertions.*; | ||
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*; | ||
``` | ||
|
||
Find a more detailed description of the assertions and helper methods available in the Camunda Platform Assert [user guide](https://github.com/camunda/camunda-bpm-assert/blob/master/docs/README.md). | ||
|
||
## Credits | ||
|
||
The Camunda Platform Assert project used to be the community extension, created and supported by | ||
|
||
<img src="http://camunda.github.io/camunda-bpm-assert/resources/images/community-award.png" align="right" width="76"> | ||
|
||
[Martin Schimak](https://github.com/martinschimak) (plexiti GmbH)<a href="http://plexiti.com"> | ||
<img src="https://plexiti.com/images/plexiti-transparent.png" align="right"></img></a><br> | ||
[Jan Galinski](https://github.com/jangalinski) (Holisticon AG)<br> | ||
[Martin Günther](https://github.com/margue) (Holisticon AG)<br> | ||
[Malte Sörensen](https://github.com/malteser) (Holisticon AG)<br> | ||
<a href="http://www.holisticon.de"><img src="https://www.holisticon.de/wp-content/uploads/2020/08/logo2016_black_242.png" align="right" /></a>[Simon Zambrovski](https://github.com/zambrovski) (Holisticon AG) | ||
|
||
|
||
... and [many others](https://github.com/camunda/camunda-bpm-assert/graphs/contributors). | ||
|
||
In 2014, the library won the **Camunda Platform Community Award**. | ||
|
||
Starting from version 3.0.0 it was adopted as part of the Camunda Platform. | ||
Starting from version 7.17.0 it was merged into the Camunda Platform main repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>camunda-bpm-assert</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Camunda Platform - Assert</name> | ||
|
||
<parent> | ||
<groupId>org.camunda.bpm.assert.project</groupId> | ||
<artifactId>camunda-bpm-assert-root</artifactId> | ||
<version>15.0.0-SNAPSHOT</version> | ||
<groupId>org.camunda.bpm</groupId> | ||
<artifactId>camunda-database-settings</artifactId> | ||
<relativePath>../../database</relativePath> | ||
<version>7.17.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>org.camunda.bpm.assert</groupId> | ||
<artifactId>camunda-bpm-assert</artifactId> | ||
|
||
<packaging>jar</packaging> | ||
<properties> | ||
<version.slf4j>1.7.26</version.slf4j> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.camunda.bpm</groupId> | ||
<artifactId>camunda-core-internal-dependencies</artifactId> | ||
<version>${project.version}</version> | ||
<scope>import</scope> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>${version.slf4j}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<version>${version.slf4j}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.camunda.bpm</groupId> | ||
<artifactId>camunda-engine</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-inline</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.uuid</groupId> | ||
<artifactId>java-uuid-generator</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,16 +21,13 @@ | |
import org.camunda.bpm.engine.test.assertions.cmmn.CmmnAwareTests; | ||
|
||
/** | ||
* Convenience class to access all available Camunda Platform related | ||
* Convenience class to access all available Camunda Platform related | ||
* Assertions PLUS helper methods. Use it with a static import: | ||
* | ||
* import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*; | ||
* | ||
* | ||
* @see BpmnAwareTests if you only want to see BPMN related functionality | ||
* | ||
* @author Martin Schimak ([email protected]) | ||
* @author Martin Günther ([email protected]) | ||
* @author Malte Sörensen ([email protected]) | ||
*/ | ||
public class ProcessEngineTests extends CmmnAwareTests { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,17 +16,14 @@ | |
*/ | ||
package org.camunda.bpm.engine.test.assertions.bpmn; | ||
|
||
import java.util.Map; | ||
|
||
import org.camunda.bpm.engine.ProcessEngine; | ||
import org.camunda.bpm.engine.ProcessEngines; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author Martin Schimak ([email protected]) | ||
*/ | ||
public abstract class AbstractAssertions { | ||
|
||
static ThreadLocal<ProcessEngine> processEngine = new ThreadLocal<ProcessEngine>(); | ||
static ThreadLocal<ProcessEngine> processEngine = new ThreadLocal<>(); | ||
|
||
/** | ||
* Retrieve the processEngine bound to the current testing thread | ||
|
@@ -36,7 +33,7 @@ public abstract class AbstractAssertions { | |
* | ||
* @return processEngine bound to the current testing thread | ||
* @throws IllegalStateException in case a processEngine has not | ||
* been initialised yet and cannot be initialised with a | ||
* been initialised yet and cannot be initialised with a | ||
* default engine. | ||
*/ | ||
public static ProcessEngine processEngine() { | ||
|
Oops, something went wrong.