TSK-726 Add HistoryPluginLoaderTests with profile option
This commit is contained in:
parent
ee792510d9
commit
6ec72b16d3
|
@ -30,6 +30,7 @@ function main {
|
|||
(cd $REL/../web && npm run test)
|
||||
mvn clean verify -q -f $REL/../lib/ -B
|
||||
mvn clean install -q -f $REL/../rest/ -B
|
||||
mvn clean verify -q -f $REL/../rest/ -B -pl taskana-rest-spring-example -P history.plugin
|
||||
else
|
||||
mvn clean verify -q -f $REL/../lib/taskana-core -B
|
||||
fi
|
||||
|
|
|
@ -22,7 +22,6 @@ public final class HistoryEventProducer {
|
|||
private ServiceLoader<TaskanaHistory> serviceLoader;
|
||||
private boolean enabled = false;
|
||||
|
||||
|
||||
public static synchronized HistoryEventProducer getInstance(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
if (emitterInstance == null) {
|
||||
emitterInstance = new HistoryEventProducer(taskanaEngineConfiguration);
|
||||
|
|
|
@ -11,7 +11,6 @@ public class TaskCompletionEvent extends TaskHistoryEvent {
|
|||
super(completedTask);
|
||||
type = "TASK_COMPLETED";
|
||||
created = completedTask.getCompleted();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,11 +33,13 @@ public class TaskHistoryEvent extends TaskanaHistoryEvent {
|
|||
if (!task.getAttachments().isEmpty()) {
|
||||
attachmentClassificationKey = task.getAttachments().get(0).getClassificationSummary().getKey();
|
||||
}
|
||||
porCompany = task.getPrimaryObjRef().getCompany();
|
||||
porSystem = task.getPrimaryObjRef().getSystem();
|
||||
porInstance = task.getPrimaryObjRef().getSystemInstance();
|
||||
porType = task.getPrimaryObjRef().getType();
|
||||
porValue = task.getPrimaryObjRef().getValue();
|
||||
if (task.getPrimaryObjRef() != null) {
|
||||
porCompany = task.getPrimaryObjRef().getCompany();
|
||||
porSystem = task.getPrimaryObjRef().getSystem();
|
||||
porInstance = task.getPrimaryObjRef().getSystemInstance();
|
||||
porType = task.getPrimaryObjRef().getType();
|
||||
porValue = task.getPrimaryObjRef().getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
|
|
|
@ -223,10 +223,8 @@ public class TaskServiceImpl implements TaskService {
|
|||
task.setOwner(userId);
|
||||
taskMapper.update(task);
|
||||
LOGGER.debug("Task '{}' completed by user '{}'.", taskId, userId);
|
||||
|
||||
if (HistoryEventProducer.isHistoryEnabled()) {
|
||||
TaskCompletionEvent event = new TaskCompletionEvent(task);
|
||||
historyEventProducer.createEvent(event);
|
||||
historyEventProducer.createEvent(new TaskCompletionEvent(task));
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package acceptance.history;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.history.HistoryEventProducer;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
|
||||
/**
|
||||
* Acceptance test for historyEventProducer class.
|
||||
*/
|
||||
public class HistoryEventProducerTest extends AbstractAccTest {
|
||||
|
||||
@Test
|
||||
public void testHistoryEventProducerIsNotEnabled() {
|
||||
HistoryEventProducer historyEventProducer = ((TaskanaEngineImpl) taskanaEngine).getHistoryEventProducer();
|
||||
assertEquals(false, historyEventProducer.isEnabled());
|
||||
}
|
||||
}
|
|
@ -1,80 +1,78 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-spring-example</artifactId>
|
||||
<version>1.0.5-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.0.2.RELEASE</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-spring</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Package as an executable jar/war -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<url>http://taskana.pro</url>
|
||||
<description>The Taskana Spring sample application.</description>
|
||||
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>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-spring-example</artifactId>
|
||||
<version>1.0.5-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.0.2.RELEASE</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-spring</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Package as an executable jar/war -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<url>http://taskana.pro</url>
|
||||
<description>The Taskana Spring sample application.</description>
|
||||
</project>
|
||||
|
|
|
@ -8,7 +8,6 @@ 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.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
@ -23,11 +22,9 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.event.Level;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
|
@ -37,8 +34,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
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.exceptions.DomainNotFoundException;
|
||||
|
@ -47,6 +42,7 @@ import pro.taskana.exceptions.NotAuthorizedException;
|
|||
import pro.taskana.exceptions.TaskanaException;
|
||||
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.history.HistoryEventProducer;
|
||||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
|
@ -63,7 +59,7 @@ import pro.taskana.transaction.TaskanaTransactionProvider;
|
|||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@ActiveProfiles({"inmemorydb", "dev"})
|
||||
@Import({TransactionalJobsConfiguration.class})
|
||||
public class TaskanaTransactionTest {
|
||||
public class TaskanaTransactionIntTest {
|
||||
|
||||
private static final int POOL_TIME_TO_WAIT = 50;
|
||||
|
|
@ -35,6 +35,42 @@
|
|||
<spring.ldap.version>2.3.2.RELEASE</spring.ldap.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>history.plugin</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<build.profile.id>history.plugin</build.profile.id>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>pro.taskana.simplehistory</groupId>
|
||||
<artifactId>taskana-simplehistory-provider</artifactId>
|
||||
<version>0.0.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.0</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Plugin*Test.java</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/Test/*.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
|
@ -67,7 +103,7 @@
|
|||
<artifactId>h2</artifactId>
|
||||
<version>1.4.197</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ibm.db2.jcc</groupId>
|
||||
<artifactId>db2jcc4</artifactId>
|
||||
|
@ -134,6 +170,18 @@
|
|||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<!-- Required for skip plugin tests by default -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.0</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*Plugin*Test.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Required for generation of REST documentation -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package pro.taskana.historyPlugin;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.history.HistoryEventProducer;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class)
|
||||
public class HistoryPluginLoaderTest {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private TaskanaEngine taskanaEngine;
|
||||
|
||||
@Test
|
||||
public void testHistoryEventProducerIsEnabled() {
|
||||
HistoryEventProducer historyEventProducer = ((TaskanaEngineImpl) taskanaEngine).getHistoryEventProducer();
|
||||
assertEquals(historyEventProducer.isEnabled(), true);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,6 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -86,6 +85,8 @@ public class AsyncUpdateJobIntTest {
|
|||
|
||||
// 1st step: get old classification :
|
||||
Instant before = Instant.now();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String updatedClassification;
|
||||
|
||||
ResponseEntity<ClassificationResource> response = template.exchange(
|
||||
"http://127.0.0.1:" + port + "/v1/classifications/CLI:100000000000000000000000000000000003",
|
||||
|
@ -103,7 +104,7 @@ public class AsyncUpdateJobIntTest {
|
|||
classification.setServiceLevel("P5D");
|
||||
classification.setPriority(1000);
|
||||
|
||||
String updatedClassification = new JSONObject(classification).toString();
|
||||
updatedClassification = mapper.writeValueAsString(classification);
|
||||
|
||||
URL url = new URL(server + port + "/v1/classifications/CLI:100000000000000000000000000000000003");
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
|
@ -201,7 +202,7 @@ public class AsyncUpdateJobIntTest {
|
|||
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
|
||||
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
return template;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue