TSK-967: Merge module taskana-rest-spring and taskana-rest-spring-test
This commit is contained in:
parent
75c9354f56
commit
7f2457ee1e
|
@ -15,8 +15,8 @@
|
|||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>taskana-core</module>
|
||||
<module>taskana-data</module>
|
||||
<module>taskana-core</module>
|
||||
<module>taskana-cdi</module>
|
||||
<module>taskana-spring</module>
|
||||
<module>taskana-cdi-example</module>
|
||||
|
|
|
@ -26,7 +26,12 @@
|
|||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${version.slf4j}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>${version.log4j}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
|
|
|
@ -9,8 +9,6 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -78,10 +76,8 @@ public class SampleDataGenerator {
|
|||
runner.setLogWriter(logWriter);
|
||||
runner.setErrorLogWriter(errorLogWriter);
|
||||
|
||||
String[] script = this.getScriptList();
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Stream.of(script)
|
||||
getScriptList()
|
||||
.map(s -> SampleDataGenerator.parseAndReplace(now, s))
|
||||
.map(StringReader::new)
|
||||
.map(BufferedReader::new)
|
||||
|
@ -130,20 +126,20 @@ public class SampleDataGenerator {
|
|||
* Create a array with the necessary script.
|
||||
* @return a array with the corresponding scripts files
|
||||
*/
|
||||
private String[] getScriptList() {
|
||||
ArrayList<String> scriptsList = getDefaultScripts();
|
||||
private Stream<String> getScriptList() {
|
||||
Stream<String> scriptsList = getDefaultScripts();
|
||||
|
||||
try {
|
||||
runner.runScript(getScriptBufferedStream(CHECK_HISTORY_EVENT_EXIST));
|
||||
runner.runScript(getScriptBufferedStream(CLEAR_HISTORY_EVENTS));
|
||||
scriptsList.add(HISTORY_EVENT);
|
||||
return Stream.concat(scriptsList, Stream.of(HISTORY_EVENT));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("The HISTORY_EVENTS table is not created");
|
||||
}
|
||||
return scriptsList.toArray(new String[0]);
|
||||
return scriptsList;
|
||||
}
|
||||
|
||||
static String parseAndReplace(LocalDateTime now, String script) {
|
||||
private static String parseAndReplace(LocalDateTime now, String script) {
|
||||
return replaceRelativeTimeFunction(now,
|
||||
getScriptBufferedStream(script).lines().collect(Collectors.joining(System.lineSeparator())));
|
||||
}
|
||||
|
@ -154,10 +150,9 @@ public class SampleDataGenerator {
|
|||
new InputStreamReader(inputStream, StandardCharsets.UTF_8))).orElse(null);
|
||||
}
|
||||
|
||||
static ArrayList<String> getDefaultScripts() {
|
||||
String[] script = {WORKBASKET, DISTRIBUTION_TARGETS, CLASSIFICATION, TASK, ATTACHMENT, WORKBASKET_ACCESS_LIST,
|
||||
OBJECT_REFERENCE};
|
||||
return new ArrayList<>(Arrays.asList(script));
|
||||
static Stream<String> getDefaultScripts() {
|
||||
return Stream.of(WORKBASKET, DISTRIBUTION_TARGETS, CLASSIFICATION, TASK, ATTACHMENT, WORKBASKET_ACCESS_LIST,
|
||||
OBJECT_REFERENCE);
|
||||
}
|
||||
|
||||
private static boolean isPostgreSQL(String databaseProductName) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package pro.taskana.sampledata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -10,19 +8,21 @@ import org.junit.jupiter.api.Test;
|
|||
*/
|
||||
class SampleDataGeneratorTest {
|
||||
|
||||
@Test
|
||||
void getScriptsNotNull() {
|
||||
Assertions.assertNotNull(SampleDataGenerator.getDefaultScripts());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getScriptsNotEmpty() {
|
||||
ArrayList<String> scripts = SampleDataGenerator.getDefaultScripts();
|
||||
Assertions.assertNotNull(scripts);
|
||||
Assertions.assertTrue(scripts.size() > 0);
|
||||
Assertions.assertTrue(SampleDataGenerator.getDefaultScripts().count() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getScriptsFileExists() {
|
||||
ArrayList<String> scripts = SampleDataGenerator.getDefaultScripts();
|
||||
for (String script : scripts) {
|
||||
Assertions.assertNotNull(SampleDataGenerator.getScriptBufferedStream(script));
|
||||
}
|
||||
|
||||
SampleDataGenerator.getDefaultScripts()
|
||||
.map(SampleDataGenerator::getScriptBufferedStream)
|
||||
.forEach(Assertions::assertNotNull);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,24 +7,16 @@ 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 static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.internal.verification.VerificationModeFactory.atLeastOnce;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
|
@ -34,9 +26,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.classic.spi.LoggingEvent;
|
||||
import ch.qos.logback.core.Appender;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -72,11 +61,6 @@ class TaskanaTransactionIntTest {
|
|||
private JdbcTemplate jdbcTemplate;
|
||||
@Autowired
|
||||
private TaskanaEngine taskanaEngine;
|
||||
@Captor
|
||||
private ArgumentCaptor<LoggingEvent> captorLoggingEvent;
|
||||
|
||||
@Mock
|
||||
private Appender<ILoggingEvent> mockAppender;
|
||||
|
||||
private static ObjectReference createDefaultObjRef() {
|
||||
ObjectReference objRef = new ObjectReference();
|
||||
|
@ -198,9 +182,6 @@ class TaskanaTransactionIntTest {
|
|||
@Test
|
||||
void testWorkbasketCleanupJobTransaction() {
|
||||
try {
|
||||
ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory
|
||||
.getLogger(WorkbasketCleanupJob.class);
|
||||
logger.addAppender(mockAppender);
|
||||
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
workbasketService.createWorkbasket(createWorkBasket("key1", "wb1"));
|
||||
|
@ -250,21 +231,9 @@ class TaskanaTransactionIntTest {
|
|||
WorkbasketCleanupJob job = new WorkbasketCleanupJob(taskanaEngine, springTransactionProvider, null);
|
||||
job.run();
|
||||
|
||||
verify(mockAppender, atLeastOnce()).doAppend(captorLoggingEvent.capture());
|
||||
|
||||
List<LoggingEvent> allValues = captorLoggingEvent.getAllValues();
|
||||
Optional<LoggingEvent> result = allValues.stream().filter(event -> event.getLevel().equals(
|
||||
ch.qos.logback.classic.Level.WARN)).findFirst();
|
||||
assertTrue(result.isPresent());
|
||||
assertTrue(result.get()
|
||||
.getFormattedMessage()
|
||||
.contains("Workbasket with id " + workbasketService.getWorkbasket("key3", "DOMAIN_A")
|
||||
.getId() + " could not be deleted. Reason: {}"));
|
||||
|
||||
assertNull(workbasketService.getWorkbasket("key1", "DOMAIN_A"));
|
||||
assertNull(workbasketService.getWorkbasket("key2", "DOMAIN_A"));
|
||||
|
||||
logger.detachAppender(mockAppender);
|
||||
} catch (TaskanaException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
1
pom.xml
1
pom.xml
|
@ -52,6 +52,7 @@
|
|||
<version.spring>5.0.5.RELEASE</version.spring>
|
||||
<version.spring.core>1.2.0.RELEASE</version.spring.core>
|
||||
<version.spring.boot>2.0.2.RELEASE</version.spring.boot>
|
||||
<version.spring.restdocs>2.0.2.RELEASE</version.spring.restdocs>
|
||||
<version.spring.mybatis>1.3.1</version.spring.mybatis>
|
||||
<version.spring.ldap>2.3.2.RELEASE</version.spring.ldap>
|
||||
<version.spring.hateos>0.24.0.RELEASE</version.spring.hateos>
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<module>taskana-rest-spring</module>
|
||||
<module>../web</module>
|
||||
<module>taskana-rest-spring-example-common</module>
|
||||
<module>taskana-rest-spring-test</module>
|
||||
<module>taskana-rest-spring-example-boot</module>
|
||||
<module>taskana-rest-spring-example-wildfly</module>
|
||||
</modules>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${version.h2}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>taskana-rest-spring-test</artifactId>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<description>Exclusive test module. Contains integration tests and build rest-doc.</description>
|
||||
|
||||
<parent>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-rest-parent</artifactId>
|
||||
<version>1.1.6-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${version.spring.boot}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-data</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-rest-spring</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.plugin</groupId>
|
||||
<artifactId>spring-plugin-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.restdocs</groupId>
|
||||
<artifactId>spring-restdocs-mockmvc</artifactId>
|
||||
<scope>test</scope>
|
||||
</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>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Required for generation of REST documentation -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${version.maven.surefire}</version>
|
||||
<configuration>
|
||||
<!-- Required for skip plugin tests by default -->
|
||||
<excludes>
|
||||
<exclude>**/*Plugin*Test.java</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
<include>**/*Documentation.java</include>
|
||||
</includes>
|
||||
<!-- Travis build workaround to prevent error that VM is closed due to an error. -->
|
||||
<argLine>-Xms1024m -Xmx2048m</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||
<version>${version.maven.asciidoctor}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-docs</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>process-asciidoc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<backend>html</backend>
|
||||
<sourceDirectory>${basedir}/src/test/resources/asciidoc</sourceDirectory>
|
||||
<doctype>book</doctype>
|
||||
<attributes>
|
||||
<snippets>${basedir}/target/generated-snippets</snippets>
|
||||
<docinfo>shared</docinfo>
|
||||
</attributes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -1,80 +0,0 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.classic.spi.LoggingEvent;
|
||||
import ch.qos.logback.core.Appender;
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
|
||||
/**
|
||||
* Test general Exception Handling.
|
||||
*/
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
class GeneralExceptionHandlingTest {
|
||||
|
||||
@Mock
|
||||
private Appender<ILoggingEvent> mockAppender;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<LoggingEvent> captorLoggingEvent;
|
||||
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
private static RestTemplate template;
|
||||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
final Logger logger = (Logger) LoggerFactory.getLogger(TaskanaRestExceptionHandler.class);
|
||||
logger.addAppender(mockAppender);
|
||||
}
|
||||
|
||||
// Always have this teardown otherwise we can stuff up our expectations. Besides, it's
|
||||
// good coding practise
|
||||
@AfterEach
|
||||
void teardown() {
|
||||
final Logger logger = (Logger) LoggerFactory.getLogger(TaskanaRestExceptionHandler.class);
|
||||
logger.detachAppender(mockAppender);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteNonExisitingClassificationExceptionIsLogged() {
|
||||
try {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"), HttpMethod.DELETE,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
verify(mockAppender).doAppend(captorLoggingEvent.capture());
|
||||
assertTrue(captorLoggingEvent.getValue()
|
||||
.getMessage()
|
||||
.contains("The classification \"non-existing-id\" wasn't found"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
logging.level.pro.taskana=INFO
|
||||
### logging.level.org.springframework=DEBUG
|
||||
######## Taskana DB #######
|
||||
datasource.url=jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0
|
||||
datasource.driverClassName=org.h2.Driver
|
||||
datasource.username=sa
|
||||
datasource.password=sa
|
||||
taskana.schemaName=TASKANA
|
||||
####### property that control rest api security deploy use true for no security.
|
||||
devMode=false
|
||||
|
||||
####### Property that informs about the Taskana's version. This version is shown the application web
|
||||
version=@project.version@
|
||||
|
||||
####### control LDAP usage
|
||||
taskana.ldap.useLdap=false
|
||||
####### properties to connect to LDAP
|
||||
taskana.ldap.serverUrl=ldap://localhost:10389
|
||||
taskana.ldap.bindDn=uid=admin,ou=system
|
||||
taskana.ldap.bindPassword=secret
|
||||
taskana.ldap.baseDn=o=TaskanaTest
|
||||
####### properties that control search for users and groups
|
||||
taskana.ldap.userSearchBase=ou=people
|
||||
taskana.ldap.userSearchFilterName=objectclass
|
||||
taskana.ldap.userSearchFilterValue=person
|
||||
taskana.ldap.userFirstnameAttribute=givenName
|
||||
taskana.ldap.userLastnameAttribute=sn
|
||||
taskana.ldap.userIdAttribute=uid
|
||||
taskana.ldap.groupSearchBase=ou=groups
|
||||
taskana.ldap.groupSearchFilterName=objectclass
|
||||
taskana.ldap.groupSearchFilterValue=groupOfUniqueNames
|
||||
taskana.ldap.groupNameAttribute=cn
|
||||
taskana.ldap.minSearchForLength=3
|
||||
taskana.ldap.maxNumberOfReturnedAccessIds=50
|
||||
####### JobScheduler cron expression that specifies when the JobSchedler runs
|
||||
taskana.jobscheduler.async.cron=0 0 * * * *
|
||||
####### cache static resources properties
|
||||
spring.resources.cache.cachecontrol.cache-private=true
|
||||
####### tomcat is not detecting the x-forward headers from bluemix as a trustworthy proxy
|
||||
server.tomcat.internal-proxies=.*
|
||||
server.use-forward-headers=true
|
|
@ -14,6 +14,18 @@
|
|||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${version.spring.boot}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
@ -74,9 +86,33 @@
|
|||
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${version.spring}</version>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-data</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${version.spring.boot}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>${version.spring.boot}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
<version>${version.spring.boot}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
<version>${version.spring.boot}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -85,6 +121,24 @@
|
|||
<version>${version.spring.core}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<version>${version.spring}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.restdocs</groupId>
|
||||
<artifactId>spring-restdocs-mockmvc</artifactId>
|
||||
<version>${version.spring.restdocs}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${version.h2}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
|
@ -103,31 +157,52 @@
|
|||
<version>${version.junit.jupiter}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${version.slf4j}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${version.h2}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- spring ldap test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-test</artifactId>
|
||||
<version>${version.spring.ldap}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Required for generation of REST documentation -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${version.maven.surefire}</version>
|
||||
<configuration>
|
||||
<!-- Required for skip plugin tests by default -->
|
||||
<excludes>
|
||||
<exclude>**/*Plugin*Test.java</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
<include>**/*Documentation.java</include>
|
||||
</includes>
|
||||
<!-- Travis build workaround to prevent error that VM is closed due to an error. -->
|
||||
<argLine>-Xms1024m -Xmx2048m</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||
<version>${version.maven.asciidoctor}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-docs</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>process-asciidoc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<backend>html</backend>
|
||||
<sourceDirectory>${basedir}/src/test/resources/asciidoc</sourceDirectory>
|
||||
<doctype>book</doctype>
|
||||
<attributes>
|
||||
<snippets>${basedir}/target/generated-snippets</snippets>
|
||||
<docinfo>shared</docinfo>
|
||||
</attributes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
|
||||
/**
|
||||
* Test general Exception Handling.
|
||||
*/
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
class GeneralExceptionHandlingTest {
|
||||
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
private static RestTemplate template;
|
||||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteNonExisitingClassificationExceptionIsLogged() {
|
||||
|
||||
HttpClientErrorException ex = Assertions.assertThrows(HttpClientErrorException.class,
|
||||
() ->
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"), HttpMethod.DELETE,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)
|
||||
));
|
||||
Assertions.assertTrue(
|
||||
ex.getResponseBodyAsString().contains("non-existing-id"));
|
||||
}
|
||||
}
|
|
@ -4,23 +4,17 @@ import java.time.Instant;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.impl.ClassificationImpl;
|
||||
import pro.taskana.rest.TestConfiguration;
|
||||
|
||||
/**
|
||||
* Test for {@link ClassificationResourceAssembler}.
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestConfiguration.class})
|
||||
@WebAppConfiguration
|
||||
@TaskanaSpringBootTest
|
||||
class ClassificationAssemblerTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
|
||||
/**
|
||||
* Tests for Taskana lib configuration.
|
||||
*/
|
||||
class ConfigurationTest {
|
||||
|
||||
@Test
|
||||
void testImplementationVersionIsInTaskanaCorePackage() {
|
||||
assertNotNull(TaskanaEngineConfiguration.class.getPackage().getImplementationVersion());
|
||||
}
|
||||
}
|
|
@ -15,25 +15,20 @@ import java.util.stream.IntStream;
|
|||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.impl.report.header.TimeIntervalColumnHeader;
|
||||
import pro.taskana.impl.report.item.DetailedMonitorQueryItem;
|
||||
import pro.taskana.impl.report.item.MonitorQueryItem;
|
||||
import pro.taskana.report.ClassificationReport;
|
||||
import pro.taskana.report.WorkbasketReport;
|
||||
import pro.taskana.rest.TestConfiguration;
|
||||
|
||||
/**
|
||||
* Test for {@link ReportResourceAssembler}.
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestConfiguration.class})
|
||||
@WebAppConfiguration
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
class ReportResourceTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -6,26 +6,21 @@ import java.util.Map;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.Attachment;
|
||||
import pro.taskana.ObjectReference;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.TaskState;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.rest.TestConfiguration;
|
||||
|
||||
/**
|
||||
* Test for {@link TaskResourceAssembler}.
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestConfiguration.class})
|
||||
@WebAppConfiguration
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
class TaskResourceAssemberTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -2,23 +2,18 @@ package pro.taskana.rest.resource;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.impl.WorkbasketAccessItemImpl;
|
||||
import pro.taskana.rest.TestConfiguration;
|
||||
|
||||
/**
|
||||
* Test for {@link WorkbasketAccessItemResourceAssembler}.
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestConfiguration.class})
|
||||
@WebAppConfiguration
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
class WorkbasketAccessItemResourceAssemblerTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -4,26 +4,21 @@ import java.time.Instant;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketType;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.rest.TestConfiguration;
|
||||
|
||||
/**
|
||||
* Test for {@link WorkbasketResourceAssembler}.
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestConfiguration.class})
|
||||
@WebAppConfiguration
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
class WorkbasketResourceAssemblerTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -2,23 +2,18 @@ package pro.taskana.rest.resource;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketType;
|
||||
import pro.taskana.impl.WorkbasketSummaryImpl;
|
||||
import pro.taskana.rest.TestConfiguration;
|
||||
|
||||
/**
|
||||
* Test for {@link WorkbasketSummaryResourceAssembler}.
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestConfiguration.class})
|
||||
@WebAppConfiguration
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
class WorkbasketSummaryAssemblerTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -18,7 +18,7 @@ import pro.taskana.security.GroupPrincipal;
|
|||
import pro.taskana.security.UserPrincipal;
|
||||
|
||||
/**
|
||||
* TODO.
|
||||
* This class will take care of Test API calls authentification. Also see {@link WebSecurityConfig}
|
||||
*/
|
||||
public class SampleLoginModule extends UsernamePasswordAuthenticationFilter implements LoginModule {
|
||||
|
|
@ -1 +1,41 @@
|
|||
logging.level.pro.taskana=INFO
|
||||
### logging.level.org.springframework=DEBUG
|
||||
######## Taskana DB #######
|
||||
datasource.url=jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0
|
||||
datasource.driverClassName=org.h2.Driver
|
||||
datasource.username=sa
|
||||
datasource.password=sa
|
||||
taskana.schemaName=TASKANA
|
||||
####### property that control rest api security deploy use true for no security.
|
||||
devMode=false
|
||||
|
||||
####### Property that informs about the Taskana's version. This version is shown the application web
|
||||
version=@project.version@
|
||||
|
||||
####### control LDAP usage
|
||||
taskana.ldap.useLdap=false
|
||||
####### properties to connect to LDAP
|
||||
taskana.ldap.serverUrl=ldap://localhost:10389
|
||||
taskana.ldap.bindDn=uid=admin,ou=system
|
||||
taskana.ldap.bindPassword=secret
|
||||
taskana.ldap.baseDn=o=TaskanaTest
|
||||
####### properties that control search for users and groups
|
||||
taskana.ldap.userSearchBase=ou=people
|
||||
taskana.ldap.userSearchFilterName=objectclass
|
||||
taskana.ldap.userSearchFilterValue=person
|
||||
taskana.ldap.userFirstnameAttribute=givenName
|
||||
taskana.ldap.userLastnameAttribute=sn
|
||||
taskana.ldap.userIdAttribute=uid
|
||||
taskana.ldap.groupSearchBase=ou=groups
|
||||
taskana.ldap.groupSearchFilterName=objectclass
|
||||
taskana.ldap.groupSearchFilterValue=groupOfUniqueNames
|
||||
taskana.ldap.groupNameAttribute=cn
|
||||
taskana.ldap.minSearchForLength=3
|
||||
taskana.ldap.maxNumberOfReturnedAccessIds=50
|
||||
####### JobScheduler cron expression that specifies when the JobSchedler runs
|
||||
taskana.jobscheduler.async.cron=0 0 * * * *
|
||||
####### cache static resources properties
|
||||
spring.resources.cache.cachecontrol.cache-private=true
|
||||
####### tomcat is not detecting the x-forward headers from bluemix as a trustworthy proxy
|
||||
server.tomcat.internal-proxies=.*
|
||||
server.use-forward-headers=true
|
||||
|
|
Loading…
Reference in New Issue