TSK-1887: taskana-simplehistory-provider is now using our docker dbs
This commit is contained in:
parent
a9936f243d
commit
20787a2166
|
@ -273,10 +273,14 @@ jobs:
|
||||||
database: POSTGRES
|
database: POSTGRES
|
||||||
- module: taskana-test-api
|
- module: taskana-test-api
|
||||||
database: DB2
|
database: DB2
|
||||||
|
- module: taskana-simplehistory-provider
|
||||||
|
database: DB2
|
||||||
|
- module: taskana-simplehistory-provider
|
||||||
|
database: POSTGRES
|
||||||
- module: taskana-rest-spring-example-boot
|
- module: taskana-rest-spring-example-boot
|
||||||
database: DB2
|
database: DB2
|
||||||
- module: taskana-rest-spring-example-wildfly
|
- module: taskana-rest-spring-example-wildfly
|
||||||
database: POSTGRES_10
|
database: POSTGRES
|
||||||
steps:
|
steps:
|
||||||
- name: Git checkout
|
- name: Git checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
|
@ -351,9 +351,6 @@ CREATE SEQUENCE SCHEDULED_JOB_SEQ
|
||||||
START WITH 1
|
START WITH 1
|
||||||
INCREMENT BY 1 CACHE 10;
|
INCREMENT BY 1 CACHE 10;
|
||||||
|
|
||||||
SET
|
|
||||||
search_path TO taskana;
|
|
||||||
|
|
||||||
CREATE INDEX IDX_CLASSIFICATION_ID ON CLASSIFICATION
|
CREATE INDEX IDX_CLASSIFICATION_ID ON CLASSIFICATION
|
||||||
(ID ASC, CUSTOM_8, CUSTOM_7, CUSTOM_6, CUSTOM_5, CUSTOM_4,
|
(ID ASC, CUSTOM_8, CUSTOM_7, CUSTOM_6, CUSTOM_5, CUSTOM_4,
|
||||||
CUSTOM_3, CUSTOM_2, CUSTOM_1, APPLICATION_ENTRY_POINT,
|
CUSTOM_3, CUSTOM_2, CUSTOM_1, APPLICATION_ENTRY_POINT,
|
||||||
|
|
|
@ -10,11 +10,11 @@ export TOP_PID=$$
|
||||||
#H
|
#H
|
||||||
#H %FILE% <database>
|
#H %FILE% <database>
|
||||||
#H
|
#H
|
||||||
#H downloads and starts docker image for taskana unit tests.
|
#H downloads and starts docker image for TASKANA unit tests.
|
||||||
#H
|
#H
|
||||||
#H %FILE% stop [database]
|
#H %FILE% stop [database]
|
||||||
#H
|
#H
|
||||||
#H stops the database and removes 'taskanaUnitTest.properties'.
|
#H stops the database.
|
||||||
#H If no database was provided all databases are stopped.
|
#H If no database was provided all databases are stopped.
|
||||||
#H
|
#H
|
||||||
#H database:
|
#H database:
|
||||||
|
|
|
@ -79,5 +79,18 @@
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ibm.db2.jcc</groupId>
|
||||||
|
<artifactId>db2jcc4</artifactId>
|
||||||
|
<version>${version.db2}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>novatec public</id>
|
||||||
|
<name>novatec-repository</name>
|
||||||
|
<url>https://repository.novatec-gmbh.de/content/repositories/novatec/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -29,14 +29,13 @@ public class WorkbasketHistoryQueryImpl implements WorkbasketHistoryQuery {
|
||||||
private static final String SQL_EXCEPTION_MESSAGE =
|
private static final String SQL_EXCEPTION_MESSAGE =
|
||||||
"Method openConnection() could not open a connection to the database.";
|
"Method openConnection() could not open a connection to the database.";
|
||||||
|
|
||||||
private TaskanaHistoryEngineImpl taskanaHistoryEngine;
|
private final TaskanaHistoryEngineImpl taskanaHistoryEngine;
|
||||||
|
private final List<String> orderColumns;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private WorkbasketHistoryQueryColumnName columnName;
|
private WorkbasketHistoryQueryColumnName columnName;
|
||||||
|
|
||||||
private List<String> orderBy;
|
private List<String> orderBy;
|
||||||
private List<String> orderColumns;
|
|
||||||
|
|
||||||
private String[] idIn;
|
private String[] idIn;
|
||||||
private String[] workbasketIdIn;
|
private String[] workbasketIdIn;
|
||||||
private String[] eventTypeIn;
|
private String[] eventTypeIn;
|
||||||
|
@ -413,6 +412,11 @@ public class WorkbasketHistoryQueryImpl implements WorkbasketHistoryQuery {
|
||||||
return addOrderCriteria("USER_ID", sortDirection);
|
return addOrderCriteria("USER_ID", sortDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkbasketHistoryQuery orderById(SortDirection sortDirection) {
|
||||||
|
return addOrderCriteria("ID", sortDirection);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkbasketHistoryQuery orderByDomain(SortDirection sortDirection) {
|
public WorkbasketHistoryQuery orderByDomain(SortDirection sortDirection) {
|
||||||
return addOrderCriteria("DOMAIN", sortDirection);
|
return addOrderCriteria("DOMAIN", sortDirection);
|
||||||
|
|
|
@ -272,6 +272,16 @@ public interface WorkbasketHistoryQuery
|
||||||
*/
|
*/
|
||||||
WorkbasketHistoryQuery orderByUserId(SortDirection sortDirection);
|
WorkbasketHistoryQuery orderByUserId(SortDirection sortDirection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort the query result by {@linkplain WorkbasketHistoryEvent#getId() id} of the {@linkplain
|
||||||
|
* WorkbasketHistoryEvent}.
|
||||||
|
*
|
||||||
|
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
|
||||||
|
* If sortDirection is null, the result is sorted in ascending order
|
||||||
|
* @return the query
|
||||||
|
*/
|
||||||
|
WorkbasketHistoryQuery orderById(SortDirection sortDirection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort the query result by Domain.
|
* Sort the query result by Domain.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
package acceptance;
|
package acceptance;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Properties;
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import org.apache.ibatis.datasource.pooled.PooledDataSource;
|
|
||||||
import org.apache.ibatis.session.SqlSessionManager;
|
import org.apache.ibatis.session.SqlSessionManager;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.slf4j.Logger;
|
import org.junit.platform.commons.JUnitException;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import pro.taskana.TaskanaEngineConfiguration;
|
import pro.taskana.TaskanaEngineConfiguration;
|
||||||
import pro.taskana.common.api.TaskanaEngine;
|
import pro.taskana.common.api.TaskanaEngine;
|
||||||
|
@ -21,6 +12,7 @@ import pro.taskana.common.api.TaskanaEngine.ConnectionManagementMode;
|
||||||
import pro.taskana.common.internal.JobMapper;
|
import pro.taskana.common.internal.JobMapper;
|
||||||
import pro.taskana.common.internal.TaskanaEngineImpl;
|
import pro.taskana.common.internal.TaskanaEngineImpl;
|
||||||
import pro.taskana.common.internal.util.IdGenerator;
|
import pro.taskana.common.internal.util.IdGenerator;
|
||||||
|
import pro.taskana.common.test.config.DataSourceGenerator;
|
||||||
import pro.taskana.sampledata.SampleDataGenerator;
|
import pro.taskana.sampledata.SampleDataGenerator;
|
||||||
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
|
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
|
||||||
import pro.taskana.simplehistory.impl.TaskanaHistoryEngineImpl;
|
import pro.taskana.simplehistory.impl.TaskanaHistoryEngineImpl;
|
||||||
|
@ -35,29 +27,10 @@ import pro.taskana.task.internal.models.ObjectReferenceImpl;
|
||||||
/** Set up database for tests. */
|
/** Set up database for tests. */
|
||||||
public abstract class AbstractAccTest {
|
public abstract class AbstractAccTest {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAccTest.class);
|
|
||||||
private static final String USER_HOME_DIRECTORY = System.getProperty("user.home");
|
|
||||||
private static final int POOL_TIME_TO_WAIT = 50;
|
|
||||||
private static final DataSource DATA_SOURCE;
|
|
||||||
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||||
protected static TaskanaHistoryEngineImpl taskanaHistoryEngine;
|
protected static TaskanaHistoryEngineImpl taskanaHistoryEngine;
|
||||||
protected static TaskanaEngine taskanaEngine;
|
protected static TaskanaEngine taskanaEngine;
|
||||||
private static SimpleHistoryServiceImpl historyService;
|
private static SimpleHistoryServiceImpl historyService;
|
||||||
private static String schemaName;
|
|
||||||
|
|
||||||
static {
|
|
||||||
String propertiesFileName = USER_HOME_DIRECTORY + "/taskanaUnitTest.properties";
|
|
||||||
File f = new File(propertiesFileName);
|
|
||||||
if (f.exists() && !f.isDirectory()) {
|
|
||||||
DATA_SOURCE = createDataSourceFromProperties(propertiesFileName);
|
|
||||||
} else {
|
|
||||||
DATA_SOURCE = createDefaultDataSource();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected AbstractAccTest() {
|
|
||||||
// not called
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create taskHistoryEvent object.
|
* create taskHistoryEvent object.
|
||||||
|
@ -109,13 +82,15 @@ public abstract class AbstractAccTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void resetDb(String schemaName) throws Exception {
|
protected static void resetDb(String schemaName) throws Exception {
|
||||||
DataSource dataSource = getDataSource();
|
DataSource dataSource = DataSourceGenerator.getDataSource();
|
||||||
|
|
||||||
taskanaEngineConfiguration =
|
taskanaEngineConfiguration =
|
||||||
new TaskanaEngineConfiguration(
|
new TaskanaEngineConfiguration(
|
||||||
dataSource,
|
dataSource,
|
||||||
false,
|
false,
|
||||||
schemaName != null && !schemaName.isEmpty() ? schemaName : getSchemaName());
|
schemaName != null && !schemaName.isEmpty()
|
||||||
|
? schemaName
|
||||||
|
: DataSourceGenerator.getSchemaName());
|
||||||
taskanaEngine =
|
taskanaEngine =
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
|
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
|
||||||
taskanaHistoryEngine = TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngine);
|
taskanaHistoryEngine = TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngine);
|
||||||
|
@ -123,41 +98,12 @@ public abstract class AbstractAccTest {
|
||||||
historyService.initialize(
|
historyService.initialize(
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT));
|
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT));
|
||||||
|
|
||||||
SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(dataSource, getSchemaName());
|
SampleDataGenerator sampleDataGenerator =
|
||||||
|
new SampleDataGenerator(dataSource, taskanaEngineConfiguration.getSchemaName());
|
||||||
sampleDataGenerator.clearDb();
|
sampleDataGenerator.clearDb();
|
||||||
sampleDataGenerator.generateTestData();
|
sampleDataGenerator.generateTestData();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static DataSource getDataSource() {
|
|
||||||
if (DATA_SOURCE == null) {
|
|
||||||
throw new RuntimeException("Datasource should be already initialized");
|
|
||||||
}
|
|
||||||
return DATA_SOURCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the SchemaName used for Junit test. If the file {user.home}/taskanaUnitTest.properties
|
|
||||||
* is present, the SchemaName is created according to the property schemaName. a sample properties
|
|
||||||
* file for DB2 looks as follows: jdbcDriver=com.ibm.db2.jcc.DB2Driver
|
|
||||||
* jdbcUrl=jdbc:db2://localhost:50000/tskdb dbUserName=db2user dbPassword=db2password
|
|
||||||
* schemaName=TASKANA If any of these properties is missing, or the file doesn't exist, the
|
|
||||||
* default schemaName TASKANA is created used.
|
|
||||||
*
|
|
||||||
* @return String for unit test
|
|
||||||
*/
|
|
||||||
protected static String getSchemaName() {
|
|
||||||
if (schemaName == null) {
|
|
||||||
String propertiesFileName = USER_HOME_DIRECTORY + "/taskanaUnitTest.properties";
|
|
||||||
File f = new File(propertiesFileName);
|
|
||||||
if (f.exists() && !f.isDirectory()) {
|
|
||||||
schemaName = getSchemaNameFromPropertiesObject(propertiesFileName);
|
|
||||||
} else {
|
|
||||||
schemaName = "TASKANA";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return schemaName;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static SimpleHistoryServiceImpl getHistoryService() {
|
protected static SimpleHistoryServiceImpl getHistoryService() {
|
||||||
return historyService;
|
return historyService;
|
||||||
}
|
}
|
||||||
|
@ -195,156 +141,38 @@ public abstract class AbstractAccTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static WorkbasketHistoryEventMapper getWorkbasketHistoryEventMapper() {
|
protected static WorkbasketHistoryEventMapper getWorkbasketHistoryEventMapper() {
|
||||||
|
|
||||||
SqlSessionManager manager = null;
|
|
||||||
|
|
||||||
Field sessionManager;
|
|
||||||
try {
|
try {
|
||||||
sessionManager = TaskanaHistoryEngineImpl.class.getDeclaredField("sessionManager");
|
Field sessionManager = TaskanaHistoryEngineImpl.class.getDeclaredField("sessionManager");
|
||||||
|
|
||||||
sessionManager.setAccessible(true);
|
sessionManager.setAccessible(true);
|
||||||
|
SqlSessionManager manager = (SqlSessionManager) sessionManager.get(taskanaHistoryEngine);
|
||||||
manager = (SqlSessionManager) sessionManager.get(taskanaHistoryEngine);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.warn("Caught unexpected exception ", e);
|
|
||||||
}
|
|
||||||
return manager.getMapper(WorkbasketHistoryEventMapper.class);
|
return manager.getMapper(WorkbasketHistoryEventMapper.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new JUnitException(
|
||||||
|
String.format(
|
||||||
|
"Could not extract %s from %s",
|
||||||
|
WorkbasketHistoryEventMapper.class, TaskanaHistoryEngineImpl.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ClassificationHistoryEventMapper getClassificationHistoryEventMapper() {
|
protected static ClassificationHistoryEventMapper getClassificationHistoryEventMapper() {
|
||||||
|
|
||||||
SqlSessionManager manager = null;
|
|
||||||
|
|
||||||
Field sessionManager;
|
|
||||||
try {
|
try {
|
||||||
sessionManager = TaskanaHistoryEngineImpl.class.getDeclaredField("sessionManager");
|
Field sessionManager = TaskanaHistoryEngineImpl.class.getDeclaredField("sessionManager");
|
||||||
|
|
||||||
sessionManager.setAccessible(true);
|
sessionManager.setAccessible(true);
|
||||||
|
|
||||||
manager = (SqlSessionManager) sessionManager.get(taskanaHistoryEngine);
|
SqlSessionManager manager = (SqlSessionManager) sessionManager.get(taskanaHistoryEngine);
|
||||||
|
return manager.getMapper(ClassificationHistoryEventMapper.class);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.warn("Caught unexpected exception ", e);
|
throw new JUnitException(
|
||||||
|
String.format(
|
||||||
|
"Could not extract %s from %s",
|
||||||
|
ClassificationHistoryEventMapper.class, TaskanaHistoryEngineImpl.class));
|
||||||
}
|
}
|
||||||
return manager.getMapper(ClassificationHistoryEventMapper.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
static void setupTest() throws Exception {
|
static void setupTest() throws Exception {
|
||||||
resetDb(null);
|
resetDb(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* create Default DataSource for in-memory database.
|
|
||||||
*
|
|
||||||
* @return the TASKANA default datasource.
|
|
||||||
*/
|
|
||||||
private static DataSource createDefaultDataSource() {
|
|
||||||
|
|
||||||
String jdbcDriver = "org.h2.Driver";
|
|
||||||
String jdbcUrl = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0";
|
|
||||||
String dbUserName = "sa";
|
|
||||||
String dbPassword = "sa";
|
|
||||||
PooledDataSource ds =
|
|
||||||
new PooledDataSource(
|
|
||||||
Thread.currentThread().getContextClassLoader(),
|
|
||||||
jdbcDriver,
|
|
||||||
jdbcUrl,
|
|
||||||
dbUserName,
|
|
||||||
dbPassword);
|
|
||||||
ds.setPoolTimeToWait(POOL_TIME_TO_WAIT);
|
|
||||||
ds.forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
|
|
||||||
|
|
||||||
return ds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create data source from properties file.
|
|
||||||
*
|
|
||||||
* @param propertiesFileName the name of the properties file.
|
|
||||||
* @return the datasource constructed from the information in the properties file.
|
|
||||||
*/
|
|
||||||
private static DataSource createDataSourceFromProperties(String propertiesFileName) {
|
|
||||||
DataSource ds = null;
|
|
||||||
try (InputStream input = new FileInputStream(propertiesFileName)) {
|
|
||||||
Properties prop = new Properties();
|
|
||||||
prop.load(input);
|
|
||||||
boolean propertiesFileIsComplete = true;
|
|
||||||
String warningMessage = "";
|
|
||||||
String jdbcDriver = prop.getProperty("jdbcDriver");
|
|
||||||
if (jdbcDriver == null || jdbcDriver.length() == 0) {
|
|
||||||
propertiesFileIsComplete = false;
|
|
||||||
warningMessage += ", jdbcDriver property missing";
|
|
||||||
}
|
|
||||||
String jdbcUrl = prop.getProperty("jdbcUrl");
|
|
||||||
if (jdbcUrl == null || jdbcUrl.length() == 0) {
|
|
||||||
propertiesFileIsComplete = false;
|
|
||||||
warningMessage += ", jdbcUrl property missing";
|
|
||||||
}
|
|
||||||
String dbUserName = prop.getProperty("dbUserName");
|
|
||||||
if (dbUserName == null || dbUserName.length() == 0) {
|
|
||||||
propertiesFileIsComplete = false;
|
|
||||||
warningMessage += ", dbUserName property missing";
|
|
||||||
}
|
|
||||||
String dbPassword = prop.getProperty("dbPassword");
|
|
||||||
if (dbPassword == null || dbPassword.length() == 0) {
|
|
||||||
propertiesFileIsComplete = false;
|
|
||||||
warningMessage += ", dbPassword property missing";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (propertiesFileIsComplete) {
|
|
||||||
ds =
|
|
||||||
new PooledDataSource(
|
|
||||||
Thread.currentThread().getContextClassLoader(),
|
|
||||||
jdbcDriver,
|
|
||||||
jdbcUrl,
|
|
||||||
dbUserName,
|
|
||||||
dbPassword);
|
|
||||||
((PooledDataSource) ds)
|
|
||||||
.forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
|
|
||||||
} else {
|
|
||||||
LOGGER.warn("propertiesFile " + propertiesFileName + " is incomplete" + warningMessage);
|
|
||||||
LOGGER.warn("Using default Datasource for Test");
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
|
|
||||||
LOGGER.warn("Using default Datasource for Test");
|
|
||||||
}
|
|
||||||
if (Objects.isNull(ds)) {
|
|
||||||
ds = createDefaultDataSource();
|
|
||||||
}
|
|
||||||
return ds;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getSchemaNameFromPropertiesObject(String propertiesFileName) {
|
|
||||||
String schemaName = "TASKANA";
|
|
||||||
try (InputStream input = new FileInputStream(propertiesFileName)) {
|
|
||||||
Properties prop = new Properties();
|
|
||||||
prop.load(input);
|
|
||||||
boolean propertiesFileIsComplete = true;
|
|
||||||
String warningMessage = "";
|
|
||||||
schemaName = prop.getProperty("schemaName");
|
|
||||||
if (schemaName == null || schemaName.length() == 0) {
|
|
||||||
propertiesFileIsComplete = false;
|
|
||||||
warningMessage += ", schemaName property missing";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!propertiesFileIsComplete) {
|
|
||||||
LOGGER.warn("propertiesFile " + propertiesFileName + " is incomplete" + warningMessage);
|
|
||||||
LOGGER.warn("Using default Datasource for Test");
|
|
||||||
schemaName = "TASKANA";
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
LOGGER.warn("getSchemaNameFromPropertiesObject caught Exception " + e);
|
|
||||||
LOGGER.warn("Using default schemaName for Test");
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
|
|
||||||
LOGGER.warn("Using default Datasource for Test");
|
|
||||||
}
|
|
||||||
|
|
||||||
return schemaName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,15 @@ package acceptance.events.task;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import acceptance.AbstractAccTest;
|
import acceptance.AbstractAccTest;
|
||||||
|
import java.time.Instant;
|
||||||
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 pro.taskana.common.api.TimeInterval;
|
||||||
import pro.taskana.common.test.security.JaasExtension;
|
import pro.taskana.common.test.security.JaasExtension;
|
||||||
import pro.taskana.common.test.security.WithAccessId;
|
import pro.taskana.common.test.security.WithAccessId;
|
||||||
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
|
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
|
||||||
import pro.taskana.simplehistory.impl.TaskHistoryQueryImpl;
|
|
||||||
import pro.taskana.simplehistory.impl.task.TaskHistoryQueryMapper;
|
|
||||||
import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
|
import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
|
||||||
import pro.taskana.spi.history.api.events.task.TaskHistoryEventType;
|
import pro.taskana.spi.history.api.events.task.TaskHistoryEventType;
|
||||||
import pro.taskana.task.api.TaskService;
|
import pro.taskana.task.api.TaskService;
|
||||||
|
@ -26,28 +26,21 @@ class CreateHistoryEventOnTaskUpdateAccTest extends AbstractAccTest {
|
||||||
@Test
|
@Test
|
||||||
@WithAccessId(user = "admin")
|
@WithAccessId(user = "admin")
|
||||||
void should_CreateUpdatedHistoryEvent_When_TaskIsCreated() throws Exception {
|
void should_CreateUpdatedHistoryEvent_When_TaskIsCreated() throws Exception {
|
||||||
|
|
||||||
final String taskId = "TKI:000000000000000000000000000000000000";
|
final String taskId = "TKI:000000000000000000000000000000000000";
|
||||||
TaskHistoryQueryMapper taskHistoryQueryMapper = getHistoryQueryMapper();
|
Instant before = Instant.now();
|
||||||
|
|
||||||
List<TaskHistoryEvent> events =
|
|
||||||
taskHistoryQueryMapper.queryHistoryEvents(
|
|
||||||
(TaskHistoryQueryImpl) historyService.createTaskHistoryQuery().taskIdIn(taskId));
|
|
||||||
|
|
||||||
assertThat(events).hasSize(3);
|
|
||||||
|
|
||||||
Task task = taskService.getTask(taskId);
|
Task task = taskService.getTask(taskId);
|
||||||
task.setName("someUpdatedName");
|
task.setName("someUpdatedName");
|
||||||
taskService.updateTask(task);
|
taskService.updateTask(task);
|
||||||
|
List<TaskHistoryEvent> events =
|
||||||
|
historyService
|
||||||
|
.createTaskHistoryQuery()
|
||||||
|
.taskIdIn(taskId)
|
||||||
|
.createdWithin(new TimeInterval(before, null))
|
||||||
|
.list();
|
||||||
|
|
||||||
events =
|
assertThat(events)
|
||||||
taskHistoryQueryMapper.queryHistoryEvents(
|
.extracting(TaskHistoryEvent::getEventType)
|
||||||
(TaskHistoryQueryImpl) historyService.createTaskHistoryQuery().taskIdIn(taskId));
|
.containsExactly(TaskHistoryEventType.UPDATED.getName());
|
||||||
|
|
||||||
assertThat(events).hasSize(4);
|
|
||||||
|
|
||||||
String eventType = events.get(0).getEventType();
|
|
||||||
|
|
||||||
assertThat(eventType).isEqualTo(TaskHistoryEventType.UPDATED.getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.junit.jupiter.api.function.ThrowingConsumer;
|
||||||
import pro.taskana.classification.internal.jobs.ClassificationChangedJob;
|
import pro.taskana.classification.internal.jobs.ClassificationChangedJob;
|
||||||
import pro.taskana.common.api.ScheduledJob;
|
import pro.taskana.common.api.ScheduledJob;
|
||||||
import pro.taskana.common.internal.util.Pair;
|
import pro.taskana.common.internal.util.Pair;
|
||||||
|
import pro.taskana.common.test.config.DataSourceGenerator;
|
||||||
import pro.taskana.common.test.security.JaasExtension;
|
import pro.taskana.common.test.security.JaasExtension;
|
||||||
import pro.taskana.common.test.security.WithAccessId;
|
import pro.taskana.common.test.security.WithAccessId;
|
||||||
import pro.taskana.simplehistory.impl.jobs.HistoryCleanupJob;
|
import pro.taskana.simplehistory.impl.jobs.HistoryCleanupJob;
|
||||||
|
@ -32,7 +33,7 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void before() throws Exception {
|
void before() throws Exception {
|
||||||
resetDb(getSchemaName());
|
resetDb(DataSourceGenerator.getSchemaName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -81,12 +81,12 @@ class QueryClassificationHistoryAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
assertThat(offsetAndLimitResult).hasSize(2);
|
assertThat(offsetAndLimitResult).hasSize(2);
|
||||||
assertThat(offsetAndLimitResult.get(0).getUserId())
|
assertThat(offsetAndLimitResult.get(0).getUserId())
|
||||||
.isNotEqualTo(regularResult.get(0).getUserId());
|
.isNotEqualTo(regularResult.get(0).getUserId())
|
||||||
assertThat(offsetAndLimitResult.get(0).getUserId()).isEqualTo(regularResult.get(1).getUserId());
|
.isEqualTo(regularResult.get(1).getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_ReturnEmptyList_When_ProvidingWrongContraints() {
|
void should_ReturnEmptyList_When_ProvidingWrongConstraints() {
|
||||||
List<ClassificationHistoryEvent> result =
|
List<ClassificationHistoryEvent> result =
|
||||||
historyService.createClassificationHistoryQuery().list(1, 1000);
|
historyService.createClassificationHistoryQuery().list(1, 1000);
|
||||||
assertThat(result).hasSize(10);
|
assertThat(result).hasSize(10);
|
||||||
|
@ -120,7 +120,7 @@ class QueryClassificationHistoryAccTest extends AbstractAccTest {
|
||||||
ClassificationHistoryQuery query =
|
ClassificationHistoryQuery query =
|
||||||
getHistoryService().createClassificationHistoryQuery().userIdIn("peter");
|
getHistoryService().createClassificationHistoryQuery().userIdIn("peter");
|
||||||
|
|
||||||
assertThatThrownBy(() -> query.single()).isInstanceOf(TooManyResultsException.class);
|
assertThatThrownBy(query::single).isInstanceOf(TooManyResultsException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -77,8 +77,8 @@ class QueryTaskHistoryAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
assertThat(offsetAndLimitResult).hasSize(2);
|
assertThat(offsetAndLimitResult).hasSize(2);
|
||||||
assertThat(offsetAndLimitResult.get(0).getUserId())
|
assertThat(offsetAndLimitResult.get(0).getUserId())
|
||||||
.isNotEqualTo(regularResult.get(0).getUserId());
|
.isNotEqualTo(regularResult.get(0).getUserId())
|
||||||
assertThat(offsetAndLimitResult.get(0).getUserId()).isEqualTo(regularResult.get(1).getUserId());
|
.isEqualTo(regularResult.get(1).getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -276,10 +276,7 @@ class QueryTaskHistoryAccTest extends AbstractAccTest {
|
||||||
assertThat(returnValues).hasSize(14);
|
assertThat(returnValues).hasSize(14);
|
||||||
|
|
||||||
returnValues =
|
returnValues =
|
||||||
getHistoryService()
|
getHistoryService().createTaskHistoryQuery().parentBusinessProcessIdLike("BPI:01%").list();
|
||||||
.createTaskHistoryQuery()
|
|
||||||
.parentBusinessProcessIdLike("BPI:01", " %")
|
|
||||||
.list();
|
|
||||||
assertThat(returnValues).hasSize(7);
|
assertThat(returnValues).hasSize(7);
|
||||||
|
|
||||||
returnValues =
|
returnValues =
|
||||||
|
|
|
@ -20,15 +20,10 @@ import pro.taskana.spi.history.api.events.workbasket.WorkbasketHistoryEvent;
|
||||||
import pro.taskana.spi.history.api.events.workbasket.WorkbasketHistoryEventType;
|
import pro.taskana.spi.history.api.events.workbasket.WorkbasketHistoryEventType;
|
||||||
import pro.taskana.workbasket.api.WorkbasketCustomField;
|
import pro.taskana.workbasket.api.WorkbasketCustomField;
|
||||||
|
|
||||||
/** Test for Workbasket History queries. */
|
|
||||||
class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
private final SimpleHistoryServiceImpl historyService = getHistoryService();
|
private final SimpleHistoryServiceImpl historyService = getHistoryService();
|
||||||
|
|
||||||
public QueryWorkbasketHistoryAccTest() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_ConfirmEquality_When_UsingListValuesAscendingAndDescending() {
|
void should_ConfirmEquality_When_UsingListValuesAscendingAndDescending() {
|
||||||
List<String> defaultList =
|
List<String> defaultList =
|
||||||
|
@ -53,7 +48,6 @@ class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_ReturnHistoryEvents_For_ComplexQuery() {
|
void should_ReturnHistoryEvents_For_ComplexQuery() {
|
||||||
|
|
||||||
WorkbasketHistoryQuery query =
|
WorkbasketHistoryQuery query =
|
||||||
historyService
|
historyService
|
||||||
.createWorkbasketHistoryQuery()
|
.createWorkbasketHistoryQuery()
|
||||||
|
@ -82,12 +76,12 @@ class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
assertThat(offsetAndLimitResult).hasSize(2);
|
assertThat(offsetAndLimitResult).hasSize(2);
|
||||||
assertThat(offsetAndLimitResult.get(0).getUserId())
|
assertThat(offsetAndLimitResult.get(0).getUserId())
|
||||||
.isNotEqualTo(regularResult.get(0).getUserId());
|
.isNotEqualTo(regularResult.get(0).getUserId())
|
||||||
assertThat(offsetAndLimitResult.get(0).getUserId()).isEqualTo(regularResult.get(1).getUserId());
|
.isEqualTo(regularResult.get(1).getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_ReturnEmptyList_When_ProvidingWrongContraints() {
|
void should_ReturnEmptyList_When_ProvidingWrongConstraints() {
|
||||||
List<WorkbasketHistoryEvent> result =
|
List<WorkbasketHistoryEvent> result =
|
||||||
historyService.createWorkbasketHistoryQuery().list(1, 1000);
|
historyService.createWorkbasketHistoryQuery().list(1, 1000);
|
||||||
assertThat(result).hasSize(9);
|
assertThat(result).hasSize(9);
|
||||||
|
@ -117,11 +111,10 @@ class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_ThrowException_When_SingleMethodRetrievesMoreThanOneEventFromDatabase() {
|
void should_ThrowException_When_SingleMethodRetrievesMoreThanOneEventFromDatabase() {
|
||||||
|
|
||||||
WorkbasketHistoryQuery query =
|
WorkbasketHistoryQuery query =
|
||||||
getHistoryService().createWorkbasketHistoryQuery().userIdIn("peter");
|
getHistoryService().createWorkbasketHistoryQuery().userIdIn("peter");
|
||||||
|
|
||||||
assertThatThrownBy(() -> query.single()).isInstanceOf(TooManyResultsException.class);
|
assertThatThrownBy(query::single).isInstanceOf(TooManyResultsException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -277,6 +270,10 @@ class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
historyService
|
historyService
|
||||||
.createWorkbasketHistoryQuery()
|
.createWorkbasketHistoryQuery()
|
||||||
.orderByCustomAttribute(1, SortDirection.ASCENDING)
|
.orderByCustomAttribute(1, SortDirection.ASCENDING)
|
||||||
|
// values of custom1 do not differ and are larger than 3 (n=5).
|
||||||
|
// Therefore, in order to guarantee the sort order,
|
||||||
|
// we have to define a secondary (unique) sort option
|
||||||
|
.orderById(SortDirection.ASCENDING)
|
||||||
.listPage(0, 3);
|
.listPage(0, 3);
|
||||||
assertThat(results)
|
assertThat(results)
|
||||||
.extracting(WorkbasketHistoryEvent::getId)
|
.extracting(WorkbasketHistoryEvent::getId)
|
||||||
|
@ -289,6 +286,10 @@ class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
historyService
|
historyService
|
||||||
.createWorkbasketHistoryQuery()
|
.createWorkbasketHistoryQuery()
|
||||||
.orderByCustomAttribute(2, SortDirection.ASCENDING)
|
.orderByCustomAttribute(2, SortDirection.ASCENDING)
|
||||||
|
// values of custom1 do not differ and are larger than 3 (n=5).
|
||||||
|
// Therefore, in order to guarantee the sort order,
|
||||||
|
// we have to define a secondary (unique) sort option
|
||||||
|
.orderById(SortDirection.ASCENDING)
|
||||||
.listPage(0, 3);
|
.listPage(0, 3);
|
||||||
assertThat(results)
|
assertThat(results)
|
||||||
.extracting(WorkbasketHistoryEvent::getId)
|
.extracting(WorkbasketHistoryEvent::getId)
|
||||||
|
@ -301,6 +302,10 @@ class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
historyService
|
historyService
|
||||||
.createWorkbasketHistoryQuery()
|
.createWorkbasketHistoryQuery()
|
||||||
.orderByCustomAttribute(3, SortDirection.ASCENDING)
|
.orderByCustomAttribute(3, SortDirection.ASCENDING)
|
||||||
|
// values of custom1 do not differ and are larger than 3 (n=5).
|
||||||
|
// Therefore, in order to guarantee the sort order,
|
||||||
|
// we have to define a secondary (unique) sort option
|
||||||
|
.orderById(SortDirection.ASCENDING)
|
||||||
.listPage(0, 3);
|
.listPage(0, 3);
|
||||||
assertThat(results)
|
assertThat(results)
|
||||||
.extracting(WorkbasketHistoryEvent::getId)
|
.extracting(WorkbasketHistoryEvent::getId)
|
||||||
|
@ -313,6 +318,10 @@ class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
historyService
|
historyService
|
||||||
.createWorkbasketHistoryQuery()
|
.createWorkbasketHistoryQuery()
|
||||||
.orderByCustomAttribute(4, SortDirection.ASCENDING)
|
.orderByCustomAttribute(4, SortDirection.ASCENDING)
|
||||||
|
// values of custom1 do not differ and are larger than 3 (n=5).
|
||||||
|
// Therefore, in order to guarantee the sort order,
|
||||||
|
// we have to define a secondary (unique) sort option
|
||||||
|
.orderById(SortDirection.ASCENDING)
|
||||||
.listPage(0, 3);
|
.listPage(0, 3);
|
||||||
assertThat(results)
|
assertThat(results)
|
||||||
.extracting(WorkbasketHistoryEvent::getId)
|
.extracting(WorkbasketHistoryEvent::getId)
|
||||||
|
@ -324,7 +333,6 @@ class QueryWorkbasketHistoryAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_ReturnHistoryEvents_For_DifferentLikeAttributes() {
|
void should_ReturnHistoryEvents_For_DifferentLikeAttributes() {
|
||||||
|
|
||||||
List<WorkbasketHistoryEvent> returnValues =
|
List<WorkbasketHistoryEvent> returnValues =
|
||||||
historyService
|
historyService
|
||||||
.createWorkbasketHistoryQuery()
|
.createWorkbasketHistoryQuery()
|
||||||
|
|
|
@ -8,15 +8,16 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import pro.taskana.TaskanaEngineConfiguration;
|
import pro.taskana.TaskanaEngineConfiguration;
|
||||||
import pro.taskana.common.api.TaskanaEngine;
|
import pro.taskana.common.api.TaskanaEngine;
|
||||||
|
import pro.taskana.common.test.config.DataSourceGenerator;
|
||||||
|
|
||||||
/** Unit Test for TaskanaEngineConfigurationTest. */
|
/** Unit Test for TaskanaEngineConfigurationTest. */
|
||||||
class TaskanaEngineConfigurationTest extends AbstractAccTest {
|
class TaskanaEngineConfigurationTest extends AbstractAccTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCreateTaskanaEngine() throws Exception {
|
void testCreateTaskanaEngine() throws Exception {
|
||||||
DataSource ds = getDataSource();
|
DataSource ds = DataSourceGenerator.getDataSource();
|
||||||
TaskanaEngineConfiguration taskEngineConfiguration =
|
TaskanaEngineConfiguration taskEngineConfiguration =
|
||||||
new TaskanaEngineConfiguration(ds, false, false, getSchemaName());
|
new TaskanaEngineConfiguration(ds, false, false, DataSourceGenerator.getSchemaName());
|
||||||
|
|
||||||
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
|
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue