TSK-1031: update Spring Boot to 2.2.4.RELEASE except Hateoas.

This commit is contained in:
Holger Hagen 2020-02-06 08:26:12 +01:00
parent e6f8883e49
commit 007f268be5
23 changed files with 2423 additions and 2473 deletions

View File

@ -1,99 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>taskana-simplehistory-rest-spring-example</artifactId> <artifactId>taskana-simplehistory-rest-spring-example</artifactId>
<name>${project.groupId}:${project.artifactId}</name> <name>${project.groupId}:${project.artifactId}</name>
<description>Demo project for taskana-simplehistory-rest-spring</description> <description>Demo project for taskana-simplehistory-rest-spring</description>
<parent> <parent>
<groupId>pro.taskana.simplehistory</groupId> <groupId>pro.taskana.simplehistory</groupId>
<artifactId>taskana-simplehistory-parent</artifactId> <artifactId>taskana-simplehistory-parent</artifactId>
<version>1.2.3-SNAPSHOT</version> <version>1.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring.boot}</version> <version>${version.spring.boot}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>pro.taskana.simplehistory</groupId> <groupId>pro.taskana.simplehistory</groupId>
<artifactId>taskana-simplehistory-rest-spring</artifactId> <artifactId>taskana-simplehistory-rest-spring</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> <exclusions>
<dependency> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.hateoas</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-hateoas</artifactId>
</dependency> </exclusion>
<dependency> </exclusions>
<groupId>org.springframework.boot</groupId> </dependency>
<artifactId>spring-boot-starter-jdbc</artifactId> <dependency>
</dependency> <groupId>org.springframework.hateoas</groupId>
<dependency> <artifactId>spring-hateoas</artifactId>
<groupId>org.springframework.plugin</groupId> <version>${version.spring.hateos}</version>
<artifactId>spring-plugin-core</artifactId> </dependency>
</dependency> <dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<groupId>com.h2database</groupId> <artifactId>spring-boot-starter-web</artifactId>
<artifactId>h2</artifactId> </dependency>
<version>${version.h2}</version> <dependency>
</dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<!-- Tests --> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.plugin</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-plugin-core</artifactId>
<scope>test</scope> <version>${version.spring.core}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>com.h2database</groupId>
<artifactId>spring-boot-test</artifactId> <artifactId>h2</artifactId>
</dependency> <version>${version.h2}</version>
<dependency> </dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <!-- Tests -->
</dependency> <dependency>
</dependencies> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<build> <scope>test</scope>
<plugins> </dependency>
<plugin> <dependency>
<artifactId>maven-resources-plugin</artifactId> <groupId>org.springframework.boot</groupId>
<version>${version.maven.resources}</version> <artifactId>spring-boot-test</artifactId>
<executions> </dependency>
<execution> <dependency>
<id>copy-documentation-to-static-folder</id> <groupId>org.springframework</groupId>
<phase>prepare-package</phase> <artifactId>spring-test</artifactId>
<goals> </dependency>
<goal>copy-resources</goal> </dependencies>
</goals>
<configuration> <build>
<outputDirectory> <plugins>
${project.build.outputDirectory}/static/docs/rest <plugin>
</outputDirectory> <artifactId>maven-resources-plugin</artifactId>
<resources> <version>${version.maven.resources}</version>
<resource> <executions>
<directory> <execution>
${project.build.directory}/generated-docs <id>copy-documentation-to-static-folder</id>
</directory> <phase>prepare-package</phase>
</resource> <goals>
</resources> <goal>copy-resources</goal>
</configuration> </goals>
</execution> <configuration>
</executions> <outputDirectory>
</plugin> ${project.build.outputDirectory}/static/docs/rest
</plugins> </outputDirectory>
</build> <resources>
</project> <resource>
<directory>
${project.build.directory}/generated-docs
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,175 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>taskana-simplehistory-spring-test</artifactId> <artifactId>taskana-simplehistory-spring-test</artifactId>
<name>${project.groupId}:${project.artifactId}</name> <name>${project.groupId}:${project.artifactId}</name>
<description>Exclusive test module. Contains integration tests and build rest-doc.</description> <description>Exclusive test module. Contains integration tests and build rest-doc.</description>
<parent> <parent>
<groupId>pro.taskana.simplehistory</groupId> <groupId>pro.taskana.simplehistory</groupId>
<artifactId>taskana-simplehistory-parent</artifactId> <artifactId>taskana-simplehistory-parent</artifactId>
<version>1.2.3-SNAPSHOT</version> <version>1.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring.boot}</version> <version>${version.spring.boot}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>pro.taskana.simplehistory</groupId> <groupId>pro.taskana.simplehistory</groupId>
<artifactId>taskana-simplehistory-rest-spring</artifactId> <artifactId>taskana-simplehistory-rest-spring</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> <exclusions>
<dependency> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.hateoas</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-hateoas</artifactId>
</dependency> </exclusion>
<dependency> </exclusions>
<groupId>org.springframework.boot</groupId> </dependency>
<artifactId>spring-boot-starter-jdbc</artifactId> <dependency>
</dependency> <groupId>org.springframework.hateoas</groupId>
<dependency> <artifactId>spring-hateoas</artifactId>
<groupId>com.h2database</groupId> <version>${version.spring.hateos}</version>
<artifactId>h2</artifactId> </dependency>
<version>${version.h2}</version> <dependency>
</dependency> <groupId>org.springframework.boot</groupId>
<dependency> <artifactId>spring-boot-starter-web</artifactId>
<groupId>org.springframework.plugin</groupId> </dependency>
<artifactId>spring-plugin-core</artifactId> <dependency>
</dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<!-- test dependencies --> </dependency>
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>com.h2database</groupId>
<artifactId>assertj-core</artifactId> <artifactId>h2</artifactId>
<version>${version.assertj}</version> <version>${version.h2}</version>
<scope>test</scope> </dependency>
</dependency> <dependency>
<dependency> <groupId>org.springframework.plugin</groupId>
<groupId>org.junit.jupiter</groupId> <artifactId>spring-plugin-core</artifactId>
<artifactId>junit-jupiter-api</artifactId> <version>${version.spring.core}</version>
<version>${version.junit.jupiter}</version> </dependency>
<scope>test</scope>
</dependency> <!-- test dependencies -->
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.assertj</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>assertj-core</artifactId>
<version>${version.junit.jupiter}</version> <version>${version.assertj}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.vintage</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-vintage-engine</artifactId> <artifactId>junit-jupiter-api</artifactId>
<version>${version.junit.jupiter}</version> <version>${version.junit.jupiter}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>spring-test</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope> <version>${version.junit.jupiter}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-test</artifactId> <groupId>org.junit.vintage</groupId>
<scope>test</scope> <artifactId>junit-vintage-engine</artifactId>
</dependency> <version>${version.junit.jupiter}</version>
<dependency> <scope>test</scope>
<groupId>org.springframework.restdocs</groupId> </dependency>
<artifactId>spring-restdocs-core</artifactId> <dependency>
<scope>test</scope> <groupId>org.springframework</groupId>
</dependency> <artifactId>spring-test</artifactId>
<dependency> <scope>test</scope>
<groupId>org.springframework.restdocs</groupId> </dependency>
<artifactId>spring-restdocs-mockmvc</artifactId> <dependency>
<scope>test</scope> <groupId>org.springframework.boot</groupId>
</dependency> <artifactId>spring-boot-test</artifactId>
</dependencies> <scope>test</scope>
</dependency>
<build> <dependency>
<plugins> <groupId>org.springframework.restdocs</groupId>
<plugin> <artifactId>spring-restdocs-core</artifactId>
<groupId>org.asciidoctor</groupId> <scope>test</scope>
<artifactId>asciidoctor-maven-plugin</artifactId> </dependency>
<version>${version.maven.asciidoctor}</version> <dependency>
<executions> <groupId>org.springframework.restdocs</groupId>
<execution> <artifactId>spring-restdocs-mockmvc</artifactId>
<id>generate-docs</id> <scope>test</scope>
<phase>prepare-package</phase> </dependency>
<goals> </dependencies>
<goal>process-asciidoc</goal>
</goals> <build>
<configuration> <plugins>
<backend>html</backend> <plugin>
<doctype>book</doctype> <groupId>org.asciidoctor</groupId>
<attributes> <artifactId>asciidoctor-maven-plugin</artifactId>
<snippets>target/generated-snippets</snippets> <version>${version.maven.asciidoctor}</version>
<docinfo>shared</docinfo> <executions>
</attributes> <execution>
</configuration> <id>generate-docs</id>
</execution> <phase>prepare-package</phase>
</executions> <goals>
</plugin> <goal>process-asciidoc</goal>
<plugin> </goals>
<artifactId>maven-resources-plugin</artifactId> <configuration>
<version>${version.maven.resources}</version> <backend>html</backend>
<executions> <doctype>book</doctype>
<execution> <attributes>
<id>copy-rest-docs</id> <snippets>target/generated-snippets</snippets>
<phase>prepare-package</phase> <docinfo>shared</docinfo>
<goals> </attributes>
<goal>copy-resources</goal> </configuration>
</goals> </execution>
<configuration> </executions>
<outputDirectory> </plugin>
${project.build.outputDirectory}/static/docs/rest <plugin>
</outputDirectory> <artifactId>maven-resources-plugin</artifactId>
<resources> <version>${version.maven.resources}</version>
<resource> <executions>
<directory> <execution>
${project.build.directory}/generated-docs <id>copy-rest-docs</id>
</directory> <phase>prepare-package</phase>
</resource> <goals>
<resource> <goal>copy-resources</goal>
<directory>${project.basedir}/src/js</directory> </goals>
</resource> <configuration>
</resources> <outputDirectory>
</configuration> ${project.build.outputDirectory}/static/docs/rest
</execution> </outputDirectory>
<execution> <resources>
<id>copy-documentation-to-taskana-simplehistory-rest-spring-example</id> <resource>
<phase>prepare-package</phase> <directory>
<goals> ${project.build.directory}/generated-docs
<goal>copy-resources</goal> </directory>
</goals> </resource>
<configuration> <resource>
<outputDirectory> <directory>${project.basedir}/src/js</directory>
../taskana-simplehistory-rest-spring-example/target/generated-docs </resource>
</outputDirectory> </resources>
<resources> </configuration>
<resource> </execution>
<directory> <execution>
${project.build.outputDirectory}/static/docs/rest <id>copy-documentation-to-taskana-simplehistory-rest-spring-example</id>
</directory> <phase>prepare-package</phase>
</resource> <goals>
</resources> <goal>copy-resources</goal>
</configuration> </goals>
</execution> <configuration>
</executions> <outputDirectory>
</plugin> ../taskana-simplehistory-rest-spring-example/target/generated-docs
</plugins> </outputDirectory>
</build> <resources>
<resource>
</project> <directory>
${project.build.outputDirectory}/static/docs/rest
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,12 +1,7 @@
package pro.taskana; package pro.taskana;
import static org.hamcrest.CoreMatchers.containsString; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.is; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
@ -45,6 +40,7 @@ import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException; import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException;
import pro.taskana.workbasket.api.exceptions.WorkbasketAlreadyExistException; import pro.taskana.workbasket.api.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.internal.WorkbasketImpl; import pro.taskana.workbasket.internal.WorkbasketImpl;
@ -52,12 +48,12 @@ import pro.taskana.workbasket.internal.WorkbasketImpl;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@SpringBootTest( @SpringBootTest(
classes = TaskanaConfigTestApplication.class, classes = TaskanaConfigTestApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = "spring.main.allow-bean-definition-overriding=true")
@ActiveProfiles({"inmemorydb", "dev"}) @ActiveProfiles({"inmemorydb", "dev"})
@Import({TransactionalJobsConfiguration.class}) @Import({TransactionalJobsConfiguration.class})
class TaskanaTransactionIntTest { class TaskanaTransactionIntTest {
private static final int POOL_TIME_TO_WAIT = 50;
@Autowired TaskanaTransactionProvider<Object> springTransactionProvider; @Autowired TaskanaTransactionProvider<Object> springTransactionProvider;
@Autowired private TestRestTemplate restTemplate; @Autowired private TestRestTemplate restTemplate;
@Autowired private DataSource dataSource; @Autowired private DataSource dataSource;
@ -75,7 +71,7 @@ class TaskanaTransactionIntTest {
@Test @Test
void testTaskanaSchema() { void testTaskanaSchema() {
ResponseEntity<String> responseEntity = restTemplate.getForEntity("/schema", String.class); ResponseEntity<String> responseEntity = restTemplate.getForEntity("/schema", String.class);
assertThat(responseEntity.getBody(), is("TASKANA")); assertThat(responseEntity.getBody()).isEqualTo("TASKANA");
} }
@Test @Test
@ -84,7 +80,7 @@ class TaskanaTransactionIntTest {
ResponseEntity<String> responseEntity = restTemplate.getForEntity("/transaction", String.class); ResponseEntity<String> responseEntity = restTemplate.getForEntity("/transaction", String.class);
System.err.println("response: " + responseEntity.getBody()); System.err.println("response: " + responseEntity.getBody());
assertThat(responseEntity.getBody(), containsString("workbaskets: 1")); assertThat(responseEntity.getBody()).containsSequence("workbaskets: 1");
assertAfter(1, 0); assertAfter(1, 0);
} }
@ -96,7 +92,7 @@ class TaskanaTransactionIntTest {
ResponseEntity<String> responseEntity = ResponseEntity<String> responseEntity =
restTemplate.getForEntity("/transaction?rollback={rollback}", String.class, "true"); restTemplate.getForEntity("/transaction?rollback={rollback}", String.class, "true");
System.err.println("result: " + responseEntity.getBody()); System.err.println("result: " + responseEntity.getBody());
assertThat(responseEntity.getBody(), containsString("workbaskets: 1")); assertThat(responseEntity.getBody()).containsSequence("workbaskets: 1");
assertAfter(0, 0); assertAfter(0, 0);
} }
@ -108,7 +104,7 @@ class TaskanaTransactionIntTest {
ResponseEntity<String> responseEntity = ResponseEntity<String> responseEntity =
restTemplate.getForEntity("/transaction-many", String.class); restTemplate.getForEntity("/transaction-many", String.class);
System.err.println("response: " + responseEntity.getBody()); System.err.println("response: " + responseEntity.getBody());
assertThat(responseEntity.getBody(), containsString("workbaskets: 3")); assertThat(responseEntity.getBody()).containsSequence("workbaskets: 3");
assertAfter(3, 0); assertAfter(3, 0);
} }
@ -120,7 +116,7 @@ class TaskanaTransactionIntTest {
ResponseEntity<String> responseEntity = ResponseEntity<String> responseEntity =
restTemplate.getForEntity("/transaction-many?rollback={rollback}", String.class, "true"); restTemplate.getForEntity("/transaction-many?rollback={rollback}", String.class, "true");
System.err.println("result: " + responseEntity.getBody()); System.err.println("result: " + responseEntity.getBody());
assertThat(responseEntity.getBody(), containsString("workbaskets: 3")); assertThat(responseEntity.getBody()).containsSequence("workbaskets: 3");
assertAfter(0, 0); assertAfter(0, 0);
} }
@ -131,8 +127,8 @@ class TaskanaTransactionIntTest {
ResponseEntity<String> responseEntity = restTemplate.getForEntity("/customdb", String.class); ResponseEntity<String> responseEntity = restTemplate.getForEntity("/customdb", String.class);
System.err.println("response: " + responseEntity.getBody()); System.err.println("response: " + responseEntity.getBody());
assertThat(responseEntity.getBody(), containsString("workbaskets: 2")); assertThat(responseEntity.getBody()).containsSequence("workbaskets: 2");
assertThat(responseEntity.getBody(), containsString("tests: 2")); assertThat(responseEntity.getBody()).containsSequence("tests: 2");
assertAfter(2, 2); assertAfter(2, 2);
} }
@ -144,8 +140,8 @@ class TaskanaTransactionIntTest {
ResponseEntity<String> responseEntity = ResponseEntity<String> responseEntity =
restTemplate.getForEntity("/customdb?rollback={rollback}", String.class, "true"); restTemplate.getForEntity("/customdb?rollback={rollback}", String.class, "true");
System.err.println("response: " + responseEntity.getBody()); System.err.println("response: " + responseEntity.getBody());
assertThat(responseEntity.getBody(), containsString("workbaskets: 2")); assertThat(responseEntity.getBody()).containsSequence("workbaskets: 2");
assertThat(responseEntity.getBody(), containsString("tests: 2")); assertThat(responseEntity.getBody()).containsSequence("tests: 2");
assertAfter(0, 0); assertAfter(0, 0);
} }
@ -158,19 +154,19 @@ class TaskanaTransactionIntTest {
final TaskanaEngineImpl taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; final TaskanaEngineImpl taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
try (Connection connection = dataSource.getConnection()) { try (Connection connection = dataSource.getConnection()) {
assertNotEquals(connection.getSchema(), "PUBLIC"); assertThat(connection.getSchema()).isNotEqualTo("PUBLIC");
jdbcTemplate.execute("INSERT INTO CUSTOMDB.TEST VALUES ('1', 'test')"); jdbcTemplate.execute("INSERT INTO CUSTOMDB.TEST VALUES ('1', 'test')");
jdbcTemplate.execute("INSERT INTO CUSTOMDB.TEST VALUES ('2', 'test2')"); jdbcTemplate.execute("INSERT INTO CUSTOMDB.TEST VALUES ('2', 'test2')");
int result = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM CUSTOMDB.TEST", Integer.class); int result = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM CUSTOMDB.TEST", Integer.class);
assertEquals(2, result); assertThat(result).isEqualTo(2);
Workbasket wbCreated = Workbasket wbCreated =
taskanaEngine taskanaEngine
.getWorkbasketService() .getWorkbasketService()
.createWorkbasket(createWorkBasket("key1", "workbasket1")); .createWorkbasket(createWorkBasket("key1", "workbasket1"));
Workbasket wb = taskanaEngineImpl.getWorkbasketService().getWorkbasket(wbCreated.getId()); Workbasket wb = taskanaEngineImpl.getWorkbasketService().getWorkbasket(wbCreated.getId());
assertNotNull(wb); assertThat(wb).isNotNull();
result = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM CUSTOMDB.TEST", Integer.class); result = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM CUSTOMDB.TEST", Integer.class);
assertEquals(2, result); assertThat(result).isEqualTo(2);
} }
} }
@ -189,8 +185,8 @@ class TaskanaTransactionIntTest {
taskService.createTask(createTask("key2", "TEST")); taskService.createTask(createTask("key2", "TEST"));
taskService.createTask(createTask("key3", "TEST")); taskService.createTask(createTask("key3", "TEST"));
assertEquals(workbasketService.createWorkbasketQuery().count(), 3); assertThat(workbasketService.createWorkbasketQuery().count()).isEqualTo(3);
assertEquals(taskService.createTaskQuery().count(), 3); assertThat(taskService.createTaskQuery().count()).isEqualTo(3);
List<TaskSummary> tasks = List<TaskSummary> tasks =
taskService taskService
@ -216,27 +212,19 @@ class TaskanaTransactionIntTest {
new TaskCleanupJob(taskanaEngine, springTransactionProvider, null); new TaskCleanupJob(taskanaEngine, springTransactionProvider, null);
taskCleanupJob.run(); taskCleanupJob.run();
tasks = assertThatThrownBy(() ->
taskService
.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("key3", "DOMAIN_A"))
.list();
taskService.claim(tasks.get(0).getId());
taskService.completeTask(tasks.get(0).getId());
try {
workbasketService.deleteWorkbasket( workbasketService.deleteWorkbasket(
workbasketService.getWorkbasket("key3", "DOMAIN_A").getId()); workbasketService.getWorkbasket("key3", "DOMAIN_A").getId()))
} catch (TaskanaException ex) { .isInstanceOf(WorkbasketInUseException.class)
assertEquals(ex.getMessage().contains("contains non-completed tasks"), true); .hasMessageContaining("contains 1 non-completed tasks");
}
WorkbasketCleanupJob job = WorkbasketCleanupJob job =
new WorkbasketCleanupJob(taskanaEngine, springTransactionProvider, null); new WorkbasketCleanupJob(taskanaEngine, springTransactionProvider, null);
job.run(); job.run();
assertNull(workbasketService.getWorkbasket("key1", "DOMAIN_A")); assertThat(workbasketService.getWorkbasket("key1", "DOMAIN_A")).isNull();
assertNull(workbasketService.getWorkbasket("key2", "DOMAIN_A")); assertThat(workbasketService.getWorkbasket("key2", "DOMAIN_A")).isNull();
assertThat(workbasketService.getWorkbasket("key3", "DOMAIN_A")).isNotNull();
} catch (TaskanaException e) { } catch (TaskanaException e) {
e.printStackTrace(); e.printStackTrace();
@ -265,14 +253,12 @@ class TaskanaTransactionIntTest {
private void assertWorkbaskets(String assertion, int value) { private void assertWorkbaskets(String assertion, int value) {
int workbaskets = getWorkbaskets(); int workbaskets = getWorkbaskets();
System.err.println(assertion + " workbaskets: " + workbaskets); assertThat(workbaskets).isEqualTo(value);
assertThat(workbaskets, is(value));
} }
private void assertCustomdbTests(String assertion, int value) { private void assertCustomdbTests(String assertion, int value) {
int tests = getCustomdbTests(); int tests = getCustomdbTests();
System.err.println(assertion + " tests: " + tests); assertThat(tests).isEqualTo(value);
assertThat(tests, is(value));
} }
private int getWorkbaskets() { private int getWorkbaskets() {

703
pom.xml
View File

@ -1,351 +1,352 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>pro.taskana</groupId> <groupId>pro.taskana</groupId>
<artifactId>taskana-parent</artifactId> <artifactId>taskana-parent</artifactId>
<version>1.2.3-SNAPSHOT</version> <version>1.2.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>${project.groupId}:${project.artifactId}</name> <name>${project.groupId}:${project.artifactId}</name>
<description>This pom is parent to all taskana modules and serves the common build.</description> <description>This pom is parent to all taskana modules and serves the common build.</description>
<url>http://taskana.pro</url> <url>http://taskana.pro</url>
<modules> <modules>
<module>lib</module> <module>lib</module>
<module>rest</module> <module>rest</module>
<!-- History is an optional module. --> <!-- History is an optional module. -->
<module>history</module> <module>history</module>
</modules> </modules>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<version.mybatis>3.5.4</version.mybatis> <version.mybatis>3.5.4</version.mybatis>
<version.slf4j>1.7.30</version.slf4j> <version.slf4j>1.7.30</version.slf4j>
<version.json>20190722</version.json> <version.json>20190722</version.json>
<version.jackson>2.9.8</version.jackson> <version.jackson>2.9.8</version.jackson>
<version.aspectjweaver>1.9.5</version.aspectjweaver> <version.aspectjweaver>1.9.5</version.aspectjweaver>
<version.javax.validation>2.0.1.Final</version.javax.validation> <version.javax.validation>2.0.1.Final</version.javax.validation>
<version.javax.servlet>4.0.1</version.javax.servlet> <version.javax.servlet>4.0.1</version.javax.servlet>
<!-- build dependencies --> <!-- build dependencies -->
<version.checkstyle>8.29</version.checkstyle> <version.checkstyle>8.29</version.checkstyle>
<version.maven.checkstyle>3.1.0</version.maven.checkstyle> <version.maven.checkstyle>3.1.0</version.maven.checkstyle>
<version.maven.jar>3.2.0</version.maven.jar> <version.maven.jar>3.2.0</version.maven.jar>
<version.maven.compiler>3.8.1</version.maven.compiler> <version.maven.compiler>3.8.1</version.maven.compiler>
<version.maven.source>3.2.1</version.maven.source> <version.maven.source>3.2.1</version.maven.source>
<version.maven.javadoc>3.1.1</version.maven.javadoc> <version.maven.javadoc>3.1.1</version.maven.javadoc>
<version.maven.resources>3.1.0</version.maven.resources> <version.maven.resources>3.1.0</version.maven.resources>
<version.maven.surefire>3.0.0-M4</version.maven.surefire> <version.maven.surefire>3.0.0-M4</version.maven.surefire>
<version.maven.asciidoctor>1.6.0</version.maven.asciidoctor> <version.maven.asciidoctor>1.6.0</version.maven.asciidoctor>
<version.maven.wildfly>2.0.2.Final</version.maven.wildfly> <version.maven.wildfly>2.0.2.Final</version.maven.wildfly>
<!-- release dependencies --> <!-- release dependencies -->
<version.maven.gpg>1.6</version.maven.gpg> <version.maven.gpg>1.6</version.maven.gpg>
<version.sonatype>1.6.8</version.sonatype> <version.sonatype>1.6.8</version.sonatype>
<!-- spring dependencies --> <!-- spring dependencies -->
<version.spring>5.0.5.RELEASE</version.spring> <version.spring>5.2.3.RELEASE</version.spring>
<version.spring.core>2.0.0.RELEASE</version.spring.core> <version.spring.security>5.2.1.RELEASE</version.spring.security>
<version.spring.boot>2.0.2.RELEASE</version.spring.boot> <version.spring.core>2.0.0.RELEASE</version.spring.core>
<version.spring.restdocs>2.0.2.RELEASE</version.spring.restdocs> <version.spring.boot>2.2.4.RELEASE</version.spring.boot>
<version.spring.mybatis>2.0.3</version.spring.mybatis> <version.spring.restdocs>2.0.2.RELEASE</version.spring.restdocs>
<version.spring.ldap>2.3.2.RELEASE</version.spring.ldap> <version.spring.mybatis>2.0.3</version.spring.mybatis>
<version.spring.hateos>0.24.0.RELEASE</version.spring.hateos> <version.spring.hateos>0.24.0.RELEASE</version.spring.hateos>
<version.spring.ldap>2.3.2.RELEASE</version.spring.ldap>
<!-- wildfly dependencies -->
<version.wildfly>11.0.0.Final</version.wildfly> <!-- wildfly dependencies -->
<version.wildfly>11.0.0.Final</version.wildfly>
<!-- java ee dependencies -->
<version.resteasy>4.4.2.Final</version.resteasy> <!-- java ee dependencies -->
<version.thorntail>2.6.0.Final</version.thorntail> <version.resteasy>4.4.2.Final</version.resteasy>
<version.wildfly.security>1.11.2.Final</version.wildfly.security> <version.thorntail>2.6.0.Final</version.thorntail>
<version.javaee-api>8.0.1</version.javaee-api> <version.wildfly.security>1.11.2.Final</version.wildfly.security>
<version.arquillian>1.6.0.Final</version.arquillian> <version.javaee-api>8.0.1</version.javaee-api>
<version.arquillian>1.6.0.Final</version.arquillian>
<!-- test dependencies -->
<version.assertj>3.15.0</version.assertj> <!-- test dependencies -->
<version.junit.jupiter>5.6.0</version.junit.jupiter> <version.assertj>3.15.0</version.assertj>
<version.log4j>2.13.0</version.log4j> <version.junit.jupiter>5.6.0</version.junit.jupiter>
<version.archunit>0.13.1</version.archunit> <version.log4j>2.13.0</version.log4j>
<version.mockito>3.2.4</version.mockito> <version.archunit>0.13.0</version.archunit>
<version.junit.mockito>3.2.4</version.junit.mockito> <version.mockito>3.2.4</version.mockito>
<!-- byte buddy 1.9.7+ is needed to solve dependency errors with spring mock tests see LdapClientTest --> <version.junit.mockito>3.2.4</version.junit.mockito>
<version.byte-buddy>1.10.7</version.byte-buddy> <!-- byte buddy 1.9.7+ is needed to solve dependency errors with spring mock tests see LdapClientTest -->
<version.byte-buddy-agent>1.10.7</version.byte-buddy-agent> <version.byte-buddy>1.10.7</version.byte-buddy>
<version.powermock>2.0.5</version.powermock> <version.byte-buddy-agent>1.10.7</version.byte-buddy-agent>
<version.hamcrest>2.2</version.hamcrest> <version.powermock>2.0.5</version.powermock>
<version.equalsverifier>3.1.12</version.equalsverifier> <version.hamcrest>2.2</version.hamcrest>
<version.openpojo>0.8.13</version.openpojo> <version.equalsverifier>3.1.12</version.equalsverifier>
<version.jacoco>0.8.5</version.jacoco> <version.openpojo>0.8.13</version.openpojo>
<version.jacoco>0.8.5</version.jacoco>
<!-- database driver versions -->
<version.h2>1.4.200</version.h2> <!-- database driver versions -->
<version.db2>11.1.1.1</version.db2> <version.h2>1.4.200</version.h2>
<version.postgres>42.2.10</version.postgres> <version.db2>11.1.1.1</version.db2>
<!-- used by jacoco to collect coverage --> <version.postgres>42.2.9</version.postgres>
<argLine></argLine> <!-- used by jacoco to collect coverage -->
</properties> <argLine></argLine>
</properties>
<developers>
<developer> <developers>
<name>Holger Hagen</name> <developer>
<email>holger.hagen@novatec-gmbh.de</email> <name>Holger Hagen</name>
<organization>Novatec Consulting GmbH</organization> <email>holger.hagen@novatec-gmbh.de</email>
<organizationUrl>https://www.novatec-gmbh.de</organizationUrl> <organization>Novatec Consulting GmbH</organization>
</developer> <organizationUrl>https://www.novatec-gmbh.de</organizationUrl>
</developers> </developer>
</developers>
<scm>
<url>http://github.com/taskana/taskana/tree/master</url> <scm>
<connection>scm:git:git://github.com/taskana/taskana.git</connection> <url>http://github.com/taskana/taskana/tree/master</url>
<developerConnection>scm:git:ssh://github.com:taskana/taskana.git</developerConnection> <connection>scm:git:git://github.com/taskana/taskana.git</connection>
</scm> <developerConnection>scm:git:ssh://github.com:taskana/taskana.git</developerConnection>
</scm>
<licenses>
<license> <licenses>
<name>The Apache License, Version 2.0</name> <license>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <name>The Apache License, Version 2.0</name>
</license> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</licenses> </license>
</licenses>
<profiles>
<profile> <profiles>
<id>snapshot</id> <profile>
<build> <id>snapshot</id>
<plugins> <build>
<plugin> <plugins>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-gpg-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>${version.maven.gpg}</version> <artifactId>maven-gpg-plugin</artifactId>
<executions> <version>${version.maven.gpg}</version>
<execution> <executions>
<id>sign-artifacts</id> <execution>
<phase>verify</phase> <id>sign-artifacts</id>
<goals> <phase>verify</phase>
<goal>sign</goal> <goals>
</goals> <goal>sign</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
<plugin> </plugin>
<groupId>org.sonatype.plugins</groupId> <plugin>
<artifactId>nexus-staging-maven-plugin</artifactId> <groupId>org.sonatype.plugins</groupId>
<version>${version.sonatype}</version> <artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions> <version>${version.sonatype}</version>
<configuration> <extensions>true</extensions>
<serverId>ossrh</serverId> <configuration>
<nexusUrl>https://oss.sonatype.org/</nexusUrl> <serverId>ossrh</serverId>
<autoReleaseAfterClose>false</autoReleaseAfterClose> <nexusUrl>https://oss.sonatype.org/</nexusUrl>
</configuration> <autoReleaseAfterClose>false</autoReleaseAfterClose>
</plugin> </configuration>
</plugins> </plugin>
</build> </plugins>
<distributionManagement> </build>
<snapshotRepository> <distributionManagement>
<id>ossrh</id> <snapshotRepository>
<url>https://oss.sonatype.org/content/repositories/snapshots</url> <id>ossrh</id>
</snapshotRepository> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</distributionManagement> </snapshotRepository>
</profile> </distributionManagement>
<profile> </profile>
<id>release</id> <profile>
<build> <id>release</id>
<plugins> <build>
<plugin> <plugins>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-gpg-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>${version.maven.gpg}</version> <artifactId>maven-gpg-plugin</artifactId>
<executions> <version>${version.maven.gpg}</version>
<execution> <executions>
<id>sign-artifacts</id> <execution>
<phase>verify</phase> <id>sign-artifacts</id>
<goals> <phase>verify</phase>
<goal>sign</goal> <goals>
</goals> <goal>sign</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
<plugin> </plugin>
<groupId>org.sonatype.plugins</groupId> <plugin>
<artifactId>nexus-staging-maven-plugin</artifactId> <groupId>org.sonatype.plugins</groupId>
<version>${version.sonatype}</version> <artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions> <version>${version.sonatype}</version>
<configuration> <extensions>true</extensions>
<serverId>ossrh</serverId> <configuration>
<nexusUrl>https://oss.sonatype.org/</nexusUrl> <serverId>ossrh</serverId>
<autoReleaseAfterClose>false</autoReleaseAfterClose> <nexusUrl>https://oss.sonatype.org/</nexusUrl>
</configuration> <autoReleaseAfterClose>false</autoReleaseAfterClose>
</plugin> </configuration>
</plugins> </plugin>
</build> </plugins>
<distributionManagement> </build>
<repository> <distributionManagement>
<id>ossrh</id> <repository>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> <id>ossrh</id>
</repository> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</distributionManagement> </repository>
</profile> </distributionManagement>
<profile> </profile>
<id>eclipse</id> <profile>
<build> <id>eclipse</id>
<pluginManagement> <build>
<plugins> <pluginManagement>
<plugin> <plugins>
<groupId>org.eclipse.m2e</groupId> <plugin>
<artifactId>lifecycle-mapping</artifactId> <groupId>org.eclipse.m2e</groupId>
<version>1.0.0</version> <artifactId>lifecycle-mapping</artifactId>
<configuration> <version>1.0.0</version>
<lifecycleMappingMetadata> <configuration>
<pluginExecutions> <lifecycleMappingMetadata>
<pluginExecution> <pluginExecutions>
<pluginExecutionFilter> <pluginExecution>
<groupId>org.apache.maven.plugins</groupId> <pluginExecutionFilter>
<artifactId>maven-checkstyle-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<versionRange>[1.0.0,)</versionRange> <artifactId>maven-checkstyle-plugin</artifactId>
<goals> <versionRange>[1.0.0,)</versionRange>
<goal>check</goal> <goals>
</goals> <goal>check</goal>
</pluginExecutionFilter> </goals>
<action> </pluginExecutionFilter>
<ignore/> <action>
</action> <ignore/>
</pluginExecution> </action>
</pluginExecutions> </pluginExecution>
</lifecycleMappingMetadata> </pluginExecutions>
</configuration> </lifecycleMappingMetadata>
</plugin> </configuration>
</plugins> </plugin>
</pluginManagement> </plugins>
</build> </pluginManagement>
</profile> </build>
<profile> </profile>
<id>coverage</id> <profile>
<build> <id>coverage</id>
<plugins> <build>
<plugin> <plugins>
<groupId>org.jacoco</groupId> <plugin>
<artifactId>jacoco-maven-plugin</artifactId> <groupId>org.jacoco</groupId>
<version>${version.jacoco}</version> <artifactId>jacoco-maven-plugin</artifactId>
<executions> <version>${version.jacoco}</version>
<execution> <executions>
<goals> <execution>
<goal>prepare-agent</goal> <goals>
<goal>report</goal> <goal>prepare-agent</goal>
</goals> <goal>report</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
</plugins> </plugin>
</build> </plugins>
</profile> </build>
</profiles> </profile>
</profiles>
<build>
<plugins> <build>
<!-- <plugins>
This plugin appends version information into the jar, so that it can be extracted from the jar. <!--
See TSK-837 for more information This plugin appends version information into the jar, so that it can be extracted from the jar.
--> See TSK-837 for more information
<plugin> -->
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-jar-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>${version.maven.jar}</version> <artifactId>maven-jar-plugin</artifactId>
<configuration> <version>${version.maven.jar}</version>
<archive> <configuration>
<manifest> <archive>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries> <manifest>
</manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</archive> </manifest>
</configuration> </archive>
</plugin> </configuration>
<plugin> </plugin>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>${version.maven.compiler}</version> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <version>${version.maven.compiler}</version>
<showWarnings>true</showWarnings> <configuration>
<failOnWarning>true</failOnWarning> <showWarnings>true</showWarnings>
<compilerArgs> <failOnWarning>true</failOnWarning>
<arg>-Xlint:all</arg> <compilerArgs>
<arg>-proc:none</arg> <arg>-Xlint:all</arg>
</compilerArgs> <arg>-proc:none</arg>
</configuration> </compilerArgs>
</plugin> </configuration>
<plugin> </plugin>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-source-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>${version.maven.source}</version> <artifactId>maven-source-plugin</artifactId>
<executions> <version>${version.maven.source}</version>
<execution> <executions>
<id>attach-sources</id> <execution>
<goals> <id>attach-sources</id>
<goal>jar-no-fork</goal> <goals>
</goals> <goal>jar-no-fork</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
<plugin> </plugin>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-javadoc-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>${version.maven.javadoc}</version> <artifactId>maven-javadoc-plugin</artifactId>
<executions> <version>${version.maven.javadoc}</version>
<execution> <executions>
<id>attach-javadocs</id> <execution>
<goals> <id>attach-javadocs</id>
<goal>jar</goal> <goals>
</goals> <goal>jar</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
<!-- JUnit 5 requires Surefire version 2.22.0 or higher --> </plugin>
<plugin> <!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>${version.maven.surefire}</version> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <version>${version.maven.surefire}</version>
<argLine>${argLine}</argLine> <configuration>
<!-- Required for generation of REST documentation --> <argLine>${argLine}</argLine>
<includes> <!-- Required for generation of REST documentation -->
<include>**/*Test.java</include> <includes>
<include>**/*Documentation.java</include> <include>**/*Test.java</include>
</includes> <include>**/*Documentation.java</include>
</configuration> </includes>
</plugin> </configuration>
<plugin> </plugin>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-checkstyle-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>${version.maven.checkstyle}</version> <artifactId>maven-checkstyle-plugin</artifactId>
<dependencies> <version>${version.maven.checkstyle}</version>
<dependency> <dependencies>
<artifactId>checkstyle</artifactId> <dependency>
<groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId>
<version>${version.checkstyle}</version> <groupId>com.puppycrawl.tools</groupId>
</dependency> <version>${version.checkstyle}</version>
</dependencies> </dependency>
<configuration> </dependencies>
<configLocation>qa/checkstyle/checkstyle.xml</configLocation> <configuration>
<encoding>UTF-8</encoding> <configLocation>qa/checkstyle/checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput> <encoding>UTF-8</encoding>
<failsOnError>true</failsOnError> <consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation> <failsOnError>true</failsOnError>
<violationSeverity>warning</violationSeverity> <failOnViolation>true</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory> <violationSeverity>warning</violationSeverity>
</configuration> <includeTestSourceDirectory>true</includeTestSourceDirectory>
<executions> </configuration>
<execution> <executions>
<phase>process-classes</phase> <execution>
<goals> <phase>process-classes</phase>
<goal>check</goal> <goals>
</goals> <goal>check</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
</plugins> </plugin>
</build> </plugins>
</project> </build>
</project>

View File

@ -1,201 +1,213 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>taskana-rest-spring-example-boot</artifactId> <artifactId>taskana-rest-spring-example-boot</artifactId>
<name>${project.groupId}:${project.artifactId}</name> <name>${project.groupId}:${project.artifactId}</name>
<description>Demo project for taskana-rest-spring</description> <description>Demo project for taskana-rest-spring</description>
<parent> <parent>
<groupId>pro.taskana</groupId> <groupId>pro.taskana</groupId>
<artifactId>taskana-rest-parent</artifactId> <artifactId>taskana-rest-parent</artifactId>
<version>1.2.3-SNAPSHOT</version> <version>1.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring.boot}</version> <version>${version.spring.boot}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId> <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.plugin</groupId> <groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId> <artifactId>spring-plugin-core</artifactId>
</dependency> <version>${version.spring.core}</version>
<dependency> </dependency>
<groupId>org.springframework.ldap</groupId> <dependency>
<artifactId>spring-ldap-core</artifactId> <groupId>org.springframework.ldap</groupId>
</dependency> <artifactId>spring-ldap-core</artifactId>
<dependency> </dependency>
<groupId>com.h2database</groupId> <dependency>
<artifactId>h2</artifactId> <groupId>com.h2database</groupId>
</dependency> <artifactId>h2</artifactId>
<dependency> </dependency>
<groupId>com.ibm.db2.jcc</groupId> <dependency>
<artifactId>db2jcc4</artifactId> <groupId>com.ibm.db2.jcc</groupId>
<version>${version.db2}</version> <artifactId>db2jcc4</artifactId>
</dependency> <version>${version.db2}</version>
<!-- https://mvnrepository.com/artifact/postgresql/postgresql --> </dependency>
<!-- Postgresql driver dependency --> <!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
<dependency> <!-- Postgresql driver dependency -->
<groupId>org.postgresql</groupId> <dependency>
<artifactId>postgresql</artifactId> <groupId>org.postgresql</groupId>
<version>${version.postgres}</version> <artifactId>postgresql</artifactId>
</dependency> <version>${version.postgres}</version>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-starter-thymeleaf</artifactId> <groupId>org.springframework.boot</groupId>
</dependency> <artifactId>spring-boot-starter-thymeleaf</artifactId>
<dependency> </dependency>
<groupId>pro.taskana</groupId> <dependency>
<artifactId>taskana-rest-spring-example-common</artifactId> <groupId>pro.taskana</groupId>
<version>${project.version}</version> <artifactId>taskana-rest-spring-example-common</artifactId>
</dependency> <version>${project.version}</version>
</dependencies> <exclusions>
<profiles> <exclusion>
<profile> <groupId>org.springframework.hateoas</groupId>
<id>history.plugin</id> <artifactId>spring-hateoas</artifactId>
<activation> </exclusion>
<activeByDefault>false</activeByDefault> </exclusions>
</activation> </dependency>
<dependencies> <dependency>
<dependency> <groupId>org.springframework.hateoas</groupId>
<groupId>pro.taskana.simplehistory</groupId> <artifactId>spring-hateoas</artifactId>
<artifactId>taskana-simplehistory-rest-spring</artifactId> <version>${version.spring.hateos}</version>
<version>${project.version}</version> </dependency>
</dependency> </dependencies>
</dependencies> <profiles>
</profile> <profile>
</profiles> <id>history.plugin</id>
<activation>
<build> <activeByDefault>false</activeByDefault>
<finalName>${project.artifactId}</finalName> </activation>
<plugins> <dependencies>
<plugin> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>pro.taskana.simplehistory</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>taskana-simplehistory-rest-spring</artifactId>
<version>${version.spring.boot}</version> <version>${project.version}</version>
<executions> </dependency>
<execution> </dependencies>
<goals> </profile>
<goal>repackage</goal> </profiles>
</goals>
</execution> <build>
</executions> <finalName>${project.artifactId}</finalName>
</plugin> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${version.maven.resources}</version> <version>${version.spring.boot}</version>
<executions> <executions>
<execution> <execution>
<id>copy-rest-documentation-to-static-folder</id> <goals>
<phase>prepare-package</phase> <goal>repackage</goal>
<goals> </goals>
<goal>copy-resources</goal> </execution>
</goals> </executions>
<configuration> </plugin>
<outputDirectory> <plugin>
${project.build.outputDirectory}/static/docs/rest <groupId>org.apache.maven.plugins</groupId>
</outputDirectory> <artifactId>maven-resources-plugin</artifactId>
<resources> <version>${version.maven.resources}</version>
<resource> <executions>
<directory> <execution>
../taskana-rest-spring/target/generated-docs <id>copy-rest-documentation-to-static-folder</id>
</directory> <phase>prepare-package</phase>
</resource> <goals>
</resources> <goal>copy-resources</goal>
</configuration> </goals>
</execution> <configuration>
<execution> <outputDirectory>
<id>copy-taskana-core-docs</id> ${project.build.outputDirectory}/static/docs/rest
<phase>prepare-package</phase> </outputDirectory>
<goals> <resources>
<goal>copy-resources</goal> <resource>
</goals> <directory>
<configuration> ../taskana-rest-spring/target/generated-docs
<outputDirectory> </directory>
${project.build.outputDirectory}/static/docs/java/taskana-core </resource>
</outputDirectory> </resources>
<resources> </configuration>
<resource> </execution>
<directory> <execution>
../../lib/taskana-core/target/apidocs <id>copy-taskana-core-docs</id>
</directory> <phase>prepare-package</phase>
</resource> <goals>
</resources> <goal>copy-resources</goal>
</configuration> </goals>
</execution> <configuration>
<execution> <outputDirectory>
<id>copy-taskana-cdi-docs</id> ${project.build.outputDirectory}/static/docs/java/taskana-core
<phase>prepare-package</phase> </outputDirectory>
<goals> <resources>
<goal>copy-resources</goal> <resource>
</goals> <directory>
<configuration> ../../lib/taskana-core/target/apidocs
<outputDirectory> </directory>
${project.build.outputDirectory}/static/docs/java/taskana-cdi </resource>
</outputDirectory> </resources>
<resources> </configuration>
<resource> </execution>
<directory> <execution>
../../lib/taskana-cdi/target/apidocs <id>copy-taskana-cdi-docs</id>
</directory> <phase>prepare-package</phase>
</resource> <goals>
</resources> <goal>copy-resources</goal>
</configuration> </goals>
</execution> <configuration>
<execution> <outputDirectory>
<id>copy-taskana-spring-docs</id> ${project.build.outputDirectory}/static/docs/java/taskana-cdi
<phase>prepare-package</phase> </outputDirectory>
<goals> <resources>
<goal>copy-resources</goal> <resource>
</goals> <directory>
<configuration> ../../lib/taskana-cdi/target/apidocs
<outputDirectory> </directory>
${project.build.outputDirectory}/static/docs/java/taskana-spring </resource>
</outputDirectory> </resources>
<resources> </configuration>
<resource> </execution>
<directory> <execution>
../../lib/taskana-spring/target/apidocs <id>copy-taskana-spring-docs</id>
</directory> <phase>prepare-package</phase>
</resource> <goals>
</resources> <goal>copy-resources</goal>
</configuration> </goals>
</execution> <configuration>
</executions> <outputDirectory>
</plugin> ${project.build.outputDirectory}/static/docs/java/taskana-spring
</plugins> </outputDirectory>
</build> <resources>
<resource>
<repositories> <directory>
<!-- this repository is needed to fetch com.ibm.db2.jcc --> ../../lib/taskana-spring/target/apidocs
<repository> </directory>
<id>novatec public</id> </resource>
<name>novatec-repository</name> </resources>
<url>https://repository.novatec-gmbh.de/content/repositories/novatec/</url> </configuration>
</repository> </execution>
</repositories> </executions>
</project> </plugin>
</plugins>
</build>
<repositories>
<!-- this repository is needed to fetch com.ibm.db2.jcc -->
<repository>
<id>novatec public</id>
<name>novatec-repository</name>
<url>https://repository.novatec-gmbh.de/content/repositories/novatec/</url>
</repository>
</repositories>
</project>

View File

@ -1,4 +1,4 @@
logging.level.pro.taskana=INFO logging.level.pro.taskana=DEBUG
server.servlet.context-path=/taskana server.servlet.context-path=/taskana
### logging.level.org.springframework=DEBUG ### logging.level.org.springframework=DEBUG
######## Taskana DB ####### ######## Taskana DB #######
@ -53,6 +53,9 @@ spring.resources.cache.cachecontrol.cache-private=true
####### for upload of big workbasket- or classification-files ####### for upload of big workbasket- or classification-files
spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB spring.servlet.multipart.max-request-size=10MB
spring.main.allow-bean-definition-overriding=true
server.tomcat.max-http-post-size=-1 server.tomcat.max-http-post-size=-1
server.tomcat.max-save-post-size=-1 server.tomcat.max-save-post-size=-1
server.tomcat.max-swallow-size=-1 server.tomcat.max-swallow-size=-1

View File

@ -1,136 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>taskana-rest-spring-example-common</artifactId> <artifactId>taskana-rest-spring-example-common</artifactId>
<name>${project.groupId}:${project.artifactId}</name> <name>${project.groupId}:${project.artifactId}</name>
<description>groups the minimum required configuration for a taskana REST APP</description> <description>groups the minimum required configuration for a taskana REST APP</description>
<parent> <parent>
<groupId>pro.taskana</groupId> <groupId>pro.taskana</groupId>
<artifactId>taskana-rest-parent</artifactId> <artifactId>taskana-rest-parent</artifactId>
<version>1.2.3-SNAPSHOT</version> <version>1.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring.boot}</version> <version>${version.spring.boot}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>pro.taskana</groupId> <groupId>pro.taskana</groupId>
<artifactId>taskana-rest-spring</artifactId> <artifactId>taskana-rest-spring</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> <exclusions>
<dependency> <exclusion>
<groupId>pro.taskana</groupId> <groupId>org.springframework.hateoas</groupId>
<artifactId>taskana-data</artifactId> <artifactId>spring-hateoas</artifactId>
<version>${project.version}</version> </exclusion>
</dependency> </exclusions>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-starter-web</artifactId> <groupId>org.springframework.hateoas</groupId>
<version>${version.spring.boot}</version> <artifactId>spring-hateoas</artifactId>
</dependency> <version>${version.spring.hateos}</version>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-starter-security</artifactId> <groupId>pro.taskana</groupId>
<version>${version.spring.boot}</version> <artifactId>taskana-data</artifactId>
</dependency> <version>${project.version}</version>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-starter-jdbc</artifactId> <groupId>org.springframework.boot</groupId>
<version>${version.spring.boot}</version> <artifactId>spring-boot-starter-web</artifactId>
</dependency> <version>${version.spring.boot}</version>
<dependency> </dependency>
<groupId>org.springframework.plugin</groupId> <dependency>
<artifactId>spring-plugin-core</artifactId> <groupId>org.springframework.boot</groupId>
</dependency> <artifactId>spring-boot-starter-security</artifactId>
<dependency> <version>${version.spring.boot}</version>
<groupId>org.springframework.ldap</groupId> </dependency>
<artifactId>spring-ldap-core</artifactId> <dependency>
<version>${version.spring.ldap}</version> <groupId>org.springframework.boot</groupId>
</dependency> <artifactId>spring-boot-starter-jdbc</artifactId>
<dependency> <version>${version.spring.boot}</version>
<groupId>org.springframework.boot</groupId> </dependency>
<artifactId>spring-boot-starter-thymeleaf</artifactId> <dependency>
<version>${version.spring.boot}</version> <groupId>org.springframework.plugin</groupId>
</dependency> <artifactId>spring-plugin-core</artifactId>
<!-- <version>${version.spring.core}</version>
Since taskana-web packs its content in /static, we do not have to unpack it again. </dependency>
However, when any local change has to be done to that folder you have to copy <dependency>
target/classes/static manually from taskana-web. <groupId>org.springframework.ldap</groupId>
--> <artifactId>spring-ldap-core</artifactId>
<dependency> <version>${version.spring.ldap}</version>
<groupId>pro.taskana</groupId> </dependency>
<artifactId>taskana-web</artifactId> <dependency>
<version>${project.version}</version> <groupId>org.springframework.boot</groupId>
</dependency> <artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>${version.spring.boot}</version>
<!-- test dependencies --> </dependency>
<dependency> <!-- Since taskana-web packs its content in /static, we do not have
<groupId>org.assertj</groupId> to unpack it again. However, when any local change has to be done to that
<artifactId>assertj-core</artifactId> folder you have to copy target/classes/static manually from taskana-web. -->
<version>${version.assertj}</version> <dependency>
<scope>test</scope> <groupId>pro.taskana</groupId>
</dependency> <artifactId>taskana-web</artifactId>
<dependency> <version>${project.version}</version>
<groupId>org.springframework.boot</groupId> </dependency>
<artifactId>spring-boot-starter-test</artifactId>
<version>${version.spring.boot}</version> <!-- test dependencies -->
<scope>test</scope> <dependency>
</dependency> <groupId>org.assertj</groupId>
<dependency> <artifactId>assertj-core</artifactId>
<groupId>org.springframework.security</groupId> <version>${version.assertj}</version>
<artifactId>spring-security-test</artifactId> <scope>test</scope>
<version>${version.spring}</version> </dependency>
<scope>test</scope> <dependency>
</dependency> <groupId>org.springframework.boot</groupId>
<dependency> <artifactId>spring-boot-starter-test</artifactId>
<groupId>com.h2database</groupId> <version>${version.spring.boot}</version>
<artifactId>h2</artifactId> <scope>test</scope>
<version>${version.h2}</version> </dependency>
<scope>test</scope> <dependency>
</dependency> <groupId>org.springframework.security</groupId>
<dependency> <artifactId>spring-security-test</artifactId>
<groupId>org.junit.jupiter</groupId> <version>${version.spring.security}</version>
<artifactId>junit-jupiter-api</artifactId> <scope>test</scope>
<version>${version.junit.jupiter}</version> </dependency>
<scope>test</scope> <dependency>
</dependency> <groupId>com.h2database</groupId>
<dependency> <artifactId>h2</artifactId>
<groupId>org.junit.jupiter</groupId> <version>${version.h2}</version>
<artifactId>junit-jupiter-engine</artifactId> <scope>test</scope>
<version>${version.junit.jupiter}</version> </dependency>
<scope>test</scope> <dependency>
</dependency> <groupId>org.springframework.ldap</groupId>
<dependency> <artifactId>spring-ldap-test</artifactId>
<groupId>org.junit.vintage</groupId> <version>${version.spring.ldap}</version>
<artifactId>junit-vintage-engine</artifactId> <scope>test</scope>
<version>${version.junit.jupiter}</version> <exclusions>
<scope>test</scope> <exclusion>
</dependency> <groupId>commons-logging</groupId>
<dependency> <artifactId>commons-logging</artifactId>
<groupId>org.springframework.ldap</groupId> </exclusion>
<artifactId>spring-ldap-test</artifactId> </exclusions>
<version>${version.spring.ldap}</version> </dependency>
<scope>test</scope> </dependencies>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project> </project>

View File

@ -1,70 +1,80 @@
package pro.taskana; package pro.taskana;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
/** Helps to simplify rest api testing. */ /** Helps to simplify rest api testing. */
@Component @Component
public class RestHelper { public class RestHelper {
@Autowired Environment environment; public static final RestTemplate template = getRestTemplate();
@Autowired Environment environment;
public String toUrl(String relativeUrl, Object... uriVariables) {
return UriComponentsBuilder.fromPath(relativeUrl) public String toUrl(String relativeUrl, Object... uriVariables) {
.scheme("http") return UriComponentsBuilder.fromPath(relativeUrl)
.host("127.0.0.1") .scheme("http")
.port(environment.getProperty("local.server.port")) .host("127.0.0.1")
.build(uriVariables) .port(environment.getProperty("local.server.port"))
.toString(); .build(false)
} .expand(uriVariables)
.toString();
public HttpEntity<String> defaultRequest() { }
return new HttpEntity<>(getHeaders());
} public HttpEntity<String> defaultRequest() {
return new HttpEntity<>(getHeaders());
public HttpHeaders getHeaders() { }
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); public HttpHeaders getHeaders() {
headers.add("Content-Type", "application/json"); HttpHeaders headers = new HttpHeaders();
return headers; headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
} headers.add("Content-Type", "application/json");
return headers;
public HttpHeaders getHeadersAdmin() { }
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin public HttpHeaders getHeadersAdmin() {
headers.add("Content-Type", "application/hal+json"); HttpHeaders headers = new HttpHeaders();
return headers; headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin
} headers.add("Content-Type", "application/hal+json");
return headers;
/** }
* Return a REST template which is capable of dealing with responses in HAL format.
* public HttpHeaders getHeadersBusinessAdmin() {
* @return RestTemplate HttpHeaders headers = new HttpHeaders();
*/ // businessadmin:businessadmin
public static RestTemplate getRestTemplate() { headers.add("Authorization", "Basic YnVzaW5lc3NhZG1pbjpidXNpbmVzc2FkbWlu");
ObjectMapper mapper = new ObjectMapper(); headers.add("Content-Type", "application/hal+json");
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return headers;
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); }
mapper.registerModule(new Jackson2HalModule());
/**
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); * Return a REST template which is capable of dealing with responses in HAL format.
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); *
converter.setObjectMapper(mapper); * @return RestTemplate
*/
RestTemplate template = new RestTemplate(); public static RestTemplate getRestTemplate() {
// important to add first to ensure priority ObjectMapper mapper = new ObjectMapper();
template.getMessageConverters().add(0, converter); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return template; mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
} mapper.registerModule(new Jackson2HalModule());
}
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate();
// important to add first to ensure priority
template.getMessageConverters().add(0, converter);
return template;
}
}

View File

@ -1,168 +1,168 @@
package pro.taskana.jobs; package pro.taskana.jobs;
import static org.junit.Assert.assertFalse; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNotNull;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper; import java.time.Instant;
import java.time.Instant; import java.util.ArrayList;
import java.util.ArrayList; import java.util.Arrays;
import java.util.Arrays; import java.util.List;
import java.util.List; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.hateoas.Link;
import org.springframework.hateoas.Link; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod;
import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper;
import pro.taskana.RestHelper; import pro.taskana.classification.api.Classification;
import pro.taskana.classification.api.Classification; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.rest.Mapping;
import pro.taskana.rest.Mapping; import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.resource.ClassificationResource;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationResourceAssembler;
import pro.taskana.rest.resource.ClassificationResourceAssembler; import pro.taskana.rest.resource.TaskResource;
import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskResourceAssembler;
import pro.taskana.rest.resource.TaskResourceAssembler; import pro.taskana.task.api.Task;
import pro.taskana.task.api.Task;
/** Test async updates. */
/** Test async updates. */ @ActiveProfiles({"test"})
@ActiveProfiles({"test"}) @ExtendWith(SpringExtension.class)
@ExtendWith(SpringExtension.class) @SpringBootTest(
@SpringBootTest( classes = RestConfiguration.class,
classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) properties = "spring.main.allow-bean-definition-overriding=true")
class AsyncUpdateJobIntTest { class AsyncUpdateJobIntTest {
private static final String CLASSIFICATION_ID = "CLI:100000000000000000000000000000000003"; private static final String CLASSIFICATION_ID = "CLI:100000000000000000000000000000000003";
static RestTemplate template; @SuppressWarnings("checkstyle:DeclarationOrder")
static RestTemplate template;
@Autowired ClassificationResourceAssembler classificationResourceAssembler;
@Autowired TaskResourceAssembler taskResourceAssembler; @Autowired ClassificationResourceAssembler classificationResourceAssembler;
@Autowired JobScheduler jobScheduler; @Autowired TaskResourceAssembler taskResourceAssembler;
@Autowired RestHelper restHelper; @Autowired JobScheduler jobScheduler;
@Autowired RestHelper restHelper;
@BeforeAll
static void init() { @BeforeAll
template = RestHelper.getRestTemplate(); static void init() {
} template = RestHelper.getRestTemplate();
}
@Test
void testUpdateClassificationPrioServiceLevel() throws Exception { @Test
void testUpdateClassificationPrioServiceLevel() throws Exception {
// 1st step: get old classification :
final Instant before = Instant.now(); // 1st step: get old classification :
final ObjectMapper mapper = new ObjectMapper(); final Instant before = Instant.now();
final ObjectMapper mapper = new ObjectMapper();
ResponseEntity<ClassificationResource> response =
template.exchange( ResponseEntity<ClassificationResource> response =
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID), template.exchange(
HttpMethod.GET, restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
new HttpEntity<String>(restHelper.getHeaders()), HttpMethod.GET,
ParameterizedTypeReference.forType(ClassificationResource.class)); new HttpEntity<String>(restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class));
assertNotNull(response.getBody());
ClassificationResource classification = response.getBody(); assertThat(response.getBody()).isNotNull();
assertNotNull(classification.getLink(Link.REL_SELF)); ClassificationResource classification = response.getBody();
assertThat(classification.getLink(Link.REL_SELF)).isNotNull();
// 2nd step: modify classification and trigger update
classification.removeLinks(); // 2nd step: modify classification and trigger update
classification.setServiceLevel("P5D"); classification.removeLinks();
classification.setPriority(1000); classification.setServiceLevel("P5D");
classification.setPriority(1000);
template.put(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID), template.put(
new HttpEntity<>(mapper.writeValueAsString(classification), restHelper.getHeaders())); restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
new HttpEntity<>(mapper.writeValueAsString(classification), restHelper.getHeaders()));
// trigger jobs twice to refresh all entries. first entry on the first call and follow up on the
// seconds call // trigger jobs twice to refresh all entries. first entry on the first call and follow up on the
jobScheduler.triggerJobs(); // seconds call
jobScheduler.triggerJobs(); jobScheduler.triggerJobs();
jobScheduler.triggerJobs();
// verify the classification modified timestamp is after 'before'
ResponseEntity<ClassificationResource> repeatedResponse = // verify the classification modified timestamp is after 'before'
template.exchange( ResponseEntity<ClassificationResource> repeatedResponse =
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID), template.exchange(
HttpMethod.GET, restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
new HttpEntity<String>(restHelper.getHeaders()), HttpMethod.GET,
ParameterizedTypeReference.forType(ClassificationResource.class)); new HttpEntity<String>(restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class));
assertNotNull(repeatedResponse.getBody());
assertThat(repeatedResponse.getBody()).isNotNull();
ClassificationResource modifiedClassificationResource = repeatedResponse.getBody();
Classification modifiedClassification = ClassificationResource modifiedClassificationResource = repeatedResponse.getBody();
classificationResourceAssembler.toModel(modifiedClassificationResource); Classification modifiedClassification =
classificationResourceAssembler.toModel(modifiedClassificationResource);
assertFalse(before.isAfter(modifiedClassification.getModified()));
assertThat(before).isBefore(modifiedClassification.getModified());
List<String> affectedTasks =
new ArrayList<>( List<String> affectedTasks =
Arrays.asList( new ArrayList<>(
"TKI:000000000000000000000000000000000003", Arrays.asList(
"TKI:000000000000000000000000000000000004", "TKI:000000000000000000000000000000000003",
"TKI:000000000000000000000000000000000005", "TKI:000000000000000000000000000000000004",
"TKI:000000000000000000000000000000000006", "TKI:000000000000000000000000000000000005",
"TKI:000000000000000000000000000000000007", "TKI:000000000000000000000000000000000006",
"TKI:000000000000000000000000000000000008", "TKI:000000000000000000000000000000000007",
"TKI:000000000000000000000000000000000009", "TKI:000000000000000000000000000000000008",
"TKI:000000000000000000000000000000000010", "TKI:000000000000000000000000000000000009",
"TKI:000000000000000000000000000000000011", "TKI:000000000000000000000000000000000010",
"TKI:000000000000000000000000000000000012", "TKI:000000000000000000000000000000000011",
"TKI:000000000000000000000000000000000013", "TKI:000000000000000000000000000000000012",
"TKI:000000000000000000000000000000000014", "TKI:000000000000000000000000000000000013",
"TKI:000000000000000000000000000000000015", "TKI:000000000000000000000000000000000014",
"TKI:000000000000000000000000000000000016", "TKI:000000000000000000000000000000000015",
"TKI:000000000000000000000000000000000017", "TKI:000000000000000000000000000000000016",
"TKI:000000000000000000000000000000000018", "TKI:000000000000000000000000000000000017",
"TKI:000000000000000000000000000000000019", "TKI:000000000000000000000000000000000018",
"TKI:000000000000000000000000000000000020", "TKI:000000000000000000000000000000000019",
"TKI:000000000000000000000000000000000021", "TKI:000000000000000000000000000000000020",
"TKI:000000000000000000000000000000000022", "TKI:000000000000000000000000000000000021",
"TKI:000000000000000000000000000000000023", "TKI:000000000000000000000000000000000022",
"TKI:000000000000000000000000000000000024", "TKI:000000000000000000000000000000000023",
"TKI:000000000000000000000000000000000025", "TKI:000000000000000000000000000000000024",
"TKI:000000000000000000000000000000000026", "TKI:000000000000000000000000000000000025",
"TKI:000000000000000000000000000000000027", "TKI:000000000000000000000000000000000026",
"TKI:000000000000000000000000000000000028", "TKI:000000000000000000000000000000000027",
"TKI:000000000000000000000000000000000029", "TKI:000000000000000000000000000000000028",
"TKI:000000000000000000000000000000000030", "TKI:000000000000000000000000000000000029",
"TKI:000000000000000000000000000000000031", "TKI:000000000000000000000000000000000030",
"TKI:000000000000000000000000000000000032", "TKI:000000000000000000000000000000000031",
"TKI:000000000000000000000000000000000033", "TKI:000000000000000000000000000000000032",
"TKI:000000000000000000000000000000000034", "TKI:000000000000000000000000000000000033",
"TKI:000000000000000000000000000000000035", "TKI:000000000000000000000000000000000034",
"TKI:000000000000000000000000000000000100", "TKI:000000000000000000000000000000000035",
"TKI:000000000000000000000000000000000101", "TKI:000000000000000000000000000000000100",
"TKI:000000000000000000000000000000000102", "TKI:000000000000000000000000000000000101",
"TKI:000000000000000000000000000000000103")); "TKI:000000000000000000000000000000000102",
for (String taskId : affectedTasks) { "TKI:000000000000000000000000000000000103"));
verifyTaskIsModifiedAfterOrEquals(taskId, before); for (String taskId : affectedTasks) {
} verifyTaskIsModifiedAfterOrEquals(taskId, before);
} }
}
private void verifyTaskIsModifiedAfterOrEquals(String taskId, Instant before)
throws InvalidArgumentException { private void verifyTaskIsModifiedAfterOrEquals(String taskId, Instant before)
throws InvalidArgumentException {
ResponseEntity<TaskResource> taskResponse =
template.exchange( ResponseEntity<TaskResource> taskResponse =
restHelper.toUrl(Mapping.URL_TASKS_ID, taskId), template.exchange(
HttpMethod.GET, restHelper.toUrl(Mapping.URL_TASKS_ID, taskId),
new HttpEntity<>(restHelper.getHeadersAdmin()), HttpMethod.GET,
ParameterizedTypeReference.forType(TaskResource.class)); new HttpEntity<>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskResource.class));
TaskResource taskResource = taskResponse.getBody();
Task task = taskResourceAssembler.toModel(taskResource); TaskResource taskResource = taskResponse.getBody();
Task task = taskResourceAssembler.toModel(taskResource);
Instant modified = task.getModified();
boolean isAfterOrEquals = before.isAfter(modified) || before.equals(modified); Instant modified = task.getModified();
assertFalse("Task " + task.getId() + " has not been refreshed.", isAfterOrEquals); assertThat(before).as("Task " + task.getId() + " has not been refreshed.").isBefore(modified);
} }
} }

View File

@ -1,36 +1,37 @@
package pro.taskana.ldap; package pro.taskana.ldap;
import static org.junit.Assert.assertEquals; import static org.assertj.core.api.Assertions.assertThat;
import java.util.List; import java.util.List;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringExtension;
import pro.taskana.common.api.LoggerUtils; import pro.taskana.common.api.LoggerUtils;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdResource;
/** Test Ldap attachment. */ /** Test Ldap attachment. */
@ActiveProfiles({"test"}) @ActiveProfiles({"test"})
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@SpringBootTest( @SpringBootTest(
classes = RestConfiguration.class, classes = RestConfiguration.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
class LdapTest { properties = "spring.main.allow-bean-definition-overriding=true")
class LdapTest {
@Autowired private LdapClient ldapClient;
@Autowired private LdapClient ldapClient;
@Test
void testFindUsers() throws InvalidArgumentException { @Test
if (ldapClient.useLdap()) { void testFindUsers() throws InvalidArgumentException {
List<AccessIdResource> usersAndGroups = ldapClient.searchUsersAndGroups("ser0"); if (ldapClient.useLdap()) {
System.out.println("#### found " + LoggerUtils.listToString(usersAndGroups)); List<AccessIdResource> usersAndGroups = ldapClient.searchUsersAndGroups("ser0");
assertEquals(50, usersAndGroups.size()); System.out.println("#### found " + LoggerUtils.listToString(usersAndGroups));
} assertThat(usersAndGroups.size()).isEqualTo(50);
} }
}
} }

View File

@ -1,86 +0,0 @@
package pro.taskana.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper;
import pro.taskana.ldap.LdapCacheTestImpl;
import pro.taskana.rest.resource.AccessIdResource;
/** Test AccessIdValidation. */
@ActiveProfiles({"test"})
@ExtendWith(SpringExtension.class)
@SpringBootTest(
classes = RestConfiguration.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class AccessIdValidationControllerIntTest {
static RestTemplate template;
@Autowired RestHelper restHelper;
@BeforeAll
static void init() {
template = RestHelper.getRestTemplate();
}
@Test
void testGetMatches() {
AccessIdController.setLdapCache(new LdapCacheTestImpl());
HttpEntity<String> request = new HttpEntity<String>(restHelper.getHeaders());
ResponseEntity<List<AccessIdResource>> response =
template.exchange(
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=ali",
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(AccessIdListResource.class));
List<AccessIdResource> body = response.getBody();
assertNotNull(body);
assertEquals(3, body.size());
List<String> expectedIds =
new ArrayList<>(Arrays.asList("Tralisch, Thea", "Bert, Ali", "Mente, Ali"));
for (AccessIdResource accessId : body) {
assertTrue(expectedIds.contains(accessId.getName()));
}
}
@Test
void testBadRequestWhenSearchForIsTooShort() {
AccessIdController.setLdapCache(new LdapCacheTestImpl());
HttpEntity<String> request = new HttpEntity<String>(restHelper.getHeaders());
try {
template.exchange(
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=al",
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(List.class));
} catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
assertTrue(e.getResponseBodyAsString().contains("Minimum searchFor length ="));
}
}
static class AccessIdListResource extends ArrayList<AccessIdResource> {
private static final long serialVersionUID = 1L;
}
}

View File

@ -1,359 +1,355 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" <project 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"> xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>taskana-rest-spring-example-wildfly</artifactId> <modelVersion>4.0.0</modelVersion>
<packaging>war</packaging> <artifactId>taskana-rest-spring-example-wildfly</artifactId>
<packaging>war</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>Demo project for the taskana REST APP in a wildfly environment.</description> <name>${project.groupId}:${project.artifactId}</name>
<description>Demo project for the taskana REST APP in a wildfly environment.</description>
<parent>
<groupId>pro.taskana</groupId> <parent>
<artifactId>taskana-rest-parent</artifactId> <groupId>pro.taskana</groupId>
<version>1.2.3-SNAPSHOT</version> <artifactId>taskana-rest-parent</artifactId>
<relativePath>../pom.xml</relativePath> <version>1.2.3-SNAPSHOT</version>
</parent> <relativePath>../pom.xml</relativePath>
</parent>
<properties>
<skipIntegrationTests>true</skipIntegrationTests> <properties>
<!-- Default H2 DB configuration --> <skipIntegrationTests>true</skipIntegrationTests>
<connection-url>jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0</connection-url> <!-- Default H2 DB configuration -->
<driver-class>org.h2.Driver</driver-class> <connection-url>jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0</connection-url>
<driver-name>h2</driver-name> <driver-class>org.h2.Driver</driver-class>
<user-name>sa</user-name> <driver-name>h2</driver-name>
<password>sa</password> <user-name>sa</user-name>
</properties> <password>sa</password>
</properties>
<dependencyManagement>
<dependencies> <dependencyManagement>
<dependency> <dependencies>
<groupId>io.thorntail</groupId> <dependency>
<artifactId>bom</artifactId> <groupId>io.thorntail</groupId>
<version>${version.thorntail}</version> <artifactId>bom</artifactId>
<scope>import</scope> <version>${version.thorntail}</version>
<type>pom</type> <scope>import</scope>
</dependency> <type>pom</type>
<dependency> </dependency>
<groupId>org.jboss.arquillian</groupId> <dependency>
<artifactId>arquillian-bom</artifactId> <groupId>org.jboss.arquillian</groupId>
<version>${version.arquillian}</version> <artifactId>arquillian-bom</artifactId>
<type>pom</type> <version>${version.arquillian}</version>
<scope>import</scope> <type>pom</type>
</dependency> <scope>import</scope>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-dependencies</artifactId> <groupId>org.springframework.boot</groupId>
<version>${version.spring.boot}</version> <artifactId>spring-boot-dependencies</artifactId>
<type>pom</type> <version>${version.spring.boot}</version>
<scope>import</scope> <type>pom</type>
</dependency> <scope>import</scope>
</dependencies> </dependency>
</dependencyManagement> </dependencies>
<dependencies> </dependencyManagement>
<dependency> <dependencies>
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-starter-web</artifactId> <groupId>org.springframework.boot</groupId>
<exclusions> <artifactId>spring-boot-starter-web</artifactId>
<exclusion> <exclusions>
<groupId>org.springframework.boot</groupId> <exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId> <groupId>org.springframework.boot</groupId>
</exclusion> <artifactId>spring-boot-starter-tomcat</artifactId>
</exclusions> </exclusion>
</dependency> </exclusions>
<dependency> </dependency>
<groupId>pro.taskana</groupId> <dependency>
<artifactId>taskana-rest-spring-example-common</artifactId> <groupId>pro.taskana</groupId>
<version>${project.version}</version> <artifactId>taskana-rest-spring-example-common</artifactId>
</dependency> <version>${project.version}</version>
<dependency> <exclusions>
<groupId>org.springframework.plugin</groupId> <exclusion>
<artifactId>spring-plugin-core</artifactId> <groupId>org.springframework.hateoas</groupId>
</dependency> <artifactId>spring-hateoas</artifactId>
<dependency> </exclusion>
<groupId>javax.servlet</groupId> </exclusions>
<artifactId>javax.servlet-api</artifactId> </dependency>
<scope>provided</scope> <dependency>
</dependency> <groupId>org.springframework.hateoas</groupId>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> <artifactId>spring-hateoas</artifactId>
<dependency> <version>${version.spring.hateos}</version>
<groupId>org.postgresql</groupId> </dependency>
<artifactId>postgresql</artifactId> <dependency>
</dependency> <groupId>org.springframework.plugin</groupId>
<!-- https://mvnrepository.com/artifact/com.h2database/h2 --> <artifactId>spring-plugin-core</artifactId>
<dependency> <version>${version.spring.core}</version>
<groupId>com.h2database</groupId> </dependency>
<artifactId>h2</artifactId> <dependency>
</dependency> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<dependency> <scope>provided</scope>
<groupId>org.wildfly.security</groupId> </dependency>
<artifactId>wildfly-elytron</artifactId> <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<version>${version.wildfly.security}</version> <dependency>
</dependency> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<!-- test dependencies --> </dependency>
<dependency> <!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<groupId>org.assertj</groupId> <dependency>
<artifactId>assertj-core</artifactId> <groupId>com.h2database</groupId>
<version>${version.assertj}</version> <artifactId>h2</artifactId>
<scope>test</scope> </dependency>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.wildfly.security</groupId>
<artifactId>junit-jupiter-api</artifactId> <artifactId>wildfly-elytron</artifactId>
<version>${version.junit.jupiter}</version> <version>${version.wildfly.security}</version>
<scope>test</scope> </dependency>
</dependency>
<dependency> <!-- test dependencies -->
<groupId>org.junit.jupiter</groupId> <dependency>
<artifactId>junit-jupiter-engine</artifactId> <groupId>org.assertj</groupId>
<version>${version.junit.jupiter}</version> <artifactId>assertj-core</artifactId>
<scope>test</scope> <version>${version.assertj}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.junit.vintage</groupId> <dependency>
<artifactId>junit-vintage-engine</artifactId> <groupId>org.jboss.resteasy</groupId>
<version>${version.junit.jupiter}</version> <artifactId>resteasy-client</artifactId>
<scope>test</scope> <version>${version.resteasy}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.jboss.resteasy</groupId> <!-- Brought in via WildFly Swarm bom -->
<artifactId>resteasy-client</artifactId> <dependency>
<version>${version.resteasy}</version> <groupId>io.thorntail</groupId>
<scope>test</scope> <artifactId>arquillian</artifactId>
</dependency> <scope>test</scope>
<!-- Brought in via WildFly Swarm bom --> </dependency>
<dependency> <!-- Brought in via Arquillian BOM, see dependencyManagement section
<groupId>io.thorntail</groupId> above -->
<artifactId>arquillian</artifactId> <dependency>
<scope>test</scope> <groupId>org.jboss.arquillian.junit</groupId>
</dependency> <artifactId>arquillian-junit-container</artifactId>
<!-- Brought in via Arquillian BOM, see dependencyManagement section above --> <scope>test</scope>
<dependency> </dependency>
<groupId>org.jboss.arquillian.junit</groupId> <dependency>
<artifactId>arquillian-junit-container</artifactId> <groupId>org.jboss.shrinkwrap.resolver</groupId>
<scope>test</scope> <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId> <dependency>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId> <groupId>org.springframework</groupId>
<scope>test</scope> <artifactId>spring-test</artifactId>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.springframework</groupId> </dependencies>
<artifactId>spring-test</artifactId>
<scope>test</scope> <profiles>
</dependency> <profile>
</dependencies> <id>postgres</id>
<activation>
<profiles> <activeByDefault>false</activeByDefault>
<profile> </activation>
<id>postgres</id> <!-- Reading properties from file and use then as data source
<activation> properties is a pending improvement of Jboss development team check out ->
<activeByDefault>false</activeByDefault> https://issues.jboss.org/browse/WFMP-70 That's why we are including postgres
</activation> connection properties directly in this pom file. -->
<!-- Reading properties from file and use then as data source properties <properties>
is a pending improvement of Jboss development team check out -> https://issues.jboss.org/browse/WFMP-70 <driver-class>org.postgresql.Driver</driver-class>
That's why we are including postgres connection properties directly in this <connection-url>jdbc:postgresql://localhost:50102/postgres</connection-url>
pom file. --> <driver-name>postgresqldriver</driver-name>
<properties> <user-name>postgres</user-name>
<driver-class>org.postgresql.Driver</driver-class> <password>postgres</password>
<connection-url>jdbc:postgresql://localhost:50102/postgres</connection-url> <activatedProperties>postgres</activatedProperties>
<driver-name>postgresqldriver</driver-name> <skipIntegrationTests>false</skipIntegrationTests>
<user-name>postgres</user-name> </properties>
<password>postgres</password> </profile>
<activatedProperties>postgres</activatedProperties> </profiles>
<skipIntegrationTests>false</skipIntegrationTests>
</properties> <build>
</profile> <resources>
</profiles> <resource>
<directory>src/main/resources</directory>
<build> <filtering>true</filtering>
<resources> </resource>
<resource> </resources>
<directory>src/main/resources</directory> <plugins>
<filtering>true</filtering> <plugin>
</resource> <groupId>org.wildfly.plugins</groupId>
</resources> <artifactId>wildfly-maven-plugin</artifactId>
<plugins> <version>${version.maven.wildfly}</version>
<plugin> <configuration>
<groupId>org.wildfly.plugins</groupId> <version>${version.wildfly}</version>
<artifactId>wildfly-maven-plugin</artifactId> <add-user>
<version>${version.maven.wildfly}</version> <users>
<configuration> <user>
<version>${version.wildfly}</version> <username>admin</username>
<add-user> <password>admin</password>
<users> </user>
<user> <user>
<username>admin</username> <username>admin</username>
<password>admin</password> <password>admin</password>
</user> <groups>
<user> <group>testGroup</group>
<username>admin</username> </groups>
<password>admin</password> <applicationUser>true</applicationUser>
<groups> </user>
<group>testGroup</group> </users>
</groups> </add-user>
<applicationUser>true</applicationUser> </configuration>
</user> <executions>
</users> <execution>
</add-user> <id>run-wildfly</id>
</configuration> <phase>install</phase>
<executions> <goals>
<execution> <goal>start</goal>
<id>run-wildfly</id> </goals>
<phase>install</phase> </execution>
<goals> <!-- Deploy the JDBC library in JBoss -->
<goal>start</goal> <execution>
</goals> <id>deploy-driver</id>
</execution> <phase>install</phase>
<!-- Deploy the JDBC library in JBoss --> <configuration>
<execution> <groupId>org.postgresql</groupId>
<id>deploy-driver</id> <artifactId>postgresql</artifactId>
<phase>install</phase> <name>postgresqldriver</name>
<configuration> </configuration>
<groupId>org.postgresql</groupId> <goals>
<artifactId>postgresql</artifactId> <goal>deploy-artifact</goal>
<name>postgresqldriver</name> </goals>
</configuration> </execution>
<goals> <!-- Add a data source -->
<goal>deploy-artifact</goal> <execution>
</goals> <id>add-datasource</id>
</execution> <phase>install</phase>
<!-- Add a data source --> <configuration>
<execution> <address>subsystem=datasources,data-source=java:/TaskanaDS</address>
<id>add-datasource</id> <resources>
<phase>install</phase> <resource>
<configuration> <properties>
<address>subsystem=datasources,data-source=java:/TaskanaDS</address> <jndi-name>java:/TaskanaDS</jndi-name>
<resources> <enabled>true</enabled>
<resource> <connection-url>${connection-url}</connection-url>
<properties> <driver-class>${driver-class}</driver-class>
<jndi-name>java:/TaskanaDS</jndi-name> <driver-name>${driver-name}</driver-name>
<enabled>true</enabled> <user-name>${user-name}</user-name>
<connection-url>${connection-url}</connection-url> <password>${password}</password>
<driver-class>${driver-class}</driver-class> </properties>
<driver-name>${driver-name}</driver-name> </resource>
<user-name>${user-name}</user-name> </resources>
<password>${password}</password> </configuration>
</properties> <goals>
</resource> <goal>add-resource</goal>
</resources> </goals>
</configuration> </execution>
<goals> <execution>
<goal>add-resource</goal> <id>edit-undertow</id>
</goals> <phase>install</phase>
</execution> <goals>
<execution> <goal>execute-commands</goal>
<id>edit-undertow</id> </goals>
<phase>install</phase> <configuration>
<goals> <commands>
<goal>execute-commands</goal> <command>/subsystem=undertow:write-attribute(name=default-server,value=default-server)</command>
</goals> <command>/subsystem=undertow:write-attribute(name=default-virtual-host,value=default-host)</command>
<configuration> <command>/subsystem=undertow:write-attribute(name=default-servlet-container,value=default)</command>
<commands> <command>/subsystem=undertow:write-attribute(name=default-security-domain,value=ApplicationDomain)</command>
<command>/subsystem=undertow:write-attribute(name=default-server,value=default-server)</command> </commands>
<command>/subsystem=undertow:write-attribute(name=default-virtual-host,value=default-host)</command> </configuration>
<command>/subsystem=undertow:write-attribute(name=default-servlet-container,value=default)</command> </execution>
<command>/subsystem=undertow:write-attribute(name=default-security-domain,value=ApplicationDomain)</command> <execution>
</commands> <id>add-application-security-domain</id>
</configuration> <phase>install</phase>
</execution> <goals>
<execution> <goal>add-resource</goal>
<id>add-application-security-domain</id> </goals>
<phase>install</phase> <configuration>
<goals> <address>subsystem=undertow</address>
<goal>add-resource</goal> <resources>
</goals> <resource>
<configuration> <address>application-security-domain=ApplicationDomain</address>
<address>subsystem=undertow</address> <properties>
<resources> <http-authentication-factory>application-http-authentication</http-authentication-factory>
<resource> </properties>
<address>application-security-domain=ApplicationDomain</address> </resource>
<properties> </resources>
<http-authentication-factory>application-http-authentication</http-authentication-factory> </configuration>
</properties> </execution>
</resource> <!-- Deploy the application on install -->
</resources> <execution>
</configuration> <id>wildfly-deploy</id>
</execution> <phase>install</phase>
<!-- Deploy the application on install --> <goals>
<execution> <goal>deploy</goal>
<id>wildfly-deploy</id> </goals>
<phase>install</phase> </execution>
<goals> <!-- shutdown the application on install -->
<goal>deploy</goal> <execution>
</goals> <id>wildfly-shutdown</id>
</execution> <phase>install</phase>
<!-- shutdown the application on install --> <goals>
<execution> <goal>shutdown</goal>
<id>wildfly-shutdown</id> </goals>
<phase>install</phase> </execution>
<goals> </executions>
<goal>shutdown</goal> </plugin>
</goals> <plugin>
</execution> <groupId>org.apache.maven.plugins</groupId>
</executions> <artifactId>maven-surefire-plugin</artifactId>
</plugin> <version>${version.maven.surefire}</version>
<plugin> <executions>
<groupId>org.apache.maven.plugins</groupId> <execution>
<artifactId>maven-surefire-plugin</artifactId> <id>default-test</id>
<version>${version.maven.surefire}</version> <configuration>
<executions> <skip>true</skip>
<execution> </configuration>
<id>default-test</id> </execution>
<configuration> <execution>
<skip>true</skip> <id>integration-tests</id>
</configuration> <phase>test</phase>
</execution> <goals>
<execution> <goal>test</goal>
<id>integration-tests</id> </goals>
<phase>test</phase> <configuration>
<goals> <skip>${skipIntegrationTests}</skip>
<goal>test</goal> <includes>
</goals> <include>**/*Test.java</include>
<configuration> </includes>
<skip>${skipIntegrationTests}</skip> </configuration>
<includes> </execution>
<include>**/*Test.java</include> </executions>
</includes> </plugin>
</configuration> <plugin>
</execution> <groupId>org.apache.maven.plugins</groupId>
</executions> <artifactId>maven-resources-plugin</artifactId>
</plugin> <version>${version.maven.resources}</version>
<plugin> <executions>
<groupId>org.apache.maven.plugins</groupId> <execution>
<artifactId>maven-resources-plugin</artifactId> <id>copy-documentation-to-static-folder</id>
<version>${version.maven.resources}</version> <phase>prepare-package</phase>
<executions> <goals>
<execution> <goal>copy-resources</goal>
<id>copy-documentation-to-static-folder</id> </goals>
<phase>prepare-package</phase> <configuration>
<goals> <outputDirectory>
<goal>copy-resources</goal> ${project.build.outputDirectory}/static/docs/rest
</goals> </outputDirectory>
<configuration> <resources>
<outputDirectory> <resource>
${project.build.outputDirectory}/static/docs/rest <directory>
</outputDirectory> ../taskana-rest-spring/target/generated-docs
<resources> </directory>
<resource> </resource>
<directory> </resources>
../taskana-rest-spring/target/generated-docs </configuration>
</directory> </execution>
</resource> </executions>
</resources> </plugin>
</configuration> </plugins>
</execution> </build>
</executions>
</plugin> <repositories>
</plugins> <repository>
</build> <id>jboss</id>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<repositories> </repository>
<repository> </repositories>
<id>jboss</id>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
</repositories>
</project> </project>

View File

@ -1,41 +1,44 @@
spring.profiles.active=@activatedProperties@ spring.profiles.active=@activatedProperties@
logging.level.pro.taskana=INFO logging.level.pro.taskana=INFO
### logging.level.org.springframework=DEBUG ### logging.level.org.springframework=DEBUG
######## Taskana DB ####### ######## Taskana DB #######
datasource.jndi=java:/TaskanaDS datasource.jndi=java:/TaskanaDS
taskana.schemaName=TASKANA taskana.schemaName=TASKANA
####### control LDAP usage ####### control LDAP usage
taskana.ldap.useLdap=false taskana.ldap.useLdap=false
####### properties to connect to LDAP ####### properties to connect to LDAP
taskana.ldap.serverUrl=ldap://localhost:10389 taskana.ldap.serverUrl=ldap://localhost:10389
taskana.ldap.bindDn=uid=admin,ou=system taskana.ldap.bindDn=uid=admin,ou=system
taskana.ldap.bindPassword=secret taskana.ldap.bindPassword=secret
taskana.ldap.baseDn=o=TaskanaTest taskana.ldap.baseDn=o=TaskanaTest
####### properties that control search for users and groups ####### properties that control search for users and groups
taskana.ldap.userSearchBase=ou=people taskana.ldap.userSearchBase=ou=people
taskana.ldap.userSearchFilterName=objectclass taskana.ldap.userSearchFilterName=objectclass
taskana.ldap.userSearchFilterValue=person taskana.ldap.userSearchFilterValue=person
taskana.ldap.userFirstnameAttribute=givenName taskana.ldap.userFirstnameAttribute=givenName
taskana.ldap.userLastnameAttribute=sn taskana.ldap.userLastnameAttribute=sn
taskana.ldap.userIdAttribute=uid taskana.ldap.userIdAttribute=uid
taskana.ldap.groupSearchBase=ou=groups taskana.ldap.groupSearchBase=ou=groups
taskana.ldap.groupSearchFilterName=objectclass taskana.ldap.groupSearchFilterName=objectclass
taskana.ldap.groupSearchFilterValue=groupOfUniqueNames taskana.ldap.groupSearchFilterValue=groupOfUniqueNames
taskana.ldap.groupNameAttribute=cn taskana.ldap.groupNameAttribute=cn
taskana.ldap.minSearchForLength=3 taskana.ldap.minSearchForLength=3
taskana.ldap.maxNumberOfReturnedAccessIds=50 taskana.ldap.maxNumberOfReturnedAccessIds=50
taskana.ldap.groupsOfUser=memberUid taskana.ldap.groupsOfUser=memberUid
####### JobScheduler cron expression that specifies when the JobSchedler runs ####### JobScheduler cron expression that specifies when the JobSchedler runs
taskana.jobscheduler.async.cron=0 * * * * * taskana.jobscheduler.async.cron=0 * * * * *
####### cache static resources properties ####### cache static resources properties
spring.resources.cache.cachecontrol.cache-private=true spring.resources.cache.cachecontrol.cache-private=true
####### for upload of big workbasket- or classification-files ####### for upload of big workbasket- or classification-files
spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB spring.servlet.multipart.max-request-size=10MB
server.tomcat.max-http-post-size=-1
server.tomcat.max-save-post-size=-1 spring.main.allow-bean-definition-overriding=true
server.tomcat.max-swallow-size=-1
####### tomcat is not detecting the x-forward headers from bluemix as a trustworthy proxy server.tomcat.max-http-post-size=-1
server.tomcat.internal-proxies=.* server.tomcat.max-save-post-size=-1
server.use-forward-headers=true server.tomcat.max-swallow-size=-1
####### tomcat is not detecting the x-forward headers from bluemix as a trustworthy proxy
server.tomcat.internal-proxies=.*
server.use-forward-headers=true

View File

@ -130,7 +130,7 @@
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId> <artifactId>spring-security-test</artifactId>
<version>${version.spring}</version> <version>${version.spring.security}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -139,18 +139,6 @@
<version>${version.spring.restdocs}</version> <version>${version.spring.restdocs}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${version.mockito}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${version.junit.mockito}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>net.bytebuddy</groupId> <groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId> <artifactId>byte-buddy</artifactId>
@ -169,24 +157,6 @@
<version>${version.h2}</version> <version>${version.h2}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${version.junit.jupiter}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${version.junit.jupiter}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${version.junit.jupiter}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -322,3 +322,4 @@ public class ClassificationController extends AbstractPagingController {
return query; return query;
} }
} }

View File

@ -1,77 +1,78 @@
package pro.taskana.rest; package pro.taskana.rest;
import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
import java.sql.SQLException; import java.sql.SQLException;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.http.converter.json.SpringHandlerInstantiator; import org.springframework.http.converter.json.SpringHandlerInstantiator;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import pro.taskana.TaskanaEngineConfiguration; import pro.taskana.TaskanaEngineConfiguration;
import pro.taskana.classification.api.ClassificationService; import pro.taskana.classification.api.ClassificationService;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.configuration.SpringTaskanaEngineConfiguration; import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.ldap.LdapClient; import pro.taskana.ldap.LdapClient;
import pro.taskana.report.api.TaskMonitorService; import pro.taskana.report.api.TaskMonitorService;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
/** Configuration for REST service. */ /** Configuration for REST service. */
@Configuration @Configuration
@ComponentScan @ComponentScan
@EnableTransactionManagement @EnableTransactionManagement
public class RestConfiguration { public class RestConfiguration {
@Value("${taskana.schemaName:TASKANA}") @Value("${taskana.schemaName:TASKANA}")
private String schemaName; private String schemaName;
@Bean @Bean
public ClassificationService getClassificationService(TaskanaEngine taskanaEngine) { public ClassificationService getClassificationService(TaskanaEngine taskanaEngine) {
return taskanaEngine.getClassificationService(); return taskanaEngine.getClassificationService();
} }
@Bean @Bean
public TaskService getTaskService(TaskanaEngine taskanaEngine) { public TaskService getTaskService(TaskanaEngine taskanaEngine) {
return taskanaEngine.getTaskService(); return taskanaEngine.getTaskService();
} }
@Bean @Bean
public TaskMonitorService getTaskMonitorService(TaskanaEngine taskanaEngine) { public TaskMonitorService getTaskMonitorService(TaskanaEngine taskanaEngine) {
return taskanaEngine.getTaskMonitorService(); return taskanaEngine.getTaskMonitorService();
} }
@Bean @Bean
public WorkbasketService getWorkbasketService(TaskanaEngine taskanaEngine) { public WorkbasketService getWorkbasketService(TaskanaEngine taskanaEngine) {
return taskanaEngine.getWorkbasketService(); return taskanaEngine.getWorkbasketService();
} }
@Bean @Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public TaskanaEngine getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration) { public TaskanaEngine getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration) {
return taskanaEngineConfiguration.buildTaskanaEngine(); return taskanaEngineConfiguration.buildTaskanaEngine();
} }
@Bean @Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public TaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) public TaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource)
throws SQLException { throws SQLException {
return new SpringTaskanaEngineConfiguration(dataSource, true, true, schemaName); return new SpringTaskanaEngineConfiguration(dataSource, true, true, schemaName);
} }
@Bean @Bean
public LdapClient ldapClient() { public LdapClient ldapClient() {
return new LdapClient(); return new LdapClient();
} }
// Needed for injection into jackson deserializer. // Needed for injection into jackson deserializer.
@Bean @Bean
public HandlerInstantiator handlerInstantiator(ApplicationContext context) { public HandlerInstantiator handlerInstantiator(ApplicationContext context) {
return new SpringHandlerInstantiator(context.getAutowireCapableBeanFactory()); return new SpringHandlerInstantiator(context.getAutowireCapableBeanFactory());
} }
}
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.Resources; import org.springframework.hateoas.Resources;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
@ -121,7 +122,7 @@ public class WorkbasketController extends AbstractPagingController {
return response; return response;
} }
@GetMapping(path = Mapping.URL_WORKBASKET_ID) @GetMapping(path = Mapping.URL_WORKBASKET_ID, produces = MediaTypes.HAL_JSON_UTF8_VALUE)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<WorkbasketResource> getWorkbasket( public ResponseEntity<WorkbasketResource> getWorkbasket(
@PathVariable(value = "workbasketId") String workbasketId) @PathVariable(value = "workbasketId") String workbasketId)
@ -308,6 +309,7 @@ public class WorkbasketController extends AbstractPagingController {
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
LOGGER.debug( LOGGER.debug(
"Entry to removeDistributionTargetForWorkbasketId(workbasketId= {})", targetWorkbasketId); "Entry to removeDistributionTargetForWorkbasketId(workbasketId= {})", targetWorkbasketId);
List<WorkbasketSummary> sourceWorkbaskets = List<WorkbasketSummary> sourceWorkbaskets =
workbasketService.getDistributionSources(targetWorkbasketId); workbasketService.getDistributionSources(targetWorkbasketId);
for (WorkbasketSummary source : sourceWorkbaskets) { for (WorkbasketSummary source : sourceWorkbaskets) {

View File

@ -1,79 +1,80 @@
package pro.taskana; package pro.taskana;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
/** Helps to simplify rest api testing. */ /** Helps to simplify rest api testing. */
@Component @Component
public class RestHelper { public class RestHelper {
public static final RestTemplate template = getRestTemplate(); public static final RestTemplate template = getRestTemplate();
@Autowired Environment environment; @Autowired Environment environment;
public String toUrl(String relativeUrl, Object... uriVariables) { public String toUrl(String relativeUrl, Object... uriVariables) {
return UriComponentsBuilder.fromPath(relativeUrl) return UriComponentsBuilder.fromPath(relativeUrl)
.scheme("http") .scheme("http")
.host("127.0.0.1") .host("127.0.0.1")
.port(environment.getProperty("local.server.port")) .port(environment.getProperty("local.server.port"))
.build(uriVariables) .build(false)
.toString(); .expand(uriVariables)
} .toString();
}
public HttpEntity<String> defaultRequest() {
return new HttpEntity<>(getHeaders()); public HttpEntity<String> defaultRequest() {
} return new HttpEntity<>(getHeaders());
}
public HttpHeaders getHeaders() {
HttpHeaders headers = new HttpHeaders(); public HttpHeaders getHeaders() {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
return headers; headers.add("Content-Type", "application/json");
} return headers;
}
public HttpHeaders getHeadersAdmin() {
HttpHeaders headers = new HttpHeaders(); public HttpHeaders getHeadersAdmin() {
headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/hal+json"); headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin
return headers; headers.add("Content-Type", "application/hal+json");
} return headers;
}
public HttpHeaders getHeadersBusinessAdmin() {
HttpHeaders headers = new HttpHeaders(); public HttpHeaders getHeadersBusinessAdmin() {
// businessadmin:businessadmin HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic YnVzaW5lc3NhZG1pbjpidXNpbmVzc2FkbWlu"); // businessadmin:businessadmin
headers.add("Content-Type", "application/hal+json"); headers.add("Authorization", "Basic YnVzaW5lc3NhZG1pbjpidXNpbmVzc2FkbWlu");
return headers; headers.add("Content-Type", "application/hal+json");
} return headers;
}
/**
* Return a REST template which is capable of dealing with responses in HAL format. /**
* * Return a REST template which is capable of dealing with responses in HAL format.
* @return RestTemplate *
*/ * @return RestTemplate
public static RestTemplate getRestTemplate() { */
ObjectMapper mapper = new ObjectMapper(); public static RestTemplate getRestTemplate() {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new Jackson2HalModule()); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.registerModule(new Jackson2HalModule());
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(mapper); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate();
// important to add first to ensure priority RestTemplate template = new RestTemplate();
template.getMessageConverters().add(0, converter); // important to add first to ensure priority
return template; template.getMessageConverters().add(0, converter);
} return template;
} }
}

View File

@ -1,24 +1,25 @@
package pro.taskana; package pro.taskana;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited; import java.lang.annotation.Inherited;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringExtension;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/** Use this annotation to test with a spring context and a standardized configuration. */ /** Use this annotation to test with a spring context and a standardized configuration. */
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Inherited @Inherited
@ActiveProfiles({"test"}) @ActiveProfiles({"test"})
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@SpringBootTest( @SpringBootTest(
classes = RestConfiguration.class, classes = RestConfiguration.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
public @interface TaskanaSpringBootTest {} properties = "spring.main.allow-bean-definition-overriding=true")
public @interface TaskanaSpringBootTest {}

View File

@ -1,364 +1,364 @@
package pro.taskana.doc.api; package pro.taskana.doc.api;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor; import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping; import pro.taskana.rest.Mapping;
/** Generate REST Dokumentation for ClassificationController. */ /** Generate REST Dokumentation for ClassificationController. */
class ClassificationControllerRestDocumentation extends BaseRestDocumentation { class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
private HashMap<String, String> classificationFieldDescriptionsMap = private HashMap<String, String> classificationFieldDescriptionsMap =
new HashMap<String, String>(); new HashMap<String, String>();
private FieldDescriptor[] allClassificationsFieldDescriptors; private FieldDescriptor[] allClassificationsFieldDescriptors;
private FieldDescriptor[] classificationFieldDescriptors; private FieldDescriptor[] classificationFieldDescriptors;
private FieldDescriptor[] classificationSubsetFieldDescriptors; private FieldDescriptor[] classificationSubsetFieldDescriptors;
private FieldDescriptor[] createClassificationFieldDescriptors; private FieldDescriptor[] createClassificationFieldDescriptors;
@BeforeEach @BeforeEach
void setUp() { void setUp() {
classificationFieldDescriptionsMap.put("classificationId", "Unique Id"); classificationFieldDescriptionsMap.put("classificationId", "Unique Id");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"key", "key",
"The key of the classification. This is typically an externally " "The key of the classification. This is typically an externally "
+ "known code or abbreviation of the classification"); + "known code or abbreviation of the classification");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"parentId", "parentId",
"The id of the parent classification. Empty string (\"\") " "The id of the parent classification. Empty string (\"\") "
+ "if this is a root classification."); + "if this is a root classification.");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"parentKey", "parentKey",
"The key of the parent classification. Empty string (\"\") " "The key of the parent classification. Empty string (\"\") "
+ "if this is a root classification."); + "if this is a root classification.");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"category", "The category of the classification (MANUAL, EXTERNAL, AUTOMATIC, PROCESS)"); "category", "The category of the classification (MANUAL, EXTERNAL, AUTOMATIC, PROCESS)");
classificationFieldDescriptionsMap.put("type", "The type of classification (TASK, DOCUMENT)"); classificationFieldDescriptionsMap.put("type", "The type of classification (TASK, DOCUMENT)");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"domain", "The domain for which this classification is specified"); "domain", "The domain for which this classification is specified");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"isValidInDomain", "True, if this classification to objects in this domain"); "isValidInDomain", "True, if this classification to objects in this domain");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"created", "The creation timestamp of the classification in the system"); "created", "The creation timestamp of the classification in the system");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"modified", "The timestamp of the last modification date"); "modified", "The timestamp of the last modification date");
classificationFieldDescriptionsMap.put("name", "The name of the classification"); classificationFieldDescriptionsMap.put("name", "The name of the classification");
classificationFieldDescriptionsMap.put("description", "The description of the classification"); classificationFieldDescriptionsMap.put("description", "The description of the classification");
classificationFieldDescriptionsMap.put("priority", "The priority of the classification"); classificationFieldDescriptionsMap.put("priority", "The priority of the classification");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"serviceLevel", "serviceLevel",
"The service level of the classification. This is stated according to ISO 8601"); "The service level of the classification. This is stated according to ISO 8601");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"applicationEntryPoint", "applicationEntryPoint",
"The logical name of the entry point, the task list application " "The logical name of the entry point, the task list application "
+ "should redirect to work on a task of this classification"); + "should redirect to work on a task of this classification");
classificationFieldDescriptionsMap.put("custom1", "A custom property with name \"1\""); classificationFieldDescriptionsMap.put("custom1", "A custom property with name \"1\"");
classificationFieldDescriptionsMap.put("custom2", "A custom property with name \"2\""); classificationFieldDescriptionsMap.put("custom2", "A custom property with name \"2\"");
classificationFieldDescriptionsMap.put("custom3", "A custom property with name \"3\""); classificationFieldDescriptionsMap.put("custom3", "A custom property with name \"3\"");
classificationFieldDescriptionsMap.put("custom4", "A custom property with name \"4\""); classificationFieldDescriptionsMap.put("custom4", "A custom property with name \"4\"");
classificationFieldDescriptionsMap.put("custom5", "A custom property with name \"5\""); classificationFieldDescriptionsMap.put("custom5", "A custom property with name \"5\"");
classificationFieldDescriptionsMap.put("custom6", "A custom property with name \"6\""); classificationFieldDescriptionsMap.put("custom6", "A custom property with name \"6\"");
classificationFieldDescriptionsMap.put("custom7", "A custom property with name \"7\""); classificationFieldDescriptionsMap.put("custom7", "A custom property with name \"7\"");
classificationFieldDescriptionsMap.put("custom8", "A custom property with name \"8\""); classificationFieldDescriptionsMap.put("custom8", "A custom property with name \"8\"");
classificationFieldDescriptionsMap.put( classificationFieldDescriptionsMap.put(
"_links.getAllClassifications.href", "Link to all classifications"); "_links.getAllClassifications.href", "Link to all classifications");
classificationFieldDescriptionsMap.put("_links.getAllClassifications.templated", ""); classificationFieldDescriptionsMap.put("_links.getAllClassifications.templated", "");
allClassificationsFieldDescriptors = allClassificationsFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[] {
subsectionWithPath("classifications") subsectionWithPath("classifications")
.description("An Array of <<classification-subset, Classification-Subsets>>"), .description("An Array of <<classification-subset, Classification-Subsets>>"),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored(), fieldWithPath("page").ignored(),
fieldWithPath("page.size").ignored(), fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(), fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(), fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored() fieldWithPath("page.number").ignored()
}; };
classificationFieldDescriptors = classificationFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[] {
fieldWithPath("classificationId") fieldWithPath("classificationId")
.description(classificationFieldDescriptionsMap.get("classificationId")), .description(classificationFieldDescriptionsMap.get("classificationId")),
fieldWithPath("key").description(classificationFieldDescriptionsMap.get("key")), fieldWithPath("key").description(classificationFieldDescriptionsMap.get("key")),
fieldWithPath("parentId").description(classificationFieldDescriptionsMap.get("parentId")), fieldWithPath("parentId").description(classificationFieldDescriptionsMap.get("parentId")),
fieldWithPath("parentKey") fieldWithPath("parentKey")
.description(classificationFieldDescriptionsMap.get("parentKey")), .description(classificationFieldDescriptionsMap.get("parentKey")),
fieldWithPath("category").description(classificationFieldDescriptionsMap.get("category")), fieldWithPath("category").description(classificationFieldDescriptionsMap.get("category")),
fieldWithPath("type").description(classificationFieldDescriptionsMap.get("type")), fieldWithPath("type").description(classificationFieldDescriptionsMap.get("type")),
fieldWithPath("domain").description(classificationFieldDescriptionsMap.get("domain")), fieldWithPath("domain").description(classificationFieldDescriptionsMap.get("domain")),
fieldWithPath("isValidInDomain") fieldWithPath("isValidInDomain")
.description(classificationFieldDescriptionsMap.get("isValidInDomain")), .description(classificationFieldDescriptionsMap.get("isValidInDomain")),
fieldWithPath("created").description(classificationFieldDescriptionsMap.get("created")), fieldWithPath("created").description(classificationFieldDescriptionsMap.get("created")),
fieldWithPath("modified").description(classificationFieldDescriptionsMap.get("modified")), fieldWithPath("modified").description(classificationFieldDescriptionsMap.get("modified")),
fieldWithPath("name").description(classificationFieldDescriptionsMap.get("name")), fieldWithPath("name").description(classificationFieldDescriptionsMap.get("name")),
fieldWithPath("description") fieldWithPath("description")
.description(classificationFieldDescriptionsMap.get("description")), .description(classificationFieldDescriptionsMap.get("description")),
fieldWithPath("priority").description(classificationFieldDescriptionsMap.get("priority")), fieldWithPath("priority").description(classificationFieldDescriptionsMap.get("priority")),
fieldWithPath("serviceLevel") fieldWithPath("serviceLevel")
.description(classificationFieldDescriptionsMap.get("serviceLevel")), .description(classificationFieldDescriptionsMap.get("serviceLevel")),
fieldWithPath("applicationEntryPoint") fieldWithPath("applicationEntryPoint")
.description(classificationFieldDescriptionsMap.get("applicationEntryPoint")), .description(classificationFieldDescriptionsMap.get("applicationEntryPoint")),
fieldWithPath("custom1").description(classificationFieldDescriptionsMap.get("custom1")), fieldWithPath("custom1").description(classificationFieldDescriptionsMap.get("custom1")),
fieldWithPath("custom2").description(classificationFieldDescriptionsMap.get("custom2")), fieldWithPath("custom2").description(classificationFieldDescriptionsMap.get("custom2")),
fieldWithPath("custom3").description(classificationFieldDescriptionsMap.get("custom3")), fieldWithPath("custom3").description(classificationFieldDescriptionsMap.get("custom3")),
fieldWithPath("custom4").description(classificationFieldDescriptionsMap.get("custom4")), fieldWithPath("custom4").description(classificationFieldDescriptionsMap.get("custom4")),
fieldWithPath("custom5").description(classificationFieldDescriptionsMap.get("custom5")), fieldWithPath("custom5").description(classificationFieldDescriptionsMap.get("custom5")),
fieldWithPath("custom6").description(classificationFieldDescriptionsMap.get("custom6")), fieldWithPath("custom6").description(classificationFieldDescriptionsMap.get("custom6")),
fieldWithPath("custom7").description(classificationFieldDescriptionsMap.get("custom7")), fieldWithPath("custom7").description(classificationFieldDescriptionsMap.get("custom7")),
fieldWithPath("custom8").description(classificationFieldDescriptionsMap.get("custom8")), fieldWithPath("custom8").description(classificationFieldDescriptionsMap.get("custom8")),
fieldWithPath("_links.self.href").ignored() fieldWithPath("_links.self.href").ignored()
}; };
classificationSubsetFieldDescriptors = classificationSubsetFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[] {
fieldWithPath("classificationId") fieldWithPath("classificationId")
.description(classificationFieldDescriptionsMap.get("classificationId")), .description(classificationFieldDescriptionsMap.get("classificationId")),
fieldWithPath("key").description(classificationFieldDescriptionsMap.get("key")), fieldWithPath("key").description(classificationFieldDescriptionsMap.get("key")),
fieldWithPath("category").description(classificationFieldDescriptionsMap.get("category")), fieldWithPath("category").description(classificationFieldDescriptionsMap.get("category")),
fieldWithPath("type").description(classificationFieldDescriptionsMap.get("type")), fieldWithPath("type").description(classificationFieldDescriptionsMap.get("type")),
fieldWithPath("domain").description(classificationFieldDescriptionsMap.get("domain")), fieldWithPath("domain").description(classificationFieldDescriptionsMap.get("domain")),
fieldWithPath("isValidInDomain").ignored(), fieldWithPath("isValidInDomain").ignored(),
fieldWithPath("created").ignored(), fieldWithPath("created").ignored(),
fieldWithPath("modified").ignored(), fieldWithPath("modified").ignored(),
fieldWithPath("name").description(classificationFieldDescriptionsMap.get("name")), fieldWithPath("name").description(classificationFieldDescriptionsMap.get("name")),
fieldWithPath("parentId").description(classificationFieldDescriptionsMap.get("parentId")), fieldWithPath("parentId").description(classificationFieldDescriptionsMap.get("parentId")),
fieldWithPath("parentKey") fieldWithPath("parentKey")
.description(classificationFieldDescriptionsMap.get("parentKey")), .description(classificationFieldDescriptionsMap.get("parentKey")),
fieldWithPath("description").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("priority").description(classificationFieldDescriptionsMap.get("priority")), fieldWithPath("priority").description(classificationFieldDescriptionsMap.get("priority")),
fieldWithPath("serviceLevel") fieldWithPath("serviceLevel")
.description(classificationFieldDescriptionsMap.get("serviceLevel")), .description(classificationFieldDescriptionsMap.get("serviceLevel")),
fieldWithPath("applicationEntryPoint").ignored(), fieldWithPath("applicationEntryPoint").ignored(),
fieldWithPath("custom1").description(classificationFieldDescriptionsMap.get("custom1")), fieldWithPath("custom1").description(classificationFieldDescriptionsMap.get("custom1")),
fieldWithPath("custom2").description(classificationFieldDescriptionsMap.get("custom2")), fieldWithPath("custom2").description(classificationFieldDescriptionsMap.get("custom2")),
fieldWithPath("custom3").description(classificationFieldDescriptionsMap.get("custom3")), fieldWithPath("custom3").description(classificationFieldDescriptionsMap.get("custom3")),
fieldWithPath("custom4").description(classificationFieldDescriptionsMap.get("custom4")), fieldWithPath("custom4").description(classificationFieldDescriptionsMap.get("custom4")),
fieldWithPath("custom5").description(classificationFieldDescriptionsMap.get("custom5")), fieldWithPath("custom5").description(classificationFieldDescriptionsMap.get("custom5")),
fieldWithPath("custom6").description(classificationFieldDescriptionsMap.get("custom6")), fieldWithPath("custom6").description(classificationFieldDescriptionsMap.get("custom6")),
fieldWithPath("custom7").description(classificationFieldDescriptionsMap.get("custom7")), fieldWithPath("custom7").description(classificationFieldDescriptionsMap.get("custom7")),
fieldWithPath("custom8").description(classificationFieldDescriptionsMap.get("custom8")), fieldWithPath("custom8").description(classificationFieldDescriptionsMap.get("custom8")),
fieldWithPath("_links.self.href").ignored() fieldWithPath("_links.self.href").ignored()
}; };
createClassificationFieldDescriptors = createClassificationFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[] {
fieldWithPath("category") fieldWithPath("category")
.type("String") .type("String")
.description( .description(
"The category of the classification (MANUAL, EXTERNAL, AUTOMATIC, PROCESS)") "The category of the classification (MANUAL, EXTERNAL, AUTOMATIC, PROCESS)")
.optional(), .optional(),
fieldWithPath("domain") fieldWithPath("domain")
.description("The domain for which this classification is specified"), .description("The domain for which this classification is specified"),
fieldWithPath("key") fieldWithPath("key")
.description( .description(
"The key of the classification. This is typically an externally " "The key of the classification. This is typically an externally "
+ "known code or abbreviation of the classification"), + "known code or abbreviation of the classification"),
fieldWithPath("name") fieldWithPath("name")
.type("String") .type("String")
.description("The name of the classification") .description("The name of the classification")
.optional(), .optional(),
fieldWithPath("type") fieldWithPath("type")
.type("String") .type("String")
.description("The type of classification (TASK, DOCUMENT)") .description("The type of classification (TASK, DOCUMENT)")
.optional(), .optional(),
fieldWithPath("parentId") fieldWithPath("parentId")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("parentId")) .description(classificationFieldDescriptionsMap.get("parentId"))
.optional(), .optional(),
fieldWithPath("parentKey") fieldWithPath("parentKey")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("parentKey")) .description(classificationFieldDescriptionsMap.get("parentKey"))
.optional(), .optional(),
fieldWithPath("isValidInDomain") fieldWithPath("isValidInDomain")
.type("Boolean") .type("Boolean")
.description(classificationFieldDescriptionsMap.get("isValidInDomain")) .description(classificationFieldDescriptionsMap.get("isValidInDomain"))
.optional(), .optional(),
fieldWithPath("created") fieldWithPath("created")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("created")) .description(classificationFieldDescriptionsMap.get("created"))
.optional(), .optional(),
fieldWithPath("modified") fieldWithPath("modified")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("modified")) .description(classificationFieldDescriptionsMap.get("modified"))
.optional(), .optional(),
fieldWithPath("description") fieldWithPath("description")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("description")) .description(classificationFieldDescriptionsMap.get("description"))
.optional(), .optional(),
fieldWithPath("priority") fieldWithPath("priority")
.type("Number") .type("Number")
.description(classificationFieldDescriptionsMap.get("priority")) .description(classificationFieldDescriptionsMap.get("priority"))
.optional(), .optional(),
fieldWithPath("serviceLevel") fieldWithPath("serviceLevel")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("serviceLevel")) .description(classificationFieldDescriptionsMap.get("serviceLevel"))
.optional(), .optional(),
fieldWithPath("applicationEntryPoint") fieldWithPath("applicationEntryPoint")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("applicationEntryPoint")) .description(classificationFieldDescriptionsMap.get("applicationEntryPoint"))
.optional(), .optional(),
fieldWithPath("custom1") fieldWithPath("custom1")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("custom1")) .description(classificationFieldDescriptionsMap.get("custom1"))
.optional(), .optional(),
fieldWithPath("custom2") fieldWithPath("custom2")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("custom2")) .description(classificationFieldDescriptionsMap.get("custom2"))
.optional(), .optional(),
fieldWithPath("custom3") fieldWithPath("custom3")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("custom3")) .description(classificationFieldDescriptionsMap.get("custom3"))
.optional(), .optional(),
fieldWithPath("custom4") fieldWithPath("custom4")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("custom4")) .description(classificationFieldDescriptionsMap.get("custom4"))
.optional(), .optional(),
fieldWithPath("custom5") fieldWithPath("custom5")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("custom5")) .description(classificationFieldDescriptionsMap.get("custom5"))
.optional(), .optional(),
fieldWithPath("custom6") fieldWithPath("custom6")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("custom6")) .description(classificationFieldDescriptionsMap.get("custom6"))
.optional(), .optional(),
fieldWithPath("custom7") fieldWithPath("custom7")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("custom7")) .description(classificationFieldDescriptionsMap.get("custom7"))
.optional(), .optional(),
fieldWithPath("custom8") fieldWithPath("custom8")
.type("String") .type("String")
.description(classificationFieldDescriptionsMap.get("custom8")) .description(classificationFieldDescriptionsMap.get("custom8"))
.optional() .optional()
}; };
} }
@Test @Test
void getAllClassificationsDocTest() throws Exception { void getAllClassificationsDocTest() throws Exception {
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.get( RestDocumentationRequestBuilders.get(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B") restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B")
.accept("application/hal+json") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo( .andDo(
MockMvcRestDocumentation.document( MockMvcRestDocumentation.document(
"GetAllClassificationsDocTest", "GetAllClassificationsDocTest",
responseFields(allClassificationsFieldDescriptors))); responseFields(allClassificationsFieldDescriptors)));
} }
@Test @Test
void getSpecificClassificationDocTest() throws Exception { void getSpecificClassificationDocTest() throws Exception {
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.get( RestDocumentationRequestBuilders.get(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009")) Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo( .andDo(
MockMvcRestDocumentation.document( MockMvcRestDocumentation.document(
"GetSpecificClassificationDocTest", "GetSpecificClassificationDocTest",
responseFields(classificationFieldDescriptors))); responseFields(classificationFieldDescriptors)));
} }
@Test @Test
void classificationSubsetDocTest() throws Exception { void classificationSubsetDocTest() throws Exception {
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.get( RestDocumentationRequestBuilders.get(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009")) Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo( .andDo(
MockMvcRestDocumentation.document( MockMvcRestDocumentation.document(
"ClassificationSubset", responseFields(classificationSubsetFieldDescriptors))); "ClassificationSubset", responseFields(classificationSubsetFieldDescriptors)));
} }
@Test @Test
void createAndDeleteClassificationDocTest() throws Exception { void createAndDeleteClassificationDocTest() throws Exception {
MvcResult result = MvcResult result =
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS)) RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS))
.contentType("application/hal+json") .contentType("application/hal+json")
.content("{\"key\":\"Key0815casdgdgh\", \"domain\":\"DOMAIN_B\"}") .content("{\"key\":\"Key0815casdgdgh\", \"domain\":\"DOMAIN_B\"}")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isCreated()) .andExpect(MockMvcResultMatchers.status().isCreated())
.andDo( .andDo(
MockMvcRestDocumentation.document( MockMvcRestDocumentation.document(
"CreateClassificationDocTest", "CreateClassificationDocTest",
requestFields(createClassificationFieldDescriptors), requestFields(createClassificationFieldDescriptors),
responseFields(classificationFieldDescriptors))) responseFields(classificationFieldDescriptors)))
.andReturn(); .andReturn();
String content = result.getResponse().getContentAsString(); String content = result.getResponse().getContentAsString();
String newId = content.substring(content.indexOf("CLI:"), content.indexOf("CLI:") + 40); String newId = content.substring(content.indexOf("CLI:"), content.indexOf("CLI:") + 40);
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.delete( RestDocumentationRequestBuilders.delete(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, newId)) restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, newId))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteClassificationDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteClassificationDocTest"));
} }
@Test @Test
void updateClassificationDocTest() throws Exception { void updateClassificationDocTest() throws Exception {
URL url = URL url =
new URL( new URL(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009")); Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"));
HttpURLConnection con = (HttpURLConnection) url.openConnection(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
assertEquals(200, con.getResponseCode()); assertEquals(200, con.getResponseCode());
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8)); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
String inputLine; String inputLine;
StringBuffer content = new StringBuffer(); StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) { while ((inputLine = in.readLine()) != null) {
content.append(inputLine); content.append(inputLine);
} }
in.close(); in.close();
con.disconnect(); con.disconnect();
String originalTask = content.toString(); String originalTask = content.toString();
String modifiedTask = originalTask; String modifiedTask = originalTask;
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.put( RestDocumentationRequestBuilders.put(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009")) Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json") .contentType("application/json")
.content(modifiedTask)) .content(modifiedTask))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo( .andDo(
MockMvcRestDocumentation.document( MockMvcRestDocumentation.document(
"UpdateClassificationDocTest", "UpdateClassificationDocTest",
requestFields(classificationFieldDescriptors), requestFields(classificationFieldDescriptors),
responseFields(classificationFieldDescriptors))); responseFields(classificationFieldDescriptors)));
} }
} }

View File

@ -1,52 +1,91 @@
package pro.taskana.rest; package pro.taskana.rest;
import static org.junit.Assert.assertEquals; import static org.assertj.core.api.Assertions.assertThat;
import java.util.List; import java.util.ArrayList;
import org.junit.jupiter.api.BeforeAll; import java.util.List;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeAll;
import org.springframework.beans.factory.annotation.Autowired; import org.junit.jupiter.api.Test;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.ResponseEntity; import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import pro.taskana.RestHelper; import org.springframework.web.client.HttpClientErrorException;
import pro.taskana.TaskanaSpringBootTest; import org.springframework.web.client.RestTemplate;
import pro.taskana.rest.resource.AccessIdResource;
import pro.taskana.RestHelper;
@TaskanaSpringBootTest import pro.taskana.TaskanaSpringBootTest;
class AccessIdControllerIntTest { import pro.taskana.rest.resource.AccessIdResource;
private static RestTemplate template; @TaskanaSpringBootTest
class AccessIdControllerIntTest {
@Autowired RestHelper restHelper;
private static RestTemplate template;
@BeforeAll
static void init() { @Autowired RestHelper restHelper;
template = RestHelper.getRestTemplate();
} @BeforeAll
static void init() {
@Test template = RestHelper.getRestTemplate();
void testQueryGroupsByDn() { }
ResponseEntity<List<AccessIdResource>> response =
template.exchange( @Test
restHelper.toUrl(Mapping.URL_ACCESSID) void testQueryGroupsByDn() {
+ "?search-for=cn=developersgroup,ou=groups,o=taskanatest", ResponseEntity<List<AccessIdResource>> response =
HttpMethod.GET, template.exchange(
restHelper.defaultRequest(), restHelper.toUrl(Mapping.URL_ACCESSID)
ParameterizedTypeReference.forType(List.class)); + "?search-for=cn=developersgroup,ou=groups,o=taskanatest",
assertEquals(1, response.getBody().size()); HttpMethod.GET,
} restHelper.defaultRequest(),
ParameterizedTypeReference.forType(List.class));
@Test assertThat(response.getBody().size()).isEqualTo(1);
void testQueryGroupsByCn() { }
ResponseEntity<List<AccessIdResource>> response =
template.exchange( @Test
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=developer", void testQueryGroupsByCn() {
HttpMethod.GET, ResponseEntity<List<AccessIdResource>> response =
restHelper.defaultRequest(), template.exchange(
ParameterizedTypeReference.forType(List.class)); restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=developer",
assertEquals(1, response.getBody().size()); HttpMethod.GET,
} restHelper.defaultRequest(),
} ParameterizedTypeReference.forType(List.class));
assertThat(response.getBody().size()).isEqualTo(1);
}
@Test
void testGetMatches() {
ResponseEntity<List<AccessIdResource>> response =
template.exchange(
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=ali",
HttpMethod.GET,
restHelper.defaultRequest(),
ParameterizedTypeReference.forType(AccessIdListResource.class));
List<AccessIdResource> body = response.getBody();
assertThat(body).isNotNull();
assertThat(body.size()).isEqualTo(3);
assertThat(body)
.extracting(AccessIdResource::getName)
.containsExactlyInAnyOrder("Tralisch, Thea", "Bert, Ali", "Mente, Ali");
}
@Test
void testBadRequestWhenSearchForIsTooShort() {
try {
template.exchange(
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=al",
HttpMethod.GET,
restHelper.defaultRequest(),
ParameterizedTypeReference.forType(List.class));
} catch (HttpClientErrorException e) {
assertThat(HttpStatus.BAD_REQUEST).isEqualTo(e.getStatusCode());
assertThat(e.getResponseBodyAsString()).containsSequence("Minimum searchFor length =");
}
}
static class AccessIdListResource extends ArrayList<AccessIdResource> {
private static final long serialVersionUID = 1L;
}
}

View File

@ -1,11 +1,8 @@
package pro.taskana.rest; package pro.taskana.rest;
import static org.junit.Assert.assertEquals; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNotNull; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
@ -35,6 +32,18 @@ class ClassificationControllerIntTest {
static RestTemplate template = RestHelper.getRestTemplate(); static RestTemplate template = RestHelper.getRestTemplate();
@Autowired RestHelper restHelper; @Autowired RestHelper restHelper;
@Test
void testGetClassification() {
ResponseEntity<ClassificationResource> response =
template.exchange(
restHelper.toUrl(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000002"),
HttpMethod.GET,
restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationResource.class));
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
}
@Test @Test
void testGetAllClassifications() { void testGetAllClassifications() {
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<ClassificationSummaryListResource> response =
@ -43,7 +52,7 @@ class ClassificationControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
} }
@Test @Test
@ -54,8 +63,8 @@ class ClassificationControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
assertEquals(13, response.getBody().getContent().size()); assertThat(response.getBody().getContent().size()).isEqualTo(13);
} }
@Test @Test
@ -67,15 +76,11 @@ class ClassificationControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
assertTrue( assertThat(response.getBody().getLink(Link.REL_SELF).getHref())
response .endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc");
.getBody() assertThat(response.getBody().getContent().size()).isEqualTo(17);
.getLink(Link.REL_SELF) assertThat(response.getBody().getContent().iterator().next().key).isEqualTo("A12");
.getHref()
.endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc"));
assertEquals(17, response.getBody().getContent().size());
assertEquals("A12", response.getBody().getContent().iterator().next().key);
} }
@Test @Test
@ -87,21 +92,17 @@ class ClassificationControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
assertEquals(5, response.getBody().getContent().size()); assertThat(response.getBody().getContent().size()).isEqualTo(5);
assertEquals("L1050", response.getBody().getContent().iterator().next().key); assertThat(response.getBody().getContent().iterator().next().key).isEqualTo("L1050");
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
assertTrue( assertThat(response.getBody().getLink(Link.REL_SELF).getHref())
response .endsWith(
.getBody() "/api/v1/classifications?"
.getLink(Link.REL_SELF) + "domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5");
.getHref() assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
.endsWith( assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
"/api/v1/classifications?" assertThat(response.getBody().getLink(Link.REL_NEXT)).isNotNull();
+ "domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5")); assertThat(response.getBody().getLink(Link.REL_PREVIOUS)).isNotNull();
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
assertNotNull(response.getBody().getLink(Link.REL_LAST));
assertNotNull(response.getBody().getLink(Link.REL_NEXT));
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
} }
@Test @Test
@ -119,8 +120,8 @@ class ClassificationControllerIntTest {
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertNotNull(responseEntity); assertThat(responseEntity).isNotNull();
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
newClassification = newClassification =
"{\"classificationId\":\"\",\"category\":\"MANUAL\"," "{\"classificationId\":\"\",\"category\":\"MANUAL\","
@ -134,7 +135,7 @@ class ClassificationControllerIntTest {
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
} }
@Test @Test
@ -153,8 +154,8 @@ class ClassificationControllerIntTest {
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertNotNull(responseEntity); assertThat(responseEntity).isNotNull();
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
} }
@Test @Test
@ -173,8 +174,8 @@ class ClassificationControllerIntTest {
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertNotNull(responseEntity); assertThat(responseEntity).isNotNull();
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
} }
@Test @Test
@ -192,8 +193,8 @@ class ClassificationControllerIntTest {
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertNotNull(responseEntity); assertThat(responseEntity).isNotNull();
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<ClassificationSummaryListResource> response =
template.exchange( template.exchange(
@ -201,7 +202,7 @@ class ClassificationControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
assertNotNull(response.getBody().getLink(Link.REL_SELF)); assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
boolean foundClassificationCreated = false; boolean foundClassificationCreated = false;
for (ClassificationSummaryResource classification : response.getBody().getContent()) { for (ClassificationSummaryResource classification : response.getBody().getContent()) {
if ("NEW_CLASS_P2".equals(classification.getKey()) if ("NEW_CLASS_P2".equals(classification.getKey())
@ -211,7 +212,7 @@ class ClassificationControllerIntTest {
} }
} }
assertEquals(true, foundClassificationCreated); assertThat(foundClassificationCreated).isTrue();
} }
@Test @Test
@ -222,19 +223,16 @@ class ClassificationControllerIntTest {
+ "\"key\":\"NEW_CLASS_P3\",\"name\":\"new classification\"," + "\"key\":\"NEW_CLASS_P3\",\"name\":\"new classification\","
+ "\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\"," + "\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\","
+ "\"parentKey\":\"T2000\"}"; + "\"parentKey\":\"T2000\"}";
HttpClientErrorException e = assertThatThrownBy(
Assertions.assertThrows( () ->
HttpClientErrorException.class, template.exchange(
() -> restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
template.exchange( HttpMethod.POST,
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), new HttpEntity<>(newClassification, restHelper.getHeaders()),
HttpMethod.POST, ParameterizedTypeReference.forType(ClassificationResource.class)))
new HttpEntity<>(newClassification, restHelper.getHeaders()), .isInstanceOf(HttpClientErrorException.class)
ParameterizedTypeReference.forType(ClassificationResource.class))); .hasFieldOrPropertyWithValue("statusCode", HttpStatus.BAD_REQUEST);
assertNotNull(e);
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
} }
@Test @Test
@ -245,18 +243,15 @@ class ClassificationControllerIntTest {
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\"," + "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\","
+ "\"name\":\"new classification\",\"type\":\"TASK\"}"; + "\"name\":\"new classification\",\"type\":\"TASK\"}";
HttpClientErrorException e = assertThatThrownBy(() ->
Assertions.assertThrows( template.exchange(
HttpClientErrorException.class, restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
() -> HttpMethod.POST,
template.exchange( new HttpEntity<>(newClassification, restHelper.getHeaders()),
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), ParameterizedTypeReference.forType(ClassificationResource.class)))
HttpMethod.POST, .isInstanceOf(HttpClientErrorException.class)
new HttpEntity<>(newClassification, restHelper.getHeaders()), .extracting(ex -> ((HttpClientErrorException)ex).getStatusCode())
ParameterizedTypeReference.forType(ClassificationResource.class))); .isEqualTo(HttpStatus.BAD_REQUEST);
assertNotNull(e);
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
} }
@Test @Test
@ -270,7 +265,7 @@ class ClassificationControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(ClassificationSummaryResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
assertEquals("Zustimmungserklärung", response.getBody().name); assertThat(response.getBody().name).isEqualTo("Zustimmungserklärung");
} }
@Test @Test
@ -285,17 +280,15 @@ class ClassificationControllerIntTest {
HttpMethod.DELETE, HttpMethod.DELETE,
request, request,
ParameterizedTypeReference.forType(ClassificationSummaryResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
assertThrows( assertThatThrownBy(() ->
HttpClientErrorException.class, template.exchange(
() -> { restHelper.toUrl(
template.exchange( Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
restHelper.toUrl( HttpMethod.GET,
Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"), request,
HttpMethod.GET, ParameterizedTypeReference.forType(ClassificationSummaryResource.class)))
request, .isInstanceOf(HttpClientErrorException.class);
ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
});
} }
} }

View File

@ -114,7 +114,7 @@ class WorkbasketControllerIntTest {
workbasketResource.setModified(String.valueOf(Instant.now())); workbasketResource.setModified(String.valueOf(Instant.now()));
assertThatThrownBy( assertThatThrownBy(
() -> () ->
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId), restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
HttpMethod.PUT, HttpMethod.PUT,
@ -131,7 +131,7 @@ class WorkbasketControllerIntTest {
String workbasketId = "WBI:100004857400039500000999999999999999"; String workbasketId = "WBI:100004857400039500000999999999999999";
assertThatThrownBy( assertThatThrownBy(
() -> () ->
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId), restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
HttpMethod.GET, HttpMethod.GET,