TSK-1987 immutable TaskanaEngineConfiguration
This commit is contained in:
parent
53f9dce1db
commit
61a5e32865
|
@ -14,7 +14,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
@ -54,7 +53,8 @@ public class TaskanaConfigurationInitializer {
|
|||
throw new IllegalStateException("utility class");
|
||||
}
|
||||
|
||||
public static void configureAnnotatedFields(Object instance, String separator, Properties props) {
|
||||
public static void configureAnnotatedFields(
|
||||
Object instance, String separator, Map<String, String> props) {
|
||||
final List<Field> fields = ReflectionUtil.retrieveAllFields(instance.getClass());
|
||||
for (Field field : fields) {
|
||||
Optional.ofNullable(field.getAnnotation(TaskanaProperty.class))
|
||||
|
@ -73,7 +73,7 @@ public class TaskanaConfigurationInitializer {
|
|||
}
|
||||
|
||||
public static Map<String, List<String>> configureClassificationCategoriesForType(
|
||||
Properties props, List<String> classificationTypes) {
|
||||
Map<String, String> props, List<String> classificationTypes) {
|
||||
Function<String, List<String>> getClassificationCategoriesForType =
|
||||
type ->
|
||||
parseProperty(
|
||||
|
@ -87,12 +87,12 @@ public class TaskanaConfigurationInitializer {
|
|||
}
|
||||
|
||||
public static Map<TaskanaRole, Set<String>> configureRoles(
|
||||
String separator, Properties props, boolean shouldUseLowerCaseForAccessIds) {
|
||||
String separator, Map<String, String> props, boolean shouldUseLowerCaseForAccessIds) {
|
||||
Function<TaskanaRole, Set<String>> getAccessIdsForRole =
|
||||
role ->
|
||||
new HashSet<>(
|
||||
splitStringAndTrimElements(
|
||||
props.getProperty(role.getPropertyName().toLowerCase(), ""),
|
||||
props.getOrDefault(role.getPropertyName().toLowerCase(), ""),
|
||||
separator,
|
||||
shouldUseLowerCaseForAccessIds
|
||||
? String::toLowerCase
|
||||
|
@ -137,8 +137,8 @@ public class TaskanaConfigurationInitializer {
|
|||
}
|
||||
|
||||
private static <T> Optional<T> parseProperty(
|
||||
Properties props, String key, CheckedFunction<String, T, Exception> function) {
|
||||
String property = props.getProperty(key, "");
|
||||
Map<String, String> props, String key, CheckedFunction<String, T, Exception> function) {
|
||||
String property = props.getOrDefault(key, "");
|
||||
if (!property.isEmpty()) {
|
||||
try {
|
||||
return Optional.ofNullable(function.apply(property));
|
||||
|
@ -155,13 +155,19 @@ public class TaskanaConfigurationInitializer {
|
|||
|
||||
interface PropertyParser<T> {
|
||||
Optional<T> initialize(
|
||||
Properties properties, String separator, Field field, TaskanaProperty taskanaProperty);
|
||||
Map<String, String> properties,
|
||||
String separator,
|
||||
Field field,
|
||||
TaskanaProperty taskanaProperty);
|
||||
}
|
||||
|
||||
static class ListPropertyParser implements PropertyParser<List<?>> {
|
||||
@Override
|
||||
public Optional<List<?>> initialize(
|
||||
Properties properties, String separator, Field field, TaskanaProperty taskanaProperty) {
|
||||
Map<String, String> properties,
|
||||
String separator,
|
||||
Field field,
|
||||
TaskanaProperty taskanaProperty) {
|
||||
if (!List.class.isAssignableFrom(field.getType())) {
|
||||
throw new SystemException(
|
||||
String.format(
|
||||
|
@ -215,7 +221,10 @@ public class TaskanaConfigurationInitializer {
|
|||
static class InstantPropertyParser implements PropertyParser<Instant> {
|
||||
@Override
|
||||
public Optional<Instant> initialize(
|
||||
Properties properties, String separator, Field field, TaskanaProperty taskanaProperty) {
|
||||
Map<String, String> properties,
|
||||
String separator,
|
||||
Field field,
|
||||
TaskanaProperty taskanaProperty) {
|
||||
return parseProperty(properties, taskanaProperty.value(), Instant::parse);
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +232,10 @@ public class TaskanaConfigurationInitializer {
|
|||
static class DurationPropertyParser implements PropertyParser<Duration> {
|
||||
@Override
|
||||
public Optional<Duration> initialize(
|
||||
Properties properties, String separator, Field field, TaskanaProperty taskanaProperty) {
|
||||
Map<String, String> properties,
|
||||
String separator,
|
||||
Field field,
|
||||
TaskanaProperty taskanaProperty) {
|
||||
return parseProperty(properties, taskanaProperty.value(), Duration::parse);
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +243,10 @@ public class TaskanaConfigurationInitializer {
|
|||
static class StringPropertyParser implements PropertyParser<String> {
|
||||
@Override
|
||||
public Optional<String> initialize(
|
||||
Properties properties, String separator, Field field, TaskanaProperty taskanaProperty) {
|
||||
Map<String, String> properties,
|
||||
String separator,
|
||||
Field field,
|
||||
TaskanaProperty taskanaProperty) {
|
||||
return parseProperty(properties, taskanaProperty.value(), String::new);
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +254,10 @@ public class TaskanaConfigurationInitializer {
|
|||
static class IntegerPropertyParser implements PropertyParser<Integer> {
|
||||
@Override
|
||||
public Optional<Integer> initialize(
|
||||
Properties properties, String separator, Field field, TaskanaProperty taskanaProperty) {
|
||||
Map<String, String> properties,
|
||||
String separator,
|
||||
Field field,
|
||||
TaskanaProperty taskanaProperty) {
|
||||
return parseProperty(properties, taskanaProperty.value(), Integer::parseInt);
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +265,10 @@ public class TaskanaConfigurationInitializer {
|
|||
static class BooleanPropertyParser implements PropertyParser<Boolean> {
|
||||
@Override
|
||||
public Optional<Boolean> initialize(
|
||||
Properties properties, String separator, Field field, TaskanaProperty taskanaProperty) {
|
||||
Map<String, String> properties,
|
||||
String separator,
|
||||
Field field,
|
||||
TaskanaProperty taskanaProperty) {
|
||||
return parseProperty(properties, taskanaProperty.value(), Boolean::parseBoolean);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,7 @@ public class LogfileHistoryServiceImpl implements TaskanaHistory {
|
|||
objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());
|
||||
|
||||
String historyLoggerName =
|
||||
taskanaEngine
|
||||
.getConfiguration()
|
||||
.readPropertiesFromFile()
|
||||
.getProperty(TASKANA_HISTORY_LOGGER_NAME);
|
||||
taskanaEngine.getConfiguration().getProperties().get(TASKANA_HISTORY_LOGGER_NAME);
|
||||
|
||||
if (historyLoggerName != null) {
|
||||
historyLogger = LoggerFactory.getLogger(historyLoggerName);
|
||||
|
|
|
@ -5,7 +5,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import java.time.Instant;
|
||||
import java.util.Properties;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -13,7 +14,7 @@ import org.mockito.Mockito;
|
|||
import uk.org.lidalia.slf4jtest.TestLogger;
|
||||
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.spi.history.api.events.classification.ClassificationHistoryEvent;
|
||||
import pro.taskana.spi.history.api.events.classification.ClassificationHistoryEventType;
|
||||
|
@ -37,13 +38,12 @@ class LogfileHistoryServiceImplTest {
|
|||
|
||||
@BeforeAll
|
||||
public static void setupObjectMapper() {
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration =
|
||||
Mockito.mock(TaskanaEngineConfiguration.class);
|
||||
TaskanaConfiguration taskanaEngineConfiguration = Mockito.mock(TaskanaConfiguration.class);
|
||||
taskanaEngineMock = Mockito.mock(TaskanaEngine.class);
|
||||
Mockito.when(taskanaEngineMock.getConfiguration()).thenReturn(taskanaEngineConfiguration);
|
||||
Properties mockProperties = new Properties();
|
||||
Map<String, String> mockProperties = new HashMap<>();
|
||||
mockProperties.put(LogfileHistoryServiceImpl.TASKANA_HISTORY_LOGGER_NAME, "AUDIT");
|
||||
Mockito.when(taskanaEngineConfiguration.readPropertiesFromFile()).thenReturn(mockProperties);
|
||||
Mockito.when(taskanaEngineConfiguration.getProperties()).thenReturn(mockProperties);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -131,7 +131,7 @@ public class SimpleHistoryServiceImpl implements TaskanaHistory {
|
|||
throw new TaskanaHistoryEventNotFoundException(historyEventId);
|
||||
}
|
||||
|
||||
if (taskanaHistoryEngine.getConfiguration().getAddAdditionalUserInfo()) {
|
||||
if (taskanaHistoryEngine.getConfiguration().isAddAdditionalUserInfo()) {
|
||||
User user = userMapper.findById(resultEvent.getUserId());
|
||||
if (user != null) {
|
||||
resultEvent.setUserLongName(user.getLongName());
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TaskHistoryQueryImpl implements TaskHistoryQuery {
|
|||
this.taskanaHistoryEngine = taskanaHistoryEngine;
|
||||
this.orderBy = new ArrayList<>();
|
||||
this.orderColumns = new ArrayList<>();
|
||||
this.joinWithUserInfo = taskanaHistoryEngine.getConfiguration().getAddAdditionalUserInfo();
|
||||
this.joinWithUserInfo = taskanaHistoryEngine.getConfiguration().isAddAdditionalUserInfo();
|
||||
}
|
||||
|
||||
public String[] getIdIn() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.ibatis.type.JdbcType;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.exceptions.MismatchedRoleException;
|
||||
|
@ -49,7 +49,7 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaHistoryEngineImpl.class);
|
||||
private static final String DEFAULT = "default";
|
||||
private final SqlSessionManager sessionManager;
|
||||
private final TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
private final TaskanaConfiguration taskanaEngineConfiguration;
|
||||
private final TaskanaEngine taskanaEngine;
|
||||
private TransactionFactory transactionFactory;
|
||||
private TaskanaHistory taskanaHistoryService;
|
||||
|
@ -58,7 +58,7 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
|
|||
this.taskanaEngineConfiguration = taskanaEngine.getConfiguration();
|
||||
this.taskanaEngine = taskanaEngine;
|
||||
|
||||
createTransactionFactory(taskanaEngineConfiguration.getUseManagedTransactions());
|
||||
createTransactionFactory(taskanaEngineConfiguration.isUseManagedTransactions());
|
||||
sessionManager = createSqlSessionManager();
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
|
|||
}
|
||||
}
|
||||
|
||||
public TaskanaEngineConfiguration getConfiguration() {
|
||||
public TaskanaConfiguration getConfiguration() {
|
||||
return this.taskanaEngineConfiguration;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.time.Instant;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -56,8 +55,7 @@ public class HistoryCleanupJob extends AbstractTaskanaJob {
|
|||
super(taskanaEngine, txProvider, scheduledJob, true);
|
||||
allCompletedSameParentBusiness =
|
||||
taskanaEngine.getConfiguration().isTaskCleanupJobAllCompletedSameParentBusiness();
|
||||
Properties props = taskanaEngine.getConfiguration().readPropertiesFromFile();
|
||||
initJobParameters(props);
|
||||
initJobParameters(taskanaEngine.getConfiguration().getProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -218,9 +216,9 @@ public class HistoryCleanupJob extends AbstractTaskanaJob {
|
|||
return deletedTasksCount;
|
||||
}
|
||||
|
||||
private void initJobParameters(Properties props) {
|
||||
private void initJobParameters(Map<String, String> props) {
|
||||
|
||||
String jobBatchSizeProperty = props.getProperty(TASKANA_JOB_HISTORY_BATCH_SIZE);
|
||||
String jobBatchSizeProperty = props.get(TASKANA_JOB_HISTORY_BATCH_SIZE);
|
||||
if (jobBatchSizeProperty != null && !jobBatchSizeProperty.isEmpty()) {
|
||||
try {
|
||||
batchSize = Integer.parseInt(jobBatchSizeProperty);
|
||||
|
@ -233,7 +231,7 @@ public class HistoryCleanupJob extends AbstractTaskanaJob {
|
|||
}
|
||||
|
||||
String historyEventCleanupJobMinimumAgeProperty =
|
||||
props.getProperty(TASKANA_JOB_HISTORY_CLEANUP_MINIMUM_AGE);
|
||||
props.get(TASKANA_JOB_HISTORY_CLEANUP_MINIMUM_AGE);
|
||||
if (historyEventCleanupJobMinimumAgeProperty != null
|
||||
&& !historyEventCleanupJobMinimumAgeProperty.isEmpty()) {
|
||||
try {
|
||||
|
|
|
@ -4,12 +4,13 @@ import static pro.taskana.common.test.OracleSchemaHelper.initOracleSchema;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import javax.sql.DataSource;
|
||||
import org.apache.ibatis.session.SqlSessionManager;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.platform.commons.JUnitException;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.common.internal.JobMapper;
|
||||
|
@ -25,16 +26,19 @@ import pro.taskana.simplehistory.impl.task.TaskHistoryQueryMapper;
|
|||
import pro.taskana.simplehistory.impl.workbasket.WorkbasketHistoryEventMapper;
|
||||
import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
|
||||
import pro.taskana.spi.history.api.events.workbasket.WorkbasketHistoryEvent;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
import pro.taskana.task.internal.models.ObjectReferenceImpl;
|
||||
|
||||
/** Set up database for tests. */
|
||||
public abstract class AbstractAccTest {
|
||||
|
||||
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaHistoryEngineImpl taskanaHistoryEngine;
|
||||
protected static TaskanaEngine taskanaEngine;
|
||||
private static SimpleHistoryServiceImpl historyService;
|
||||
protected static SimpleHistoryServiceImpl historyService;
|
||||
|
||||
protected static TaskService taskService;
|
||||
|
||||
/**
|
||||
* create taskHistoryEvent object.
|
||||
|
@ -97,19 +101,25 @@ public abstract class AbstractAccTest {
|
|||
initOracleSchema(dataSource, schemaNameTmp);
|
||||
}
|
||||
}
|
||||
TaskanaConfiguration tec =
|
||||
new TaskanaConfiguration.Builder(dataSource, false, schemaNameTmp).build();
|
||||
initTaskanaEngine(tec);
|
||||
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaNameTmp);
|
||||
SampleDataGenerator sampleDataGenerator =
|
||||
new SampleDataGenerator(dataSource, tec.getSchemaName());
|
||||
sampleDataGenerator.clearDb();
|
||||
sampleDataGenerator.generateTestData();
|
||||
}
|
||||
|
||||
protected static void initTaskanaEngine(TaskanaConfiguration tec) throws SQLException {
|
||||
taskanaEngineConfiguration = tec;
|
||||
taskanaEngine =
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||
taskanaHistoryEngine = TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngine);
|
||||
taskService = taskanaEngine.getTaskService();
|
||||
historyService = new SimpleHistoryServiceImpl();
|
||||
historyService.initialize(taskanaEngine);
|
||||
|
||||
SampleDataGenerator sampleDataGenerator =
|
||||
new SampleDataGenerator(dataSource, taskanaEngineConfiguration.getSchemaName());
|
||||
sampleDataGenerator.clearDb();
|
||||
sampleDataGenerator.generateTestData();
|
||||
}
|
||||
|
||||
protected static SimpleHistoryServiceImpl getHistoryService() {
|
||||
|
|
|
@ -4,32 +4,29 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
import pro.taskana.common.test.security.WithAccessId;
|
||||
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.task.api.TaskService;
|
||||
import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
||||
|
||||
@ExtendWith(JaasExtension.class)
|
||||
class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
|
||||
|
||||
private final TaskService taskService = taskanaEngine.getTaskService();
|
||||
private final SimpleHistoryServiceImpl historyService = getHistoryService();
|
||||
|
||||
@Test
|
||||
@WithAccessId(user = "admin")
|
||||
void should_DeleteHistoryEvents_When_TaskIsDeletedWithHistoryDeletionEnabled() throws Exception {
|
||||
|
||||
final String taskid = "TKI:000000000000000000000000000000000036";
|
||||
taskanaEngineConfiguration.setDeleteHistoryOnTaskDeletionEnabled(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
|
||||
TaskHistoryQueryMapper taskHistoryQueryMapper = getHistoryQueryMapper();
|
||||
|
||||
|
@ -62,7 +59,7 @@ class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
|
|||
final String taskId_1 = "TKI:000000000000000000000000000000000037";
|
||||
final String taskId_2 = "TKI:000000000000000000000000000000000038";
|
||||
|
||||
taskanaEngineConfiguration.setDeleteHistoryOnTaskDeletionEnabled(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
|
||||
TaskHistoryQueryMapper taskHistoryQueryMapper = getHistoryQueryMapper();
|
||||
|
||||
|
@ -101,7 +98,7 @@ class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
|
|||
|
||||
final String taskId = "TKI:000000000000000000000000000000000039";
|
||||
|
||||
taskanaEngineConfiguration.setDeleteHistoryOnTaskDeletionEnabled(false);
|
||||
createTaskanaEngineWithNewConfig(false);
|
||||
|
||||
TaskHistoryQueryMapper taskHistoryQueryMapper = getHistoryQueryMapper();
|
||||
|
||||
|
@ -133,7 +130,7 @@ class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
|
|||
final String taskId_1 = "TKI:000000000000000000000000000000000040";
|
||||
final String taskId_2 = "TKI:000000000000000000000000000000000068";
|
||||
|
||||
taskanaEngineConfiguration.setDeleteHistoryOnTaskDeletionEnabled(false);
|
||||
createTaskanaEngineWithNewConfig(false);
|
||||
|
||||
TaskHistoryQueryMapper taskHistoryQueryMapper = getHistoryQueryMapper();
|
||||
|
||||
|
@ -158,4 +155,14 @@ class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
|
|||
historyService.createTaskHistoryQuery().taskIdIn(taskId_1, taskId_2));
|
||||
assertThat(listEvents).hasSize(2);
|
||||
}
|
||||
|
||||
private void createTaskanaEngineWithNewConfig(boolean deleteHistoryOnTaskDeletionEnabled)
|
||||
throws SQLException {
|
||||
|
||||
TaskanaConfiguration tec =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.deleteHistoryOnTaskDeletionEnabled(deleteHistoryOnTaskDeletionEnabled)
|
||||
.build();
|
||||
initTaskanaEngine(tec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@ package acceptance.events.task;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import java.sql.SQLException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
|
||||
import pro.taskana.spi.history.api.events.task.TaskHistoryEventType;
|
||||
|
||||
|
@ -33,7 +35,7 @@ class GetTaskHistoryEventAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
void should_SetTaskOwnerLongNameOfTask_When_PropertyEnabled() throws Exception {
|
||||
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
|
||||
TaskHistoryEvent taskHistoryEvent =
|
||||
getHistoryService().getTaskHistoryEvent("THI:000000000000000000000000000000000000");
|
||||
|
@ -49,7 +51,7 @@ class GetTaskHistoryEventAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
void should_NotSetTaskOwnerLongNameOfTask_When_PropertyDisabled() throws Exception {
|
||||
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
createTaskanaEngineWithNewConfig(false);
|
||||
|
||||
TaskHistoryEvent taskHistoryEvent =
|
||||
getHistoryService().getTaskHistoryEvent("THI:000000000000000000000000000000000000");
|
||||
|
@ -58,4 +60,13 @@ class GetTaskHistoryEventAccTest extends AbstractAccTest {
|
|||
|
||||
assertThat(taskHistoryEvent).extracting(TaskHistoryEvent::getUserLongName).isNull();
|
||||
}
|
||||
|
||||
private void createTaskanaEngineWithNewConfig(boolean addAdditionalUserInfo) throws SQLException {
|
||||
|
||||
TaskanaConfiguration tec =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(addAdditionalUserInfo)
|
||||
.build();
|
||||
initTaskanaEngine(tec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package acceptance.jobs;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Arrays;
|
||||
|
@ -17,6 +18,7 @@ import org.junit.jupiter.api.TestFactory;
|
|||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.function.ThrowingConsumer;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.internal.jobs.ClassificationChangedJob;
|
||||
import pro.taskana.common.api.ScheduledJob;
|
||||
import pro.taskana.common.internal.util.Pair;
|
||||
|
@ -118,7 +120,7 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
|||
|
||||
assertThat(getHistoryService().createTaskHistoryQuery().count()).isEqualTo(20);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
|
||||
HistoryCleanupJob job = new HistoryCleanupJob(taskanaEngine, null, null);
|
||||
job.run();
|
||||
|
@ -211,7 +213,7 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
|||
|
||||
assertThat(getHistoryService().createTaskHistoryQuery().count()).isEqualTo(17);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
|
||||
HistoryCleanupJob job = new HistoryCleanupJob(taskanaEngine, null, null);
|
||||
job.run();
|
||||
|
@ -277,7 +279,7 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
|||
|
||||
assertThat(getHistoryService().createTaskHistoryQuery().count()).isEqualTo(18);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
|
||||
HistoryCleanupJob job = new HistoryCleanupJob(taskanaEngine, null, null);
|
||||
job.run();
|
||||
|
@ -366,7 +368,7 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
|||
|
||||
assertThat(getHistoryService().createTaskHistoryQuery().count()).isEqualTo(20);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(false);
|
||||
createTaskanaEngineWithNewConfig(false);
|
||||
|
||||
HistoryCleanupJob job = new HistoryCleanupJob(taskanaEngine, null, null);
|
||||
job.run();
|
||||
|
@ -419,7 +421,7 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
|||
|
||||
assertThat(getHistoryService().createTaskHistoryQuery().count()).isEqualTo(17);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
|
||||
HistoryCleanupJob job = new HistoryCleanupJob(taskanaEngine, null, null);
|
||||
job.run();
|
||||
|
@ -461,16 +463,16 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "admin")
|
||||
@TestFactory
|
||||
Stream<DynamicTest>
|
||||
should_CleanTaskHistoryEventsWithParentProcessIdEmptyOrNull_When_TaskCompleted() {
|
||||
should_CleanTaskHistoryEventsWithParentProcessIdEmptyOrNull_When_TaskCompleted()
|
||||
throws SQLException {
|
||||
Iterator<String> iterator = Arrays.asList("", null).iterator();
|
||||
String taskId1 = "taskId1";
|
||||
String taskId2 = "taskId2";
|
||||
List<TaskHistoryEvent> events =
|
||||
List.of(
|
||||
Stream.of(
|
||||
Pair.of(taskId1, TaskHistoryEventType.CREATED),
|
||||
Pair.of(taskId1, TaskHistoryEventType.COMPLETED),
|
||||
Pair.of(taskId2, TaskHistoryEventType.CREATED))
|
||||
.stream()
|
||||
.map(
|
||||
pair ->
|
||||
createTaskHistoryEvent(
|
||||
|
@ -482,7 +484,7 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
|||
"someDetails"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
HistoryCleanupJob job = new HistoryCleanupJob(taskanaEngine, null, null);
|
||||
|
||||
ThrowingConsumer<String> test =
|
||||
|
@ -503,4 +505,15 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
|
|||
|
||||
return DynamicTest.stream(iterator, c -> "for parentBusinessProcessId = '" + c + "'", test);
|
||||
}
|
||||
|
||||
private void createTaskanaEngineWithNewConfig(
|
||||
boolean taskCleanupJobAllCompletedSameParentBusiness) throws SQLException {
|
||||
|
||||
TaskanaConfiguration tec =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.taskCleanupJobAllCompletedSameParentBusiness(
|
||||
taskCleanupJobAllCompletedSameParentBusiness)
|
||||
.build();
|
||||
initTaskanaEngine(tec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -12,6 +13,7 @@ import org.apache.ibatis.exceptions.TooManyResultsException;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.BaseQuery.SortDirection;
|
||||
import pro.taskana.common.api.TimeInterval;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
|
@ -446,7 +448,7 @@ class QueryTaskHistoryAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetUserLongNameOfTask_When_PropertyEnabled() throws Exception {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
List<TaskHistoryEvent> taskHistoryEvents =
|
||||
getHistoryService()
|
||||
.createTaskHistoryQuery()
|
||||
|
@ -464,7 +466,7 @@ class QueryTaskHistoryAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetTaskOwnerLongNameOfTaskHistoryEvent_When_PropertyEnabled() throws Exception {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
List<TaskHistoryEvent> taskHistoryEvents =
|
||||
getHistoryService()
|
||||
.createTaskHistoryQuery()
|
||||
|
@ -489,8 +491,8 @@ class QueryTaskHistoryAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_NotSetUserLongNameOfTaskHistoryEvent_When_PropertyDisabled() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_NotSetUserLongNameOfTaskHistoryEvent_When_PropertyDisabled() throws Exception {
|
||||
createTaskanaEngineWithNewConfig(false);
|
||||
List<TaskHistoryEvent> taskHistoryEvents =
|
||||
getHistoryService()
|
||||
.createTaskHistoryQuery()
|
||||
|
@ -503,8 +505,8 @@ class QueryTaskHistoryAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_NotSetTaskOwnerLongNameOfTaskHistoryEvent_When_PropertyDisabled() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_NotSetTaskOwnerLongNameOfTaskHistoryEvent_When_PropertyDisabled() throws Exception {
|
||||
createTaskanaEngineWithNewConfig(false);
|
||||
List<TaskHistoryEvent> taskHistoryEvents =
|
||||
getHistoryService()
|
||||
.createTaskHistoryQuery()
|
||||
|
@ -519,8 +521,9 @@ class QueryTaskHistoryAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetUserLongNameOfTaskHistoryEventToNull_When_NotExistingAsUserInDatabase() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
void should_SetUserLongNameOfTaskHistoryEventToNull_When_NotExistingAsUserInDatabase()
|
||||
throws Exception {
|
||||
createTaskanaEngineWithNewConfig(true);
|
||||
List<TaskHistoryEvent> taskHistoryEvents =
|
||||
getHistoryService()
|
||||
.createTaskHistoryQuery()
|
||||
|
@ -530,4 +533,13 @@ class QueryTaskHistoryAccTest extends AbstractAccTest {
|
|||
assertThat(taskHistoryEvents).hasSize(1);
|
||||
assertThat(taskHistoryEvents.get(0)).extracting(TaskHistoryEvent::getUserLongName).isNull();
|
||||
}
|
||||
|
||||
private void createTaskanaEngineWithNewConfig(boolean addAdditionalUserInfo) throws SQLException {
|
||||
|
||||
TaskanaConfiguration tec =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(addAdditionalUserInfo)
|
||||
.build();
|
||||
initTaskanaEngine(tec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import acceptance.AbstractAccTest;
|
|||
import javax.sql.DataSource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.test.config.DataSourceGenerator;
|
||||
|
||||
|
@ -16,8 +16,9 @@ class TaskanaEngineConfigurationTest extends AbstractAccTest {
|
|||
@Test
|
||||
void testCreateTaskanaEngine() throws Exception {
|
||||
DataSource ds = DataSourceGenerator.getDataSource();
|
||||
TaskanaEngineConfiguration taskEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(ds, false, false, DataSourceGenerator.getSchemaName());
|
||||
TaskanaConfiguration taskEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(ds, false, DataSourceGenerator.getSchemaName(), false)
|
||||
.build();
|
||||
|
||||
TaskanaEngine te = TaskanaEngine.buildTaskanaEngine(taskEngineConfiguration);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.mockito.Mock;
|
|||
import org.mockito.Spy;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.simplehistory.impl.task.TaskHistoryEventMapper;
|
||||
import pro.taskana.simplehistory.impl.task.TaskHistoryQueryMapper;
|
||||
|
@ -44,7 +44,7 @@ class SimpleHistoryServiceImplTest {
|
|||
|
||||
@Mock private TaskanaHistoryEngineImpl taskanaHistoryEngineMock;
|
||||
|
||||
@Mock private TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@Mock private TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Mock private TaskanaEngine taskanaEngine;
|
||||
|
||||
|
@ -86,7 +86,7 @@ class SimpleHistoryServiceImplTest {
|
|||
"wbKey1", "taskId1", "type1", "wbKey2", "someUserId", "someDetails"));
|
||||
|
||||
when(taskanaHistoryEngineMock.getConfiguration()).thenReturn(taskanaEngineConfiguration);
|
||||
when(taskanaEngineConfiguration.getAddAdditionalUserInfo()).thenReturn(false);
|
||||
when(taskanaEngineConfiguration.isAddAdditionalUserInfo()).thenReturn(false);
|
||||
|
||||
when(taskanaHistoryEngineMock.getSqlSession()).thenReturn(sqlSessionMock);
|
||||
when(sqlSessionMock.selectList(any(), any())).thenReturn(new ArrayList<>(returnList));
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.BaseQuery.SortDirection;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
|
@ -42,7 +42,7 @@ public class TaskHistoryEventController {
|
|||
|
||||
@Autowired
|
||||
public TaskHistoryEventController(
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
||||
TaskanaConfiguration taskanaEngineConfiguration,
|
||||
SimpleHistoryServiceImpl simpleHistoryServiceImpl,
|
||||
TaskHistoryEventRepresentationModelAssembler assembler)
|
||||
throws SQLException {
|
||||
|
|
|
@ -17,7 +17,7 @@ import javax.sql.DataSource;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
|
@ -33,7 +33,7 @@ public class TaskanaProducers {
|
|||
|
||||
@Inject private TaskanaEngine taskanaEngine;
|
||||
|
||||
private TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
private TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
@ -54,7 +54,7 @@ public class TaskanaProducers {
|
|||
}
|
||||
}
|
||||
this.taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(dataSource, true, false, "TASKANA");
|
||||
new TaskanaConfiguration.Builder(dataSource, true, "TASKANA", false).build();
|
||||
} catch (NamingException | SQLException | IOException e) {
|
||||
LOGGER.error("Could not start Taskana: ", e);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ import org.junit.jupiter.api.TestTemplate;
|
|||
import org.junit.jupiter.api.function.ThrowingConsumer;
|
||||
import org.junit.platform.commons.support.AnnotationSupport;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
|
@ -77,7 +77,6 @@ import pro.taskana.testapi.TaskanaIntegrationTest;
|
|||
class ArchitectureTest {
|
||||
|
||||
// region Test setup
|
||||
|
||||
private static final List<String> TASKANA_ROOT_PACKAGES =
|
||||
List.of(
|
||||
"pro.taskana.classification",
|
||||
|
@ -455,7 +454,7 @@ class ArchitectureTest {
|
|||
.resideInAnyPackage(dependentModulesList.toArray(new String[0]))
|
||||
.orShould()
|
||||
.dependOnClassesThat()
|
||||
.areAssignableTo(TaskanaEngineConfiguration.class)
|
||||
.areAssignableTo(TaskanaConfiguration.class)
|
||||
.check(importedClasses);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package acceptance;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.DynamicTest;
|
||||
import org.junit.jupiter.api.TestFactory;
|
||||
import org.junit.jupiter.api.function.ThrowingConsumer;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.internal.util.ReflectionUtil;
|
||||
import pro.taskana.testapi.extensions.TestContainerExtension;
|
||||
|
||||
class TaskanaConfigurationTest {
|
||||
|
||||
@TestFactory
|
||||
Stream<DynamicTest> should_SaveUnmodifiableCollections() {
|
||||
TaskanaConfiguration configuration =
|
||||
new TaskanaConfiguration.Builder(
|
||||
TestContainerExtension.createDataSourceForH2(), false, "TASKANA")
|
||||
.build();
|
||||
|
||||
Stream<Field> fields =
|
||||
ReflectionUtil.retrieveAllFields(TaskanaConfiguration.class).stream()
|
||||
.filter(f -> Collection.class.isAssignableFrom(f.getType()));
|
||||
|
||||
ThrowingConsumer<Field> testCase =
|
||||
field -> {
|
||||
field.setAccessible(true);
|
||||
Collection<?> o = (Collection<?>) field.get(configuration);
|
||||
|
||||
// PLEASE do not change this to the _assertThatThrownBy_ syntax.
|
||||
// That syntax does not respect the given description and thus might confuse future devs.
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||
.as("Field '%s' should be an unmodifiable Collection", field.getName())
|
||||
.isThrownBy(() -> o.add(null));
|
||||
};
|
||||
|
||||
return DynamicTest.stream(fields, Field::getName, testCase);
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Stream<DynamicTest> should_SaveUnmodifiableMaps() {
|
||||
TaskanaConfiguration configuration =
|
||||
new TaskanaConfiguration.Builder(
|
||||
TestContainerExtension.createDataSourceForH2(), false, "TASKANA")
|
||||
.build();
|
||||
|
||||
Stream<Field> fields =
|
||||
ReflectionUtil.retrieveAllFields(TaskanaConfiguration.class).stream()
|
||||
.filter(f -> Map.class.isAssignableFrom(f.getType()));
|
||||
|
||||
ThrowingConsumer<Field> testCase =
|
||||
field -> {
|
||||
field.setAccessible(true);
|
||||
Map<?, ?> o = (Map<?, ?>) field.get(configuration);
|
||||
|
||||
// PLEASE do not change this to the _assertThatThrownBy_ syntax.
|
||||
// That syntax does not respect the given description and thus might confuse future devs.
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||
.as("Field '%s' should be an unmodifiable Collection", field.getName())
|
||||
.isThrownBy(() -> o.put(null, null));
|
||||
};
|
||||
|
||||
return DynamicTest.stream(fields, Field::getName, testCase);
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import org.junit.jupiter.api.BeforeAll;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
import pro.taskana.common.api.BulkOperationResults;
|
||||
|
@ -33,6 +34,7 @@ import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.task.api.models.ObjectReference;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.testapi.DefaultTestEntities;
|
||||
import pro.taskana.testapi.TaskanaEngineConfigurationModifier;
|
||||
import pro.taskana.testapi.TaskanaInject;
|
||||
import pro.taskana.testapi.TaskanaIntegrationTest;
|
||||
import pro.taskana.testapi.builder.TaskBuilder;
|
||||
|
@ -46,7 +48,7 @@ import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionExcep
|
|||
import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
||||
|
||||
@TaskanaIntegrationTest
|
||||
class CompleteTaskAccTest {
|
||||
class CompleteTaskAccTest implements TaskanaEngineConfigurationModifier {
|
||||
|
||||
@TaskanaInject TaskService taskService;
|
||||
@TaskanaInject CurrentUserContext currentUserContext;
|
||||
|
@ -59,6 +61,12 @@ class CompleteTaskAccTest {
|
|||
WorkbasketSummary defaultWorkbasketSummary;
|
||||
ObjectReference defaultObjectReference;
|
||||
|
||||
@Override
|
||||
public TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder) {
|
||||
return taskanaEngineConfigurationBuilder.addAdditionalUserInfo(true);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "businessadmin")
|
||||
@BeforeAll
|
||||
void setup(ClassificationService classificationService, WorkbasketService workbasketService)
|
||||
|
@ -76,7 +84,6 @@ class CompleteTaskAccTest {
|
|||
|
||||
defaultObjectReference = DefaultTestEntities.defaultTestObjectReference().build();
|
||||
|
||||
taskanaEngine.getConfiguration().setAddAdditionalUserInfo(true);
|
||||
UserBuilder user11 = UserBuilder.newUser().id("user-1-1")
|
||||
.longName("Mustermann, Max - (user-1-1)").firstName("Max").lastName("Mustermann");
|
||||
user11.buildAndStore(userService);
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
|
@ -247,7 +247,7 @@ public class RequestChangesWithAfterSpiAccTest {
|
|||
PlainJavaTransactionProvider transactionProvider;
|
||||
|
||||
@BeforeAll
|
||||
void setup(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
void setup(TaskanaConfiguration taskanaEngineConfiguration) {
|
||||
transactionProvider =
|
||||
new PlainJavaTransactionProvider(
|
||||
taskanaEngine, taskanaEngineConfiguration.getDatasource());
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
|
@ -282,7 +282,7 @@ public class RequestChangesWithBeforeSpiAccTest {
|
|||
PlainJavaTransactionProvider transactionProvider;
|
||||
|
||||
@BeforeAll
|
||||
void setup(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
void setup(TaskanaConfiguration taskanaEngineConfiguration) {
|
||||
transactionProvider =
|
||||
new PlainJavaTransactionProvider(
|
||||
taskanaEngine, taskanaEngineConfiguration.getDatasource());
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
|
@ -248,7 +248,7 @@ public class RequestReviewWithAfterSpiAccTest {
|
|||
PlainJavaTransactionProvider transactionProvider;
|
||||
|
||||
@BeforeAll
|
||||
void setup(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
void setup(TaskanaConfiguration taskanaEngineConfiguration) {
|
||||
transactionProvider =
|
||||
new PlainJavaTransactionProvider(
|
||||
taskanaEngine, taskanaEngineConfiguration.getDatasource());
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
|
@ -283,7 +283,7 @@ public class RequestReviewWithBeforeSpiAccTest {
|
|||
PlainJavaTransactionProvider transactionProvider;
|
||||
|
||||
@BeforeAll
|
||||
void setup(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
void setup(TaskanaConfiguration taskanaEngineConfiguration) {
|
||||
transactionProvider =
|
||||
new PlainJavaTransactionProvider(
|
||||
taskanaEngine, taskanaEngineConfiguration.getDatasource());
|
||||
|
|
|
@ -8,8 +8,12 @@ import java.time.Instant;
|
|||
import java.util.List;
|
||||
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
|
@ -18,12 +22,14 @@ import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
|
|||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.api.models.TaskComment;
|
||||
import pro.taskana.testapi.DefaultTestEntities;
|
||||
import pro.taskana.testapi.TaskanaEngineConfigurationModifier;
|
||||
import pro.taskana.testapi.TaskanaInject;
|
||||
import pro.taskana.testapi.TaskanaIntegrationTest;
|
||||
import pro.taskana.testapi.builder.TaskBuilder;
|
||||
import pro.taskana.testapi.builder.TaskCommentBuilder;
|
||||
import pro.taskana.testapi.builder.WorkbasketAccessItemBuilder;
|
||||
import pro.taskana.testapi.security.WithAccessId;
|
||||
import pro.taskana.user.api.UserService;
|
||||
import pro.taskana.user.api.models.User;
|
||||
import pro.taskana.workbasket.api.WorkbasketPermission;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
|
@ -180,82 +186,105 @@ class GetTaskCommentAccTest {
|
|||
assertThat(e.getTaskCommentId()).isEqualTo(nonExistingId);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetCreatorFullNameOfTaskComment_When_PropertyEnabled() throws Exception {
|
||||
TaskComment comment =
|
||||
TaskCommentBuilder.newTaskComment()
|
||||
.taskId(task1.getId())
|
||||
.textField("Text1")
|
||||
.created(Instant.now())
|
||||
.modified(Instant.now())
|
||||
.buildAndStore(taskService);
|
||||
@Nested
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class WithAdditionalUserInfoEnabled implements TaskanaEngineConfigurationModifier {
|
||||
|
||||
taskanaEngine.getConfiguration().setAddAdditionalUserInfo(true);
|
||||
TaskComment taskComment = taskService.getTaskComment(comment.getId());
|
||||
String creatorFullName =
|
||||
taskanaEngine.getUserService().getUser(taskComment.getCreator()).getFullName();
|
||||
assertThat(taskComment).extracting(TaskComment::getCreatorFullName).isEqualTo(creatorFullName);
|
||||
@TaskanaInject TaskService taskService;
|
||||
|
||||
@TaskanaInject UserService userService;
|
||||
|
||||
@Override
|
||||
public TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder) {
|
||||
return taskanaEngineConfigurationBuilder.addAdditionalUserInfo(true);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetCreatorFullNameOfTaskComment_When_PropertyEnabled() throws Exception {
|
||||
TaskComment comment =
|
||||
TaskCommentBuilder.newTaskComment()
|
||||
.taskId(task1.getId())
|
||||
.textField("Text1")
|
||||
.created(Instant.now())
|
||||
.modified(Instant.now())
|
||||
.buildAndStore(taskService);
|
||||
|
||||
TaskComment taskComment = taskService.getTaskComment(comment.getId());
|
||||
String creatorFullName = userService.getUser(taskComment.getCreator()).getFullName();
|
||||
assertThat(taskComment)
|
||||
.extracting(TaskComment::getCreatorFullName)
|
||||
.isEqualTo(creatorFullName);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetCreatorFullNameOfTaskComments_When_PropertyEnabled() throws Exception {
|
||||
TaskCommentBuilder.newTaskComment()
|
||||
.taskId(task1.getId())
|
||||
.textField("Text1")
|
||||
.created(Instant.now())
|
||||
.modified(Instant.now())
|
||||
.buildAndStore(taskService);
|
||||
|
||||
List<TaskComment> taskComments = taskService.getTaskComments(task1.getId());
|
||||
|
||||
taskComments.forEach(
|
||||
wrap(
|
||||
taskComment -> {
|
||||
String creatorFullName =
|
||||
userService.getUser(taskComment.getCreator()).getFullName();
|
||||
assertThat(taskComment)
|
||||
.extracting(TaskComment::getCreatorFullName)
|
||||
.isEqualTo(creatorFullName);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_NotSetCreatorFullNameOfTaskComment_When_PropertyDisabled() throws Exception {
|
||||
TaskComment comment =
|
||||
TaskCommentBuilder.newTaskComment()
|
||||
.taskId(task1.getId())
|
||||
.textField("Text1")
|
||||
.created(Instant.now())
|
||||
.modified(Instant.now())
|
||||
.buildAndStore(taskService);
|
||||
@Nested
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class WithAdditionalUserInfoDisabled implements TaskanaEngineConfigurationModifier {
|
||||
|
||||
taskanaEngine.getConfiguration().setAddAdditionalUserInfo(false);
|
||||
TaskComment taskComment = taskService.getTaskComment(comment.getId());
|
||||
@TaskanaInject TaskService taskService;
|
||||
|
||||
assertThat(taskComment).extracting(TaskComment::getCreatorFullName).isNull();
|
||||
}
|
||||
@Override
|
||||
public TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder) {
|
||||
return taskanaEngineConfigurationBuilder.addAdditionalUserInfo(false);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetCreatorFullNameOfTaskComments_When_PropertyEnabled() throws Exception {
|
||||
TaskCommentBuilder.newTaskComment()
|
||||
.taskId(task1.getId())
|
||||
.textField("Text1")
|
||||
.created(Instant.now())
|
||||
.modified(Instant.now())
|
||||
.buildAndStore(taskService);
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_NotSetCreatorFullNameOfTaskComment_When_PropertyDisabled() throws Exception {
|
||||
TaskComment comment =
|
||||
TaskCommentBuilder.newTaskComment()
|
||||
.taskId(task1.getId())
|
||||
.textField("Text1")
|
||||
.created(Instant.now())
|
||||
.modified(Instant.now())
|
||||
.buildAndStore(taskService);
|
||||
|
||||
taskanaEngine.getConfiguration().setAddAdditionalUserInfo(true);
|
||||
TaskComment taskComment = taskService.getTaskComment(comment.getId());
|
||||
|
||||
List<TaskComment> taskComments = taskService.getTaskComments(task1.getId());
|
||||
assertThat(taskComment).extracting(TaskComment::getCreatorFullName).isNull();
|
||||
}
|
||||
|
||||
taskComments.forEach(
|
||||
wrap(
|
||||
taskComment -> {
|
||||
String creatorFullName =
|
||||
taskanaEngine.getUserService().getUser(taskComment.getCreator()).getFullName();
|
||||
assertThat(taskComment)
|
||||
.extracting(TaskComment::getCreatorFullName)
|
||||
.isEqualTo(creatorFullName);
|
||||
}));
|
||||
}
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_NotSetCreatorFullNameOfTaskComments_When_PropertyDisabled() throws Exception {
|
||||
TaskCommentBuilder.newTaskComment()
|
||||
.taskId(task1.getId())
|
||||
.textField("Text1")
|
||||
.created(Instant.now())
|
||||
.modified(Instant.now())
|
||||
.buildAndStore(taskService);
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_NotSetCreatorFullNameOfTaskComments_When_PropertyDisabled() throws Exception {
|
||||
TaskCommentBuilder.newTaskComment()
|
||||
.taskId(task1.getId())
|
||||
.textField("Text1")
|
||||
.created(Instant.now())
|
||||
.modified(Instant.now())
|
||||
.buildAndStore(taskService);
|
||||
List<TaskComment> taskComments = taskService.getTaskComments(task1.getId());
|
||||
|
||||
taskanaEngine.getConfiguration().setAddAdditionalUserInfo(false);
|
||||
|
||||
List<TaskComment> taskComments = taskService.getTaskComments(task1.getId());
|
||||
|
||||
taskComments.forEach(
|
||||
taskComment ->
|
||||
assertThat(taskComment).extracting(TaskComment::getCreatorFullName).isNull());
|
||||
taskComments.forEach(
|
||||
taskComment ->
|
||||
assertThat(taskComment).extracting(TaskComment::getCreatorFullName).isNull());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import static pro.taskana.testapi.DefaultTestEntities.defaultTestWorkbasket;
|
|||
import static pro.taskana.testapi.DefaultTestEntities.randomTestUser;
|
||||
import static pro.taskana.testapi.builder.UserBuilder.newUser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -25,7 +26,7 @@ import org.junit.jupiter.api.TestInstance;
|
|||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
import org.junit.jupiter.api.function.ThrowingConsumer;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
|
@ -1016,8 +1017,9 @@ class UserServiceAccTest {
|
|||
@TaskanaInject WorkbasketService workbasketService;
|
||||
|
||||
@Override
|
||||
public void modify(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
taskanaEngineConfiguration.setMinimalPermissionsToAssignDomains(
|
||||
public TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder) {
|
||||
return taskanaEngineConfigurationBuilder.minimalPermissionsToAssignDomains(
|
||||
List.of(WorkbasketPermission.APPEND));
|
||||
}
|
||||
|
||||
|
@ -1094,8 +1096,10 @@ class UserServiceAccTest {
|
|||
@TaskanaInject WorkbasketService workbasketService;
|
||||
|
||||
@Override
|
||||
public void modify(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
taskanaEngineConfiguration.setMinimalPermissionsToAssignDomains(null);
|
||||
public TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder) {
|
||||
return taskanaEngineConfigurationBuilder.minimalPermissionsToAssignDomains(
|
||||
new ArrayList<>());
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
|
|
|
@ -0,0 +1,685 @@
|
|||
package pro.taskana;
|
||||
|
||||
import static pro.taskana.common.internal.configuration.TaskanaConfigurationInitializer.configureAnnotatedFields;
|
||||
import static pro.taskana.common.internal.configuration.TaskanaConfigurationInitializer.configureClassificationCategoriesForType;
|
||||
import static pro.taskana.common.internal.configuration.TaskanaConfigurationInitializer.configureRoles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.sql.DataSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.common.api.CustomHoliday;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.common.internal.configuration.DB;
|
||||
import pro.taskana.common.internal.configuration.TaskanaProperty;
|
||||
import pro.taskana.common.internal.util.FileLoaderUtil;
|
||||
import pro.taskana.workbasket.api.WorkbasketPermission;
|
||||
|
||||
/**
|
||||
* This central class creates the TaskanaEngine and holds all the information about DB and Security.
|
||||
* <br>
|
||||
* Security is enabled by default. <br>
|
||||
* All members are immutable, also Lists and Maps and Sets.
|
||||
*/
|
||||
public class TaskanaConfiguration {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaConfiguration.class);
|
||||
|
||||
private final DataSource dataSource;
|
||||
private final String schemaName;
|
||||
private final Map<String, String> properties;
|
||||
|
||||
// Taskana role configuration
|
||||
private final Map<TaskanaRole, Set<String>> roleMap;
|
||||
|
||||
private final boolean securityEnabled;
|
||||
|
||||
private final boolean useManagedTransactions;
|
||||
|
||||
private final List<String> domains;
|
||||
private final List<String> classificationTypes;
|
||||
|
||||
private final Map<String, List<String>> classificationCategoriesByTypeMap;
|
||||
|
||||
private final List<CustomHoliday> customHolidays;
|
||||
// Properties for the monitor
|
||||
private final boolean deleteHistoryOnTaskDeletionEnabled;
|
||||
|
||||
private final boolean germanPublicHolidaysEnabled;
|
||||
|
||||
private final boolean corpusChristiEnabled;
|
||||
|
||||
private final int jobBatchSize;
|
||||
|
||||
private final int maxNumberOfJobRetries;
|
||||
|
||||
private final Instant cleanupJobFirstRun;
|
||||
|
||||
private final Duration cleanupJobRunEvery;
|
||||
|
||||
private final Duration cleanupJobMinimumAge;
|
||||
|
||||
private final boolean taskCleanupJobAllCompletedSameParentBusiness;
|
||||
|
||||
private final boolean validationAllowTimestampServiceLevelMismatch;
|
||||
private final boolean addAdditionalUserInfo;
|
||||
|
||||
private final int priorityJobBatchSize;
|
||||
|
||||
private final Instant priorityJobFirstRun;
|
||||
|
||||
private final Duration priorityJobRunEvery;
|
||||
|
||||
private final boolean priorityJobActive;
|
||||
|
||||
private final Duration userRefreshJobRunEvery;
|
||||
|
||||
private final Instant userRefreshJobFirstRun;
|
||||
|
||||
private final List<WorkbasketPermission> minimalPermissionsToAssignDomains;
|
||||
|
||||
protected TaskanaConfiguration(Builder builder) {
|
||||
|
||||
this.dataSource = builder.dataSource;
|
||||
this.schemaName = builder.schemaName;
|
||||
|
||||
this.properties = Collections.unmodifiableMap(builder.properties);
|
||||
|
||||
this.roleMap =
|
||||
builder.roleMap.entrySet().stream()
|
||||
.collect(
|
||||
Collectors.toUnmodifiableMap(
|
||||
Entry::getKey, e -> Collections.unmodifiableSet(e.getValue())));
|
||||
|
||||
this.securityEnabled = builder.securityEnabled;
|
||||
this.useManagedTransactions = builder.useManagedTransactions;
|
||||
this.domains = Collections.unmodifiableList(builder.domains);
|
||||
this.classificationTypes = Collections.unmodifiableList(builder.classificationTypes);
|
||||
|
||||
this.classificationCategoriesByTypeMap =
|
||||
builder.classificationCategoriesByTypeMap.entrySet().stream()
|
||||
.collect(
|
||||
Collectors.toUnmodifiableMap(
|
||||
Entry::getKey, e -> Collections.unmodifiableList(e.getValue())));
|
||||
|
||||
this.customHolidays = Collections.unmodifiableList(builder.customHolidays);
|
||||
this.deleteHistoryOnTaskDeletionEnabled = builder.deleteHistoryOnTaskDeletionEnabled;
|
||||
this.germanPublicHolidaysEnabled = builder.germanPublicHolidaysEnabled;
|
||||
this.corpusChristiEnabled = builder.corpusChristiEnabled;
|
||||
this.jobBatchSize = builder.jobBatchSize;
|
||||
this.maxNumberOfJobRetries = builder.maxNumberOfJobRetries;
|
||||
this.cleanupJobFirstRun = builder.cleanupJobFirstRun;
|
||||
this.cleanupJobRunEvery = builder.cleanupJobRunEvery;
|
||||
this.cleanupJobMinimumAge = builder.cleanupJobMinimumAge;
|
||||
this.taskCleanupJobAllCompletedSameParentBusiness =
|
||||
builder.taskCleanupJobAllCompletedSameParentBusiness;
|
||||
this.validationAllowTimestampServiceLevelMismatch =
|
||||
builder.validationAllowTimestampServiceLevelMismatch;
|
||||
this.addAdditionalUserInfo = builder.addAdditionalUserInfo;
|
||||
this.priorityJobBatchSize = builder.priorityJobBatchSize;
|
||||
this.priorityJobFirstRun = builder.priorityJobFirstRun;
|
||||
this.priorityJobRunEvery = builder.priorityJobRunEvery;
|
||||
this.priorityJobActive = builder.priorityJobActive;
|
||||
this.userRefreshJobRunEvery = builder.userRefreshJobRunEvery;
|
||||
this.userRefreshJobFirstRun = builder.userRefreshJobFirstRun;
|
||||
this.minimalPermissionsToAssignDomains =
|
||||
Collections.unmodifiableList(builder.minimalPermissionsToAssignDomains);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
// TODO remove the reflection magic when introducing lombok toString magic :-)
|
||||
StringBuilder result = new StringBuilder();
|
||||
String newLine = System.getProperty("line.separator");
|
||||
Field[] fields = this.getClass().getDeclaredFields();
|
||||
result.append("TaskanaConfiguration:").append(newLine);
|
||||
// print field names paired with their values
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
result.append(field.getName());
|
||||
result.append(": ");
|
||||
// requires access to private field:
|
||||
result.append(field.get(this));
|
||||
} catch (IllegalAccessException ex) {
|
||||
// ignore this error
|
||||
}
|
||||
result.append(newLine);
|
||||
}
|
||||
LOGGER.debug(result.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSecurityEnabled() {
|
||||
return this.securityEnabled;
|
||||
}
|
||||
|
||||
public DataSource getDatasource() {
|
||||
return this.dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* return all properties loaded from taskana properties file. Per Design the normal Properties are
|
||||
* not immutable, so we return here an ImmutableMap, because we don't want direct changes in the
|
||||
* configuration.
|
||||
*
|
||||
* @return all properties loaded from taskana properties file
|
||||
*/
|
||||
public Map<String, String> getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public boolean isUseManagedTransactions() {
|
||||
return this.useManagedTransactions;
|
||||
}
|
||||
|
||||
public int getMaxNumberOfUpdatesPerTransaction() {
|
||||
return jobBatchSize;
|
||||
}
|
||||
|
||||
public int getMaxNumberOfJobRetries() {
|
||||
return maxNumberOfJobRetries;
|
||||
}
|
||||
|
||||
public boolean isCorpusChristiEnabled() {
|
||||
return corpusChristiEnabled;
|
||||
}
|
||||
|
||||
public boolean isGermanPublicHolidaysEnabled() {
|
||||
return this.germanPublicHolidaysEnabled;
|
||||
}
|
||||
|
||||
public boolean isValidationAllowTimestampServiceLevelMismatch() {
|
||||
return validationAllowTimestampServiceLevelMismatch;
|
||||
}
|
||||
|
||||
public boolean isDeleteHistoryOnTaskDeletionEnabled() {
|
||||
return deleteHistoryOnTaskDeletionEnabled;
|
||||
}
|
||||
|
||||
public List<CustomHoliday> getCustomHolidays() {
|
||||
return customHolidays;
|
||||
}
|
||||
|
||||
public Map<TaskanaRole, Set<String>> getRoleMap() {
|
||||
return roleMap;
|
||||
}
|
||||
|
||||
public List<String> getDomains() {
|
||||
return domains;
|
||||
}
|
||||
|
||||
public boolean isAddAdditionalUserInfo() {
|
||||
return addAdditionalUserInfo;
|
||||
}
|
||||
|
||||
public List<String> getClassificationTypes() {
|
||||
return classificationTypes;
|
||||
}
|
||||
|
||||
public List<String> getAllClassificationCategories() {
|
||||
List<String> classificationCategories = new ArrayList<>();
|
||||
for (Map.Entry<String, List<String>> type : this.classificationCategoriesByTypeMap.entrySet()) {
|
||||
classificationCategories.addAll(type.getValue());
|
||||
}
|
||||
return classificationCategories;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getClassificationCategoriesByTypeMap() {
|
||||
return this.classificationCategoriesByTypeMap.entrySet().stream()
|
||||
.collect(Collectors.toMap(Entry::getKey, e -> new ArrayList<>(e.getValue())));
|
||||
}
|
||||
|
||||
public List<String> getClassificationCategoriesByType(String type) {
|
||||
return classificationCategoriesByTypeMap.getOrDefault(type, Collections.emptyList());
|
||||
}
|
||||
|
||||
public Instant getCleanupJobFirstRun() {
|
||||
return cleanupJobFirstRun;
|
||||
}
|
||||
|
||||
public Duration getCleanupJobRunEvery() {
|
||||
return cleanupJobRunEvery;
|
||||
}
|
||||
|
||||
public Duration getCleanupJobMinimumAge() {
|
||||
return cleanupJobMinimumAge;
|
||||
}
|
||||
|
||||
public boolean isTaskCleanupJobAllCompletedSameParentBusiness() {
|
||||
return taskCleanupJobAllCompletedSameParentBusiness;
|
||||
}
|
||||
|
||||
public int getPriorityJobBatchSize() {
|
||||
return priorityJobBatchSize;
|
||||
}
|
||||
|
||||
public Instant getPriorityJobFirstRun() {
|
||||
return priorityJobFirstRun;
|
||||
}
|
||||
|
||||
public Duration getPriorityJobRunEvery() {
|
||||
return priorityJobRunEvery;
|
||||
}
|
||||
|
||||
public Duration getUserRefreshJobRunEvery() {
|
||||
return userRefreshJobRunEvery;
|
||||
}
|
||||
|
||||
public List<WorkbasketPermission> getMinimalPermissionsToAssignDomains() {
|
||||
return minimalPermissionsToAssignDomains;
|
||||
}
|
||||
|
||||
public Instant getUserRefreshJobFirstRun() {
|
||||
return userRefreshJobFirstRun;
|
||||
}
|
||||
|
||||
public boolean isPriorityJobActive() {
|
||||
return priorityJobActive;
|
||||
}
|
||||
|
||||
public String getSchemaName() {
|
||||
return schemaName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to determine whether all access ids (user Id and group ids) should be used in
|
||||
* lower case.
|
||||
*
|
||||
* @return true if all access ids should be used in lower case, false otherwise
|
||||
*/
|
||||
public static boolean shouldUseLowerCaseForAccessIds() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Builder.class);
|
||||
|
||||
private static final String TASKANA_PROPERTIES = "/taskana.properties";
|
||||
private static final String TASKANA_PROPERTY_SEPARATOR = "|";
|
||||
|
||||
private final DataSource dataSource;
|
||||
private final boolean securityEnabled;
|
||||
private final boolean useManagedTransactions;
|
||||
private String schemaName;
|
||||
private Map<String, String> properties;
|
||||
|
||||
private Map<TaskanaRole, Set<String>> roleMap = new EnumMap<>(TaskanaRole.class);
|
||||
|
||||
// List of configured domain names
|
||||
@TaskanaProperty("taskana.domains")
|
||||
private List<String> domains = new ArrayList<>();
|
||||
|
||||
@TaskanaProperty("taskana.classification.types")
|
||||
private List<String> classificationTypes = new ArrayList<>();
|
||||
|
||||
private Map<String, List<String>> classificationCategoriesByTypeMap = new HashMap<>();
|
||||
|
||||
@TaskanaProperty("taskana.custom.holidays")
|
||||
private List<CustomHoliday> customHolidays = new ArrayList<>();
|
||||
// Properties for the monitor
|
||||
@TaskanaProperty("taskana.history.deletion.on.task.deletion.enabled")
|
||||
private boolean deleteHistoryOnTaskDeletionEnabled;
|
||||
|
||||
@TaskanaProperty("taskana.german.holidays.enabled")
|
||||
private boolean germanPublicHolidaysEnabled;
|
||||
|
||||
@TaskanaProperty("taskana.german.holidays.corpus-christi.enabled")
|
||||
private boolean corpusChristiEnabled;
|
||||
|
||||
// Properties for general job execution
|
||||
@TaskanaProperty("taskana.jobs.batchSize")
|
||||
private int jobBatchSize = 100;
|
||||
|
||||
@TaskanaProperty("taskana.jobs.maxRetries")
|
||||
private int maxNumberOfJobRetries = 3;
|
||||
|
||||
// Properties for the cleanup job
|
||||
@TaskanaProperty("taskana.jobs.cleanup.firstRunAt")
|
||||
private Instant cleanupJobFirstRun = Instant.parse("2018-01-01T00:00:00Z");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.cleanup.runEvery")
|
||||
private Duration cleanupJobRunEvery = Duration.parse("P1D");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.cleanup.minimumAge")
|
||||
private Duration cleanupJobMinimumAge = Duration.parse("P14D");
|
||||
// TASKANA behavior
|
||||
|
||||
@TaskanaProperty("taskana.jobs.cleanup.allCompletedSameParentBusiness")
|
||||
private boolean taskCleanupJobAllCompletedSameParentBusiness = true;
|
||||
|
||||
@TaskanaProperty("taskana.validation.allowTimestampServiceLevelMismatch")
|
||||
private boolean validationAllowTimestampServiceLevelMismatch = false;
|
||||
// Property to enable/disable the addition of user full/long name through joins
|
||||
@TaskanaProperty("taskana.addAdditionalUserInfo")
|
||||
private boolean addAdditionalUserInfo = false;
|
||||
|
||||
@TaskanaProperty("taskana.jobs.priority.batchSize")
|
||||
private int priorityJobBatchSize = 100;
|
||||
|
||||
@TaskanaProperty("taskana.jobs.priority.firstRunAt")
|
||||
private Instant priorityJobFirstRun = Instant.parse("2018-01-01T00:00:00Z");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.priority.runEvery")
|
||||
private Duration priorityJobRunEvery = Duration.parse("P1D");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.priority.active")
|
||||
private boolean priorityJobActive = false;
|
||||
|
||||
@TaskanaProperty("taskana.jobs.user.refresh.runEvery")
|
||||
private Duration userRefreshJobRunEvery = Duration.parse("P1D");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.user.refresh.firstRunAt")
|
||||
private Instant userRefreshJobFirstRun = Instant.parse("2018-01-01T23:00:00Z");
|
||||
|
||||
@TaskanaProperty("taskana.user.minimalPermissionsToAssignDomains")
|
||||
private List<WorkbasketPermission> minimalPermissionsToAssignDomains = new ArrayList<>();
|
||||
|
||||
public Builder(TaskanaConfiguration tec) {
|
||||
this.dataSource = tec.getDatasource();
|
||||
this.schemaName = tec.getSchemaName();
|
||||
this.properties = tec.getProperties();
|
||||
this.roleMap = tec.getRoleMap();
|
||||
this.securityEnabled = tec.isSecurityEnabled();
|
||||
this.useManagedTransactions = tec.isUseManagedTransactions();
|
||||
this.domains = tec.getDomains();
|
||||
this.classificationTypes = tec.getClassificationTypes();
|
||||
this.classificationCategoriesByTypeMap = tec.getClassificationCategoriesByTypeMap();
|
||||
this.customHolidays = tec.getCustomHolidays();
|
||||
this.deleteHistoryOnTaskDeletionEnabled = tec.isDeleteHistoryOnTaskDeletionEnabled();
|
||||
this.germanPublicHolidaysEnabled = tec.isGermanPublicHolidaysEnabled();
|
||||
this.corpusChristiEnabled = tec.isCorpusChristiEnabled();
|
||||
this.jobBatchSize = tec.getMaxNumberOfUpdatesPerTransaction();
|
||||
this.maxNumberOfJobRetries = tec.getMaxNumberOfJobRetries();
|
||||
this.cleanupJobFirstRun = tec.getCleanupJobFirstRun();
|
||||
this.cleanupJobRunEvery = tec.getCleanupJobRunEvery();
|
||||
this.cleanupJobMinimumAge = tec.getCleanupJobMinimumAge();
|
||||
this.taskCleanupJobAllCompletedSameParentBusiness =
|
||||
tec.isTaskCleanupJobAllCompletedSameParentBusiness();
|
||||
this.validationAllowTimestampServiceLevelMismatch =
|
||||
tec.isValidationAllowTimestampServiceLevelMismatch();
|
||||
this.addAdditionalUserInfo = tec.isAddAdditionalUserInfo();
|
||||
this.priorityJobBatchSize = tec.getPriorityJobBatchSize();
|
||||
this.priorityJobFirstRun = tec.getPriorityJobFirstRun();
|
||||
this.priorityJobRunEvery = tec.getPriorityJobRunEvery();
|
||||
this.priorityJobActive = tec.isPriorityJobActive();
|
||||
this.userRefreshJobRunEvery = tec.getUserRefreshJobRunEvery();
|
||||
this.userRefreshJobFirstRun = tec.getUserRefreshJobFirstRun();
|
||||
this.minimalPermissionsToAssignDomains = tec.getMinimalPermissionsToAssignDomains();
|
||||
}
|
||||
|
||||
public Builder(DataSource dataSource, boolean useManagedTransactions, String schemaName) {
|
||||
this(dataSource, useManagedTransactions, schemaName, true);
|
||||
}
|
||||
|
||||
public Builder(
|
||||
DataSource dataSource,
|
||||
boolean useManagedTransactions,
|
||||
String schemaName,
|
||||
boolean securityEnabled) {
|
||||
this(
|
||||
dataSource,
|
||||
useManagedTransactions,
|
||||
schemaName,
|
||||
securityEnabled,
|
||||
TASKANA_PROPERTIES,
|
||||
TASKANA_PROPERTY_SEPARATOR);
|
||||
}
|
||||
|
||||
public Builder(
|
||||
DataSource dataSource,
|
||||
boolean useManagedTransactions,
|
||||
String schemaName,
|
||||
boolean securityEnabled,
|
||||
String propertiesFileName,
|
||||
String propertySeparator) {
|
||||
this.useManagedTransactions = useManagedTransactions;
|
||||
this.securityEnabled = securityEnabled;
|
||||
|
||||
if (dataSource != null) {
|
||||
this.dataSource = dataSource;
|
||||
} else {
|
||||
throw new SystemException("DataSource can't be null");
|
||||
}
|
||||
|
||||
this.schemaName = initSchemaName(schemaName);
|
||||
|
||||
this.initTaskanaProperties(propertiesFileName, propertySeparator);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder schemaName(String schemaName) {
|
||||
this.schemaName = initSchemaName(schemaName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder roleMap(Map<TaskanaRole, Set<String>> roleMap) {
|
||||
this.roleMap = roleMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder domains(List<String> domains) {
|
||||
this.domains = domains;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder classificationTypes(List<String> classificationTypes) {
|
||||
this.classificationTypes = classificationTypes;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder classificationCategoriesByTypeMap(
|
||||
Map<String, List<String>> classificationCategoriesByTypeMap) {
|
||||
this.classificationCategoriesByTypeMap = classificationCategoriesByTypeMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder customHolidays(List<CustomHoliday> customHolidays) {
|
||||
this.customHolidays = customHolidays;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder deleteHistoryOnTaskDeletionEnabled(boolean deleteHistoryOnTaskDeletionEnabled) {
|
||||
this.deleteHistoryOnTaskDeletionEnabled = deleteHistoryOnTaskDeletionEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder germanPublicHolidaysEnabled(boolean germanPublicHolidaysEnabled) {
|
||||
this.germanPublicHolidaysEnabled = germanPublicHolidaysEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder corpusChristiEnabled(boolean corpusChristiEnabled) {
|
||||
this.corpusChristiEnabled = corpusChristiEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder jobBatchSize(int jobBatchSize) {
|
||||
this.jobBatchSize = jobBatchSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder maxNumberOfJobRetries(int maxNumberOfJobRetries) {
|
||||
this.maxNumberOfJobRetries = maxNumberOfJobRetries;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder cleanupJobFirstRun(Instant cleanupJobFirstRun) {
|
||||
this.cleanupJobFirstRun = cleanupJobFirstRun;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder cleanupJobRunEvery(Duration cleanupJobRunEvery) {
|
||||
this.cleanupJobRunEvery = cleanupJobRunEvery;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder cleanupJobMinimumAge(Duration cleanupJobMinimumAge) {
|
||||
this.cleanupJobMinimumAge = cleanupJobMinimumAge;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder taskCleanupJobAllCompletedSameParentBusiness(
|
||||
boolean taskCleanupJobAllCompletedSameParentBusiness) {
|
||||
this.taskCleanupJobAllCompletedSameParentBusiness =
|
||||
taskCleanupJobAllCompletedSameParentBusiness;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder validationAllowTimestampServiceLevelMismatch(
|
||||
boolean validationAllowTimestampServiceLevelMismatch) {
|
||||
this.validationAllowTimestampServiceLevelMismatch =
|
||||
validationAllowTimestampServiceLevelMismatch;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder addAdditionalUserInfo(boolean addAdditionalUserInfo) {
|
||||
this.addAdditionalUserInfo = addAdditionalUserInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder priorityJobBatchSize(int priorityJobBatchSize) {
|
||||
this.priorityJobBatchSize = priorityJobBatchSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder priorityJobFirstRun(Instant priorityJobFirstRun) {
|
||||
this.priorityJobFirstRun = priorityJobFirstRun;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder priorityJobRunEvery(Duration priorityJobRunEvery) {
|
||||
this.priorityJobRunEvery = priorityJobRunEvery;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder priorityJobActive(boolean priorityJobActive) {
|
||||
this.priorityJobActive = priorityJobActive;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder userRefreshJobRunEvery(Duration userRefreshJobRunEvery) {
|
||||
this.userRefreshJobRunEvery = userRefreshJobRunEvery;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder userRefreshJobFirstRun(Instant userRefreshJobFirstRun) {
|
||||
this.userRefreshJobFirstRun = userRefreshJobFirstRun;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder minimalPermissionsToAssignDomains(
|
||||
List<WorkbasketPermission> minimalPermissionsToAssignDomains) {
|
||||
this.minimalPermissionsToAssignDomains = minimalPermissionsToAssignDomains;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskanaConfiguration build() {
|
||||
return new TaskanaConfiguration(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder initTaskanaProperties() {
|
||||
return this.initTaskanaProperties(TASKANA_PROPERTIES, TASKANA_PROPERTY_SEPARATOR);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Builder initTaskanaProperties(String propertiesFile) {
|
||||
return this.initTaskanaProperties(propertiesFile, TASKANA_PROPERTY_SEPARATOR);
|
||||
}
|
||||
|
||||
public Builder initTaskanaProperties(String propertiesFile, String separator) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"Reading taskana configuration from {} with separator {}", propertiesFile, separator);
|
||||
}
|
||||
loadProperties(propertiesFile);
|
||||
configureAnnotatedFields(this, separator, properties);
|
||||
roleMap = configureRoles(separator, properties, shouldUseLowerCaseForAccessIds());
|
||||
classificationCategoriesByTypeMap =
|
||||
configureClassificationCategoriesForType(properties, classificationTypes);
|
||||
return this;
|
||||
}
|
||||
|
||||
private String initSchemaName(String schemaName) {
|
||||
String schemaNameTmp;
|
||||
if (schemaName != null && !schemaName.isEmpty()) {
|
||||
schemaNameTmp = schemaName;
|
||||
} else {
|
||||
throw new SystemException("SchemaName can't be null or empty");
|
||||
}
|
||||
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
String databaseProductId = DB.getDatabaseProductId(connection);
|
||||
if (DB.isPostgres(databaseProductId)) {
|
||||
schemaNameTmp = schemaNameTmp.toLowerCase();
|
||||
} else {
|
||||
schemaNameTmp = schemaNameTmp.toUpperCase();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
LOGGER.error("Caught exception when attempting to initialize the schema name", ex);
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Using schema name {}", schemaNameTmp);
|
||||
}
|
||||
return schemaNameTmp;
|
||||
}
|
||||
|
||||
private void loadProperties(String propertiesFile) {
|
||||
Properties props = new Properties();
|
||||
try (InputStream stream =
|
||||
FileLoaderUtil.openFileFromClasspathOrSystem(
|
||||
propertiesFile, TaskanaConfiguration.class)) {
|
||||
props.load(stream);
|
||||
} catch (IOException e) {
|
||||
throw new SystemException(
|
||||
"internal System error when processing properties file " + propertiesFile, e);
|
||||
}
|
||||
this.properties =
|
||||
props.entrySet().stream()
|
||||
.collect(
|
||||
Collectors.toUnmodifiableMap(
|
||||
e -> e.getKey().toString(), e -> e.getValue().toString()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,518 +0,0 @@
|
|||
package pro.taskana;
|
||||
|
||||
import static pro.taskana.common.internal.configuration.TaskanaConfigurationInitializer.configureAnnotatedFields;
|
||||
import static pro.taskana.common.internal.configuration.TaskanaConfigurationInitializer.configureClassificationCategoriesForType;
|
||||
import static pro.taskana.common.internal.configuration.TaskanaConfigurationInitializer.configureRoles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.sql.DataSource;
|
||||
import org.apache.ibatis.datasource.pooled.PooledDataSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.common.api.CustomHoliday;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.common.internal.configuration.DB;
|
||||
import pro.taskana.common.internal.configuration.TaskanaProperty;
|
||||
import pro.taskana.common.internal.util.FileLoaderUtil;
|
||||
import pro.taskana.workbasket.api.WorkbasketPermission;
|
||||
|
||||
/**
|
||||
* This central class creates the TaskanaEngine and holds all the information about DB and Security.
|
||||
* <br>
|
||||
* Security is enabled by default.
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
|
||||
public class TaskanaEngineConfiguration {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class);
|
||||
|
||||
private static final String TASKANA_PROPERTIES = "/taskana.properties";
|
||||
private static final String TASKANA_PROPERTY_SEPARATOR = "|";
|
||||
|
||||
// TASKANA_SCHEMA_VERSION
|
||||
private static final String DEFAULT_SCHEMA_NAME = "TASKANA";
|
||||
|
||||
// Taskana properties file
|
||||
protected String propertiesFileName = TASKANA_PROPERTIES;
|
||||
// Taskana datasource configuration
|
||||
protected DataSource dataSource;
|
||||
protected String schemaName;
|
||||
// Taskana role configuration
|
||||
protected String propertiesSeparator = TASKANA_PROPERTY_SEPARATOR;
|
||||
protected Map<TaskanaRole, Set<String>> roleMap;
|
||||
|
||||
// global switch to enable JAAS based authentication and Taskana
|
||||
// authorizations
|
||||
protected boolean securityEnabled;
|
||||
protected boolean useManagedTransactions;
|
||||
// List of configured domain names
|
||||
@TaskanaProperty("taskana.domains")
|
||||
protected List<String> domains = new ArrayList<>();
|
||||
// List of configured classification types
|
||||
@TaskanaProperty("taskana.classification.types")
|
||||
protected List<String> classificationTypes = new ArrayList<>();
|
||||
|
||||
protected Map<String, List<String>> classificationCategoriesByTypeMap = new HashMap<>();
|
||||
|
||||
@TaskanaProperty("taskana.custom.holidays")
|
||||
private List<CustomHoliday> customHolidays = new ArrayList<>();
|
||||
// Properties for the monitor
|
||||
@TaskanaProperty("taskana.history.deletion.on.task.deletion.enabled")
|
||||
private boolean deleteHistoryOnTaskDeletionEnabled;
|
||||
|
||||
@TaskanaProperty("taskana.german.holidays.enabled")
|
||||
private boolean germanPublicHolidaysEnabled;
|
||||
|
||||
@TaskanaProperty("taskana.german.holidays.corpus-christi.enabled")
|
||||
private boolean corpusChristiEnabled;
|
||||
|
||||
// Properties for general job execution
|
||||
@TaskanaProperty("taskana.jobs.batchSize")
|
||||
private int jobBatchSize = 100;
|
||||
|
||||
@TaskanaProperty("taskana.jobs.maxRetries")
|
||||
private int maxNumberOfJobRetries = 3;
|
||||
|
||||
// Properties for the cleanup job
|
||||
@TaskanaProperty("taskana.jobs.cleanup.firstRunAt")
|
||||
private Instant cleanupJobFirstRun = Instant.parse("2018-01-01T00:00:00Z");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.cleanup.runEvery")
|
||||
private Duration cleanupJobRunEvery = Duration.parse("P1D");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.cleanup.minimumAge")
|
||||
private Duration cleanupJobMinimumAge = Duration.parse("P14D");
|
||||
// TASKANA behavior
|
||||
|
||||
@TaskanaProperty("taskana.jobs.cleanup.allCompletedSameParentBusiness")
|
||||
private boolean taskCleanupJobAllCompletedSameParentBusiness = true;
|
||||
|
||||
@TaskanaProperty("taskana.validation.allowTimestampServiceLevelMismatch")
|
||||
private boolean validationAllowTimestampServiceLevelMismatch = false;
|
||||
// Property to enable/disable the addition of user full/long name through joins
|
||||
@TaskanaProperty("taskana.addAdditionalUserInfo")
|
||||
private boolean addAdditionalUserInfo = false;
|
||||
|
||||
@TaskanaProperty("taskana.jobs.priority.batchSize")
|
||||
private int priorityJobBatchSize = 100;
|
||||
|
||||
@TaskanaProperty("taskana.jobs.priority.firstRunAt")
|
||||
private Instant priorityJobFirstRun = Instant.parse("2018-01-01T00:00:00Z");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.priority.runEvery")
|
||||
private Duration priorityJobRunEvery = Duration.parse("P1D");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.priority.active")
|
||||
private boolean priorityJobActive = false;
|
||||
|
||||
@TaskanaProperty("taskana.jobs.user.refresh.runEvery")
|
||||
private Duration userRefreshJobRunEvery = Duration.parse("P1D");
|
||||
|
||||
@TaskanaProperty("taskana.jobs.user.refresh.firstRunAt")
|
||||
private Instant userRefreshJobFirstRun = Instant.parse("2018-01-01T23:00:00Z");
|
||||
|
||||
@TaskanaProperty("taskana.user.minimalPermissionsToAssignDomains")
|
||||
private List<WorkbasketPermission> minimalPermissionsToAssignDomains;
|
||||
|
||||
public TaskanaEngineConfiguration(
|
||||
DataSource dataSource, boolean useManagedTransactions, String schemaName) {
|
||||
this(dataSource, useManagedTransactions, true, schemaName);
|
||||
}
|
||||
|
||||
public TaskanaEngineConfiguration(
|
||||
DataSource dataSource,
|
||||
boolean useManagedTransactions,
|
||||
boolean securityEnabled,
|
||||
String schemaName) {
|
||||
this(dataSource, useManagedTransactions, securityEnabled, null, null, schemaName);
|
||||
}
|
||||
|
||||
public TaskanaEngineConfiguration(
|
||||
DataSource dataSource,
|
||||
boolean useManagedTransactions,
|
||||
boolean securityEnabled,
|
||||
String propertiesFileName,
|
||||
String propertySeparator,
|
||||
String schemaName) {
|
||||
this.useManagedTransactions = useManagedTransactions;
|
||||
this.securityEnabled = securityEnabled;
|
||||
|
||||
if (propertiesFileName != null) {
|
||||
this.propertiesFileName = propertiesFileName;
|
||||
}
|
||||
|
||||
if (propertySeparator != null) {
|
||||
this.propertiesSeparator = propertySeparator;
|
||||
}
|
||||
|
||||
if (dataSource != null) {
|
||||
this.dataSource = dataSource;
|
||||
} else {
|
||||
// use default In Memory datasource
|
||||
this.dataSource = createDefaultDataSource();
|
||||
}
|
||||
|
||||
initSchemaName(schemaName);
|
||||
initTaskanaProperties(this.propertiesFileName, this.propertiesSeparator);
|
||||
}
|
||||
|
||||
public static Properties loadProperties(String propertiesFile) {
|
||||
Properties props = new Properties();
|
||||
try (InputStream stream =
|
||||
FileLoaderUtil.openFileFromClasspathOrSystem(
|
||||
propertiesFile, TaskanaEngineConfiguration.class)) {
|
||||
props.load(stream);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("caught IOException when processing properties file {}.", propertiesFile);
|
||||
throw new SystemException(
|
||||
"internal System error when processing properties file " + propertiesFile, e.getCause());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
public void initTaskanaProperties(String propertiesFile, String separator) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"Reading taskana configuration from {} with separator {}", propertiesFile, separator);
|
||||
}
|
||||
Properties props = loadProperties(propertiesFile);
|
||||
configureAnnotatedFields(this, separator, props);
|
||||
roleMap = configureRoles(separator, props, shouldUseLowerCaseForAccessIds());
|
||||
classificationCategoriesByTypeMap =
|
||||
configureClassificationCategoriesForType(props, classificationTypes);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
roleMap.forEach((k, v) -> LOGGER.debug("Found Taskana RoleConfig {} : {} ", k, v));
|
||||
LOGGER.debug(
|
||||
"Configured number of task and workbasket updates per transaction: {}", jobBatchSize);
|
||||
LOGGER.debug("Number of retries of failed task updates: {}", maxNumberOfJobRetries);
|
||||
LOGGER.debug("CleanupJob configuration: first run at {}", cleanupJobFirstRun);
|
||||
LOGGER.debug("CleanupJob configuration: runs every {}", cleanupJobRunEvery);
|
||||
LOGGER.debug(
|
||||
"CleanupJob configuration: minimum age of tasks to be cleanup up is {}",
|
||||
cleanupJobMinimumAge);
|
||||
LOGGER.debug(
|
||||
"TaskCleanupJob configuration: all completed task with the "
|
||||
+ "same parent business property id {}",
|
||||
taskCleanupJobAllCompletedSameParentBusiness);
|
||||
LOGGER.debug("Configured classification categories : {}", classificationCategoriesByTypeMap);
|
||||
LOGGER.debug("Configured domains: {}", domains);
|
||||
LOGGER.debug("Configured classificationTypes: {}", classificationTypes);
|
||||
LOGGER.debug("Configured custom Holidays : {}", customHolidays);
|
||||
LOGGER.debug(
|
||||
"Configured minimalPermissionsToAssignDomains : {}", minimalPermissionsToAssignDomains);
|
||||
}
|
||||
}
|
||||
|
||||
public static DataSource createDefaultDataSource() {
|
||||
String driverClass = "org.h2.Driver";
|
||||
String jdbcUrl =
|
||||
"jdbc:h2:mem:taskana;NON_KEYWORDS=KEY,VALUE;"
|
||||
+ "IGNORECASE=TRUE;LOCK_MODE=0;"
|
||||
+ "INIT=CREATE SCHEMA IF NOT EXISTS TASKANA\\;"
|
||||
+ "SET COLLATION DEFAULT_de_DE";
|
||||
String username = "sa";
|
||||
String password = "sa";
|
||||
LOGGER.info(
|
||||
"No datasource is provided. An in-memory db is used: " + "'{}', '{}', '{}', '{}'",
|
||||
driverClass,
|
||||
jdbcUrl,
|
||||
username,
|
||||
password);
|
||||
return createDatasource(driverClass, jdbcUrl, username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a PooledDataSource, if the needed properties are provided.
|
||||
*
|
||||
* @param driver the name of the jdbc driver
|
||||
* @param jdbcUrl the url to which the jdbc driver connects
|
||||
* @param username the user name for database access
|
||||
* @param password the password for database access
|
||||
* @return DataSource
|
||||
*/
|
||||
public static DataSource createDatasource(
|
||||
String driver, String jdbcUrl, String username, String password) {
|
||||
return new PooledDataSource(driver, jdbcUrl, username, password);
|
||||
}
|
||||
|
||||
public boolean isSecurityEnabled() {
|
||||
return this.securityEnabled;
|
||||
}
|
||||
|
||||
public DataSource getDatasource() {
|
||||
return this.dataSource;
|
||||
}
|
||||
|
||||
public boolean getUseManagedTransactions() {
|
||||
return this.useManagedTransactions;
|
||||
}
|
||||
|
||||
public int getMaxNumberOfUpdatesPerTransaction() {
|
||||
return jobBatchSize;
|
||||
}
|
||||
|
||||
public void setMaxNumberOfUpdatesPerTransaction(int jobBatchSize) {
|
||||
this.jobBatchSize = jobBatchSize;
|
||||
}
|
||||
|
||||
public int getMaxNumberOfJobRetries() {
|
||||
return maxNumberOfJobRetries;
|
||||
}
|
||||
|
||||
public void setMaxNumberOfJobRetries(int maxNumberOfJobRetries) {
|
||||
this.maxNumberOfJobRetries = maxNumberOfJobRetries;
|
||||
}
|
||||
|
||||
public boolean isCorpusChristiEnabled() {
|
||||
return corpusChristiEnabled;
|
||||
}
|
||||
|
||||
public void setCorpusChristiEnabled(boolean corpusChristiEnabled) {
|
||||
this.corpusChristiEnabled = corpusChristiEnabled;
|
||||
}
|
||||
|
||||
public boolean isGermanPublicHolidaysEnabled() {
|
||||
return this.germanPublicHolidaysEnabled;
|
||||
}
|
||||
|
||||
public void setGermanPublicHolidaysEnabled(boolean germanPublicHolidaysEnabled) {
|
||||
this.germanPublicHolidaysEnabled = germanPublicHolidaysEnabled;
|
||||
}
|
||||
|
||||
public boolean isValidationAllowTimestampServiceLevelMismatch() {
|
||||
return validationAllowTimestampServiceLevelMismatch;
|
||||
}
|
||||
|
||||
public void setValidationAllowTimestampServiceLevelMismatch(
|
||||
boolean validationAllowTimestampServiceLevelMismatch) {
|
||||
this.validationAllowTimestampServiceLevelMismatch =
|
||||
validationAllowTimestampServiceLevelMismatch;
|
||||
}
|
||||
|
||||
public boolean isDeleteHistoryOnTaskDeletionEnabled() {
|
||||
return deleteHistoryOnTaskDeletionEnabled;
|
||||
}
|
||||
|
||||
public void setDeleteHistoryOnTaskDeletionEnabled(boolean deleteHistoryOnTaskDeletionEnabled) {
|
||||
this.deleteHistoryOnTaskDeletionEnabled = deleteHistoryOnTaskDeletionEnabled;
|
||||
}
|
||||
|
||||
public List<CustomHoliday> getCustomHolidays() {
|
||||
return customHolidays;
|
||||
}
|
||||
|
||||
public void setCustomHolidays(List<CustomHoliday> customHolidays) {
|
||||
this.customHolidays = new ArrayList<>(customHolidays);
|
||||
}
|
||||
|
||||
public void addCustomHolidays(List<CustomHoliday> customHolidays) {
|
||||
this.customHolidays.addAll(customHolidays);
|
||||
}
|
||||
|
||||
public Map<TaskanaRole, Set<String>> getRoleMap() {
|
||||
return roleMap;
|
||||
}
|
||||
|
||||
public void setRoleMap(Map<TaskanaRole, Set<String>> roleMap) {
|
||||
this.roleMap = roleMap;
|
||||
}
|
||||
|
||||
public List<String> getDomains() {
|
||||
return domains;
|
||||
}
|
||||
|
||||
public void setDomains(List<String> domains) {
|
||||
this.domains = domains;
|
||||
}
|
||||
|
||||
public boolean getAddAdditionalUserInfo() {
|
||||
return addAdditionalUserInfo;
|
||||
}
|
||||
|
||||
public void setAddAdditionalUserInfo(boolean addAdditionalUserInfo) {
|
||||
this.addAdditionalUserInfo = addAdditionalUserInfo;
|
||||
}
|
||||
|
||||
public List<String> getClassificationTypes() {
|
||||
return classificationTypes;
|
||||
}
|
||||
|
||||
public void setClassificationTypes(List<String> classificationTypes) {
|
||||
this.classificationTypes = classificationTypes;
|
||||
}
|
||||
|
||||
public List<String> getAllClassificationCategories() {
|
||||
List<String> classificationCategories = new ArrayList<>();
|
||||
for (Map.Entry<String, List<String>> type : this.classificationCategoriesByTypeMap.entrySet()) {
|
||||
classificationCategories.addAll(type.getValue());
|
||||
}
|
||||
return classificationCategories;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getClassificationCategoriesByTypeMap() {
|
||||
return this.classificationCategoriesByTypeMap.entrySet().stream()
|
||||
.collect(Collectors.toMap(Entry::getKey, e -> new ArrayList<>(e.getValue())));
|
||||
}
|
||||
|
||||
public List<String> getClassificationCategoriesByType(String type) {
|
||||
return classificationCategoriesByTypeMap.getOrDefault(type, Collections.emptyList());
|
||||
}
|
||||
|
||||
public void setClassificationCategoriesByType(
|
||||
Map<String, List<String>> classificationCategoriesByType) {
|
||||
this.classificationCategoriesByTypeMap = classificationCategoriesByType;
|
||||
}
|
||||
|
||||
public Instant getCleanupJobFirstRun() {
|
||||
return cleanupJobFirstRun;
|
||||
}
|
||||
|
||||
public void setCleanupJobFirstRun(Instant cleanupJobFirstRun) {
|
||||
this.cleanupJobFirstRun = cleanupJobFirstRun;
|
||||
}
|
||||
|
||||
public Duration getCleanupJobRunEvery() {
|
||||
return cleanupJobRunEvery;
|
||||
}
|
||||
|
||||
public void setCleanupJobRunEvery(Duration cleanupJobRunEvery) {
|
||||
this.cleanupJobRunEvery = cleanupJobRunEvery;
|
||||
}
|
||||
|
||||
public Duration getCleanupJobMinimumAge() {
|
||||
return cleanupJobMinimumAge;
|
||||
}
|
||||
|
||||
public void setCleanupJobMinimumAge(Duration cleanupJobMinimumAge) {
|
||||
this.cleanupJobMinimumAge = cleanupJobMinimumAge;
|
||||
}
|
||||
|
||||
public boolean isTaskCleanupJobAllCompletedSameParentBusiness() {
|
||||
return taskCleanupJobAllCompletedSameParentBusiness;
|
||||
}
|
||||
|
||||
public void setTaskCleanupJobAllCompletedSameParentBusiness(
|
||||
boolean taskCleanupJobAllCompletedSameParentBusiness) {
|
||||
this.taskCleanupJobAllCompletedSameParentBusiness =
|
||||
taskCleanupJobAllCompletedSameParentBusiness;
|
||||
}
|
||||
|
||||
public int getPriorityJobBatchSize() {
|
||||
return priorityJobBatchSize;
|
||||
}
|
||||
|
||||
public void setPriorityJobBatchSize(int priorityJobBatchSize) {
|
||||
this.priorityJobBatchSize = priorityJobBatchSize;
|
||||
}
|
||||
|
||||
public Instant getPriorityJobFirstRun() {
|
||||
return priorityJobFirstRun;
|
||||
}
|
||||
|
||||
public void setPriorityJobFirstRun(Instant priorityJobFirstRun) {
|
||||
this.priorityJobFirstRun = priorityJobFirstRun;
|
||||
}
|
||||
|
||||
public Duration getPriorityJobRunEvery() {
|
||||
return priorityJobRunEvery;
|
||||
}
|
||||
|
||||
public void setPriorityJobRunEvery(Duration priorityJobRunEvery) {
|
||||
this.priorityJobRunEvery = priorityJobRunEvery;
|
||||
}
|
||||
|
||||
public Duration getUserRefreshJobRunEvery() {
|
||||
return userRefreshJobRunEvery;
|
||||
}
|
||||
|
||||
public void setUserRefreshJobRunEvery(Duration userRefreshJobRunEvery) {
|
||||
this.userRefreshJobRunEvery = userRefreshJobRunEvery;
|
||||
}
|
||||
|
||||
public List<WorkbasketPermission> getMinimalPermissionsToAssignDomains() {
|
||||
return minimalPermissionsToAssignDomains;
|
||||
}
|
||||
|
||||
public void setMinimalPermissionsToAssignDomains(
|
||||
List<WorkbasketPermission> minimalPermissionsToAssignDomains) {
|
||||
this.minimalPermissionsToAssignDomains = minimalPermissionsToAssignDomains;
|
||||
}
|
||||
|
||||
public Instant getUserRefreshJobFirstRun() {
|
||||
return userRefreshJobFirstRun;
|
||||
}
|
||||
|
||||
public void setUserRefreshJobFirstRun(Instant userRefreshJobFirstRun) {
|
||||
this.userRefreshJobFirstRun = userRefreshJobFirstRun;
|
||||
}
|
||||
|
||||
public boolean isPriorityJobActive() {
|
||||
return priorityJobActive;
|
||||
}
|
||||
|
||||
public void setPriorityJobActive(boolean priorityJobActive) {
|
||||
this.priorityJobActive = priorityJobActive;
|
||||
}
|
||||
|
||||
public String getSchemaName() {
|
||||
return schemaName;
|
||||
}
|
||||
|
||||
public void setSchemaName(String schemaName) {
|
||||
this.schemaName = schemaName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to determine whether all access ids (user Id and group ids) should be used in
|
||||
* lower case.
|
||||
*
|
||||
* @return true if all access ids should be used in lower case, false otherwise
|
||||
*/
|
||||
public static boolean shouldUseLowerCaseForAccessIds() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Properties readPropertiesFromFile() {
|
||||
return loadProperties(this.propertiesFileName);
|
||||
}
|
||||
|
||||
private void initSchemaName(String schemaName) {
|
||||
if (schemaName != null && !schemaName.isEmpty()) {
|
||||
this.setSchemaName(schemaName);
|
||||
} else {
|
||||
this.setSchemaName(DEFAULT_SCHEMA_NAME);
|
||||
}
|
||||
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
String databaseProductId = DB.getDatabaseProductId(connection);
|
||||
if (DB.isPostgres(databaseProductId)) {
|
||||
this.schemaName = this.schemaName.toLowerCase();
|
||||
} else {
|
||||
this.schemaName = this.schemaName.toUpperCase();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
LOGGER.error("Caught exception when attempting to initialize the schema name", ex);
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Using schema name {}", this.getSchemaName());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package pro.taskana.common.api;
|
|||
import java.sql.SQLException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.common.api.security.CurrentUserContext;
|
||||
|
@ -78,26 +78,25 @@ public interface TaskanaEngine {
|
|||
ConfigurationService getConfigurationService();
|
||||
|
||||
/**
|
||||
* Returns the {@linkplain TaskanaEngineConfiguration configuration} of the TaskanaEngine.
|
||||
* Returns the {@linkplain TaskanaConfiguration configuration} of the TaskanaEngine.
|
||||
*
|
||||
* @return {@linkplain TaskanaEngineConfiguration configuration}
|
||||
* @return {@linkplain TaskanaConfiguration configuration}
|
||||
*/
|
||||
TaskanaEngineConfiguration getConfiguration();
|
||||
TaskanaConfiguration getConfiguration();
|
||||
|
||||
/**
|
||||
* This method creates the {@linkplain TaskanaEngine} with {@linkplain
|
||||
* ConnectionManagementMode#PARTICIPATE }.
|
||||
*
|
||||
* @see TaskanaEngine#buildTaskanaEngine(TaskanaEngineConfiguration, ConnectionManagementMode)
|
||||
* @see TaskanaEngine#buildTaskanaEngine(TaskanaConfiguration, ConnectionManagementMode)
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||
static TaskanaEngine buildTaskanaEngine(TaskanaEngineConfiguration configuration)
|
||||
throws SQLException {
|
||||
static TaskanaEngine buildTaskanaEngine(TaskanaConfiguration configuration) throws SQLException {
|
||||
return buildTaskanaEngine(configuration, ConnectionManagementMode.PARTICIPATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an {@linkplain TaskanaEngine} based on {@linkplain TaskanaEngineConfiguration} and
|
||||
* Builds an {@linkplain TaskanaEngine} based on {@linkplain TaskanaConfiguration} and
|
||||
* SqlConnectionMode.
|
||||
*
|
||||
* @param configuration complete taskanaEngineConfig to build the engine
|
||||
|
@ -106,7 +105,7 @@ public interface TaskanaEngine {
|
|||
* @throws SQLException when the db schema could not be initialized
|
||||
*/
|
||||
static TaskanaEngine buildTaskanaEngine(
|
||||
TaskanaEngineConfiguration configuration, ConnectionManagementMode connectionManagementMode)
|
||||
TaskanaConfiguration configuration, ConnectionManagementMode connectionManagementMode)
|
||||
throws SQLException {
|
||||
return TaskanaEngineImpl.createTaskanaEngine(configuration, connectionManagementMode);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.ibatis.type.JdbcType;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.internal.ClassificationMapper;
|
||||
import pro.taskana.classification.internal.ClassificationQueryMapper;
|
||||
|
@ -98,14 +98,14 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
private final WorkingDaysToDaysConverter workingDaysToDaysConverter;
|
||||
private final HistoryEventManager historyEventManager;
|
||||
private final CurrentUserContext currentUserContext;
|
||||
protected TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
protected TaskanaConfiguration taskanaEngineConfiguration;
|
||||
protected TransactionFactory transactionFactory;
|
||||
protected SqlSessionManager sessionManager;
|
||||
protected ConnectionManagementMode mode;
|
||||
protected Connection connection;
|
||||
|
||||
protected TaskanaEngineImpl(
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
||||
TaskanaConfiguration taskanaEngineConfiguration,
|
||||
ConnectionManagementMode connectionManagementMode)
|
||||
throws SQLException {
|
||||
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
|
||||
|
@ -117,8 +117,8 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
taskanaEngineConfiguration.isCorpusChristiEnabled(),
|
||||
taskanaEngineConfiguration.getCustomHolidays());
|
||||
currentUserContext =
|
||||
new CurrentUserContextImpl(TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds());
|
||||
createTransactionFactory(taskanaEngineConfiguration.getUseManagedTransactions());
|
||||
new CurrentUserContextImpl(TaskanaConfiguration.shouldUseLowerCaseForAccessIds());
|
||||
createTransactionFactory(taskanaEngineConfiguration.isUseManagedTransactions());
|
||||
sessionManager = createSqlSessionManager();
|
||||
|
||||
initializeDbSchema(taskanaEngineConfiguration);
|
||||
|
@ -137,7 +137,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
}
|
||||
|
||||
public static TaskanaEngine createTaskanaEngine(
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
||||
TaskanaConfiguration taskanaEngineConfiguration,
|
||||
ConnectionManagementMode connectionManagementMode)
|
||||
throws SQLException {
|
||||
return new TaskanaEngineImpl(taskanaEngineConfiguration, connectionManagementMode);
|
||||
|
@ -204,7 +204,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TaskanaEngineConfiguration getConfiguration() {
|
||||
public TaskanaConfiguration getConfiguration() {
|
||||
return this.taskanaEngineConfiguration;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
return SqlSessionManager.newInstance(localSessionFactory);
|
||||
}
|
||||
|
||||
private void initializeDbSchema(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
||||
private void initializeDbSchema(TaskanaConfiguration taskanaEngineConfiguration)
|
||||
throws SQLException {
|
||||
DbSchemaCreator dbSchemaCreator =
|
||||
new DbSchemaCreator(
|
||||
|
|
|
@ -61,7 +61,7 @@ public class TaskCommentQueryImpl implements TaskCommentQuery {
|
|||
this.taskService = (TaskServiceImpl) taskanaEngine.getEngine().getTaskService();
|
||||
this.orderBy = new ArrayList<>();
|
||||
this.orderColumns = new ArrayList<>();
|
||||
this.joinWithUserInfo = taskanaEngine.getEngine().getConfiguration().getAddAdditionalUserInfo();
|
||||
this.joinWithUserInfo = taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -187,7 +187,7 @@ class TaskCommentServiceImpl {
|
|||
|
||||
taskService.getTask(result.getTaskId());
|
||||
|
||||
if (taskanaEngine.getEngine().getConfiguration().getAddAdditionalUserInfo()) {
|
||||
if (taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo()) {
|
||||
User creator = userMapper.findById(result.getCreator());
|
||||
if (creator != null) {
|
||||
result.setCreatorFullName(creator.getFullName());
|
||||
|
|
|
@ -340,7 +340,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
this.orderBy = new ArrayList<>();
|
||||
this.filterByAccessIdIn = true;
|
||||
this.withoutAttachment = false;
|
||||
this.joinWithUserInfo = taskanaEngine.getEngine().getConfiguration().getAddAdditionalUserInfo();
|
||||
this.joinWithUserInfo = taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -393,7 +393,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
if (resultTask.getOwner() != null
|
||||
&& !resultTask.getOwner().isEmpty()
|
||||
&& taskanaEngine.getEngine().getConfiguration().getAddAdditionalUserInfo()) {
|
||||
&& taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo()) {
|
||||
User owner = userMapper.findById(resultTask.getOwner());
|
||||
if (owner != null) {
|
||||
resultTask.setOwnerLongName(owner.getLongName());
|
||||
|
@ -1111,7 +1111,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
} else {
|
||||
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
|
||||
String userLongName;
|
||||
if (taskanaEngine.getEngine().getConfiguration().getAddAdditionalUserInfo()) {
|
||||
if (taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo()) {
|
||||
User user = userMapper.findById(userId);
|
||||
if (user != null) {
|
||||
userLongName = user.getLongName();
|
||||
|
@ -1220,7 +1220,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
NotAuthorizedException {
|
||||
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
|
||||
String userLongName = null;
|
||||
if (taskanaEngine.getEngine().getConfiguration().getAddAdditionalUserInfo()) {
|
||||
if (taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo()) {
|
||||
User user = userMapper.findById(userId);
|
||||
if (user != null) {
|
||||
userLongName = user.getLongName();
|
||||
|
@ -1274,8 +1274,8 @@ public class TaskServiceImpl implements TaskService {
|
|||
task.getId(), task.getState(), EnumUtil.allValuesExceptFor(TaskState.END_STATES));
|
||||
}
|
||||
if (!force && taskIsNotClaimed(task)) {
|
||||
throw new InvalidTaskStateException(task.getId(), task.getState(), TaskState.CLAIMED,
|
||||
TaskState.IN_REVIEW);
|
||||
throw new InvalidTaskStateException(
|
||||
task.getId(), task.getState(), TaskState.CLAIMED, TaskState.IN_REVIEW);
|
||||
}
|
||||
if (!force && !task.getOwner().equals(userId)) {
|
||||
throw new InvalidOwnerException(userId, task.getId());
|
||||
|
@ -1717,7 +1717,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
task.setDescription(classification.getDescription());
|
||||
}
|
||||
if (task.getOwner() != null
|
||||
&& taskanaEngine.getEngine().getConfiguration().getAddAdditionalUserInfo()) {
|
||||
&& taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo()) {
|
||||
User user = userMapper.findById(task.getOwner());
|
||||
if (user != null) {
|
||||
task.setOwnerLongName(user.getLongName());
|
||||
|
|
|
@ -2,7 +2,7 @@ package pro.taskana.user.api.models;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
|
||||
/** The User holds some relevant information about the TASKANA users. */
|
||||
public interface User {
|
||||
|
@ -208,7 +208,7 @@ public interface User {
|
|||
*
|
||||
* <p>The domains are derived from the {@linkplain pro.taskana.workbasket.api.WorkbasketPermission
|
||||
* WorkbasketPermissions} and the according TASKANA property {@linkplain
|
||||
* TaskanaEngineConfiguration#getMinimalPermissionsToAssignDomains()}.
|
||||
* TaskanaConfiguration#getMinimalPermissionsToAssignDomains()}.
|
||||
*
|
||||
* @return domains
|
||||
*/
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.apache.ibatis.exceptions.PersistenceException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.BaseQuery.SortDirection;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
|
@ -52,7 +52,7 @@ public class UserServiceImpl implements UserService {
|
|||
throw new InvalidArgumentException("UserId can't be used as NULL-Parameter.");
|
||||
}
|
||||
String finalUserId;
|
||||
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
if (TaskanaConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
finalUserId = userId.toLowerCase();
|
||||
} else {
|
||||
finalUserId = userId;
|
||||
|
@ -74,7 +74,7 @@ public class UserServiceImpl implements UserService {
|
|||
throw new InvalidArgumentException("UserIds can't be used as NULL-Parameter.");
|
||||
}
|
||||
Set<String> finalUserIds;
|
||||
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
if (TaskanaConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
finalUserIds = userIds.stream().map(String::toLowerCase).collect(Collectors.toSet());
|
||||
} else {
|
||||
finalUserIds = userIds;
|
||||
|
@ -202,7 +202,7 @@ public class UserServiceImpl implements UserService {
|
|||
if (user.getLongName() == null || user.getLongName().isEmpty()) {
|
||||
user.setLongName(user.getFullName() + " - (" + user.getId() + ")");
|
||||
}
|
||||
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
if (TaskanaConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
user.setId(user.getId().toLowerCase());
|
||||
user.setGroups(
|
||||
user.getGroups().stream().map((String::toLowerCase)).collect(Collectors.toSet()));
|
||||
|
@ -223,7 +223,7 @@ public class UserServiceImpl implements UserService {
|
|||
newUser.setLongName(newUser.getFullName() + " - (" + newUser.getId() + ")");
|
||||
}
|
||||
}
|
||||
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
if (TaskanaConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
newUser.setId(newUser.getId().toLowerCase());
|
||||
newUser.setGroups(
|
||||
newUser.getGroups().stream().map((String::toLowerCase)).collect(Collectors.toSet()));
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
import org.apache.ibatis.exceptions.PersistenceException;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.TimeInterval;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
|
@ -65,9 +65,9 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
private String[] orgLevel4Like;
|
||||
private Boolean markedForDeletion;
|
||||
|
||||
private InternalTaskanaEngine taskanaEngine;
|
||||
private List<String> orderBy;
|
||||
private List<String> orderColumns;
|
||||
private final InternalTaskanaEngine taskanaEngine;
|
||||
private final List<String> orderBy;
|
||||
private final List<String> orderColumns;
|
||||
private boolean joinWithAccessList;
|
||||
private boolean checkReadPermission;
|
||||
private boolean usedToAugmentTasks;
|
||||
|
@ -581,7 +581,7 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
}
|
||||
|
||||
public static void lowercaseAccessIds(String[] accessIdArray) {
|
||||
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
if (TaskanaConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
for (int i = 0; i < accessIdArray.length; i++) {
|
||||
String id = accessIdArray[i];
|
||||
if (id != null) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.apache.ibatis.exceptions.PersistenceException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.BulkOperationResults;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.exceptions.ConcurrencyException;
|
||||
|
@ -241,7 +241,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
public WorkbasketAccessItem newWorkbasketAccessItem(String workbasketId, String accessId) {
|
||||
WorkbasketAccessItemImpl accessItem = new WorkbasketAccessItemImpl();
|
||||
accessItem.setWorkbasketId(workbasketId);
|
||||
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
if (TaskanaConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
accessItem.setAccessId(accessId != null ? accessId.toLowerCase() : null);
|
||||
} else {
|
||||
accessItem.setAccessId(accessId);
|
||||
|
@ -919,7 +919,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds() && accessId != null) {
|
||||
if (TaskanaConfiguration.shouldUseLowerCaseForAccessIds() && accessId != null) {
|
||||
accessId = accessId.toLowerCase();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import javax.sql.DataSource;
|
|||
import org.apache.ibatis.session.SqlSessionManager;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.common.api.TimeInterval;
|
||||
|
@ -37,7 +37,7 @@ public abstract class AbstractAccTest {
|
|||
public static final String GROUP_2_DN =
|
||||
"cn=Organisationseinheit KSC 2,cn=Organisationseinheit KSC,cn=organisation,OU=Test,O=TASKANA";
|
||||
|
||||
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaEngine taskanaEngine;
|
||||
|
||||
protected static TaskServiceImpl taskService;
|
||||
|
@ -52,8 +52,11 @@ public abstract class AbstractAccTest {
|
|||
|
||||
DataSource dataSource = DataSourceGenerator.getDataSource();
|
||||
String schemaName = DataSourceGenerator.getSchemaName();
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaName);
|
||||
taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(true);
|
||||
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(dataSource, false, schemaName)
|
||||
.germanPublicHolidaysEnabled(true)
|
||||
.build();
|
||||
SampleDataGenerator sampleDataGenerator =
|
||||
new SampleDataGenerator(dataSource, taskanaEngineConfiguration.getSchemaName());
|
||||
if (dropTables) {
|
||||
|
@ -69,7 +72,8 @@ public abstract class AbstractAccTest {
|
|||
sampleDataGenerator.generateTestData();
|
||||
}
|
||||
|
||||
protected JobMapper getJobMapper() throws NoSuchFieldException, IllegalAccessException {
|
||||
protected JobMapper getJobMapper(TaskanaEngine taskanaEngine)
|
||||
throws NoSuchFieldException, IllegalAccessException {
|
||||
|
||||
Field sessionManagerField = TaskanaEngineImpl.class.getDeclaredField("sessionManager");
|
||||
sessionManagerField.setAccessible(true);
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.test.config.DataSourceGenerator;
|
||||
import pro.taskana.workbasket.api.WorkbasketPermission;
|
||||
|
||||
|
@ -22,13 +22,14 @@ import pro.taskana.workbasket.api.WorkbasketPermission;
|
|||
class TaskanaConfigAccTest {
|
||||
|
||||
@TempDir Path tempDir;
|
||||
private TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
private TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
DataSourceGenerator.getDataSource(), true, DataSourceGenerator.getSchemaName());
|
||||
new TaskanaConfiguration.Builder(
|
||||
DataSourceGenerator.getDataSource(), true, DataSourceGenerator.getSchemaName())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,13 +61,14 @@ class TaskanaConfigAccTest {
|
|||
String propertiesFileName = createNewConfigFile("dummyTestConfig1.properties", false, true);
|
||||
String delimiter = ";";
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter,
|
||||
DataSourceGenerator.getSchemaName());
|
||||
new TaskanaConfiguration.Builder(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter)
|
||||
.build();
|
||||
assertThat(taskanaEngineConfiguration.getClassificationTypes()).isEmpty();
|
||||
}
|
||||
|
||||
|
@ -75,13 +77,14 @@ class TaskanaConfigAccTest {
|
|||
String propertiesFileName = createNewConfigFile("dummyTestConfig2.properties", true, false);
|
||||
String delimiter = ";";
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter,
|
||||
DataSourceGenerator.getSchemaName());
|
||||
new TaskanaConfiguration.Builder(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter)
|
||||
.build();
|
||||
assertThat(taskanaEngineConfiguration.getClassificationCategoriesByTypeMap())
|
||||
.containsExactly(
|
||||
Map.entry("TASK", Collections.emptyList()),
|
||||
|
@ -93,13 +96,14 @@ class TaskanaConfigAccTest {
|
|||
String propertiesFileName = createNewConfigFile("dummyTestConfig3.properties", true, true);
|
||||
String delimiter = ";";
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter,
|
||||
DataSourceGenerator.getSchemaName());
|
||||
new TaskanaConfiguration.Builder(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter)
|
||||
.build();
|
||||
assertThat(taskanaEngineConfiguration.getClassificationCategoriesByTypeMap())
|
||||
.containsExactly(
|
||||
Map.entry("TASK", List.of("EXTERNAL", "MANUAL", "AUTOMATIC", "PROCESS")),
|
||||
|
|
|
@ -5,7 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import javax.sql.DataSource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.CustomHoliday;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.test.config.DataSourceGenerator;
|
||||
|
@ -16,8 +16,8 @@ class TaskanaEngineConfigTest {
|
|||
@Test
|
||||
void should_ReturnTaskanaEngine_When_BuildingWithConfiguration() throws Exception {
|
||||
DataSource ds = DataSourceGenerator.getDataSource();
|
||||
TaskanaEngineConfiguration taskEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(ds, false, DataSourceGenerator.getSchemaName());
|
||||
TaskanaConfiguration taskEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(ds, false, DataSourceGenerator.getSchemaName()).build();
|
||||
|
||||
TaskanaEngine te = TaskanaEngine.buildTaskanaEngine(taskEngineConfiguration);
|
||||
|
||||
|
@ -27,14 +27,15 @@ class TaskanaEngineConfigTest {
|
|||
@Test
|
||||
void should_SetCorpusChristiEnabled_When_PropertyIsSet() throws Exception {
|
||||
DataSource ds = DataSourceGenerator.getDataSource();
|
||||
TaskanaEngineConfiguration taskEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
ds,
|
||||
false,
|
||||
true,
|
||||
"/corpusChristiEnabled.properties",
|
||||
"|",
|
||||
DataSourceGenerator.getSchemaName());
|
||||
TaskanaConfiguration taskEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(
|
||||
ds,
|
||||
false,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
true,
|
||||
"/corpusChristiEnabled.properties",
|
||||
"|")
|
||||
.build();
|
||||
|
||||
assertThat(taskEngineConfiguration.isCorpusChristiEnabled()).isTrue();
|
||||
}
|
||||
|
@ -43,14 +44,15 @@ class TaskanaEngineConfigTest {
|
|||
void should_ReturnTheTwoCustomHolidays_When_TwoCustomHolidaysAreConfiguredInThePropertiesFile()
|
||||
throws Exception {
|
||||
DataSource ds = DataSourceGenerator.getDataSource();
|
||||
TaskanaEngineConfiguration taskEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
ds,
|
||||
false,
|
||||
true,
|
||||
"/custom_holiday_taskana.properties",
|
||||
"|",
|
||||
DataSourceGenerator.getSchemaName());
|
||||
TaskanaConfiguration taskEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(
|
||||
ds,
|
||||
false,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
true,
|
||||
"/custom_holiday_taskana.properties",
|
||||
"|")
|
||||
.build();
|
||||
assertThat(taskEngineConfiguration.getCustomHolidays()).contains(CustomHoliday.of(31, 7));
|
||||
assertThat(taskEngineConfiguration.getCustomHolidays()).contains(CustomHoliday.of(16, 12));
|
||||
}
|
||||
|
@ -59,14 +61,15 @@ class TaskanaEngineConfigTest {
|
|||
void should_ReturnEmptyCustomHolidaysList_When_AllCustomHolidaysAreInWrongFormatInPropertiesFile()
|
||||
throws Exception {
|
||||
DataSource ds = DataSourceGenerator.getDataSource();
|
||||
TaskanaEngineConfiguration taskEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
ds,
|
||||
false,
|
||||
true,
|
||||
"/custom_holiday_with_wrong_format_taskana.properties",
|
||||
"|",
|
||||
DataSourceGenerator.getSchemaName());
|
||||
TaskanaConfiguration taskEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(
|
||||
ds,
|
||||
false,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
true,
|
||||
"/custom_holiday_with_wrong_format_taskana.properties",
|
||||
"|")
|
||||
.build();
|
||||
assertThat(taskEngineConfiguration.getCustomHolidays()).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.test.config.DataSourceGenerator;
|
||||
|
||||
|
@ -19,13 +19,14 @@ import pro.taskana.common.test.config.DataSourceGenerator;
|
|||
class TaskanaRoleConfigAccTest {
|
||||
|
||||
@TempDir Path tempDir;
|
||||
private TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
private TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
DataSourceGenerator.getDataSource(), true, DataSourceGenerator.getSchemaName());
|
||||
new TaskanaConfiguration.Builder(
|
||||
DataSourceGenerator.getDataSource(), true, DataSourceGenerator.getSchemaName())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -72,13 +73,14 @@ class TaskanaRoleConfigAccTest {
|
|||
String propertiesFileName = createNewConfigFileWithSameDelimiter("dummyTestConfig.properties");
|
||||
String delimiter = "|";
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter,
|
||||
DataSourceGenerator.getSchemaName());
|
||||
new TaskanaConfiguration.Builder(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter)
|
||||
.build();
|
||||
|
||||
Set<TaskanaRole> rolesConfigured = taskanaEngineConfiguration.getRoleMap().keySet();
|
||||
assertThat(rolesConfigured).containsExactlyInAnyOrder(TaskanaRole.values());
|
||||
|
@ -104,13 +106,14 @@ class TaskanaRoleConfigAccTest {
|
|||
createNewConfigFileWithDifferentDelimiter("dummyTestConfig.properties", delimiter);
|
||||
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter,
|
||||
DataSourceGenerator.getSchemaName());
|
||||
new TaskanaConfiguration.Builder(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
true,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
true,
|
||||
propertiesFileName,
|
||||
delimiter)
|
||||
.build();
|
||||
|
||||
Set<TaskanaRole> rolesConfigured = taskanaEngineConfiguration.getRoleMap().keySet();
|
||||
assertThat(rolesConfigured).containsExactlyInAnyOrder(TaskanaRole.values());
|
||||
|
|
|
@ -12,7 +12,7 @@ import javax.sql.DataSource;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.common.internal.configuration.DB;
|
||||
|
@ -77,11 +77,12 @@ class TaskanaSecurityConfigAccTest {
|
|||
|
||||
private void createTaskanaEngine(boolean securityEnabled) throws SQLException {
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
new TaskanaEngineConfiguration(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
false,
|
||||
securityEnabled,
|
||||
DataSourceGenerator.getSchemaName()));
|
||||
new TaskanaConfiguration.Builder(
|
||||
DataSourceGenerator.getDataSource(),
|
||||
false,
|
||||
DataSourceGenerator.getSchemaName(),
|
||||
securityEnabled)
|
||||
.build());
|
||||
}
|
||||
|
||||
private Boolean retrieveSecurityFlag() throws Exception {
|
||||
|
|
|
@ -66,7 +66,7 @@ class JobRunnerAccTest extends AbstractAccTest {
|
|||
// runEvery is set to P1D Therefore we need to check which jobs run tomorrow.
|
||||
// Just to be sure the jobs are found we will look for any job scheduled in the next 2 days.
|
||||
List<ScheduledJob> jobsToRun =
|
||||
getJobMapper().findJobsToRun(Instant.now().plus(2, ChronoUnit.DAYS));
|
||||
getJobMapper(taskanaEngine).findJobsToRun(Instant.now().plus(2, ChronoUnit.DAYS));
|
||||
|
||||
assertThat(jobsToRun).hasSize(1).doesNotContain(job);
|
||||
}
|
||||
|
|
|
@ -19,13 +19,17 @@ import org.junit.jupiter.api.TestFactory;
|
|||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.function.ThrowingConsumer;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.internal.jobs.ClassificationChangedJob;
|
||||
import pro.taskana.common.api.ScheduledJob;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.common.internal.JobMapper;
|
||||
import pro.taskana.common.internal.JobServiceImpl;
|
||||
import pro.taskana.common.internal.jobs.JobRunner;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
import pro.taskana.common.test.security.WithAccessId;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.api.models.TaskSummary;
|
||||
import pro.taskana.task.internal.jobs.TaskCleanupJob;
|
||||
|
@ -45,15 +49,21 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_CleanCompletedTasksUntilDate() throws Exception {
|
||||
String taskId = createAndInsertTask(null);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.taskCleanupJobAllCompletedSameParentBusiness(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine =
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
String taskId = createAndInsertTask(taskService, null);
|
||||
taskService.claim(taskId);
|
||||
taskService.completeTask(taskId);
|
||||
|
||||
long totalTasksCount = taskService.createTaskQuery().count();
|
||||
assertThat(totalTasksCount).isEqualTo(100);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(false);
|
||||
|
||||
TaskCleanupJob job = new TaskCleanupJob(taskanaEngine, null, null);
|
||||
job.run();
|
||||
|
||||
|
@ -67,10 +77,20 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
long totalTasksCount = taskService.createTaskQuery().count();
|
||||
assertThat(totalTasksCount).isEqualTo(99);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngine.getConfiguration())
|
||||
.taskCleanupJobAllCompletedSameParentBusiness(true)
|
||||
.build();
|
||||
|
||||
TaskanaEngine taskanaEngine =
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||
List<TaskSummary> tasks =
|
||||
taskService.createTaskQuery().parentBusinessProcessIdIn("DOC_0000000000000000006").list();
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.parentBusinessProcessIdIn("DOC_0000000000000000006")
|
||||
.list();
|
||||
List<String> ids = new ArrayList<>();
|
||||
tasks.forEach(
|
||||
item -> {
|
||||
|
@ -78,19 +98,19 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
ids.add(item.getId());
|
||||
}
|
||||
});
|
||||
taskService.deleteTasks(ids);
|
||||
taskanaEngine.getTaskService().deleteTasks(ids);
|
||||
|
||||
TaskCleanupJob job = new TaskCleanupJob(taskanaEngine, null, null);
|
||||
job.run();
|
||||
|
||||
totalTasksCount = taskService.createTaskQuery().count();
|
||||
totalTasksCount = taskanaEngine.getTaskService().createTaskQuery().count();
|
||||
assertThat(totalTasksCount).isEqualTo(79);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void shouldNotCleanCompleteTasksAfterDefinedDay() throws Exception {
|
||||
String taskId = createAndInsertTask(null);
|
||||
String taskId = createAndInsertTask(taskService, null);
|
||||
taskService.claim(taskId);
|
||||
taskService.completeTask(taskId);
|
||||
|
||||
|
@ -115,7 +135,7 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
taskanaEngine.getJobService().createJob(job);
|
||||
}
|
||||
|
||||
List<ScheduledJob> jobsToRun = getJobMapper().findJobsToRun(Instant.now());
|
||||
List<ScheduledJob> jobsToRun = getJobMapper(taskanaEngine).findJobsToRun(Instant.now());
|
||||
|
||||
assertThat(jobsToRun).hasSize(30);
|
||||
|
||||
|
@ -126,7 +146,7 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
|
||||
TaskCleanupJob.initializeSchedule(taskanaEngine);
|
||||
|
||||
jobsToRun = getJobMapper().findJobsToRun(Instant.now());
|
||||
jobsToRun = getJobMapper(taskanaEngine).findJobsToRun(Instant.now());
|
||||
|
||||
assertThat(jobsToRun).doesNotContainAnyElementsOf(taskCleanupJobs);
|
||||
}
|
||||
|
@ -134,19 +154,27 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "admin")
|
||||
@TestFactory
|
||||
Stream<DynamicTest>
|
||||
should_DeleteCompletedTaskWithParentBusinessEmptyOrNull_When_RunningCleanupJob() {
|
||||
should_DeleteCompletedTaskWithParentBusinessEmptyOrNull_When_RunningCleanupJob()
|
||||
throws Exception {
|
||||
Iterator<String> iterator = Arrays.asList("", null).iterator();
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
|
||||
taskanaEngine.getConfiguration().setCleanupJobMinimumAge(Duration.ZERO);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngine.getConfiguration())
|
||||
.taskCleanupJobAllCompletedSameParentBusiness(true)
|
||||
.cleanupJobMinimumAge(Duration.ZERO)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine =
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||
TaskCleanupJob job = new TaskCleanupJob(taskanaEngine, null, null);
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
ThrowingConsumer<String> test =
|
||||
parentBusinessId -> {
|
||||
String taskId1 = createAndInsertTask(parentBusinessId);
|
||||
String taskId1 = createAndInsertTask(taskService, parentBusinessId);
|
||||
taskService.claim(taskId1);
|
||||
taskService.completeTask(taskId1);
|
||||
String taskId2 = createAndInsertTask(parentBusinessId);
|
||||
String taskId2 = createAndInsertTask(taskService, parentBusinessId);
|
||||
taskService.claim(taskId2);
|
||||
|
||||
job.run();
|
||||
|
@ -163,7 +191,7 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
void should_SetNextScheduledJobBasedOnDueDateOfPredecessor_When_RunningTaskCleanupJob()
|
||||
throws Exception {
|
||||
JobMapper jobMapper = getJobMapper();
|
||||
JobMapper jobMapper = getJobMapper(AbstractAccTest.taskanaEngine);
|
||||
List<ScheduledJob> jobsToRun = jobMapper.findJobsToRun(Instant.now());
|
||||
assertThat(jobsToRun).isEmpty();
|
||||
|
||||
|
@ -191,12 +219,19 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
void should_ScheduleNextJobAccordingToFirstRun_When_PreviousJobNotExisting() throws Exception {
|
||||
Instant firstRun = Instant.now().minus(2, ChronoUnit.MINUTES).truncatedTo(ChronoUnit.MILLIS);
|
||||
Duration runEvery = Duration.ofMinutes(5);
|
||||
taskanaEngineConfiguration.setCleanupJobRunEvery(runEvery);
|
||||
taskanaEngineConfiguration.setCleanupJobFirstRun(firstRun);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.cleanupJobRunEvery(runEvery)
|
||||
.cleanupJobFirstRun(firstRun)
|
||||
.build();
|
||||
|
||||
TaskanaEngine taskanaEngine =
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||
TaskCleanupJob.initializeSchedule(taskanaEngine);
|
||||
|
||||
List<ScheduledJob> nextJobs = getJobMapper().findJobsToRun(Instant.now().plus(runEvery));
|
||||
List<ScheduledJob> nextJobs =
|
||||
getJobMapper(taskanaEngine).findJobsToRun(Instant.now().plus(runEvery));
|
||||
assertThat(nextJobs).extracting(ScheduledJob::getDue).containsExactly(firstRun.plus(runEvery));
|
||||
}
|
||||
|
||||
|
@ -204,16 +239,21 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
void should_FindNoJobsToRunUntilFirstRunIsReached_When_CleanupScheduleIsInitialized()
|
||||
throws Exception {
|
||||
taskanaEngineConfiguration.setCleanupJobRunEvery(Duration.ZERO);
|
||||
taskanaEngineConfiguration.setCleanupJobFirstRun(Instant.now().plus(5, ChronoUnit.MINUTES));
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngine.getConfiguration())
|
||||
.cleanupJobRunEvery(Duration.ZERO)
|
||||
.cleanupJobFirstRun(Instant.now().plus(5, ChronoUnit.MINUTES))
|
||||
.build();
|
||||
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
TaskCleanupJob.initializeSchedule(taskanaEngine);
|
||||
|
||||
List<ScheduledJob> nextJobs = getJobMapper().findJobsToRun(Instant.now());
|
||||
List<ScheduledJob> nextJobs = getJobMapper(taskanaEngine).findJobsToRun(Instant.now());
|
||||
assertThat(nextJobs).isEmpty();
|
||||
}
|
||||
|
||||
private String createAndInsertTask(String parentBusinessProcessId) throws Exception {
|
||||
private String createAndInsertTask(TaskService taskService, String parentBusinessProcessId)
|
||||
throws Exception {
|
||||
Task newTask = taskService.newTask("user-1-1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setPrimaryObjRef(
|
||||
|
|
|
@ -13,8 +13,11 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.BaseQuery.SortDirection;
|
||||
import pro.taskana.common.api.ScheduledJob;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
import pro.taskana.common.test.security.WithAccessId;
|
||||
|
@ -31,10 +34,14 @@ class TaskUpdatePriorityJobAccTest extends AbstractAccTest {
|
|||
// TODO split test class into readOnly & modifying tests to improve performance
|
||||
resetDb(true);
|
||||
|
||||
taskanaEngineConfiguration.setPriorityJobActive(true);
|
||||
taskanaEngineConfiguration.setPriorityJobBatchSize(20);
|
||||
taskanaEngineConfiguration.setPriorityJobRunEvery(Duration.ofMinutes(30));
|
||||
taskanaEngineConfiguration.setPriorityJobFirstRun(Instant.parse("2007-12-03T10:15:30.00Z"));
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.priorityJobActive(true)
|
||||
.priorityJobBatchSize(20)
|
||||
.priorityJobRunEvery(Duration.ofMinutes(30))
|
||||
.priorityJobFirstRun(Instant.parse("2007-12-03T10:15:30.00Z"))
|
||||
.build();
|
||||
taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -49,10 +56,14 @@ class TaskUpdatePriorityJobAccTest extends AbstractAccTest {
|
|||
|
||||
@Test
|
||||
@WithAccessId(user = "admin")
|
||||
void should_catchException_When_executedWithWrongSettings() {
|
||||
void should_catchException_When_executedWithWrongSettings() throws Exception {
|
||||
// given
|
||||
taskanaEngineConfiguration.setPriorityJobBatchSize(0);
|
||||
TaskUpdatePriorityJob job = new TaskUpdatePriorityJob(taskanaEngine);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.priorityJobBatchSize(0)
|
||||
.build();
|
||||
TaskUpdatePriorityJob job =
|
||||
new TaskUpdatePriorityJob(TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration));
|
||||
|
||||
// then
|
||||
assertThatThrownBy(job::execute).isInstanceOf(SystemException.class);
|
||||
|
@ -60,9 +71,13 @@ class TaskUpdatePriorityJobAccTest extends AbstractAccTest {
|
|||
|
||||
@Test
|
||||
@WithAccessId(user = "admin")
|
||||
void should_doNothing_When_NotActive() {
|
||||
void should_doNothing_When_NotActive() throws Exception {
|
||||
// given
|
||||
taskanaEngineConfiguration.setPriorityJobActive(false);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.priorityJobActive(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
TaskUpdatePriorityJob job = new TaskUpdatePriorityJob(taskanaEngine);
|
||||
List<String> priorities =
|
||||
taskanaEngine
|
||||
|
@ -85,15 +100,19 @@ class TaskUpdatePriorityJobAccTest extends AbstractAccTest {
|
|||
|
||||
@Test
|
||||
@WithAccessId(user = "admin")
|
||||
void should_ScheduleNextJob() throws NoSuchFieldException, IllegalAccessException {
|
||||
void should_ScheduleNextJob() throws Exception {
|
||||
// given
|
||||
final Instant someTimeInTheFuture = Instant.now().plus(10, ChronoUnit.DAYS);
|
||||
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration).build();
|
||||
TaskanaEngine taskanaEngine =
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||
// when
|
||||
TaskUpdatePriorityJob.initializeSchedule(taskanaEngine);
|
||||
|
||||
// then
|
||||
assertThat(getJobMapper().findJobsToRun(someTimeInTheFuture))
|
||||
assertThat(getJobMapper(taskanaEngine).findJobsToRun(someTimeInTheFuture))
|
||||
.hasSizeGreaterThanOrEqualTo(1)
|
||||
.extracting(ScheduledJob::getType)
|
||||
.contains(TaskUpdatePriorityJob.class.getName());
|
||||
|
@ -101,12 +120,16 @@ class TaskUpdatePriorityJobAccTest extends AbstractAccTest {
|
|||
|
||||
@Test
|
||||
@WithAccessId(user = "admin")
|
||||
void should_readConfigurationForBatchSize() {
|
||||
void should_readConfigurationForBatchSize() throws Exception {
|
||||
// given
|
||||
taskanaEngineConfiguration.setPriorityJobBatchSize(20);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.priorityJobBatchSize(20)
|
||||
.build();
|
||||
|
||||
// when
|
||||
final TaskUpdatePriorityJob job = new TaskUpdatePriorityJob(taskanaEngine);
|
||||
final TaskUpdatePriorityJob job =
|
||||
new TaskUpdatePriorityJob(TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration));
|
||||
|
||||
// then
|
||||
assertThat(job.getBatchSize()).isEqualTo(20);
|
||||
|
@ -114,25 +137,33 @@ class TaskUpdatePriorityJobAccTest extends AbstractAccTest {
|
|||
|
||||
@Test
|
||||
@WithAccessId(user = "admin")
|
||||
void should_readConfigurationForIsActive() {
|
||||
void should_readConfigurationForIsActive() throws Exception {
|
||||
// given
|
||||
taskanaEngineConfiguration.setPriorityJobActive(false);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.priorityJobActive(false)
|
||||
.build();
|
||||
|
||||
// when
|
||||
final TaskUpdatePriorityJob job = new TaskUpdatePriorityJob(taskanaEngine);
|
||||
final TaskUpdatePriorityJob job =
|
||||
new TaskUpdatePriorityJob(TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration));
|
||||
|
||||
// then
|
||||
assertThat(job.isJobActive()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_containInformation_When_convertedToString() {
|
||||
void should_containInformation_When_convertedToString() throws Exception {
|
||||
// given
|
||||
taskanaEngineConfiguration.setPriorityJobBatchSize(543);
|
||||
taskanaEngineConfiguration.setPriorityJobRunEvery(Duration.ofMinutes(30));
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.priorityJobBatchSize(543)
|
||||
.priorityJobRunEvery(Duration.ofMinutes(30))
|
||||
.build();
|
||||
|
||||
// when
|
||||
final TaskUpdatePriorityJob job = new TaskUpdatePriorityJob(taskanaEngine);
|
||||
final TaskUpdatePriorityJob job =
|
||||
new TaskUpdatePriorityJob(TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration));
|
||||
|
||||
// then
|
||||
assertThat(job).asString().contains("543").contains(Duration.ofMinutes(30).toString());
|
||||
|
|
|
@ -102,7 +102,7 @@ class WorkbasketCleanupJobAccTest extends AbstractAccTest {
|
|||
taskanaEngine.getJobService().createJob(job);
|
||||
}
|
||||
|
||||
List<ScheduledJob> jobsToRun = getJobMapper().findJobsToRun(Instant.now());
|
||||
List<ScheduledJob> jobsToRun = getJobMapper(taskanaEngine).findJobsToRun(Instant.now());
|
||||
|
||||
assertThat(jobsToRun).hasSize(30);
|
||||
|
||||
|
@ -114,7 +114,7 @@ class WorkbasketCleanupJobAccTest extends AbstractAccTest {
|
|||
|
||||
WorkbasketCleanupJob.initializeSchedule(taskanaEngine);
|
||||
|
||||
jobsToRun = getJobMapper().findJobsToRun(Instant.now());
|
||||
jobsToRun = getJobMapper(taskanaEngine).findJobsToRun(Instant.now());
|
||||
|
||||
assertThat(jobsToRun).doesNotContainAnyElementsOf(workbasketCleanupJobs);
|
||||
}
|
||||
|
|
|
@ -8,9 +8,12 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
|
@ -64,9 +67,14 @@ class SqlConnectionRunnerAccTest extends AbstractAccTest {
|
|||
|
||||
@Test
|
||||
@WithAccessId(user = "admin")
|
||||
@Disabled("This Test does not make sense anymore")
|
||||
void should_SetOriginalSchema_When_ExceptionThrown() throws Exception {
|
||||
|
||||
taskanaEngine.getConfiguration().setSchemaName("NotExisting");
|
||||
TaskanaEngine taskanaEngine =
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngine.getConfiguration())
|
||||
.schemaName("NotExisting")
|
||||
.build());
|
||||
SqlConnectionRunner runner = new SqlConnectionRunner(taskanaEngine);
|
||||
|
||||
// TSK-1749
|
||||
|
|
|
@ -83,12 +83,12 @@ class PriorityServiceAccTest extends AbstractAccTest {
|
|||
classification.setPriority(10);
|
||||
|
||||
classificationService.updateClassification(classification);
|
||||
List<ScheduledJob> jobsToRun = getJobMapper().findJobsToRun(Instant.now());
|
||||
List<ScheduledJob> jobsToRun = getJobMapper(taskanaEngine).findJobsToRun(Instant.now());
|
||||
assertThat(jobsToRun).isEmpty();
|
||||
|
||||
classification.setServiceLevel("P4D");
|
||||
classificationService.updateClassification(classification);
|
||||
jobsToRun = getJobMapper().findJobsToRun(Instant.now());
|
||||
jobsToRun = getJobMapper(taskanaEngine).findJobsToRun(Instant.now());
|
||||
assertThat(jobsToRun).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package acceptance.report;
|
|||
import javax.sql.DataSource;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.test.config.DataSourceGenerator;
|
||||
import pro.taskana.sampledata.SampleDataGenerator;
|
||||
|
@ -11,14 +11,16 @@ import pro.taskana.sampledata.SampleDataGenerator;
|
|||
/** Abstract test class for all report building tests. */
|
||||
public abstract class AbstractReportAccTest {
|
||||
|
||||
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaEngine taskanaEngine;
|
||||
|
||||
protected static void resetDb() throws Exception {
|
||||
DataSource dataSource = DataSourceGenerator.getDataSource();
|
||||
String schemaName = DataSourceGenerator.getSchemaName();
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaName);
|
||||
taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(false);
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(dataSource, false, schemaName)
|
||||
.germanPublicHolidaysEnabled(false)
|
||||
.build();
|
||||
taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
taskanaEngine.setConnectionManagementMode(TaskanaEngine.ConnectionManagementMode.AUTOCOMMIT);
|
||||
SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(dataSource, schemaName);
|
||||
|
|
|
@ -20,10 +20,12 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestTemplate;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
import pro.taskana.classification.internal.models.ClassificationSummaryImpl;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
|
@ -146,7 +148,13 @@ class CreateTaskAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_CreateTaskWithAdditionalUserInfo() throws Exception {
|
||||
taskanaEngine.getConfiguration().setAddAdditionalUserInfo(true);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(true)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
Task newTask = taskService.newTask("USER-1-1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
ObjectReferenceImpl objectReference =
|
||||
|
@ -160,8 +168,6 @@ class CreateTaskAccTest extends AbstractAccTest {
|
|||
assertThat(createdTask).isNotNull();
|
||||
assertThat(createdTask.getOwner()).isEqualTo("user-1-1");
|
||||
assertThat(createdTask.getOwnerLongName()).isEqualTo("Mustermann, Max - (user-1-1)");
|
||||
|
||||
taskanaEngine.getConfiguration().setAddAdditionalUserInfo(false);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
|
@ -191,28 +197,28 @@ class CreateTaskAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
void should_AllowTimestampServiceLevelMismatch_When_ConfigurationAllowsIt() throws Exception {
|
||||
// Given
|
||||
try {
|
||||
taskanaEngineConfiguration.setValidationAllowTimestampServiceLevelMismatch(true);
|
||||
Task newTask = taskService.newTask("USER-1-1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T6310");
|
||||
ObjectReference objectReference =
|
||||
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567");
|
||||
newTask.setPrimaryObjRef(objectReference);
|
||||
newTask.setOwner("user-1-1");
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.validationAllowTimestampServiceLevelMismatch(true)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
Task newTask = taskanaEngine.getTaskService().newTask("USER-1-1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T6310");
|
||||
ObjectReference objectReference =
|
||||
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567");
|
||||
newTask.setPrimaryObjRef(objectReference);
|
||||
newTask.setOwner("user-1-1");
|
||||
|
||||
// When
|
||||
Instant planned = Instant.parse("2018-01-02T00:00:00Z");
|
||||
newTask.setPlanned(planned);
|
||||
Instant due = Instant.parse("2018-02-15T00:00:00Z");
|
||||
newTask.setDue(due);
|
||||
Task createdTask = taskService.createTask(newTask);
|
||||
// When
|
||||
Instant planned = Instant.parse("2018-01-02T00:00:00Z");
|
||||
newTask.setPlanned(planned);
|
||||
Instant due = Instant.parse("2018-02-15T00:00:00Z");
|
||||
newTask.setDue(due);
|
||||
Task createdTask = taskanaEngine.getTaskService().createTask(newTask);
|
||||
|
||||
// Then
|
||||
assertThat(createdTask.getPlanned()).isEqualTo(planned);
|
||||
assertThat(createdTask.getDue()).isEqualTo(due);
|
||||
} finally {
|
||||
taskanaEngineConfiguration.setValidationAllowTimestampServiceLevelMismatch(false);
|
||||
}
|
||||
// Then
|
||||
assertThat(createdTask.getPlanned()).isEqualTo(planned);
|
||||
assertThat(createdTask.getDue()).isEqualTo(due);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
|
|
|
@ -11,6 +11,8 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestTemplate;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
import pro.taskana.common.test.security.WithAccessId;
|
||||
|
@ -95,7 +97,11 @@ class GetTaskAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
void should_SetTaskOwnerLongNameOfTask_When_PropertyEnabled() throws Exception {
|
||||
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(true)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
|
@ -107,8 +113,11 @@ class GetTaskAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_NotSetTaskOwnerLongNameOfTask_When_PropertyDisabled() throws Exception {
|
||||
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.mockito.MockedStatic;
|
|||
import org.mockito.Mockito;
|
||||
import org.mockito.internal.stubbing.answers.CallsRealMethods;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.internal.util.CollectionUtil;
|
||||
import pro.taskana.common.internal.util.Triplet;
|
||||
|
@ -59,9 +61,18 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetOwnerLongNameOfTask_When_PropertyEnabled() throws Exception {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(true)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
|
||||
List<TaskSummary> tasks =
|
||||
taskService.createTaskQuery().idIn("TKI:000000000000000000000000000000000000").list();
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.idIn("TKI:000000000000000000000000000000000000")
|
||||
.list();
|
||||
|
||||
assertThat(tasks).hasSize(1);
|
||||
String longName = taskanaEngine.getUserService().getUser(tasks.get(0).getOwner()).getLongName();
|
||||
|
@ -70,10 +81,19 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_NotSetOwnerLongNameOfTask_When_PropertyDisabled() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_NotSetOwnerLongNameOfTask_When_PropertyDisabled() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
|
||||
List<TaskSummary> tasks =
|
||||
taskService.createTaskQuery().idIn("TKI:000000000000000000000000000000000000").list();
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.idIn("TKI:000000000000000000000000000000000000")
|
||||
.list();
|
||||
|
||||
assertThat(tasks).hasSize(1);
|
||||
assertThat(tasks.get(0)).extracting(TaskSummary::getOwnerLongName).isNull();
|
||||
|
@ -81,10 +101,16 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-2")
|
||||
@Test
|
||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameIn() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameIn() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
|
||||
String longName = "Eifrig, Elena - (user-1-2)";
|
||||
List<TaskSummary> tasks = taskService.createTaskQuery().ownerLongNameIn(longName).list();
|
||||
List<TaskSummary> tasks =
|
||||
taskanaEngine.getTaskService().createTaskQuery().ownerLongNameIn(longName).list();
|
||||
|
||||
assertThat(tasks)
|
||||
.hasSize(25)
|
||||
|
@ -95,10 +121,15 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameNotIn() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameNotIn() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
List<TaskSummary> tasks =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.idIn(
|
||||
"TKI:000000000000000000000000000000000000",
|
||||
|
@ -114,9 +145,15 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-2")
|
||||
@Test
|
||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameLike() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
List<TaskSummary> tasks = taskService.createTaskQuery().ownerLongNameLike("%1-2%").list();
|
||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameLike() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
|
||||
List<TaskSummary> tasks =
|
||||
taskanaEngine.getTaskService().createTaskQuery().ownerLongNameLike("%1-2%").list();
|
||||
|
||||
assertThat(tasks)
|
||||
.hasSize(25)
|
||||
|
@ -127,9 +164,15 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-2")
|
||||
@Test
|
||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameNotLike() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
List<TaskSummary> tasks = taskService.createTaskQuery().ownerLongNameNotLike("%1-1%").list();
|
||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameNotLike() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
|
||||
List<TaskSummary> tasks =
|
||||
taskanaEngine.getTaskService().createTaskQuery().ownerLongNameNotLike("%1-1%").list();
|
||||
|
||||
assertThat(tasks)
|
||||
.hasSize(25)
|
||||
|
@ -140,10 +183,20 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_SetOwnerLongNameOfTaskToNull_When_OwnerNotExistingAsUserInDatabase() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
void should_SetOwnerLongNameOfTaskToNull_When_OwnerNotExistingAsUserInDatabase()
|
||||
throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(true)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
|
||||
List<TaskSummary> tasks =
|
||||
taskService.createTaskQuery().idIn("TKI:000000000000000000000000000000000041").list();
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.idIn("TKI:000000000000000000000000000000000041")
|
||||
.list();
|
||||
|
||||
assertThat(tasks).hasSize(1);
|
||||
ThrowingCallable call =
|
||||
|
@ -154,10 +207,15 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_OrderByOwnerLongName_When_QueryingTask() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_OrderByOwnerLongName_When_QueryingTask() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
List<TaskSummary> tasks =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.stateIn(TaskState.CLAIMED)
|
||||
.ownerNotIn("user-b-1")
|
||||
|
@ -166,7 +224,8 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
assertThat(tasks).extracting(TaskSummary::getOwnerLongName).hasSize(18).isSorted();
|
||||
|
||||
tasks =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.stateIn(TaskState.CLAIMED)
|
||||
.ownerNotIn("user-b-1")
|
||||
|
@ -180,10 +239,15 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_ListValues_For_OwnerLongName() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_ListValues_For_OwnerLongName() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
List<String> longNames =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.listValues(TaskQueryColumnName.OWNER_LONG_NAME, ASCENDING)
|
||||
.stream()
|
||||
|
@ -195,7 +259,8 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
.containsExactly("Eifrig, Elena - (user-1-2)", "Mustermann, Max - (user-1-1)");
|
||||
|
||||
longNames =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.listValues(TaskQueryColumnName.OWNER_LONG_NAME, DESCENDING)
|
||||
.stream()
|
||||
|
@ -209,11 +274,16 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-2")
|
||||
@Test
|
||||
void should_ListValuesCorrectly_When_FilteringWithOwnerLongName() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_ListValuesCorrectly_When_FilteringWithOwnerLongName() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
String longName = "Eifrig, Elena - (user-1-2)";
|
||||
List<String> listedValues =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.ownerLongNameIn(longName)
|
||||
.orderByTaskId(null)
|
||||
|
@ -221,19 +291,29 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
assertThat(listedValues).hasSize(25);
|
||||
|
||||
List<TaskSummary> query =
|
||||
taskService.createTaskQuery().ownerLongNameIn(longName).orderByTaskId(null).list();
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.ownerLongNameIn(longName)
|
||||
.orderByTaskId(null)
|
||||
.list();
|
||||
assertThat(query).hasSize(25).extracting(TaskSummary::getId).isEqualTo(listedValues);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-2")
|
||||
@Test
|
||||
void should_CountCorrectly_When_FilteringWithOwnerLongName() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_CountCorrectly_When_FilteringWithOwnerLongName() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
String longName = "Eifrig, Elena - (user-1-2)";
|
||||
long count = taskService.createTaskQuery().ownerLongNameIn(longName).count();
|
||||
long count = taskanaEngine.getTaskService().createTaskQuery().ownerLongNameIn(longName).count();
|
||||
assertThat(count).isEqualTo(25);
|
||||
|
||||
List<TaskSummary> query = taskService.createTaskQuery().ownerLongNameIn(longName).list();
|
||||
List<TaskSummary> query =
|
||||
taskanaEngine.getTaskService().createTaskQuery().ownerLongNameIn(longName).list();
|
||||
assertThat(query.size()).isEqualTo(count);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestTemplate;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.ConcurrencyException;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
|
@ -70,9 +72,12 @@ class UpdateTaskAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
void should_PreventTimestampServiceLevelMismatch_When_ConfigurationPreventsIt() throws Exception {
|
||||
// Given
|
||||
|
||||
taskanaEngineConfiguration.setValidationAllowTimestampServiceLevelMismatch(false);
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.validationAllowTimestampServiceLevelMismatch(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
Task task = taskanaEngine.getTaskService().getTask("TKI:000000000000000000000000000000000000");
|
||||
// When
|
||||
Instant planned = Instant.parse("2018-03-02T00:00:00Z");
|
||||
task.setPlanned(planned);
|
||||
|
@ -80,7 +85,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
|
|||
task.setDue(due);
|
||||
|
||||
// Then
|
||||
assertThatThrownBy(() -> taskService.updateTask(task))
|
||||
assertThatThrownBy(() -> taskanaEngine.getTaskService().updateTask(task))
|
||||
.isInstanceOf(InvalidArgumentException.class)
|
||||
.hasMessageContaining("not matching the service level");
|
||||
}
|
||||
|
@ -88,24 +93,24 @@ class UpdateTaskAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_AllowTimestampServiceLevelMismatch_When_ConfigurationAllowsIt() throws Exception {
|
||||
try {
|
||||
// Given
|
||||
taskanaEngineConfiguration.setValidationAllowTimestampServiceLevelMismatch(true);
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
// Given
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.validationAllowTimestampServiceLevelMismatch(true)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
Task task = taskanaEngine.getTaskService().getTask("TKI:000000000000000000000000000000000000");
|
||||
|
||||
// When
|
||||
Instant planned = Instant.parse("2018-01-02T00:00:00Z");
|
||||
task.setPlanned(planned);
|
||||
Instant due = Instant.parse("2018-02-15T00:00:00Z");
|
||||
task.setDue(due);
|
||||
Task updateTask = taskService.updateTask(task);
|
||||
// When
|
||||
Instant planned = Instant.parse("2018-01-02T00:00:00Z");
|
||||
task.setPlanned(planned);
|
||||
Instant due = Instant.parse("2018-02-15T00:00:00Z");
|
||||
task.setDue(due);
|
||||
Task updateTask = taskanaEngine.getTaskService().updateTask(task);
|
||||
|
||||
// Then
|
||||
assertThat(updateTask.getPlanned()).isEqualTo(planned);
|
||||
assertThat(updateTask.getDue()).isEqualTo(due);
|
||||
} finally {
|
||||
taskanaEngineConfiguration.setValidationAllowTimestampServiceLevelMismatch(false);
|
||||
}
|
||||
// Then
|
||||
assertThat(updateTask.getPlanned()).isEqualTo(planned);
|
||||
assertThat(updateTask.getDue()).isEqualTo(due);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
|
|
|
@ -11,6 +11,8 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TimeInterval;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
import pro.taskana.common.test.security.WithAccessId;
|
||||
|
@ -206,10 +208,15 @@ class QueryTaskCommentAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_ReturnListedValues_For_QueryColumnCreatorLongName() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_ReturnListedValues_For_QueryColumnCreatorLongName() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
List<String> listedValues =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskCommentQuery()
|
||||
.listValues(TaskCommentQueryColumnName.CREATOR_FULL_NAME, null);
|
||||
assertThat(listedValues).hasSize(3);
|
||||
|
@ -276,9 +283,14 @@ class QueryTaskCommentAccTest extends AbstractAccTest {
|
|||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_SetTaskCreatorFullNameOfTaskComment_When_PropertyEnabled() throws Exception {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(true)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
List<TaskComment> taskComments =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskCommentQuery()
|
||||
.idIn("TCI:000000000000000000000000000000000000")
|
||||
.list();
|
||||
|
@ -293,10 +305,15 @@ class QueryTaskCommentAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@Test
|
||||
void should_NotSetTaskCreatorFullNameOfTaskComment_When_PropertyDisabled() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||
void should_NotSetTaskCreatorFullNameOfTaskComment_When_PropertyDisabled() throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(false)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
List<TaskComment> taskComments =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskCommentQuery()
|
||||
.idIn("TCI:000000000000000000000000000000000000")
|
||||
.list();
|
||||
|
@ -307,10 +324,16 @@ class QueryTaskCommentAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_SetTaskCreatorFullNameOfTaskCommentToNull_When_NotExistingAsUserInDatabase() {
|
||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(true);
|
||||
void should_SetTaskCreatorFullNameOfTaskCommentToNull_When_NotExistingAsUserInDatabase()
|
||||
throws Exception {
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(AbstractAccTest.taskanaEngineConfiguration)
|
||||
.addAdditionalUserInfo(true)
|
||||
.build();
|
||||
TaskanaEngine taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
List<TaskComment> taskComments =
|
||||
taskService
|
||||
taskanaEngine
|
||||
.getTaskService()
|
||||
.createTaskCommentQuery()
|
||||
.idIn("TCI:000000000000000000000000000000000008")
|
||||
.list();
|
||||
|
|
|
@ -5,26 +5,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import pro.taskana.classification.api.exceptions.ClassificationAlreadyExistException;
|
||||
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.classification.api.exceptions.MalformedServiceLevelException;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
|
||||
import pro.taskana.task.api.exceptions.InvalidOwnerException;
|
||||
import pro.taskana.task.api.exceptions.InvalidStateException;
|
||||
import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException;
|
||||
import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
|
||||
import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.internal.models.ObjectReferenceImpl;
|
||||
import pro.taskana.workbasket.api.WorkbasketType;
|
||||
import pro.taskana.workbasket.api.exceptions.WorkbasketAlreadyExistException;
|
||||
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
||||
/** TODO. */
|
||||
|
@ -37,12 +23,7 @@ public class ExampleBootstrap {
|
|||
@Autowired private TaskanaEngine taskanaEngine;
|
||||
|
||||
@PostConstruct
|
||||
public void test()
|
||||
throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException,
|
||||
NotAuthorizedException, ClassificationAlreadyExistException,
|
||||
MalformedServiceLevelException, TaskAlreadyExistException, WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, AttachmentPersistenceException, TaskNotFoundException,
|
||||
InvalidOwnerException, InvalidStateException, ObjectReferencePersistenceException {
|
||||
public void test() throws Exception {
|
||||
System.out.println("---------------------------> Start App");
|
||||
|
||||
Workbasket wb = taskanaEngine.getWorkbasketService().newWorkbasket("workbasket", "DOMAIN_A");
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.springframework.context.annotation.PropertySource;
|
|||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.internal.SpringTaskanaEngine;
|
||||
|
@ -50,12 +50,12 @@ public class TaskanaConfig {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public TaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
||||
return new TaskanaEngineConfiguration(dataSource, true, false, schemaName);
|
||||
public TaskanaConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
||||
return new TaskanaConfiguration.Builder(dataSource, true, schemaName, false).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TaskanaEngine taskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
||||
public TaskanaEngine taskanaEngine(TaskanaConfiguration taskanaEngineConfiguration)
|
||||
throws SQLException {
|
||||
return SpringTaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package pro.taskana.common.internal;
|
|||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
|
||||
public interface SpringTaskanaEngine extends TaskanaEngine {
|
||||
|
@ -11,18 +11,17 @@ public interface SpringTaskanaEngine extends TaskanaEngine {
|
|||
* This method creates the {@linkplain SpringTaskanaEngine} with {@linkplain
|
||||
* ConnectionManagementMode#PARTICIPATE }.
|
||||
*
|
||||
* @see SpringTaskanaEngine#buildTaskanaEngine(TaskanaEngineConfiguration,
|
||||
* ConnectionManagementMode)
|
||||
* @see SpringTaskanaEngine#buildTaskanaEngine(TaskanaConfiguration, ConnectionManagementMode)
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||
static SpringTaskanaEngine buildTaskanaEngine(TaskanaEngineConfiguration configuration)
|
||||
static SpringTaskanaEngine buildTaskanaEngine(TaskanaConfiguration configuration)
|
||||
throws SQLException {
|
||||
return SpringTaskanaEngine.buildTaskanaEngine(
|
||||
configuration, ConnectionManagementMode.PARTICIPATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an {@linkplain SpringTaskanaEngine} based on {@linkplain TaskanaEngineConfiguration} and
|
||||
* Builds an {@linkplain SpringTaskanaEngine} based on {@linkplain TaskanaConfiguration} and
|
||||
* SqlConnectionMode.
|
||||
*
|
||||
* @param configuration complete taskanaEngineConfig to build the engine
|
||||
|
@ -31,7 +30,7 @@ public interface SpringTaskanaEngine extends TaskanaEngine {
|
|||
* @throws SQLException when the db schema could not be initialized
|
||||
*/
|
||||
static SpringTaskanaEngine buildTaskanaEngine(
|
||||
TaskanaEngineConfiguration configuration, ConnectionManagementMode connectionManagementMode)
|
||||
TaskanaConfiguration configuration, ConnectionManagementMode connectionManagementMode)
|
||||
throws SQLException {
|
||||
return SpringTaskanaEngineImpl.createTaskanaEngine(configuration, connectionManagementMode);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ package pro.taskana.common.internal;
|
|||
import java.sql.SQLException;
|
||||
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
|
||||
/** This class configures the TaskanaEngine for spring. */
|
||||
public class SpringTaskanaEngineImpl extends TaskanaEngineImpl implements SpringTaskanaEngine {
|
||||
|
||||
public SpringTaskanaEngineImpl(
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration, ConnectionManagementMode mode)
|
||||
TaskanaConfiguration taskanaEngineConfiguration, ConnectionManagementMode mode)
|
||||
throws SQLException {
|
||||
super(taskanaEngineConfiguration, mode);
|
||||
this.transactionFactory = new SpringManagedTransactionFactory();
|
||||
|
@ -17,7 +17,7 @@ public class SpringTaskanaEngineImpl extends TaskanaEngineImpl implements Spring
|
|||
}
|
||||
|
||||
public static SpringTaskanaEngine createTaskanaEngine(
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
||||
TaskanaConfiguration taskanaEngineConfiguration,
|
||||
ConnectionManagementMode connectionManagementMode)
|
||||
throws SQLException {
|
||||
return new SpringTaskanaEngineImpl(taskanaEngineConfiguration, connectionManagementMode);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package pro.taskana.testapi;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
|
||||
public interface TaskanaEngineConfigurationModifier {
|
||||
|
||||
void modify(TaskanaEngineConfiguration taskanaEngineConfiguration);
|
||||
TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.junit.platform.commons.JUnitException;
|
|||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.internal.ClassificationServiceImpl;
|
||||
import pro.taskana.common.api.ConfigurationService;
|
||||
|
@ -61,13 +61,13 @@ public class TaskanaInitializationExtension implements TestInstancePostProcessor
|
|||
|| isAnnotated(testClass, WithServiceProviders.class)
|
||||
|| testInstance instanceof TaskanaEngineConfigurationModifier) {
|
||||
Store store = getClassLevelStore(context);
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration =
|
||||
createDefaultTaskanaEngineConfiguration(store);
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder =
|
||||
createDefaultTaskanaEngineConfigurationBuilder(store);
|
||||
|
||||
if (testInstance instanceof TaskanaEngineConfigurationModifier) {
|
||||
TaskanaEngineConfigurationModifier modifier =
|
||||
(TaskanaEngineConfigurationModifier) testInstance;
|
||||
modifier.modify(taskanaEngineConfiguration);
|
||||
taskanaEngineConfigurationBuilder = modifier.modify(taskanaEngineConfigurationBuilder);
|
||||
}
|
||||
|
||||
TaskanaEngine taskanaEngine;
|
||||
|
@ -79,7 +79,7 @@ public class TaskanaInitializationExtension implements TestInstancePostProcessor
|
|||
staticMock.when(() -> SpiLoader.load(spi)).thenReturn(serviceProviders));
|
||||
taskanaEngine =
|
||||
TaskanaEngine.buildTaskanaEngine(
|
||||
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||
taskanaEngineConfigurationBuilder.build(), ConnectionManagementMode.AUTOCOMMIT);
|
||||
}
|
||||
|
||||
store.put(STORE_TASKANA_ENTITY_MAP, generateTaskanaEntityMap(taskanaEngine));
|
||||
|
@ -95,7 +95,8 @@ public class TaskanaInitializationExtension implements TestInstancePostProcessor
|
|||
return instanceByClass;
|
||||
}
|
||||
|
||||
private static TaskanaEngineConfiguration createDefaultTaskanaEngineConfiguration(Store store) {
|
||||
private static TaskanaConfiguration.Builder createDefaultTaskanaEngineConfigurationBuilder(
|
||||
Store store) {
|
||||
String schemaName = store.get(TestContainerExtension.STORE_SCHEMA_NAME, String.class);
|
||||
if (schemaName == null) {
|
||||
throw new JUnitException("Expected schemaName to be defined in store, but it's not.");
|
||||
|
@ -105,7 +106,7 @@ public class TaskanaInitializationExtension implements TestInstancePostProcessor
|
|||
throw new JUnitException("Expected dataSource to be defined in store, but it's not.");
|
||||
}
|
||||
|
||||
return new TaskanaEngineConfiguration(dataSource, false, schemaName);
|
||||
return new TaskanaConfiguration.Builder(dataSource, false, schemaName);
|
||||
}
|
||||
|
||||
private static Map<Class<?>, Object> generateTaskanaEntityMap(TaskanaEngine taskanaEngine)
|
||||
|
@ -121,7 +122,7 @@ public class TaskanaInitializationExtension implements TestInstancePostProcessor
|
|||
UserService userService = taskanaEngine.getUserService();
|
||||
SqlSession sqlSession = taskanaEngineProxy.getSqlSession();
|
||||
return Map.ofEntries(
|
||||
Map.entry(TaskanaEngineConfiguration.class, taskanaEngine.getConfiguration()),
|
||||
Map.entry(TaskanaConfiguration.class, taskanaEngine.getConfiguration()),
|
||||
Map.entry(TaskanaEngineImpl.class, taskanaEngine),
|
||||
Map.entry(TaskanaEngine.class, taskanaEngine),
|
||||
Map.entry(InternalTaskanaEngine.class, taskanaEngineProxy.getEngine()),
|
||||
|
|
|
@ -71,6 +71,24 @@ public class TestContainerExtension implements InvocationInterceptor {
|
|||
return invocation.proceed();
|
||||
}
|
||||
|
||||
public static DataSource createDataSourceForH2() {
|
||||
PooledDataSource ds =
|
||||
new PooledDataSource(
|
||||
Thread.currentThread().getContextClassLoader(),
|
||||
"org.h2.Driver",
|
||||
"jdbc:h2:mem:"
|
||||
+ "taskana"
|
||||
+ ";NON_KEYWORDS=KEY,VALUE;LOCK_MODE=0;"
|
||||
+ "INIT=CREATE SCHEMA IF NOT EXISTS TASKANA\\;"
|
||||
+ "SET COLLATION DEFAULT_de_DE ",
|
||||
"sa",
|
||||
"sa");
|
||||
ds.setPoolTimeToWait(50);
|
||||
ds.forceCloseAll(); // otherwise, the MyBatis pool is not initialized correctly
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
private static void copyValue(String key, Store source, Store destination) {
|
||||
Object value = source.get(key);
|
||||
destination.put(key, value);
|
||||
|
@ -96,22 +114,4 @@ public class TestContainerExtension implements InvocationInterceptor {
|
|||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
private static DataSource createDataSourceForH2() {
|
||||
PooledDataSource ds =
|
||||
new PooledDataSource(
|
||||
Thread.currentThread().getContextClassLoader(),
|
||||
"org.h2.Driver",
|
||||
"jdbc:h2:mem:"
|
||||
+ "taskana"
|
||||
+ ";NON_KEYWORDS=KEY,VALUE;LOCK_MODE=0;"
|
||||
+ "INIT=CREATE SCHEMA IF NOT EXISTS TASKANA\\;"
|
||||
+ "SET COLLATION DEFAULT_de_DE ",
|
||||
"sa",
|
||||
"sa");
|
||||
ds.setPoolTimeToWait(50);
|
||||
ds.forceCloseAll(); // otherwise, the MyBatis pool is not initialized correctly
|
||||
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.internal.ClassificationServiceImpl;
|
||||
import pro.taskana.common.api.ConfigurationService;
|
||||
|
@ -30,8 +30,8 @@ import pro.taskana.workbasket.internal.WorkbasketServiceImpl;
|
|||
@TaskanaIntegrationTest
|
||||
class TaskanaDependencyInjectionExtensionTest {
|
||||
|
||||
TaskanaEngineConfiguration taskanaEngineConfigurationNotAnnotated;
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
TaskanaConfiguration taskanaEngineConfigurationNotAnnotated;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaEngine taskanaEngine;
|
||||
@TaskanaInject TaskanaEngine taskanaEngine2;
|
||||
@TaskanaInject TaskanaEngineImpl taskanaEngineImpl;
|
||||
|
@ -67,7 +67,7 @@ class TaskanaDependencyInjectionExtensionTest {
|
|||
|
||||
@Test
|
||||
void should_InjectTaskanaEngineConfiguration_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
TaskanaConfiguration taskanaEngineConfiguration) {
|
||||
assertThat(taskanaEngineConfiguration).isSameAs(this.taskanaEngineConfiguration).isNotNull();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.spi.priority.api.PriorityServiceProvider;
|
||||
import pro.taskana.spi.priority.internal.PriorityServiceManager;
|
||||
|
@ -19,7 +19,7 @@ import pro.taskana.testapi.TaskanaInitializationExtensionTest.NestedTestClassWit
|
|||
@TaskanaIntegrationTest
|
||||
class TaskanaInitializationExtensionTest {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Test
|
||||
void should_UseDefaultTaskanaEngine_When_TestIsCreated() {
|
||||
|
@ -31,7 +31,7 @@ class TaskanaInitializationExtensionTest {
|
|||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class ReuseTaskana {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Test
|
||||
void should_useTopLevelTaskanaInstance_For_NestedTestClasses() {
|
||||
|
@ -44,11 +44,12 @@ class TaskanaInitializationExtensionTest {
|
|||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class ModifiedTaskanaEngineConfig implements TaskanaEngineConfigurationModifier {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Override
|
||||
public void modify(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
taskanaEngineConfiguration.setDomains(List.of("A", "B"));
|
||||
public TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder) {
|
||||
return taskanaEngineConfigurationBuilder.domains(List.of("A", "B"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -68,7 +69,7 @@ class TaskanaInitializationExtensionTest {
|
|||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class NestedTestClassAnnotatedWithCleanTaskanaContext {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Test
|
||||
void should_createNewTaskanaInstance_For_NestedTestClassAnnotatedWithCleanTaskanaContext() {
|
||||
|
@ -89,7 +90,7 @@ class TaskanaInitializationExtensionTest {
|
|||
@Nested
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class NestedTestClassWithServiceProvider {
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaEngine taskanaEngine;
|
||||
|
||||
@Test
|
||||
|
@ -132,7 +133,7 @@ class TaskanaInitializationExtensionTest {
|
|||
@Nested
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class NestedTestClassWithMultipleServiceProviders {
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaEngine taskanaEngine;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.spi.priority.api.PriorityServiceProvider;
|
||||
import pro.taskana.task.api.models.TaskSummary;
|
||||
import pro.taskana.testapi.TestContainerExtensionTest.NestedTestClassWithServiceProvider.DummyPriorityServiceProvider;
|
||||
|
@ -17,7 +17,7 @@ import pro.taskana.testapi.TestContainerExtensionTest.NestedTestClassWithService
|
|||
@TaskanaIntegrationTest
|
||||
class TestContainerExtensionTest {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Test
|
||||
void should_CreateDataSource_For_TopLevelTestClass() {
|
||||
|
@ -37,7 +37,7 @@ class TestContainerExtensionTest {
|
|||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class NestedTestClass {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Test
|
||||
void should_ReuseDataSource_For_NestedTestClass() {
|
||||
|
@ -62,11 +62,12 @@ class TestContainerExtensionTest {
|
|||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class NestedTestClassWithConfigurationModifier implements TaskanaEngineConfigurationModifier {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Override
|
||||
public void modify(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
// do nothing
|
||||
public TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder) {
|
||||
return taskanaEngineConfigurationBuilder;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -93,7 +94,7 @@ class TestContainerExtensionTest {
|
|||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class NestedTestClassAnnotatedWithCleanTaskanaContext {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Test
|
||||
void should_ReuseDataSource_For_NestedTestAnnotatedWithCleanTaskanaContext() {
|
||||
|
@ -118,7 +119,7 @@ class TestContainerExtensionTest {
|
|||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class NestedNestedTestClassAnnotatedWithCleanTaskanaContext {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Test
|
||||
void should_ReuseDataSource_For_NestedTestAnnotatedWithCleanTaskanaContext() {
|
||||
|
@ -160,11 +161,12 @@ class TestContainerExtensionTest {
|
|||
class NestedTestClassAnnotatedWithCleanTaskanaContextAndConfigModifier
|
||||
implements TaskanaEngineConfigurationModifier {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Override
|
||||
public void modify(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
// do nothing
|
||||
public TaskanaConfiguration.Builder modify(
|
||||
TaskanaConfiguration.Builder taskanaEngineConfigurationBuilder) {
|
||||
return taskanaEngineConfigurationBuilder;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -193,7 +195,7 @@ class TestContainerExtensionTest {
|
|||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
class NestedTestClassWithServiceProvider {
|
||||
|
||||
@TaskanaInject TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@TaskanaInject TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Test
|
||||
void should_ReuseDataSource_For_NestedTestClassWithServiceProvider() {
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.context.annotation.DependsOn;
|
|||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.internal.configuration.DbSchemaCreator;
|
||||
import pro.taskana.sampledata.SampleDataGenerator;
|
||||
|
@ -26,7 +26,7 @@ public class ExampleRestConfiguration {
|
|||
@Bean
|
||||
@DependsOn("taskanaEngineConfiguration") // generate sample data after schema was inserted
|
||||
public SampleDataGenerator generateSampleData(
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
||||
TaskanaConfiguration taskanaEngineConfiguration,
|
||||
DataSource dataSource,
|
||||
@Value("${generateSampleData:true}") boolean generateSampleData)
|
||||
throws SQLException {
|
||||
|
@ -43,7 +43,7 @@ public class ExampleRestConfiguration {
|
|||
|
||||
@Bean
|
||||
@DependsOn("generateSampleData")
|
||||
public TaskanaEngine getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
||||
public TaskanaEngine getTaskanaEngine(TaskanaConfiguration taskanaEngineConfiguration)
|
||||
throws SQLException {
|
||||
return TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.http.converter.json.SpringHandlerInstantiator;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.common.api.ConfigurationService;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
|
@ -72,15 +72,15 @@ public class RestConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(TaskanaEngine.class)
|
||||
public TaskanaEngine getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
||||
public TaskanaEngine getTaskanaEngine(TaskanaConfiguration taskanaEngineConfiguration)
|
||||
throws SQLException {
|
||||
return SpringTaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(TaskanaEngineConfiguration.class)
|
||||
public TaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
||||
return new TaskanaEngineConfiguration(dataSource, true, true, schemaName);
|
||||
@ConditionalOnMissingBean(TaskanaConfiguration.class)
|
||||
public TaskanaConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
||||
return new TaskanaConfiguration.Builder(dataSource, true, schemaName).build();
|
||||
}
|
||||
|
||||
// Needed for injection into jackson deserializer.
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.ConfigurationService;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.security.CurrentUserContext;
|
||||
|
@ -25,14 +25,14 @@ import pro.taskana.common.rest.models.VersionRepresentationModel;
|
|||
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
|
||||
public class TaskanaEngineController {
|
||||
|
||||
private final TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
private final TaskanaConfiguration taskanaEngineConfiguration;
|
||||
private final TaskanaEngine taskanaEngine;
|
||||
private final CurrentUserContext currentUserContext;
|
||||
private final ConfigurationService configurationService;
|
||||
|
||||
@Autowired
|
||||
TaskanaEngineController(
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
||||
TaskanaConfiguration taskanaEngineConfiguration,
|
||||
TaskanaEngine taskanaEngine,
|
||||
CurrentUserContext currentUserContext,
|
||||
ConfigurationService configurationService) {
|
||||
|
@ -159,7 +159,7 @@ public class TaskanaEngineController {
|
|||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<VersionRepresentationModel> currentVersion() {
|
||||
VersionRepresentationModel resource = new VersionRepresentationModel();
|
||||
resource.setVersion(TaskanaEngineConfiguration.class.getPackage().getImplementationVersion());
|
||||
resource.setVersion(TaskanaConfiguration.class.getPackage().getImplementationVersion());
|
||||
return ResponseEntity.ok(resource);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.springframework.ldap.filter.WhitespaceWildcardsFilter;
|
|||
import org.springframework.ldap.support.LdapNameBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
|
@ -43,7 +43,7 @@ public class LdapClient {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(LdapClient.class);
|
||||
private static final String CN = "cn";
|
||||
|
||||
private final TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
private final TaskanaConfiguration taskanaEngineConfiguration;
|
||||
private final Environment env;
|
||||
private final LdapTemplate ldapTemplate;
|
||||
private final boolean useLowerCaseForAccessIds;
|
||||
|
@ -54,13 +54,11 @@ public class LdapClient {
|
|||
|
||||
@Autowired
|
||||
public LdapClient(
|
||||
Environment env,
|
||||
LdapTemplate ldapTemplate,
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
Environment env, LdapTemplate ldapTemplate, TaskanaConfiguration taskanaEngineConfiguration) {
|
||||
this.env = env;
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
|
||||
this.useLowerCaseForAccessIds = TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds();
|
||||
this.useLowerCaseForAccessIds = TaskanaConfiguration.shouldUseLowerCaseForAccessIds();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
|||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
|
@ -42,7 +42,7 @@ class LdapClientTest {
|
|||
|
||||
@Mock LdapTemplate ldapTemplate;
|
||||
|
||||
@Mock TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@Mock TaskanaConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@Spy @InjectMocks LdapClient cut;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.springframework.core.io.ClassPathResource;
|
|||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import pro.taskana.TaskanaEngineConfiguration;
|
||||
import pro.taskana.TaskanaConfiguration;
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
|
@ -44,9 +44,10 @@ class DmnConverterServiceAccTest {
|
|||
|
||||
DataSource dataSource = DataSourceGenerator.createDataSourceForH2();
|
||||
String schemaName = "TASKANA";
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaEngineConfiguration(dataSource, false, schemaName);
|
||||
taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(true);
|
||||
TaskanaConfiguration taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(dataSource, false, schemaName)
|
||||
.germanPublicHolidaysEnabled(true)
|
||||
.build();
|
||||
SampleDataGenerator sampleDataGenerator =
|
||||
new SampleDataGenerator(dataSource, taskanaEngineConfiguration.getSchemaName());
|
||||
if (dropTables) {
|
||||
|
|
|
@ -99,8 +99,7 @@ public class DmnTaskRouter implements TaskRoutingProvider {
|
|||
}
|
||||
|
||||
protected DmnModelInstance readModelFromDmnTable() {
|
||||
String pathToDmn =
|
||||
taskanaEngine.getConfiguration().readPropertiesFromFile().getProperty(DMN_TABLE_PROPERTY);
|
||||
String pathToDmn = taskanaEngine.getConfiguration().getProperties().get(DMN_TABLE_PROPERTY);
|
||||
try (InputStream stream = FileLoaderUtil.openFileFromClasspathOrSystem(pathToDmn, getClass())) {
|
||||
return Dmn.readModelFromStream(stream);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import pro.taskana.task.internal.models.ObjectReferenceImpl;
|
|||
|
||||
public abstract class AbstractAccTest {
|
||||
|
||||
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaEngine taskanaEngine;
|
||||
protected static WorkingDaysToDaysConverter converter;
|
||||
|
||||
|
@ -32,8 +32,10 @@ public abstract class AbstractAccTest {
|
|||
sampleDataGenerator.dropDb();
|
||||
}
|
||||
dataSource = DataSourceGenerator.getDataSource();
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaName);
|
||||
taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(true);
|
||||
taskanaEngineConfiguration =
|
||||
new TaskanaConfiguration.Builder(dataSource, false, schemaName)
|
||||
.germanPublicHolidaysEnabled(true)
|
||||
.build();
|
||||
DbSchemaCreator dbSchemaCreator =
|
||||
new DbSchemaCreator(dataSource, taskanaEngineConfiguration.getSchemaName());
|
||||
dbSchemaCreator.run();
|
||||
|
|
Loading…
Reference in New Issue