Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gclaussn committed Jan 29, 2024
1 parent 60294c1 commit bcdcba4
Show file tree
Hide file tree
Showing 137 changed files with 1,784 additions and 1,528 deletions.
534 changes: 534 additions & 0 deletions dependencies.txt

Large diffs are not rendered by default.

41 changes: 25 additions & 16 deletions gradle-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Gradle Plugin

The plugin `org.camunda.community.bpmndt` registers the Gradle task `generateTestCases`.
It generates the test code under `build/bpmndt` and adds this directory as test source directory, which is automatically compiled before the `compileTestJava` task of Gradle's Java plugin.
The compilation results (test cases and [API classes](../impl/src/main/java/org/camunda/community/bpmndt/api)) will be available in the test classpath afterwards.
It generates the test code under `build/bpmndt` and adds this directory as test source directory, which is automatically compiled before the `compileTestJava`
task of Gradle's Java plugin.
The compilation results (test cases and [API classes](../impl/src/main/java/org/camunda/community/bpmndt/platform7/api)) will be available in the test classpath
afterwards.

:warning: Within **Eclipse**, the Gradle task `generateTestCases` must be executed manually to generate the test cases:

Expand All @@ -10,7 +13,8 @@ The compilation results (test cases and [API classes](../impl/src/main/java/org/
3. Add the `generateTestCases` task
4. Run the Gradle task configuration

:warning: Within **IntelliJ IDEA**, the Gradle task `generateTestCases` must be executed manually to generate the test cases - see [Run Gradle tasks](https://www.jetbrains.com/help/idea/work-with-gradle-tasks.html#gradle_tasks):
:warning: Within **IntelliJ IDEA**, the Gradle task `generateTestCases` must be executed manually to generate the test cases -
see [Run Gradle tasks](https://www.jetbrains.com/help/idea/work-with-gradle-tasks.html#gradle_tasks):

1. Type

Expand Down Expand Up @@ -54,16 +58,18 @@ plugins {
}
```

Please see [Maven Central](https://central.sonatype.com/artifact/org.camunda.community/bpmn-driven-testing-gradle-plugin/0.9.0/versions) to get a specific version.
Please see [Maven Central](https://central.sonatype.com/artifact/org.camunda.community/bpmn-driven-testing-gradle-plugin/0.9.0/versions) to get a specific
version.

## Configuration

Available properties:

| Parameter | Type | Description | Default value |
|:---------------------|:-------------|:---------------------------------------------------------------------------|:--------------|
| packageName | String | Package name, used for the generated test sources | generated |
| processEnginePlugins | List<String> | List of process engine plugins to register at the process engine (not required for Spring Boot, since process engine plugins must be exposed as beans) | - |
| springEnabled | Boolean | Enables Spring based testing (not required for Spring Boot, since here only the [BpmndtProcessEnginePlugin](../impl/src/main/java/org/camunda/community/bpmndt/api/cfg/BpmndtProcessEnginePlugin.java) must be exposed as a bean) | false |
| Parameter | Type | Description | Default value |
|:---------------------|:-------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------|
| packageName | String | Package name, used for the generated test sources | generated |
| processEnginePlugins | List<String> | List of process engine plugins to register at the process engine (not required for Spring Boot, since process engine plugins must be exposed as beans) | - |
| springEnabled | Boolean | Enables Spring based testing (not required for Spring Boot, since here only the [BpmndtProcessEnginePlugin](../impl/src/main/java/org/camunda/community/bpmndt/platform7/api/cfg/BpmndtProcessEnginePlugin.java) must be exposed as a bean) | false |

The plugin's configuration is done in `build.gradle` within the `bpmndt` extension element:

Expand All @@ -76,22 +82,23 @@ bpmndt {
```

## Dependencies

Add dependencies, which are required to execute the generated test code:

```groovy
dependencies {
implementation 'org.camunda.bpm:camunda-engine:7.19.0'
implementation 'org.camunda.bpm:camunda-engine:7.19.0'
testImplementation 'com.h2database:h2:2.2.220'
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'org.camunda.bpm.assert:camunda-bpm-assert:15.0.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3'
testImplementation 'com.h2database:h2:2.2.220'
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'org.camunda.bpm.assert:camunda-bpm-assert:15.0.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
}
test {
useJUnitPlatform()
useJUnitPlatform()
}
```

Expand Down Expand Up @@ -130,6 +137,7 @@ Recommended versions:
| Spring Boot | 2.7.18 |

## Development

:warning: This and the subsequent sections are only important for Gradle plugin development!

Since the latest Gradle dependencies are not available via Maven Central or other remote repositories,
Expand All @@ -139,6 +147,7 @@ For the development within an IDE, it is recommended to add the `lib/` directory
The development is done with Gradle in version `7.5.1`.

## Testing

Beside unit tests, a set of [integration tests](../integration-tests) exist,
which verify that the Gradle plugin works correctly when executed within a Gradle build.
The integration tests are implemented using the [Robot Framework](https://robotframework.org/) (Java implementation).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Collections;
import java.util.List;

import org.camunda.community.bpmndt.platform7.Generator;
import org.camunda.community.bpmndt.platform7.GeneratorContext;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;
Expand All @@ -13,7 +15,9 @@
*/
public class GeneratorTask extends DefaultTask {

/** Name of the task, used for registration. */
/**
* Name of the task, used for registration.
*/
protected static final String NAME = "generateTestCases";

@Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public class GradlePlugin implements Plugin<Project> {
private static final Logger LOGGER = LoggerFactory.getLogger(GradlePlugin.class);

/**
* Name of the test source set, which must contain "test" to indicate that the source set contains
* test code. Otherwise Eclipse will not recognize it!
* Name of the test source set, which must contain "test" to indicate that the source set contains test code. Otherwise Eclipse will not recognize it!
*/
private static final String SOURCE_SET_NAME = "bpmndtTestCases";

Expand Down
79 changes: 0 additions & 79 deletions impl-8/pom.xml

This file was deleted.

16 changes: 0 additions & 16 deletions impl-8/src/main/java/org/camunda/community/bpmndt8/Constants.java

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions impl-8/src/test/resources/log4j.properties

This file was deleted.

23 changes: 20 additions & 3 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@
<artifactId>bpmn-driven-testing-model</artifactId>
</dependency>

<!-- Camunda -->
<!-- Camunda Platform 7 -->
<dependency>
<groupId>org.camunda.bpm.model</groupId>
<artifactId>camunda-bpmn-model</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
<exclusions>
<exclusion>
<groupId>org.camunda.feel</groupId>
<artifactId>feel-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
Expand All @@ -52,6 +58,13 @@
<version>${assertj.version}</version>
</dependency>

<!-- Camunda Platform 8 -->
<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-process-test-extension</artifactId>
<version>${camunda.zeebe.version}</version>
</dependency>

<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
Expand Down Expand Up @@ -129,8 +142,12 @@

<!-- Add API classes as resources, since those are needed to run generated test code -->
<resource>
<directory>${project.basedir}/src/main/java/org/camunda/community/bpmndt/api</directory>
<targetPath>${project.build.outputDirectory}/org/camunda/community/bpmndt/api</targetPath>
<directory>src/main/java/org/camunda/community/bpmndt/platform7/api</directory>
<targetPath>${project.build.outputDirectory}/org/camunda/community/bpmndt/platform7/api</targetPath>
</resource>
<resource>
<directory>src/main/java/org/camunda/community/bpmndt/platform8/api</directory>
<targetPath>${project.build.outputDirectory}/org/camunda/community/bpmndt/platform8/api</targetPath>
</resource>
</resources>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.camunda.community.bpmndt;

/**
* Please note: This constants cannot be used within the API classes nor within the generated test
* code, since this class will not be available in the test classpath of the target project.
* Please note: This constants cannot be used within the API classes nor within the generated test code, since this class will not be available in the test
* classpath of the target project.
*/
public final class Constants {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import org.camunda.community.bpmndt.Constants;

/**
* Collects the paths of all BPMN files within the project's resource directory
* ({@code src/main/resources}).
* Collects the paths of all BPMN files within the project's resource directory ({@code src/main/resources}).
*/
public class CollectBpmnFiles extends SimpleFileVisitor<Path> implements Function<Path, Collection<Path>> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.Function;
import java.util.stream.Stream;

import org.apache.commons.io.FileUtils;
import org.camunda.community.bpmndt.GeneratorContext;
import org.camunda.community.bpmndt.platform7.GeneratorContext;

public class DeleteTestSources implements Function<GeneratorContext, Void> {

Expand All @@ -16,8 +17,8 @@ public Void apply(GeneratorContext ctx) {
return null;
}

try {
Files.list(ctx.getTestSourcePath()).map(Path::toFile).forEach(FileUtils::deleteQuietly);
try (Stream<Path> stream = Files.list(ctx.getTestSourcePath())) {
stream.map(Path::toFile).forEach(FileUtils::deleteQuietly);
} catch (IOException e) {
throw new RuntimeException("Test sources could not be deleted", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.function.Consumer;

import org.camunda.community.bpmndt.Constants;
import org.camunda.community.bpmndt.GeneratorContext;
import org.camunda.community.bpmndt.platform7.GeneratorContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.function.Consumer;

import org.apache.commons.io.FileUtils;
import org.camunda.community.bpmndt.GeneratorContext;
import org.camunda.community.bpmndt.platform7.GeneratorContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -37,12 +37,13 @@ public void accept(Class<?> type) {
}

InputStream resource = this.getClass().getClassLoader().getResourceAsStream(resourceName);
if (resource == null) {
throw new RuntimeException(String.format("Java type resource '%s' could not be found", resourceName));
}

// write Java type
try {
FileUtils.copyInputStreamToFile(resource, javaTypePath.toFile());
} catch (NullPointerException e) {
throw new RuntimeException(String.format("Java type resource '%s' could not be found", resourceName), e);
} catch (IOException e) {
throw new RuntimeException(String.format("Java type '%s' could not be written", type.getName()), e);
}
Expand Down
Loading

0 comments on commit bcdcba4

Please sign in to comment.