TSK-1358: Added Wildflytests, renamed history module
This commit is contained in:
parent
a37a859573
commit
64701e785c
|
@ -32,6 +32,10 @@
|
|||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${version.jackson-databind}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
|
@ -40,10 +44,6 @@
|
|||
<version>${version.slf4j-test}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
|
|
|
@ -20,9 +20,9 @@ import pro.taskana.common.api.exceptions.SystemException;
|
|||
import pro.taskana.spi.history.api.TaskanaHistory;
|
||||
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
|
||||
|
||||
public class LogfileHistoryServiceProvider implements TaskanaHistory {
|
||||
public class LogfileHistoryServiceImpl implements TaskanaHistory {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LogfileHistoryServiceProvider.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LogfileHistoryServiceImpl.class);
|
||||
private static final String TASKANA_PROPERTIES = "/taskana.properties";
|
||||
private static final String TASKANA_HISTORYLOGGER_NAME = "taskana.historylogger.name";
|
||||
private static Logger historyLogger;
|
|
@ -1 +1 @@
|
|||
pro.taskana.loghistory.impl.LogfileHistoryServiceProvider
|
||||
pro.taskana.loghistory.impl.LogfileHistoryServiceImpl
|
||||
|
|
|
@ -15,10 +15,10 @@ import uk.org.lidalia.slf4jtest.TestLoggerFactory;
|
|||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
|
||||
|
||||
class LogfileHistoryServiceProviderTest {
|
||||
class LogfileHistoryServiceImplTest {
|
||||
|
||||
static ObjectMapper objectMapper = new ObjectMapper();
|
||||
LogfileHistoryServiceProvider logfileHistoryServiceProvider = new LogfileHistoryServiceProvider();
|
||||
LogfileHistoryServiceImpl logfileHistoryServiceImpl = new LogfileHistoryServiceImpl();
|
||||
TestLogger logger = TestLoggerFactory.getTestLogger("AUDIT");
|
||||
@Mock TaskanaEngine taskanaEngine;
|
||||
|
||||
|
@ -35,7 +35,7 @@ class LogfileHistoryServiceProviderTest {
|
|||
@Test
|
||||
void should_LogEventAsJson_When_CreateIsCalled() throws Exception {
|
||||
|
||||
logfileHistoryServiceProvider.initialize(taskanaEngine);
|
||||
logfileHistoryServiceImpl.initialize(taskanaEngine);
|
||||
TaskanaHistoryEvent eventToBeLogged = new TaskanaHistoryEvent();
|
||||
eventToBeLogged.setId("someId");
|
||||
eventToBeLogged.setUserId("someUser");
|
||||
|
@ -50,7 +50,7 @@ class LogfileHistoryServiceProviderTest {
|
|||
eventToBeLogged.setTaskClassificationCategory("someTaskClassificationCategory");
|
||||
eventToBeLogged.setDetails("someDetails");
|
||||
|
||||
logfileHistoryServiceProvider.create(eventToBeLogged);
|
||||
logfileHistoryServiceImpl.create(eventToBeLogged);
|
||||
|
||||
String logMessage = logger.getLoggingEvents().asList().get(0).getMessage();
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
<Appenders>
|
||||
|
||||
<RollingFile name="auditFileJson"
|
||||
fileName="_audit.json"
|
||||
fileName="target/_audit.json"
|
||||
filePattern="${LOG_FOLDER}/${QUALIFIED_SERVICE_NAME}_audit-%d{yyyy-MM-dd}-%i.json">
|
||||
<JsonLayout compact="true" complete="false" properties="true" locationInfo="true"
|
||||
propertiesAsList="false" eventEol="true" stacktraceAsString="true">
|
|
@ -18,3 +18,4 @@ taskana.german.holidays.enabled=true
|
|||
taskana.german.holidays.corpus-christi.enabled=true
|
||||
|
||||
taskana.historylogger.name=AUDIT
|
||||
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -73,6 +77,12 @@
|
|||
</dependency>
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>pro.taskana.simplehistory</groupId>
|
||||
<artifactId>taskana-simplehistory-rest-spring</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
package pro.taskana;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.Collections;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import pro.taskana.classification.rest.models.ClassificationSummaryRepresentationModel;
|
||||
import pro.taskana.simplehistory.rest.models.TaskHistoryEventListResource;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
import pro.taskana.task.rest.models.TaskRepresentationModel;
|
||||
import pro.taskana.workbasket.rest.models.WorkbasketSummaryRepresentationModel;
|
||||
|
||||
public class AbstractAccTest {
|
||||
|
||||
protected static final String DEPENDENCY_VERSION = "3.2.1-SNAPSHOT";
|
||||
private static final String AUTHORIZATION_TEAMLEAD_1 = "Basic dGVhbWxlYWQtMTp0ZWFtbGVhZC0x";
|
||||
|
||||
/**
|
||||
* Return a REST template which is capable of dealing with responses in HAL format.
|
||||
*
|
||||
* @return RestTemplate
|
||||
*/
|
||||
protected static RestTemplate getRestTemplate() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
mapper.registerModule(new Jackson2HalModule());
|
||||
mapper
|
||||
.registerModule(new ParameterNamesModule())
|
||||
.registerModule(new Jdk8Module())
|
||||
.registerModule(new JavaTimeModule());
|
||||
|
||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||
converter.setSupportedMediaTypes(Collections.singletonList(MediaTypes.HAL_JSON));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate();
|
||||
// important to add first to ensure priority
|
||||
template.getMessageConverters().add(0, converter);
|
||||
return template;
|
||||
}
|
||||
|
||||
protected HttpHeaders getHeadersTeamlead_1() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_TEAMLEAD_1);
|
||||
headers.add("Content-Type", "application/json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
protected TaskRepresentationModel getTaskResourceSample() {
|
||||
ClassificationSummaryRepresentationModel classificationResource =
|
||||
new ClassificationSummaryRepresentationModel();
|
||||
classificationResource.setKey("L11010");
|
||||
WorkbasketSummaryRepresentationModel workbasketSummary =
|
||||
new WorkbasketSummaryRepresentationModel();
|
||||
workbasketSummary.setWorkbasketId("WBI:100000000000000000000000000000000004");
|
||||
|
||||
ObjectReference objectReference = new ObjectReference();
|
||||
objectReference.setCompany("MyCompany1");
|
||||
objectReference.setSystem("MySystem1");
|
||||
objectReference.setSystemInstance("MyInstance1");
|
||||
objectReference.setType("MyType1");
|
||||
objectReference.setValue("00000001");
|
||||
|
||||
TaskRepresentationModel taskRepresentationModel = new TaskRepresentationModel();
|
||||
taskRepresentationModel.setClassificationSummary(classificationResource);
|
||||
taskRepresentationModel.setWorkbasketSummary(workbasketSummary);
|
||||
taskRepresentationModel.setPrimaryObjRef(objectReference);
|
||||
return taskRepresentationModel;
|
||||
}
|
||||
|
||||
protected ResponseEntity<TaskHistoryEventListResource> performGetHistoryEventsRestCall() {
|
||||
|
||||
HttpEntity<TaskHistoryEventListResource> httpEntity = new HttpEntity<>(getHeadersTeamlead_1());
|
||||
|
||||
ResponseEntity<TaskHistoryEventListResource> response =
|
||||
getRestTemplate()
|
||||
.exchange(
|
||||
"http://127.0.0.1:" + "8080" + "/taskana/api/v1/task-history-event",
|
||||
HttpMethod.GET,
|
||||
httpEntity,
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
protected ResponseEntity<TaskRepresentationModel> performCreateTaskRestCall() {
|
||||
|
||||
TaskRepresentationModel taskRepresentationModel = getTaskResourceSample();
|
||||
ResponseEntity<TaskRepresentationModel> responseCreateTask =
|
||||
getRestTemplate()
|
||||
.exchange(
|
||||
"http://127.0.0.1:" + "8080" + "/taskana/api/v1/tasks",
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(taskRepresentationModel, getHeadersTeamlead_1()),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
return responseCreateTask;
|
||||
}
|
||||
|
||||
protected String parseServerLog() throws Exception {
|
||||
|
||||
// TO-DO: make log4j log into rollingFile from log4j.xml
|
||||
File file = new File("target/wildfly-13.0.0.Final/standalone/log/server.log");
|
||||
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
|
||||
String str;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
while ((str = br.readLine()) != null) {
|
||||
stringBuilder.append(str);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -3,15 +3,8 @@ package pro.taskana;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.container.test.api.RunAsClient;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
|
@ -24,15 +17,10 @@ import org.junit.runner.RunWith;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import pro.taskana.common.rest.models.AccessIdRepresentationModel;
|
||||
import pro.taskana.common.rest.models.TaskanaUserInfoRepresentationModel;
|
||||
|
@ -43,12 +31,10 @@ import pro.taskana.task.rest.models.TaskRepresentationModel;
|
|||
* to change data source configuration at project-defaults.yml.
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class TaskanaWildflyTest {
|
||||
public class TaskanaWildflyTest extends AbstractAccTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaWildflyTest.class);
|
||||
|
||||
public static final String AUTHORIZATION_TEAMLEAD_1 = "Basic dGVhbWxlYWQtMTp0ZWFtbGVhZC0x";
|
||||
|
||||
@Deployment(testable = false)
|
||||
public static Archive<?> createTestArchive() {
|
||||
|
||||
|
@ -128,38 +114,6 @@ public class TaskanaWildflyTest {
|
|||
assertThat(response.getBody()).isNotNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a REST template which is capable of dealing with responses in HAL format.
|
||||
*
|
||||
* @return RestTemplate
|
||||
*/
|
||||
private static RestTemplate getRestTemplate() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
mapper.registerModule(new Jackson2HalModule());
|
||||
mapper
|
||||
.registerModule(new ParameterNamesModule())
|
||||
.registerModule(new Jdk8Module())
|
||||
.registerModule(new JavaTimeModule());
|
||||
|
||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||
converter.setSupportedMediaTypes(Collections.singletonList(MediaTypes.HAL_JSON));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate();
|
||||
// important to add first to ensure priority
|
||||
template.getMessageConverters().add(0, converter);
|
||||
return template;
|
||||
}
|
||||
|
||||
private HttpHeaders getHeadersTeamlead_1() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_TEAMLEAD_1);
|
||||
headers.add("Content-Type", "application/json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
static class AccessIdListResource extends ArrayList<AccessIdRepresentationModel> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package pro.taskana;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.container.test.api.RunAsClient;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.PackagingType;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinate;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinates;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency;
|
||||
import org.jboss.shrinkwrap.resolver.impl.maven.coordinate.MavenDependencyImpl;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This test class is configured to run with postgres DB if you want to run it with h2 it is needed.
|
||||
* to change data source configuration at project-defaults.yml.
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class TaskanaWildflyWithHistoryLoggerEnabled extends AbstractAccTest {
|
||||
|
||||
private static final Logger LOGGER =
|
||||
LoggerFactory.getLogger(TaskanaWildflyWithHistoryLoggerEnabled.class);
|
||||
|
||||
@Deployment(testable = false)
|
||||
public static Archive<?> createTestArchive() {
|
||||
|
||||
String applicationPropertyFile = "application.properties";
|
||||
String dbType = System.getProperty("db.type");
|
||||
if (dbType != null && !dbType.isEmpty()) {
|
||||
applicationPropertyFile = "application-" + dbType + ".properties";
|
||||
}
|
||||
|
||||
LOGGER.info(
|
||||
"Running with db.type '{}' and using property file '{}'", dbType, applicationPropertyFile);
|
||||
|
||||
MavenCoordinate historyLoggerCoordinate =
|
||||
MavenCoordinates.createCoordinate(
|
||||
"pro.taskana.simplehistory",
|
||||
"taskana-loghistory-provider",
|
||||
DEPENDENCY_VERSION,
|
||||
PackagingType.JAR,
|
||||
null);
|
||||
|
||||
MavenDependency historyLoggerDependency =
|
||||
new MavenDependencyImpl(historyLoggerCoordinate, ScopeType.TEST, false);
|
||||
|
||||
File[] files =
|
||||
Maven.resolver()
|
||||
.loadPomFromFile("pom.xml")
|
||||
.importRuntimeDependencies()
|
||||
.addDependency(historyLoggerDependency)
|
||||
.resolve()
|
||||
.withTransitivity()
|
||||
.asFile();
|
||||
|
||||
return ShrinkWrap.create(WebArchive.class, "taskana.war")
|
||||
.addPackages(true, "pro.taskana")
|
||||
.addAsResource("taskana.properties")
|
||||
.addAsResource(applicationPropertyFile, "application.properties")
|
||||
.addAsResource("taskana-test.ldif")
|
||||
.addAsWebInfResource("int-test-web.xml", "web.xml")
|
||||
.addAsWebInfResource("int-test-jboss-web.xml", "jboss-web.xml")
|
||||
.addAsLibraries(files);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void should_WriteHistoryEventIntoDatabase_And_LogEventToFile() throws Exception {
|
||||
|
||||
String log = parseServerLog();
|
||||
|
||||
assertThat(log).contains("AUDIT");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package pro.taskana;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.container.test.api.RunAsClient;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.PackagingType;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinate;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinates;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency;
|
||||
import org.jboss.shrinkwrap.resolver.impl.maven.coordinate.MavenDependencyImpl;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import pro.taskana.simplehistory.rest.models.TaskHistoryEventListResource;
|
||||
import pro.taskana.task.rest.models.TaskRepresentationModel;
|
||||
|
||||
/**
|
||||
* This test class is configured to run with postgres DB if you want to run it with h2 it is needed.
|
||||
* to change data source configuration at project-defaults.yml.
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class TaskanaWildflyWithSimpleHistoryAndHistoryLoggerEnabled extends AbstractAccTest {
|
||||
|
||||
private static final Logger LOGGER =
|
||||
LoggerFactory.getLogger(TaskanaWildflyWithSimpleHistoryAndHistoryLoggerEnabled.class);
|
||||
|
||||
@Deployment(testable = false)
|
||||
public static Archive<?> createTestArchive() {
|
||||
|
||||
String applicationPropertyFile = "application.properties";
|
||||
String dbType = System.getProperty("db.type");
|
||||
if (dbType != null && !dbType.isEmpty()) {
|
||||
applicationPropertyFile = "application-" + dbType + ".properties";
|
||||
}
|
||||
|
||||
LOGGER.info(
|
||||
"Running with db.type '{}' and using property file '{}'", dbType, applicationPropertyFile);
|
||||
|
||||
MavenCoordinate simpleHistoryCoordinate =
|
||||
MavenCoordinates.createCoordinate(
|
||||
"pro.taskana.simplehistory",
|
||||
"taskana-simplehistory-rest-spring",
|
||||
DEPENDENCY_VERSION,
|
||||
PackagingType.JAR,
|
||||
null);
|
||||
|
||||
MavenDependency simpleHistoryDependency =
|
||||
new MavenDependencyImpl(simpleHistoryCoordinate, ScopeType.TEST, false);
|
||||
|
||||
MavenCoordinate historyLoggerCoordinate =
|
||||
MavenCoordinates.createCoordinate(
|
||||
"pro.taskana.simplehistory",
|
||||
"taskana-loghistory-provider",
|
||||
DEPENDENCY_VERSION,
|
||||
PackagingType.JAR,
|
||||
null);
|
||||
|
||||
MavenDependency historyLoggerDependency =
|
||||
new MavenDependencyImpl(historyLoggerCoordinate, ScopeType.TEST, false);
|
||||
|
||||
File[] files =
|
||||
Maven.resolver()
|
||||
.loadPomFromFile("pom.xml")
|
||||
.importRuntimeDependencies()
|
||||
.addDependency(simpleHistoryDependency)
|
||||
.addDependency(historyLoggerDependency)
|
||||
.resolve()
|
||||
.withTransitivity()
|
||||
.asFile();
|
||||
|
||||
return ShrinkWrap.create(WebArchive.class, "taskana.war")
|
||||
.addPackages(true, "pro.taskana")
|
||||
.addAsResource("taskana.properties")
|
||||
.addAsResource(applicationPropertyFile, "application.properties")
|
||||
.addAsResource("taskana-test.ldif")
|
||||
.addAsWebInfResource("int-test-web.xml", "web.xml")
|
||||
.addAsWebInfResource("int-test-jboss-web.xml", "jboss-web.xml")
|
||||
.addAsLibraries(files);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void should_WriteHistoryEventIntoDatabase_And_LogEventToFile() throws Exception {
|
||||
|
||||
ResponseEntity<TaskHistoryEventListResource> getHistoryEventsResponse =
|
||||
performGetHistoryEventsRestCall();
|
||||
assertThat(getHistoryEventsResponse.getBody()).isNotNull();
|
||||
assertThat(getHistoryEventsResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getHistoryEventsResponse.getBody().getContent()).hasSize(0);
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> responseCreateTask = performCreateTaskRestCall();
|
||||
assertThat(HttpStatus.CREATED).isEqualTo(responseCreateTask.getStatusCode());
|
||||
assertThat(responseCreateTask.getBody()).isNotNull();
|
||||
|
||||
getHistoryEventsResponse = performGetHistoryEventsRestCall();
|
||||
|
||||
assertThat(getHistoryEventsResponse.getBody()).isNotNull();
|
||||
assertThat(getHistoryEventsResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getHistoryEventsResponse.getBody().getContent()).hasSize(1);
|
||||
|
||||
String log = parseServerLog();
|
||||
|
||||
assertThat(log).contains("AUDIT");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package pro.taskana;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.container.test.api.RunAsClient;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.PackagingType;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinate;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinates;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency;
|
||||
import org.jboss.shrinkwrap.resolver.impl.maven.coordinate.MavenDependencyImpl;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import pro.taskana.simplehistory.rest.models.TaskHistoryEventListResource;
|
||||
import pro.taskana.task.rest.models.TaskRepresentationModel;
|
||||
|
||||
/**
|
||||
* This test class is configured to run with postgres DB if you want to run it with h2 it is needed.
|
||||
* to change data source configuration at project-defaults.yml.
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class TaskanaWildflyWithSimpleHistoryEnabled extends AbstractAccTest {
|
||||
|
||||
private static final Logger LOGGER =
|
||||
LoggerFactory.getLogger(TaskanaWildflyWithSimpleHistoryEnabled.class);
|
||||
|
||||
@Deployment(testable = false)
|
||||
public static Archive<?> createTestArchive() {
|
||||
|
||||
String applicationPropertyFile = "application.properties";
|
||||
String dbType = System.getProperty("db.type");
|
||||
if (dbType != null && !dbType.isEmpty()) {
|
||||
applicationPropertyFile = "application-" + dbType + ".properties";
|
||||
}
|
||||
|
||||
LOGGER.info(
|
||||
"Running with db.type '{}' and using property file '{}'", dbType, applicationPropertyFile);
|
||||
|
||||
MavenCoordinate simpleHistoryCoordinate =
|
||||
MavenCoordinates.createCoordinate(
|
||||
"pro.taskana.simplehistory",
|
||||
"taskana-simplehistory-rest-spring",
|
||||
DEPENDENCY_VERSION,
|
||||
PackagingType.JAR,
|
||||
null);
|
||||
|
||||
MavenDependency simpleHistoryDependency =
|
||||
new MavenDependencyImpl(simpleHistoryCoordinate, ScopeType.TEST, false);
|
||||
|
||||
File[] files =
|
||||
Maven.resolver()
|
||||
.loadPomFromFile("pom.xml")
|
||||
.importRuntimeDependencies()
|
||||
.addDependency(simpleHistoryDependency)
|
||||
.resolve()
|
||||
.withTransitivity()
|
||||
.asFile();
|
||||
|
||||
return ShrinkWrap.create(WebArchive.class, "taskana.war")
|
||||
.addPackages(true, "pro.taskana")
|
||||
.addAsResource("taskana.properties")
|
||||
.addAsResource(applicationPropertyFile, "application.properties")
|
||||
.addAsResource("taskana-test.ldif")
|
||||
.addAsWebInfResource("int-test-web.xml", "web.xml")
|
||||
.addAsWebInfResource("int-test-jboss-web.xml", "jboss-web.xml")
|
||||
.addAsLibraries(files);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void should_WriteHistoryEventIntoDatabase() {
|
||||
|
||||
ResponseEntity<TaskHistoryEventListResource> getHistoryEventsResponse =
|
||||
performGetHistoryEventsRestCall();
|
||||
assertThat(getHistoryEventsResponse.getBody()).isNotNull();
|
||||
assertThat(getHistoryEventsResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getHistoryEventsResponse.getBody().getContent()).hasSize(0);
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> responseCreateTask = performCreateTaskRestCall();
|
||||
assertThat(HttpStatus.CREATED).isEqualTo(responseCreateTask.getStatusCode());
|
||||
assertThat(responseCreateTask.getBody()).isNotNull();
|
||||
|
||||
getHistoryEventsResponse = performGetHistoryEventsRestCall();
|
||||
|
||||
assertThat(getHistoryEventsResponse.getBody()).isNotNull();
|
||||
assertThat(getHistoryEventsResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getHistoryEventsResponse.getBody().getContent()).hasSize(1);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,3 +15,4 @@ taskana.jobs.cleanup.runEvery=P1D
|
|||
taskana.jobs.cleanup.firstRunAt=2018-07-25T08:00:00Z
|
||||
taskana.jobs.cleanup.minimumAge=P14D
|
||||
taskana.german.holidays.enabled=true
|
||||
taskana.historylogger.name=AUDIT
|
||||
|
|
Loading…
Reference in New Issue