Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Oct 6, 2023
2 parents 33fbb99 + 37459a4 commit c688c5c
Show file tree
Hide file tree
Showing 215 changed files with 5,213 additions and 7,138 deletions.
10 changes: 8 additions & 2 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---
engines:
duplications:
exclude_paths:
- "**/src/test/kotlin/**"

exclude_paths:
- '.github/**'
- 'docs/**'
- "README.md"
- ".github/**"
- "docs/**"
- '**/packages.md'
10 changes: 8 additions & 2 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
cache: maven
distribution: zulu
java-version: 11
cache: maven

- name: Prepare mvnw
run: chmod +x ./mvnw
Expand All @@ -35,6 +35,12 @@ jobs:

- name: Upload coverage to Codecov
if: github.event_name == 'push' && github.actor != 'dependabot[bot]'
uses: codecov/codecov-action@v1.0.2
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}

- 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}}"
10 changes: 8 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ jobs:
- name: Deploy a new version to central
run: ./mvnw clean deploy -B -DskipTests -DskipExamples -Prelease -Dgpg.keyname="${{secrets.GPG_KEYNAME}}" -Dgpg.passphrase="${{secrets.GPG_PASSPHRASE}}"
env:
OSS_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
OSS_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
OSS_CENTRAL_USERNAME: "${{ secrets.SONATYPE_USERNAME }}"
OSS_CENTRAL_PASSWORD: "${{ secrets.SONATYPE_PASSWORD }}"

- name: Upload test coverage to Codacy
if: github.event_name == 'push' && github.actor != 'dependabot[bot]'
run: bash <(curl -Ls https://coverage.codacy.com/get.sh)
env:
CODACY_PROJECT_TOKEN: "${{secrets.CODACY_PROJECT_TOKEN}}"
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,18 @@ public class ApproveOrderTaskController {

If you want to write the test for the REST controller, you will need to stub
the task service and verify that the correct variables has been set. To simplify
these tests, we created an additional library module `camunda-bpm-data-test`.
Please put the following dependency into your `pom.xml`:
these tests, we added some helper code to the famous library `camunda-platform-7-mockito`.

``` xml
<dependency>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-test</artifactId>
<version>1.2.6</version>
<scope>test</scope>
</dependency>
```

Now you can use `TaskServiceVariableMockBuilder` to stub correct behavior of Camunda Task Service
and `TaskServiceVerifier` to verify the correct access to variables easily. Here is the JUnit
test of the REST controller above, making use of `camunda-bpm-data-test`.
Now you can use `TaskServiceVariableStubBuilder` to stub correct behavior of Camunda Task Service
and `TaskServiceVerification` to verify the correct access to variables easily. Here is the JUnit
test of the REST controller above, making use of `camunda-platform-7-mockito`.

``` java
public class ApproveOrderTaskControllerTest {

private static Order order = new Order("ORDER-ID-1", new Date(), new ArrayList<>());
private TaskService taskService = mock(TaskService.class);
private TaskServiceMockVerifier verifier = taskServiceMockVerifier(taskService);
private TaskServiceVerification verifier = new TaskServiceVerification(taskService);
private ApproveOrderTaskController controller = new ApproveOrderTaskController(taskService);
private String taskId;

Expand All @@ -167,7 +157,7 @@ public class ApproveOrderTaskControllerTest {
@Test
public void testLoadTask() {
// given
taskServiceVariableMockBuilder(taskService).initial(ORDER, order).build();
new TaskServiceVariableStubBuilder(taskService).initial(ORDER, order).build();
// when
ResponseEntity<ApproveTaskDto> responseEntity = controller.loadTask(taskId);
// then
Expand Down
1 change: 0 additions & 1 deletion docs/developer-guide/project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ Currently, the following modules are released to OSS Maven Central:

* camunda-bpm-data-parent
* camunda-bpm-data
* camunda-bpm-data-test

#### Trigger new release

Expand Down
64 changes: 0 additions & 64 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,67 +107,3 @@ public class ApproveOrderTaskController {
}

```

## Testing correct variable access

If you want to write the test for the REST controller, you will need to stub
the task service and verify that the correct variables has been set. To simplify
these tests, we created an additional library module `camunda-bpm-data-test`.
Please put the following dependency into your `pom.xml`:

```xml

<dependency>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-test</artifactId>
<version>${camunda-bpm-data.version}</version>
<scope>test</scope>
</dependency>
```

Now you can use `TaskServiceVariableMockBuilder` to stub correct behavior of Camunda Task Service
and `TaskServiceVerifier` to verify the correct access to variables easily. Here is the JUnit
test of the REST controller above, making use of `camunda-bpm-data-test`.


```java

public class ApproveOrderTaskControllerTest {

private static Order order = new Order("ORDER-ID-1", new Date(), new ArrayList<>());
private TaskService taskService = mock(TaskService.class);
private TaskServiceMockVerifier verifier = taskServiceMockVerifier(taskService);
private ApproveOrderTaskController controller = new ApproveOrderTaskController(taskService);
private String taskId;

@Before
public void prepareTest() {
reset(taskService);
taskId = UUID.randomUUID().toString();
}

@Test
public void testLoadTask() {
// given
taskServiceVariableMockBuilder(taskService).initial(ORDER, order).build();
// when
ResponseEntity<ApproveTaskDto> responseEntity = controller.loadTask(taskId);
// then
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isEqualTo(new ApproveTaskDto(order));
verifier.verifyGet(ORDER, taskId);
verifier.verifyNoMoreInteractions();
}

@Test
public void testCompleteTask() {
// when
ApproveTaskCompleteDto response = new ApproveTaskCompleteDto(true);
ResponseEntity<Void> responseEntity = controller.completeTask(taskId, response);
// then
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
verifier.verifyComplete(builder().set(ORDER_APPROVED, response.getApproved()).build(), taskId);
verifier.verifyNoMoreInteractions();
}
}
```
8 changes: 0 additions & 8 deletions docs/user-guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,3 @@
- Task listener to handle `VariableGuard`-based conditions and `VariableMapTransformer`-based modifications.
- Factory methods to create `AntiCorruptionLayer` with a `VariableGuard` (see `CamundaBpmDataACL`)
- Factory methods to create `AntiCorruptionLayer` without a `VariableGuard` (see `CamundaBpmDataMapper`)

* Testing variable access and mocking `RuntimeService`, `TaskService` and `CaseService` (will be moved to [camunda-platform-7-mockito](https://github.com/camunda-community-hub/camunda-platform-7-mockito))
- Builder to create Mockito-based behaviour of `RuntimeService` accessing variables.
- Builder to create Mockito-based behaviour of `TaskServiceService` accessing variables.
- Builder to create Mockito-based behaviour of `CaseServiceService` accessing variables.
- Verifier to check correct access to variables in `RuntimeService`
- Verifier to check correct access to variables in `TaskService`
- Verifier to check correct access to variables in `CaseService`
8 changes: 1 addition & 7 deletions example/coverage-report-aggregator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.2.8</version>
<version>1.3.0</version>
</parent>

<artifactId>camunda-bpm-data-coverage-report</artifactId>
Expand All @@ -24,12 +24,6 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-test</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-integration-test</artifactId>
Expand Down
61 changes: 13 additions & 48 deletions example/example-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.2.8</version>
<version>1.3.0</version>
</parent>

<artifactId>camunda-bpm-data-example-java</artifactId>
Expand Down Expand Up @@ -81,51 +81,10 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-datetime</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jmx</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jsr223</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-macro</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-nio</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-templates</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
</dependency>

<!-- Testing -->
<dependency>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.assert</groupId>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bpm-assert</artifactId>
<scope>test</scope>
</dependency>
Expand All @@ -134,11 +93,12 @@
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.community.mockito</groupId>
<artifactId>camunda-platform-7-mockito</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -150,6 +110,11 @@
<artifactId>camunda-bpm-jgiven</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bpm-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 0 additions & 3 deletions example/example-java/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ spring:
name: Camunda BPM Data Java Example
jpa:
open-in-view: true
groovy:
template:
check-template-location: false

camunda:
bpm:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package io.holunda.camunda.bpm.data.example.process;

import com.google.common.collect.Lists;
import io.holunda.camunda.bpm.data.example.domain.Order;
import io.holunda.camunda.bpm.data.guard.integration.GuardViolationException;
import org.camunda.bpm.engine.ProcessEngineException;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.bpm.engine.runtime.Job;
import org.camunda.bpm.engine.task.Task;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.camunda.bpm.engine.test.junit5.ProcessEngineExtension;
import org.camunda.bpm.engine.test.mock.Mocks;
import org.camunda.bpm.spring.boot.starter.test.helper.StandaloneInMemoryTestConfiguration;
import org.camunda.spin.plugin.impl.SpinProcessEnginePlugin;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.sql.Date;
import java.time.Instant;
Expand All @@ -25,12 +24,15 @@

@Deployment(resources = "order_approval.bpmn")
public class GuardProcessTest {
@Rule
public final ProcessEngineRule rule = new StandaloneInMemoryTestConfiguration(
Lists.newArrayList(new SpinProcessEnginePlugin())
).rule();

@Before
@RegisterExtension
private static final ProcessEngineExtension engine = ProcessEngineExtension
.builder()
.useProcessEngine(new StandaloneInMemoryTestConfiguration(new SpinProcessEnginePlugin()).buildProcessEngine())
.build();


@BeforeEach
public void register() {
OrderApproval config = new OrderApproval();
Mocks.register("guardExecutionListener", config.guardExecutionListener());
Expand All @@ -56,25 +58,25 @@ public void shouldFireExceptionIfOrderIdIsMissing() {
assertThrows(
GuardViolationException.class,
// manual start by-passing the factory
() -> rule.getRuntimeService().startProcessInstanceByKey(OrderApproval.KEY),
() -> engine.getRuntimeService().startProcessInstanceByKey(OrderApproval.KEY),
"Guard violated by execution '6' in activity 'Order created'\nExpecting variable 'orderId' to be set, but it was not found.\n");

}

@Test
public void shouldFireExceptionApproveDecisionIsMissing() {

OrderApprovalInstanceFactory factory = new OrderApprovalInstanceFactory(rule.getRuntimeService());
OrderApprovalInstanceFactory factory = new OrderApprovalInstanceFactory(engine.getRuntimeService());
factory.start("1");

// async after start
Job asyncStart = rule.getManagementService().createJobQuery().singleResult();
rule.getManagementService().executeJob(asyncStart.getId());
Task task = rule.getTaskService().createTaskQuery().singleResult();
Job asyncStart = engine.getManagementService().createJobQuery().singleResult();
engine.getManagementService().executeJob(asyncStart.getId());
Task task = engine.getTaskService().createTaskQuery().singleResult();

assertThrows(
ProcessEngineException.class,
() -> rule.getTaskService().complete(task.getId()),
() -> engine.getTaskService().complete(task.getId()),
"Guard violated in task 'Approve order' (taskId: '21')\nExpecting variable 'orderApproved' to be set, but it was not found.\n"
);
}
Expand Down
Loading

0 comments on commit c688c5c

Please sign in to comment.