Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# 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.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
22 changes: 15 additions & 7 deletions camunda-outbox-example-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>pro.taskana</groupId>
<artifactId>taskana-adapter-parent</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<dependencies>
Expand All @@ -34,7 +34,6 @@
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
<version>${version.camunda}</version>
<exclusions>
<exclusion>
<groupId>org.skyscreamer</groupId>
Expand All @@ -47,18 +46,14 @@
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
<version>${version.camunda}</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-plugin-spin</artifactId>
<version>${version.camunda}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.camunda.spin</groupId>
<artifactId>camunda-spin-dataformat-json-jackson</artifactId>
<version>${version.camunda.spin}</version>
</dependency>

<!-- outbox-rest-spring-boot-starter-->
Expand All @@ -69,9 +64,22 @@
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring-boot-starter</artifactId>
<artifactId>resteasy-servlet-spring-boot-starter</artifactId>
<version>${version.resteasy.spring.boot}</version>
</dependency>
<!-- testing dependencies -->
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit</artifactId>
<version>${version.archunit}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ camunda.bpm.admin-user.last-name=demo

camunda.bpm.database.type=h2

# new mandatory field starting from camunda version 7.20
# see https://forum.camunda.io/t/camunda-7-20-history-time-to-live-cannot-be-null-cannot-deploy-wf-created-in-7-18/48159
camunda.bpm.generic-properties.properties.historyTimeToLive: P180D

# properties for resteasy-servlet-spring-boot-starter
# without these 2 propertiers the camunda-context is registered twice
resteasy.jaxrs.app.registration=property
resteasy.jaxrs.app.classes=pro.taskana.adapter.camunda.outbox.rest.config.OutboxRestServiceConfig

#spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
#spring.datasource.driver-class-name = org.postgresql.Driver
#spring.datasource.username = postgres
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package pro.taskana.camunda.spring.boot;

import static com.tngtech.archunit.core.domain.JavaCall.Predicates.target;
import static com.tngtech.archunit.core.domain.properties.CanBeAnnotated.Predicates.annotatedWith;
import static com.tngtech.archunit.core.domain.properties.HasName.Predicates.nameMatching;
import static com.tngtech.archunit.lang.conditions.ArchPredicates.are;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;

import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption.OnlyIncludeTests;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.TestTemplate;

class ArchitectureTest {

public static final String[] PACKAGE_NAMES = {"pro.taskana", "acceptance"};
private static final JavaClasses IMPORTED_CLASSES =
new ClassFileImporter().importPackages(PACKAGE_NAMES);

private static final JavaClasses IMPORTED_TEST_CLASSES =
new ClassFileImporter(List.of(new OnlyIncludeTests())).importPackages(PACKAGE_NAMES);

@Test
void testMethodNamesShouldMatchAccordingToOurGuidelines() {
methods()
.that(
are(
annotatedWith(Test.class)
.or(annotatedWith(TestFactory.class))
.or(annotatedWith(TestTemplate.class))))
.and()
.areNotDeclaredIn(ArchitectureTest.class)
.should()
.haveNameMatching("^should_[A-Z][^_]+(_(For|When)_[A-Z][^_]+)?$")
.check(IMPORTED_TEST_CLASSES);
}

@Test
void testClassesAndTestMethodsShouldBePackagePrivate() {
classes()
.that()
.haveSimpleNameStartingWith("Test")
.or()
.haveSimpleNameEndingWith("Test")
.should()
.bePackagePrivate()
.check(IMPORTED_TEST_CLASSES);
methods()
.that()
.areDeclaredInClassesThat()
.haveSimpleNameStartingWith("Test")
.or()
.areDeclaredInClassesThat()
.haveSimpleNameEndingWith("Test")
.should()
.bePackagePrivate()
.orShould()
.bePrivate()
.check(IMPORTED_TEST_CLASSES);
}

@Test
void noMethodsShouldUseThreadSleep() {
noClasses()
.should()
.callMethod(Thread.class, "sleep", long.class)
.orShould()
.callMethod(Thread.class, "sleep", long.class, int.class)
.check(IMPORTED_CLASSES);
}

@Test
void noMethodsShouldUsePrintln() {
noClasses()
.should()
.callMethodWhere(target(nameMatching("println")))
.check(IMPORTED_CLASSES);
}

@Test
void noImportsForOldJunitClasses() {
noClasses()
.should()
.dependOnClassesThat()
.haveFullyQualifiedName("org.junit.Test")
.orShould()
.dependOnClassesThat()
.haveFullyQualifiedName("org.junit.Assert")
.check(IMPORTED_TEST_CLASSES);
}

@Test
void noImportsForJunitAssertionsWeWantAssertJ() {
noClasses()
.should()
.dependOnClassesThat()
.haveFullyQualifiedName("org.junit.jupiter.api.Assertions")
.check(IMPORTED_TEST_CLASSES);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package pro.taskana.camunda.spring.boot;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import pro.taskana.adapter.camunda.outbox.rest.config.OutboxRestServiceConfig;
import pro.taskana.adapter.camunda.outbox.rest.controller.CamundaTaskEventsController;
import pro.taskana.adapter.camunda.parselistener.TaskanaParseListenerProcessEnginePlugin;

@SpringBootTest(classes = CamundaSpringBootExample.class, webEnvironment = RANDOM_PORT)
class CamundaSpringBootExampleIntegrationTest {

private final OutboxRestServiceConfig outboxRestServiceConfig;

private final CamundaTaskEventsController camundaTaskEventsController;

private final TaskanaParseListenerProcessEnginePlugin taskanaParseListenerProcessEnginePlugin;

CamundaSpringBootExampleIntegrationTest(
@Autowired(required = false) OutboxRestServiceConfig outboxRestServiceConfig,
@Autowired(required = false) CamundaTaskEventsController camundaTaskEventsController,
@Autowired(required = false)
TaskanaParseListenerProcessEnginePlugin taskanaParseListenerProcessEnginePlugin) {
this.outboxRestServiceConfig = outboxRestServiceConfig;
this.camundaTaskEventsController = camundaTaskEventsController;
this.taskanaParseListenerProcessEnginePlugin = taskanaParseListenerProcessEnginePlugin;
}

@Test
void should_AutowireOutboxRestServiceConfig_When_ApplicationIsStarting() {
assertThat(outboxRestServiceConfig).isNotNull();
}

@Test
void should_AutowireCamundaTaskEventsController_When_ApplicationIsStarting() {
assertThat(camundaTaskEventsController).isNotNull();
}

@Test
void should_AutowireTaskanaParseListenerProcessEnginePlugin_When_ApplicationIsStarting() {
assertThat(taskanaParseListenerProcessEnginePlugin).isNotNull();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="pro.taskana.adapter" level="info"/>
</configuration>
2 changes: 1 addition & 1 deletion ci/taskana-adapter-sonar-test-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>pro.taskana</groupId>
<artifactId>taskana-adapter-parent</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
8 changes: 8 additions & 0 deletions docker-databases/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'
services:
taskana-postgres_14:
build: postgres_14
ports:
- 50102:5432
environment:
- POSTGRES_PASSWORD=postgres
3 changes: 3 additions & 0 deletions docker-databases/postgres_14/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM postgres:14.7
RUN localedef -i de_DE -c -f UTF-8 -A /usr/share/locale/locale.alias de_DE.UTF-8
ENV LANG de_DE.utf8
43 changes: 43 additions & 0 deletions docker-databases/prepare_db.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@ECHO OFF
SETLOCAL

:MENU
ECHO.
ECHO -----------------------------------------------------
ECHO PRESS a number to select your task - anything to EXIT.
ECHO -----------------------------------------------------
ECHO.
ECHO 1 - Start POSTGRES 14
ECHO 2 - Stop POSTGRES 14
ECHO.
ECHO 3 - Stop all
ECHO.
SET /P MENU=Select task then press ENTER:
ECHO.
IF [%MENU%]==[1] GOTO START_POSTGRES_14
IF [%MENU%]==[2] GOTO STOP_POSTGRES_14
IF [%MENU%]==[3] GOTO STOP_ALL
EXIT /B

:START_POSTGRES_14
ECHO ---
ECHO docker-compose -f %~dp0/docker-compose.yml up -d taskana-postgres_14
docker-compose -f %~dp0/docker-compose.yml up -d taskana-postgres_14

ECHO ---
GOTO MENU

:STOP_POSTGRES_14
ECHO ---
ECHO docker stop taskana-postgres_14
ECHO docker-compose -f %~dp0/docker-compose.yml rm -f -s -v taskana-postgres_14
docker-compose -f %~dp0/docker-compose.yml rm -f -s -v taskana-postgres_14
ECHO ---
GOTO MENU

:STOP_ALL
ECHO ---
ECHO docker-compose -f %~dp0/docker-compose.yml down -v
docker-compose -f %~dp0/docker-compose.yml down -v
ECHO ---
GOTO MENU
68 changes: 68 additions & 0 deletions docker-databases/prepare_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
set -e #fail fast
trap "exit 1" TERM
export TOP_PID=$$

#H Usage:
#H %FILE% -h | %FILE% --help
#H
#H prints this help and exits
#H
#H %FILE% <database>
#H
#H downloads and starts docker image for TASKANA unit tests.
#H
#H %FILE% stop [database]
#H
#H stops the database.
#H If no database was provided all databases are stopped.
#H
#H database:
#H - POSTGRES | POSTGRES_14
# Arguments:
# $1: exit code
function helpAndExit() {
cat "$0" | grep "^#H" | cut -c4- | sed -e "s/%FILE%/$(basename "$0")/g"
exit "$1"
}

# This function maps the database parameter (for this file) to the docker-compose service name.
# Arguments:
# $1: the database which should be mapped
function mapDBToDockerComposeServiceName() {
[[ -z "$1" || "$1" == "H2" ]] && return
case "$1" in
POSTGRES|POSTGRES_14)
echo "taskana-postgres_14"
;;
*)
echo "unknown database '$1'" >&2 && kill -s TERM $TOP_PID
esac
}

function main() {
[[ $# -eq 0 || "$1" == '-h' || "$1" == '--help' ]] && helpAndExit 0
scriptDir=$(dirname "$0")

case "$1" in
H2)
;;
POSTGRES|POSTGRES_14)
docker-compose -f $scriptDir/docker-compose.yml up -d "$(mapDBToDockerComposeServiceName "$1")"
;;
stop)
# this variable is necessary, so that the script can terminate properly
# when the provided database name does not match. PLEASE DO NOT INLINE!
local composeServiceName="$(mapDBToDockerComposeServiceName "$2")"
docker-compose -f $scriptDir/docker-compose.yml rm -f -s -v $composeServiceName
;;
*)
echo "unknown database '$1'" >&2
exit 1
;;
esac

docker ps
}

main "$@"
Loading