TSK-1244: added due/planned logic for SLA P0D

This commit is contained in:
Stefan Schultz 2020-05-20 16:02:45 +02:00 committed by Mustapha Zorgati
parent 8a6f7d573b
commit c6755b35b7
40 changed files with 516 additions and 438 deletions

View File

@ -40,8 +40,7 @@ import pro.taskana.common.internal.configuration.DbSchemaCreator;
import pro.taskana.common.internal.configuration.SecurityVerifier;
/**
* This central class creates the TaskanaEngine and holds all the information about DB and
* Security.
* This central class creates the TaskanaEngine and holds all the information about DB and Security.
* <br>
* Security is enabled by default.
*/
@ -302,7 +301,7 @@ public class TaskanaEngineConfiguration {
public Map<String, List<String>> getClassificationCategoriesByTypeMap() {
return this.classificationCategoriesByTypeMap.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, e -> new ArrayList<>(e.getValue())));
.collect(Collectors.toMap(Entry::getKey, e -> new ArrayList<>(e.getValue())));
}
public List<String> getClassificationCategoriesByType(String type) {
@ -428,7 +427,7 @@ public class TaskanaEngineConfiguration {
String taskCleanupJobAllCompletedSameParentBusinessProperty =
props.getProperty(TASKANA_JOB_TASK_CLEANUP_ALL_COMPLETED_SAME_PARENTE_BUSINESS);
if (taskCleanupJobAllCompletedSameParentBusinessProperty != null
&& !taskCleanupJobAllCompletedSameParentBusinessProperty.isEmpty()) {
&& !taskCleanupJobAllCompletedSameParentBusinessProperty.isEmpty()) {
try {
taskCleanupJobAllCompletedSameParentBusiness =
Boolean.parseBoolean(taskCleanupJobAllCompletedSameParentBusinessProperty);
@ -534,8 +533,7 @@ public class TaskanaEngineConfiguration {
validPropertyName ->
roleMap.put(
TaskanaRole.fromPropertyName(validPropertyName),
getTokensWithCollection(props.getProperty(validPropertyName),
rolesSeparator)));
getTokensWithCollection(props.getProperty(validPropertyName), rolesSeparator)));
ensureRoleMapIsFullyInitialized();
@ -549,9 +547,7 @@ public class TaskanaEngineConfiguration {
private void initCustomHolidays(Properties props) {
if (props.getProperty(TASKANA_CUSTOM_HOLIDAY) != null) {
Arrays.asList(
props
.getProperty(TASKANA_CUSTOM_HOLIDAY)
.split(Pattern.quote(propertiesSeparator)))
props.getProperty(TASKANA_CUSTOM_HOLIDAY).split(Pattern.quote(propertiesSeparator)))
.forEach(
entry -> {
try {
@ -579,8 +575,8 @@ public class TaskanaEngineConfiguration {
private HashSet<String> getTokensWithCollection(String str, String rolesSeparator) {
return Collections.list(new StringTokenizer(str, rolesSeparator)).stream()
.map(token -> String.valueOf(token).toLowerCase().trim())
.collect(Collectors.toCollection(HashSet::new));
.map(token -> String.valueOf(token).toLowerCase().trim())
.collect(Collectors.toCollection(HashSet::new));
}
private Properties readPropertiesFromFile(String propertiesFile) {
@ -594,8 +590,7 @@ public class TaskanaEngineConfiguration {
LOGGER.error("taskana properties file {} was not found on classpath.", propertiesFile);
} else {
props.load(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
LOGGER
.debug("Role properties were loaded from file {} from classpath.", propertiesFile);
LOGGER.debug("Role properties were loaded from file {} from classpath.", propertiesFile);
}
} else {
props.load(new FileInputStream(propertiesFile));
@ -604,8 +599,7 @@ public class TaskanaEngineConfiguration {
} 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());
"internal System error when processing properties file " + propertiesFile, e.getCause());
}
return props;
}
@ -621,7 +615,6 @@ public class TaskanaEngineConfiguration {
private void ensureRoleMapIsFullyInitialized() {
// make sure that roleMap does not return null for any role
Arrays.stream(TaskanaRole.values())
.forEach(role -> roleMap.putIfAbsent(role, new HashSet<>()));
Arrays.stream(TaskanaRole.values()).forEach(role -> roleMap.putIfAbsent(role, new HashSet<>()));
}
}

View File

@ -7,6 +7,12 @@ public final class CustomHoliday {
private final Integer day;
private final Integer month;
public CustomHoliday(Integer day, Integer month) {
super();
this.day = day;
this.month = month;
}
public Integer getDay() {
return day;
}
@ -15,12 +21,6 @@ public final class CustomHoliday {
return month;
}
public CustomHoliday(Integer day, Integer month) {
super();
this.day = day;
this.month = month;
}
public static CustomHoliday of(Integer day, Integer month) {
return new CustomHoliday(day, month);
}

View File

@ -167,9 +167,7 @@ public class DbSchemaCreator {
while (line != null) {
line = reader.readLine();
if (line != null) {
content
.append(line.replace("%schemaName%", schemaName))
.append(System.lineSeparator());
content.append(line.replace("%schemaName%", schemaName)).append(System.lineSeparator());
}
}
} catch (IOException e) {

View File

@ -19,7 +19,6 @@ public class SecurityVerifier {
private final String schemaName;
private DataSource dataSource;
public SecurityVerifier(DataSource dataSource, String schema) {
super();
this.dataSource = dataSource;
@ -29,8 +28,9 @@ public class SecurityVerifier {
public void checkSecureAccess(boolean securityEnabled) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("Entering checkSecureAccess with securityEnabled set to %b",
securityEnabled));
LOGGER.debug(
String.format(
"Entering checkSecureAccess with securityEnabled set to %b", securityEnabled));
}
try (Connection connection = dataSource.getConnection()) {
@ -41,37 +41,34 @@ public class SecurityVerifier {
SqlRunner sqlRunner = new SqlRunner(connection);
String querySecurity = String.format(SELECT_SECURITY_FLAG, SECURITY_FLAG_COLUMN_NAME,
schemaName);
String querySecurity =
String.format(SELECT_SECURITY_FLAG, SECURITY_FLAG_COLUMN_NAME, schemaName);
if ((boolean) sqlRunner.selectOne(querySecurity).get(SECURITY_FLAG_COLUMN_NAME)
&& !securityEnabled) {
&& !securityEnabled) {
LOGGER.error("Tried to start TASKANA in unsecured mode while secured mode is enforced!");
throw new SystemException(
"Secured TASKANA mode is enforced, can't start in unsecured mode");
}
} catch (SQLException ex) {
LOGGER.info(String.format(
"Security-mode is not yet set. Setting security flag to %b", securityEnabled));
LOGGER.info(
String.format(
"Security-mode is not yet set. Setting security flag to %b", securityEnabled));
setInitialSecurityMode(securityEnabled);
}
LOGGER.debug("Security-mode is enabled");
}
private void setInitialSecurityMode(boolean securityEnabled) {
try (Connection connection = dataSource.getConnection()) {
String setSecurityFlagSql = String.format(INSERT_SECURITY_FLAG,
schemaName, securityEnabled);
String setSecurityFlagSql = String.format(INSERT_SECURITY_FLAG, schemaName, securityEnabled);
try (PreparedStatement preparedStatement = connection.prepareStatement(setSecurityFlagSql)) {

View File

@ -25,6 +25,12 @@ import pro.taskana.common.api.exceptions.SystemException;
*/
public final class WorkingDaysToDaysConverter {
// offset in days from easter sunday
private static final int OFFSET_GOOD_FRIDAY = -2; // Karfreitag
private static final int OFFSET_EASTER_MONDAY = 1; // Ostermontag
private static final int OFFSET_ASCENSION_DAY = 39; // Himmelfahrt
private static final int OFFSET_WHIT_MONDAY = 50; // Pfingstmontag
private static boolean germanHolidaysEnabled;
private static Set<CustomHoliday> customHolidays = new HashSet<>();
private Instant referenceDate;
@ -83,32 +89,54 @@ public final class WorkingDaysToDaysConverter {
}
public long convertWorkingDaysToDays(Instant startTime, long numberOfDays) {
return convertWorkingDaysToDays(startTime, numberOfDays, ZeroDirection.ADD_DAYS);
}
public long convertWorkingDaysToDays(
final Instant startTime, long numberOfDays, ZeroDirection zeroDirection) {
if (startTime == null) {
throw new SystemException(
"Internal Error: convertWorkingDasToDays was called with a null startTime");
"Internal Error: convertWorkingDaysToDays was called with a null startTime");
} else if (!startTime.equals(referenceDate)) {
refreshReferenceDate(referenceDate);
}
int direction = numberOfDays >= 0 ? 1 : -1;
int direction = calculateDirection(numberOfDays, zeroDirection);
long limit = Math.abs(numberOfDays);
final Instant finalStartTime = startTime;
return LongStream.iterate(0, i -> i + direction)
.filter(day -> isWorkingDay(day, finalStartTime))
.filter(day -> isWorkingDay(day, startTime))
.skip(limit)
.findFirst()
.orElse(0);
}
public Instant addWorkingDaysToInstant(Instant instant, Duration workingDays) {
long days = convertWorkingDaysToDays(instant, workingDays.toDays());
long days = convertWorkingDaysToDays(instant, workingDays.toDays(), ZeroDirection.ADD_DAYS);
return instant.plus(Duration.ofDays(days));
}
public Instant subtractWorkingDaysFromInstant(Instant instant, Duration workingDays) {
long days = convertWorkingDaysToDays(instant, -workingDays.toDays());
long days = convertWorkingDaysToDays(instant, -workingDays.toDays(), ZeroDirection.SUB_DAYS);
return instant.plus(Duration.ofDays(days));
}
/** counts working days between two dates, inclusive for both margins. */
public boolean hasWorkingDaysInBetween(Instant leftInstant, Instant rightInstant) {
Instant left = leftInstant;
Instant right = rightInstant;
// make sure dates are ordered
if (leftInstant.isAfter(rightInstant)) {
left = rightInstant;
right = leftInstant;
}
long days = Duration.between(left, right).toDays();
for (long day = 0; day <= days; day++) {
if (isWorkingDay(day, left)) {
return true;
}
}
return false;
}
public boolean isWorkingDay(long day, Instant referenceDate) {
LocalDateTime dateToCheck =
LocalDateTime.ofInstant(referenceDate, ZoneId.systemDefault()).plusDays(day);
@ -139,12 +167,9 @@ public final class WorkingDaysToDaysConverter {
// Easter holidays Good Friday, Easter Monday, Ascension Day, Whit Monday.
long diffFromEasterSunday = DAYS.between(easterSunday, date);
long goodFriday = -2;
long easterMonday = 1;
long ascensionDay = 39;
long whitMonday = 50;
return LongStream.of(goodFriday, easterMonday, ascensionDay, whitMonday)
return LongStream.of(
OFFSET_GOOD_FRIDAY, OFFSET_EASTER_MONDAY, OFFSET_ASCENSION_DAY, OFFSET_WHIT_MONDAY)
.anyMatch(diff -> diff == diffFromEasterSunday);
}
@ -177,6 +202,14 @@ public final class WorkingDaysToDaysConverter {
return LocalDate.of(year, 3, 22).plusDays((long) d + e);
}
private int calculateDirection(long numberOfDays, ZeroDirection zeroDirection) {
if (numberOfDays == 0) {
return zeroDirection.getDirection();
} else {
return numberOfDays >= 0 ? 1 : -1;
}
}
private void refreshReferenceDate(Instant newReferenceDate) {
int yearOfReferenceDate =
LocalDateTime.ofInstant(referenceDate, ZoneId.systemDefault()).getYear();
@ -198,6 +231,21 @@ public final class WorkingDaysToDaysConverter {
+ '}';
}
private enum ZeroDirection {
SUB_DAYS(-1),
ADD_DAYS(1);
private int direction;
ZeroDirection(int direction) {
this.direction = direction;
}
public int getDirection() {
return direction;
}
}
/** Enumeration of German holidays. */
private enum GermanFixHolidays {
NEWYEAR(1, 1),

View File

@ -25,6 +25,7 @@ import pro.taskana.common.internal.util.WorkingDaysToDaysConverter;
import pro.taskana.task.api.exceptions.UpdateFailedException;
import pro.taskana.task.api.models.Attachment;
import pro.taskana.task.api.models.AttachmentSummary;
import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.AttachmentSummaryImpl;
import pro.taskana.task.internal.models.MinimalTaskSummary;
import pro.taskana.task.internal.models.TaskImpl;
@ -129,8 +130,7 @@ class ServiceLevelHandler {
// classification update
if (forRefreshOnClassificationUpdate) {
newTaskImpl.setDue(
converter.addWorkingDaysToInstant(
newTaskImpl.getPlanned(), durationPrioHolder.getDuration()));
getFollowingWorkingDays(newTaskImpl.getPlanned(), durationPrioHolder.getDuration()));
return newTaskImpl;
}
// creation of new task
@ -183,7 +183,7 @@ class ServiceLevelHandler {
referenceTask.setModified(Instant.now());
priorityToTaskIdsMap.forEach(
(prio, taskIdList) -> {
referenceTask.setPriority(prio.intValue());
referenceTask.setPriority(prio);
if (!taskIdList.isEmpty()) {
taskMapper.updatePriorityOfTasks(taskIdList, referenceTask);
}
@ -249,66 +249,45 @@ class ServiceLevelHandler {
if (newTaskImpl.getPlanned() == null && newTaskImpl.getDue() == null) {
newTaskImpl.setPlanned(oldTaskImpl.getPlanned());
}
// case 1: no change of planned / due, but potentially change of an attachment or classification
if (oldTaskImpl.getDue().equals(newTaskImpl.getDue())
&& oldTaskImpl.getPlanned().equals(newTaskImpl.getPlanned())) {
// case 1: no change of planned/due, but potentially change of an attachment or classification
// -> recalculate due
newTaskImpl.setDue(
converter.addWorkingDaysToInstant(
newTaskImpl.getPlanned(), durationPrioHolder.getDuration()));
} else if (oldTaskImpl.getDue().equals(newTaskImpl.getDue())
&& newTaskImpl.getPlanned() != null) {
// case 2: planned was changed and due not
getFollowingWorkingDays(newTaskImpl.getPlanned(), durationPrioHolder.getDuration()));
} else if (dueIsUnchangedOrNull(newTaskImpl, oldTaskImpl) && newTaskImpl.getPlanned() != null) {
// case 2: due is null or only planned was changed -> recalculate due
newTaskImpl.setPlanned(getFollowingWorkingDays(newTaskImpl.getPlanned(), Duration.ofDays(0)));
newTaskImpl.setDue(
converter.addWorkingDaysToInstant(
newTaskImpl.getPlanned(), durationPrioHolder.getDuration()));
if (!converter.isWorkingDay(0, newTaskImpl.getPlanned())) {
newTaskImpl.setPlanned(getFirstFollowingWorkingDay(newTaskImpl.getPlanned()));
}
getFollowingWorkingDays(newTaskImpl.getPlanned(), durationPrioHolder.getDuration()));
} else {
updatePlannedDueOnTaskUpdateWhenDueWasChanged(newTaskImpl, oldTaskImpl, durationPrioHolder);
// case 3: due and (maybe) planned were changed -> validate SLA if planned changed
Instant calcDue = getPrecedingWorkingDays(newTaskImpl.getDue(), Duration.ofDays(0));
Instant calcPlanned = getPrecedingWorkingDays(calcDue, durationPrioHolder.getDuration());
if (plannedHasChanged(newTaskImpl, oldTaskImpl)) {
ensureServiceLevelIsNotViolated(newTaskImpl, durationPrioHolder.getDuration(), calcPlanned);
}
newTaskImpl.setPlanned(calcPlanned);
newTaskImpl.setDue(calcDue);
}
return newTaskImpl;
}
private void updatePlannedDueOnTaskUpdateWhenDueWasChanged(
TaskImpl newTaskImpl, TaskImpl oldTaskImpl, DurationPrioHolder durationPrioHolder)
throws InvalidArgumentException {
if (newTaskImpl.getDue() == null) {
newTaskImpl.setDue(
converter.addWorkingDaysToInstant(
newTaskImpl.getPlanned(), durationPrioHolder.getDuration()));
if (!converter.isWorkingDay(0, newTaskImpl.getPlanned())) {
newTaskImpl.setPlanned(getFirstFollowingWorkingDay(newTaskImpl.getPlanned()));
}
} else {
Instant planned =
(converter.subtractWorkingDaysFromInstant(
newTaskImpl.getDue(), durationPrioHolder.getDuration()));
if (newTaskImpl.getPlanned() != null
&& !newTaskImpl.getPlanned().equals(oldTaskImpl.getPlanned())) {
ensureServiceLevelIsNotViolated(newTaskImpl, durationPrioHolder.getDuration(), planned);
}
newTaskImpl.setPlanned(planned);
if (!converter.isWorkingDay(0, newTaskImpl.getDue())) {
newTaskImpl.setDue(getFirstPreceedingWorkingDay(newTaskImpl.getDue()));
}
}
private boolean dueIsUnchangedOrNull(Task newTask, Task oldTask) {
return newTask.getDue() == null || oldTask.getDue().equals(newTask.getDue());
}
private Instant getFirstFollowingWorkingDay(Instant planned) {
long days = 0;
while (!converter.isWorkingDay(days, planned)) {
days++;
}
return planned.plus(Duration.ofDays(days));
private boolean plannedHasChanged(Task newTask, Task oldTask) {
return newTask.getPlanned() != null && !oldTask.getPlanned().equals(newTask.getPlanned());
}
private Instant getFirstPreceedingWorkingDay(Instant due) {
long days = 0;
while (!converter.isWorkingDay(days, due)) {
days--;
}
return due.minus(Duration.ofDays(Math.abs(days)));
private Instant getPrecedingWorkingDays(Instant instant, Duration days) {
return converter.subtractWorkingDaysFromInstant(instant, days);
}
private Instant getFollowingWorkingDays(Instant instant, Duration days) {
return converter.addWorkingDaysToInstant(instant, days);
}
/**
@ -319,34 +298,23 @@ class ServiceLevelHandler {
* calculating forward from planned to due will give Tuesday morning as due date, because sunday
* is skipped. On the other hand, calculating from due (Tuesday morning) 1 day backwards will
* result in a planned date of monday morning which differs from task.planned. Therefore, if
* task.getPlanned is not equal to planned, the service level is not violated and we still must
* grant the request if the following conditions are fulfilled: - planned is after task.planned -
* task.planned is not a working day, - there is no working day between task.planned and planned.
* task.planned is not equal to calcPlanned, the service level is not violated and we still must
* grant the request if the following conditions are fulfilled:
*
* <ul>
* <li>task.planned is not a working day
* <li>there are no working days between task.planned and calcPlanned
* </ul>
*
* @param task the task for the difference between planned and due must be duration
* @param duration the serviceLevel for the task
* @param planned the planned Timestamp thas was calculated based on due and duration
* @param planned the planned timestamp that was calculated based on due and duration
* @throws InvalidArgumentException if service level is violated.
*/
private void ensureServiceLevelIsNotViolated(TaskImpl task, Duration duration, Instant planned)
throws InvalidArgumentException {
if (task.getPlanned() != null && !task.getPlanned().equals(planned)) {
boolean isServiceLevelViolated = false;
Instant taskPlanned = task.getPlanned();
if (converter.isWorkingDay(0, taskPlanned)) {
isServiceLevelViolated = true;
} else if (taskPlanned.isAfter(planned)) {
isServiceLevelViolated = true;
} else {
long days = Duration.between(taskPlanned, planned).toDays();
for (long day = 0; day < days; day++) {
if (converter.isWorkingDay(day, taskPlanned)) {
isServiceLevelViolated = true;
break;
}
}
}
if (isServiceLevelViolated) {
if (hasWorkingDaysInBetween(task.getPlanned(), planned)) {
throw new InvalidArgumentException(
String.format(
"Cannot update a task with given planned %s "
@ -356,24 +324,50 @@ class ServiceLevelHandler {
}
}
private TaskImpl updatePlannedDueOnCreationOfNewTask(
TaskImpl newTaskImpl, DurationPrioHolder durationPrioHolder) throws InvalidArgumentException {
if (newTaskImpl.getDue() != null) { // due is specified: calculate back and check correctnes
Instant planned =
(converter.subtractWorkingDaysFromInstant(
newTaskImpl.getDue(), durationPrioHolder.getDuration()));
if (newTaskImpl.getPlanned() != null && !planned.equals(newTaskImpl.getPlanned())) {
throw new InvalidArgumentException(
"Cannot create a task with given planned "
+ "and due date not matching the service level");
}
newTaskImpl.setPlanned(planned);
} else { // task.due is null: calculate forward from planned
newTaskImpl.setDue(
converter.addWorkingDaysToInstant(
newTaskImpl.getPlanned(), durationPrioHolder.getDuration()));
/**
* Check if there are working days between the dates. The method respects if calc > planned or
* vise versa and excludes the calculated planned date from the check since it is always a working
* day!
*
* @param planned the changed planned date of a task
* @param calculated the calculated planned date of a task
* @return true if there are working days between the two dates
*/
private boolean hasWorkingDaysInBetween(Instant planned, Instant calculated) {
Instant withoutCalculated;
// exclude calculated from check since it is always a working day
if (planned.isAfter(calculated)) {
withoutCalculated = calculated.plus(Duration.ofDays(1)); // start 1 day later
} else if (planned.isBefore(calculated)) {
withoutCalculated = calculated.minus(Duration.ofDays(1)); // stop 1 day earlier
} else {
return false; // no violation if they are equal
}
return newTaskImpl;
return converter.hasWorkingDaysInBetween(planned, withoutCalculated);
}
private TaskImpl updatePlannedDueOnCreationOfNewTask(
TaskImpl newTask, DurationPrioHolder durationPrioHolder) throws InvalidArgumentException {
if (newTask.getDue() != null) {
// due is specified: calculate back and check correctness
Instant calcDue = getPrecedingWorkingDays(newTask.getDue(), Duration.ofDays(0));
Instant calcPlanned = getPrecedingWorkingDays(calcDue, durationPrioHolder.getDuration());
if (newTask.getPlanned() != null && !calcPlanned.equals(newTask.getPlanned())) {
throw new InvalidArgumentException(
String.format(
"Cannot update a task with given planned %s "
+ "and due date %s not matching the service level %s.",
newTask.getPlanned(), newTask.getDue(), durationPrioHolder.getDuration()));
}
newTask.setDue(calcDue);
newTask.setPlanned(calcPlanned);
} else {
// task.due is null: calculate forward from planned
newTask.setPlanned(getFollowingWorkingDays(newTask.getPlanned(), Duration.ofDays(0)));
newTask.setDue(
getFollowingWorkingDays(newTask.getPlanned(), durationPrioHolder.getDuration()));
}
return newTask;
}
private BulkLog updateDuePropertyOfAffectedTasks(
@ -388,13 +382,13 @@ class ServiceLevelHandler {
private BulkOperationResults<String, TaskanaException>
updateDuePropertyOfTasksWithIdenticalDueDate(
InstantDurationHolder instDurHld, List<TaskDuration> taskDurationList) {
InstantDurationHolder durationHolder, List<TaskDuration> taskDurationList) {
BulkLog bulkLog = new BulkLog();
TaskImpl referenceTask = new TaskImpl();
referenceTask.setPlanned(instDurHld.getPlanned());
referenceTask.setPlanned(durationHolder.getPlanned());
referenceTask.setModified(Instant.now());
referenceTask.setDue(
converter.addWorkingDaysToInstant(referenceTask.getPlanned(), instDurHld.getDuration()));
getFollowingWorkingDays(referenceTask.getPlanned(), durationHolder.getDuration()));
List<String> taskIdsToUpdate =
taskDurationList.stream().map(TaskDuration::getTaskId).collect(Collectors.toList());
long numTasksUpdated = taskMapper.updateTaskDueDates(taskIdsToUpdate, referenceTask);
@ -415,8 +409,7 @@ class ServiceLevelHandler {
referenceTask.setModified(Instant.now());
for (Map.Entry<Duration, List<String>> entry : durationToTaskIdsMap.entrySet()) {
List<String> taskIdsToUpdate = entry.getValue();
referenceTask.setDue(
converter.addWorkingDaysToInstant(referenceTask.getPlanned(), entry.getKey()));
referenceTask.setDue(getFollowingWorkingDays(referenceTask.getPlanned(), entry.getKey()));
long numTasksUpdated = taskMapper.updateTaskDueDates(taskIdsToUpdate, referenceTask);
if (numTasksUpdated != taskIdsToUpdate.size()) {
BulkLog checkResult =
@ -448,7 +441,7 @@ class ServiceLevelHandler {
if (numErrorsNotLogged != 0) {
for (int i = 1; i <= numErrorsNotLogged; i++) {
bulkLog.addError(
String.format("UnknownTaskId%s", Integer.valueOf(i)),
String.format("UnknownTaskId: %d", i),
new UpdateFailedException("Update of unknown task failed"));
}
}
@ -681,12 +674,14 @@ class ServiceLevelHandler {
}
static class BulkLog extends BulkOperationResults<String, TaskanaException> {
BulkLog() {
super();
}
}
static final class DurationPrioHolder {
private Duration duration;
private int priority;
@ -734,6 +729,7 @@ class ServiceLevelHandler {
}
private static final class TaskIdPriority {
private String taskId;
private int priority;
@ -760,6 +756,7 @@ class ServiceLevelHandler {
}
private static final class InstantDurationHolder {
private Instant planned;
private Duration duration;
@ -806,6 +803,7 @@ class ServiceLevelHandler {
}
private static final class ClassificationWithServiceLevelResolved {
private final int priority;
private final String classificationId;
private final Duration duration;

View File

@ -24,9 +24,7 @@ import pro.taskana.common.internal.transaction.TaskanaTransactionProvider;
import pro.taskana.common.internal.util.LogSanitizer;
import pro.taskana.task.api.models.TaskSummary;
/**
* Job to cleanup completed tasks after a period of time.
*/
/** Job to cleanup completed tasks after a period of time. */
public class TaskCleanupJob extends AbstractTaskanaJob {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskCleanupJob.class);
@ -56,8 +54,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
@Override
public void run() throws TaskanaException {
Instant completedBefore = Instant.now().minus(minimumAge);
LOGGER.info(
"Running job to delete all tasks completed before ({})", completedBefore);
LOGGER.info("Running job to delete all tasks completed before ({})", completedBefore);
try {
List<TaskSummary> tasksCompletedBefore = getTasksCompletedBefore(completedBefore);
int totalNumberOfTasksCompleted = 0;

View File

@ -41,9 +41,7 @@ import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
import pro.taskana.workbasket.internal.models.WorkbasketSummaryImpl;
/**
* This is the implementation of WorkbasketService.
*/
/** This is the implementation of WorkbasketService. */
public class WorkbasketServiceImpl implements WorkbasketService {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketServiceImpl.class);
@ -78,9 +76,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
workbasketId, "Workbasket with id " + workbasketId + " was not found.");
}
if (!taskanaEngine
.getEngine()
.isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN,
TaskanaRole.TASK_ADMIN)) {
.getEngine()
.isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN, TaskanaRole.TASK_ADMIN)) {
this.checkAuthorization(workbasketId, WorkbasketPermission.READ);
}
return result;
@ -105,9 +102,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
"Workbasket with key " + workbasketKey + " and domain " + domain + " was not found.");
}
if (!taskanaEngine
.getEngine()
.isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN,
TaskanaRole.TASK_ADMIN)) {
.getEngine()
.isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN, TaskanaRole.TASK_ADMIN)) {
this.checkAuthorization(workbasketKey, domain, WorkbasketPermission.READ);
}
return result;
@ -120,7 +116,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override
public Workbasket createWorkbasket(Workbasket newWorkbasket)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
DomainNotFoundException {
DomainNotFoundException {
LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -209,7 +205,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override
public WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException,
WorkbasketAccessItemAlreadyExistException {
WorkbasketAccessItemAlreadyExistException {
LOGGER.debug(
"entry to createWorkbasketAccessItemn(workbasketAccessItem = {})", workbasketAccessItem);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -218,8 +214,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection();
accessItem.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
if (workbasketAccessItem.getId() == null
|| workbasketAccessItem.getAccessId() == null
|| workbasketAccessItem.getWorkbasketId() == null) {
|| workbasketAccessItem.getAccessId() == null
|| workbasketAccessItem.getWorkbasketId() == null) {
throw new InvalidArgumentException(
String.format(
"Checking the preconditions of the current "
@ -246,7 +242,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
"SQLCODE=-803", // DB2
"uc_accessid_wbid", // POSTGRES
"UC_ACCESSID_WBID_INDEX_E" // H2
);
);
if (accessItemExistsIdentifier.anyMatch(e.getMessage()::contains)) {
throw new WorkbasketAccessItemAlreadyExistException(accessItem);
}
@ -273,9 +269,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
WorkbasketAccessItem originalItem = workbasketAccessMapper.findById(accessItem.getId());
if ((originalItem.getAccessId() != null
&& !originalItem.getAccessId().equals(accessItem.getAccessId()))
|| (originalItem.getWorkbasketId() != null
&& !originalItem.getWorkbasketId().equals(accessItem.getWorkbasketId()))) {
&& !originalItem.getAccessId().equals(accessItem.getAccessId()))
|| (originalItem.getWorkbasketId() != null
&& !originalItem.getWorkbasketId().equals(accessItem.getWorkbasketId()))) {
throw new InvalidArgumentException(
"AccessId and WorkbasketId must not be changed in updateWorkbasketAccessItem calls");
}
@ -439,7 +435,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
public void setWorkbasketAccessItems(
String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws InvalidArgumentException, NotAuthorizedException,
WorkbasketAccessItemAlreadyExistException {
WorkbasketAccessItemAlreadyExistException {
LOGGER.debug(
"entry to setWorkbasketAccessItems(workbasketAccessItems = {})", wbAccessItems.toString());
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -518,8 +514,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection();
// check that source workbasket exists
getWorkbasket(workbasketId);
if (!taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN,
TaskanaRole.TASK_ADMIN)) {
if (!taskanaEngine
.getEngine()
.isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN, TaskanaRole.TASK_ADMIN)) {
checkAuthorization(workbasketId, WorkbasketPermission.READ);
}
List<WorkbasketSummaryImpl> distributionTargets =
@ -548,8 +545,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection();
// check that source workbasket exists
Workbasket workbasket = getWorkbasket(workbasketKey, domain);
if (!taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN,
TaskanaRole.TASK_ADMIN)) {
if (!taskanaEngine
.getEngine()
.isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN, TaskanaRole.TASK_ADMIN)) {
checkAuthorization(workbasket.getId(), WorkbasketPermission.READ);
}
List<WorkbasketSummaryImpl> distributionTargets =
@ -696,7 +694,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override
public boolean deleteWorkbasket(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException,
InvalidArgumentException {
InvalidArgumentException {
LOGGER.debug("entry to deleteWorkbasket(workbasketId = {})", workbasketId);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -868,9 +866,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
/**
* Check if current workbasket is based on the newest (by modified).
*
* @param oldWorkbasket the old workbasket in the system
* @param oldWorkbasket the old workbasket in the system
* @param workbasketImplToUpdate the workbasket to update
* @throws ConcurrencyException if the workbasket has been modified by some other process.
* @throws ConcurrencyException if the workbasket has been modified by some other process.
* @throws WorkbasketNotFoundException if the given workbasket does not exist.
*/
void checkModifiedHasNotChanged(Workbasket oldWorkbasket, WorkbasketImpl workbasketImplToUpdate)
@ -897,21 +895,21 @@ public class WorkbasketServiceImpl implements WorkbasketService {
private long getCountTasksByWorkbasketId(String workbasketId) {
return taskanaEngine
.getEngine()
.getTaskService()
.createTaskQuery()
.workbasketIdIn(workbasketId)
.count();
.getEngine()
.getTaskService()
.createTaskQuery()
.workbasketIdIn(workbasketId)
.count();
}
private long getCountTasksNotCompletedByWorkbasketId(String workbasketId) {
return taskanaEngine
.getEngine()
.getTaskService()
.createTaskQuery()
.workbasketIdIn(workbasketId)
.stateNotIn(TaskState.COMPLETED, TaskState.TERMINATED, TaskState.CANCELLED)
.count();
.getEngine()
.getTaskService()
.createTaskQuery()
.workbasketIdIn(workbasketId)
.stateNotIn(TaskState.COMPLETED, TaskState.TERMINATED, TaskState.CANCELLED)
.count();
}
private boolean skipAuthorizationCheck(WorkbasketPermission... requestedPermissions) {

View File

@ -7,6 +7,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
@ -102,9 +103,9 @@ public abstract class AbstractAccTest {
protected TimeInterval toDaysInterval() {
Instant begin =
LocalDateTime.of(LocalDate.now(), LocalTime.MIN).atZone(ZoneId.of("UTC")).toInstant();
ZonedDateTime.of(LocalDate.now(ZoneId.of("UTC")), LocalTime.MIN, ZoneId.of("UTC")).toInstant();
Instant end =
LocalDateTime.of(LocalDate.now(), LocalTime.MAX).atZone(ZoneId.of("UTC")).toInstant();
ZonedDateTime.of(LocalDate.now(ZoneId.of("UTC")), LocalTime.MAX, ZoneId.of("UTC")).toInstant();
return new TimeInterval(begin, end);
}

View File

@ -17,9 +17,7 @@ import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
/**
* Acceptance test for all "delete classification" scenarios.
*/
/** Acceptance test for all "delete classification" scenarios. */
@ExtendWith(JaasExtension.class)
class DeleteClassificationAccTest extends AbstractAccTest {
@ -55,8 +53,7 @@ class DeleteClassificationAccTest extends AbstractAccTest {
@TestTemplate
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
ThrowingCallable call =
() -> classificationService.deleteClassification("L140101", "DOMAIN_A");
ThrowingCallable call = () -> classificationService.deleteClassification("L140101", "DOMAIN_A");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);

View File

@ -76,7 +76,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
.domainIn("DOMAIN_A")
.list();
assertThat(classificationSummaryList).hasSize(2);
assertThat(classificationSummaryList).hasSize(3);
}
@Test
@ -101,10 +101,10 @@ class QueryClassificationAccTest extends AbstractAccTest {
.list();
assertThat(classifications)
.hasSize(28)
.hasSize(30)
.extracting(ClassificationSummary::getType)
.containsOnly("TASK", "DOCUMENT")
.areExactly(26, new Condition<>("TASK"::equals, "TASK"))
.areExactly(28, new Condition<>("TASK"::equals, "TASK"))
.areExactly(2, new Condition<>("DOCUMENT"::equals, "DOCUMENT"));
}
@ -193,7 +193,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
.domainIn("DOMAIN_A")
.typeIn("TASK")
.list();
assertThat(classifications).hasSize(13);
assertThat(classifications).hasSize(14);
}
@Test
@ -217,7 +217,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
.createdWithin(toDaysInterval())
.list();
assertThat(classificationSummaryList).hasSize(17);
assertThat(classificationSummaryList).hasSize(18);
}
@Test
@ -229,7 +229,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
.priorityIn(1, 2, 3)
.list();
assertThat(list).hasSize(15);
assertThat(list).hasSize(16);
}
@WithAccessId(user = "businessadmin")
@ -326,7 +326,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
.createClassificationQuery()
.customAttributeIn("2", "CUSTOM2", "custom2")
.list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(5);
}
@Test
@ -336,28 +336,28 @@ class QueryClassificationAccTest extends AbstractAccTest {
.createClassificationQuery()
.customAttributeIn("3", "Custom3", "custom3")
.list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(5);
}
@Test
void testQueryForCustom4In() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeIn("4", "custom4").list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(5);
}
@Test
void testQueryForCustom5In() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeIn("5", "custom5").list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(5);
}
@Test
void testQueryForCustom6In() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeIn("6", "custom6").list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(5);
}
@Test
@ -367,7 +367,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
.createClassificationQuery()
.customAttributeIn("7", "custom7", "custom_7")
.list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(5);
}
@Test
@ -377,56 +377,56 @@ class QueryClassificationAccTest extends AbstractAccTest {
.createClassificationQuery()
.customAttributeIn("8", "custom_8", "custom8")
.list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(5);
}
@Test
void testQueryForCustom2Like() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("2", "cus%").list();
assertThat(results).hasSize(4);
assertThat(results).hasSize(6);
}
@Test
void testQueryForCustom3Like() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("3", "cus%").list();
assertThat(results).hasSize(4);
assertThat(results).hasSize(6);
}
@Test
void testQueryForCustom4Like() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("4", "cus%").list();
assertThat(results).hasSize(4);
assertThat(results).hasSize(6);
}
@Test
void testQueryForCustom5Like() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("5", "cus%").list();
assertThat(results).hasSize(4);
assertThat(results).hasSize(6);
}
@Test
void testQueryForCustom6Like() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("6", "cus%").list();
assertThat(results).hasSize(4);
assertThat(results).hasSize(6);
}
@Test
void testQueryForCustom7Like() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("7", "cus%").list();
assertThat(results).hasSize(4);
assertThat(results).hasSize(6);
}
@Test
void testQueryForCustom8Like() throws InvalidArgumentException {
List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("8", "cus%").list();
assertThat(results).hasSize(4);
assertThat(results).hasSize(6);
}
@Test

View File

@ -85,7 +85,7 @@ class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
.createClassificationQuery()
.domainIn("DOMAIN_A")
.listPage(pageNumber, pageSize);
assertThat(results).hasSize(17);
assertThat(results).hasSize(18);
// Getting last results on multiple pages
pageNumber = 2;
@ -95,7 +95,7 @@ class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
.createClassificationQuery()
.domainIn("DOMAIN_A")
.listPage(pageNumber, pageSize);
assertThat(results).hasSize(7);
assertThat(results).hasSize(8);
}
@Test
@ -137,6 +137,6 @@ class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
void testCountOfClassificationsQuery() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
long count = classificationService.createClassificationQuery().domainIn("DOMAIN_A").count();
assertThat(count).isEqualTo(17L);
assertThat(count).isEqualTo(18L);
}
}

View File

@ -30,7 +30,6 @@ public class TaskanaSecurityConfigAccTest {
sampleDataGenerator.dropDb();
DbSchemaCreator dbSchemaCreator = new DbSchemaCreator(dataSource, schemaName);
dbSchemaCreator.run();
}
@Test
@ -39,17 +38,19 @@ public class TaskanaSecurityConfigAccTest {
setSecurityFlag(true);
ThrowingCallable createUnsecuredTaskanaEngineConfiguration = () -> {
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(
TaskanaEngineTestConfiguration.getDataSource(), false, false,
TaskanaEngineTestConfiguration.getSchemaName());
};
ThrowingCallable createUnsecuredTaskanaEngineConfiguration =
() -> {
TaskanaEngineConfiguration taskanaEngineConfiguration =
new TaskanaEngineConfiguration(
TaskanaEngineTestConfiguration.getDataSource(),
false,
false,
TaskanaEngineTestConfiguration.getSchemaName());
};
assertThatThrownBy(createUnsecuredTaskanaEngineConfiguration)
.isInstanceOf(SystemException.class)
.hasMessageContaining("Secured TASKANA mode is enforced, can't start in unsecured mode");
}
@Test
@ -58,15 +59,17 @@ public class TaskanaSecurityConfigAccTest {
setSecurityFlag(false);
ThrowingCallable createUnsecuredTaskanaEngineConfiguration = () -> {
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(
TaskanaEngineTestConfiguration.getDataSource(), false, false,
TaskanaEngineTestConfiguration.getSchemaName());
};
ThrowingCallable createUnsecuredTaskanaEngineConfiguration =
() -> {
TaskanaEngineConfiguration taskanaEngineConfiguration =
new TaskanaEngineConfiguration(
TaskanaEngineTestConfiguration.getDataSource(),
false,
false,
TaskanaEngineTestConfiguration.getSchemaName());
};
assertThatCode(createUnsecuredTaskanaEngineConfiguration).doesNotThrowAnyException();
}
@Test
@ -75,17 +78,19 @@ public class TaskanaSecurityConfigAccTest {
assertThat(retrieveSecurityFlag()).isNull();
ThrowingCallable createUnsecuredTaskanaEngineConfiguration = () -> {
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(
TaskanaEngineTestConfiguration.getDataSource(), false, false,
TaskanaEngineTestConfiguration.getSchemaName());
};
ThrowingCallable createUnsecuredTaskanaEngineConfiguration =
() -> {
TaskanaEngineConfiguration taskanaEngineConfiguration =
new TaskanaEngineConfiguration(
TaskanaEngineTestConfiguration.getDataSource(),
false,
false,
TaskanaEngineTestConfiguration.getSchemaName());
};
assertThatCode(createUnsecuredTaskanaEngineConfiguration).doesNotThrowAnyException();
assertThat(retrieveSecurityFlag()).isFalse();
}
@Test
@ -94,26 +99,28 @@ public class TaskanaSecurityConfigAccTest {
assertThat(retrieveSecurityFlag()).isNull();
ThrowingCallable createSecuredTaskanaEngineConfiguration = () -> {
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(
TaskanaEngineTestConfiguration.getDataSource(), false, true,
TaskanaEngineTestConfiguration.getSchemaName());
};
ThrowingCallable createSecuredTaskanaEngineConfiguration =
() -> {
TaskanaEngineConfiguration taskanaEngineConfiguration =
new TaskanaEngineConfiguration(
TaskanaEngineTestConfiguration.getDataSource(),
false,
true,
TaskanaEngineTestConfiguration.getSchemaName());
};
assertThatCode(createSecuredTaskanaEngineConfiguration).doesNotThrowAnyException();
assertThat(retrieveSecurityFlag()).isTrue();
}
private Boolean retrieveSecurityFlag() throws SQLException {
try (Connection connection = TaskanaEngineTestConfiguration.getDataSource().getConnection()) {
String selectSecurityFlagSql = String
.format("SELECT * FROM %s.CONFIGURATION",
TaskanaEngineTestConfiguration.getSchemaName());
String selectSecurityFlagSql =
String.format(
"SELECT * FROM %s.CONFIGURATION", TaskanaEngineTestConfiguration.getSchemaName());
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(selectSecurityFlagSql);
@ -123,18 +130,17 @@ public class TaskanaSecurityConfigAccTest {
}
statement.close();
return null;
}
}
private void setSecurityFlag(boolean securityFlag) throws SQLException {
try (Connection connection = TaskanaEngineTestConfiguration.getDataSource().getConnection()) {
String sql = String
.format("INSERT INTO %s.CONFIGURATION VALUES (%b)",
TaskanaEngineTestConfiguration.getSchemaName(), securityFlag);
String sql =
String.format(
"INSERT INTO %s.CONFIGURATION VALUES (%b)",
TaskanaEngineTestConfiguration.getSchemaName(), securityFlag);
Statement statement = connection.createStatement();
statement.execute(sql);
@ -142,7 +148,6 @@ public class TaskanaSecurityConfigAccTest {
connection.commit();
}
statement.close();
}
}
}

View File

@ -45,7 +45,7 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
createAndCompleteTask();
long totalTasksCount = taskService.createTaskQuery().count();
assertThat(totalTasksCount).isEqualTo(84);
assertThat(totalTasksCount).isEqualTo(85);
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(false);
@ -53,14 +53,14 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
job.run();
totalTasksCount = taskService.createTaskQuery().count();
assertThat(totalTasksCount).isEqualTo(68);
assertThat(totalTasksCount).isEqualTo(69);
}
@WithAccessId(user = "admin")
@Test
void shouldCleanCompletedTasksUntilDateWithSameParentBussiness() throws Exception {
long totalTasksCount = taskService.createTaskQuery().count();
assertThat(totalTasksCount).isEqualTo(83);
assertThat(totalTasksCount).isEqualTo(84);
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
@ -79,7 +79,7 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
job.run();
totalTasksCount = taskService.createTaskQuery().count();
assertThat(totalTasksCount).isEqualTo(66);
assertThat(totalTasksCount).isEqualTo(67);
}
@WithAccessId(user = "admin")

View File

@ -31,7 +31,7 @@ class ClassificationQueryAccTest extends AbstractAccTest {
classificationService.createClassificationQuery().domainIn("DOMAIN_A").list();
assertThat(classificationSummaryList).isNotNull();
assertThat(classificationSummaryList).hasSize(17);
assertThat(classificationSummaryList).hasSize(18);
}
@WithAccessId(user = "businessadmin")
@ -42,7 +42,7 @@ class ClassificationQueryAccTest extends AbstractAccTest {
classificationService.createClassificationQuery().domainIn("DOMAIN_A").list();
assertThat(classificationSummaryList).isNotNull();
assertThat(classificationSummaryList).hasSize(17);
assertThat(classificationSummaryList).hasSize(18);
}
@WithAccessId(user = "admin")
@ -53,6 +53,6 @@ class ClassificationQueryAccTest extends AbstractAccTest {
classificationService.createClassificationQuery().domainIn("DOMAIN_A").list();
assertThat(classificationSummaryList).isNotNull();
assertThat(classificationSummaryList).hasSize(17);
assertThat(classificationSummaryList).hasSize(18);
}
}

View File

@ -36,7 +36,7 @@ class TaskQueryAccTest extends AbstractAccTest {
List<TaskSummary> results = taskService.createTaskQuery().ownerLike("%a%", "%u%").list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(4);
}
@WithAccessId(user = "user_1_1", groups = "businessadmin")
@ -46,7 +46,7 @@ class TaskQueryAccTest extends AbstractAccTest {
List<TaskSummary> results = taskService.createTaskQuery().ownerLike("%a%", "%u%").list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(4);
}
@WithAccessId(user = "user_1_1", groups = "admin")
@ -56,6 +56,6 @@ class TaskQueryAccTest extends AbstractAccTest {
List<TaskSummary> results = taskService.createTaskQuery().ownerLike("%a%", "%u%").list();
assertThat(results).hasSize(35);
assertThat(results).hasSize(36);
}
}

View File

@ -22,9 +22,7 @@ import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary;
/**
* Acceptance tests for all "cancel task" scenarios.
*/
/** Acceptance tests for all "cancel task" scenarios. */
@ExtendWith(JaasExtension.class)
class CancelTaskAccTest extends AbstractAccTest {
@ -81,14 +79,14 @@ class CancelTaskAccTest extends AbstractAccTest {
throws NotAuthorizedException, TaskNotFoundException, InvalidStateException {
List<TaskSummary> taskSummaries =
taskService.createTaskQuery().stateIn(TaskState.CLAIMED).list();
assertThat(taskSummaries).hasSize(16);
assertThat(taskSummaries).hasSize(17);
long numTasksCancelled = taskService.createTaskQuery().stateIn(TaskState.CANCELLED).count();
assertThat(numTasksCancelled).isEqualTo(5);
taskService.cancelTask(taskSummaries.get(0).getId());
long numTasksClaimed = taskService.createTaskQuery().stateIn(TaskState.CLAIMED).count();
assertThat(numTasksClaimed).isEqualTo(15);
assertThat(numTasksClaimed).isEqualTo(16);
numTasksCancelled = taskService.createTaskQuery().stateIn(TaskState.CANCELLED).count();
assertThat(numTasksCancelled).isEqualTo(6);
}

View File

@ -27,9 +27,7 @@ import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
/**
* Acceptance tests for all claim and complete scenarios.
*/
/** Acceptance tests for all claim and complete scenarios. */
@ExtendWith(JaasExtension.class)
class CompleteTaskAccTest extends AbstractAccTest {
@ -41,7 +39,7 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testCompleteTask()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
assertThat(taskService.getTask("TKI:000000000000000000000000000000000001").getState())
@ -58,7 +56,7 @@ class CompleteTaskAccTest extends AbstractAccTest {
@TestTemplate
void should_ForceCompleteTask_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException, SQLException {
NotAuthorizedException, SQLException {
resetDb(false);
TaskService taskService = taskanaEngine.getTaskService();
@ -76,7 +74,7 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testCompleteTaskTwice()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
Task completedTask = taskService.completeTask("TKI:000000000000000000000000000000000002");
Task completedTask2 = taskService.completeTask("TKI:000000000000000000000000000000000002");
@ -87,8 +85,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testForceCompleteAlreadyClaimed()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidOwnerException, InvalidStateException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidOwnerException, InvalidStateException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -113,8 +111,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testForceCompleteNotClaimed()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidOwnerException, InvalidStateException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidOwnerException, InvalidStateException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -168,8 +166,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testClaimTaskWithDefaultFlag()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -198,8 +196,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testForceClaimTaskFromOtherUser()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -276,8 +274,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testCancelClaimDefaultFlag()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -299,7 +297,7 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testForceCancelClaimSuccessfull()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException, InterruptedException {
NotAuthorizedException, InterruptedException {
TaskService taskService = taskanaEngine.getTaskService();
Task taskBefore = taskService.getTask("TKI:000000000000000000000000000000000043");

View File

@ -493,7 +493,7 @@ class CreateTaskAccTest extends AbstractAccTest {
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Instant planned = Instant.now().plus(10, ChronoUnit.DAYS);
Instant planned = getInstant("2020-05-25T07:00:00");
newTask.setPlanned(planned);
Task createdTask = taskService.createTask(newTask);
assertThat(createdTask.getId()).isNotNull();

View File

@ -31,7 +31,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
@Test
void should_DeleteTaskComment_For_TaskCommentId()
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
InvalidArgumentException {
InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
@ -74,7 +74,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
@TestTemplate
void should_DeleteTaskComment_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
InvalidArgumentException, SQLException {
InvalidArgumentException, SQLException {
resetDb(false);

View File

@ -19,9 +19,7 @@ import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task;
/**
* Acceptance test for all "get task" scenarios.
*/
/** Acceptance test for all "get task" scenarios. */
@ExtendWith(JaasExtension.class)
class GetTaskAccTest extends AbstractAccTest {

View File

@ -145,7 +145,7 @@ class QueryTasksAccTest extends AbstractAccTest {
.orderByClassificationKey(DESCENDING)
.listValues(CLASSIFICATION_KEY, null);
assertThat(columnValueList).isNotNull();
assertThat(columnValueList).hasSize(6);
assertThat(columnValueList).hasSize(7);
}
@WithAccessId(
@ -157,7 +157,7 @@ class QueryTasksAccTest extends AbstractAccTest {
List<TaskSummary> results =
taskService.createTaskQuery().ownerLike("%a%", "%u%").orderByCreated(ASCENDING).list();
assertThat(results).hasSize(35);
assertThat(results).hasSize(36);
TaskSummary previousSummary = null;
for (TaskSummary taskSummary : results) {
if (previousSummary != null) {
@ -175,7 +175,7 @@ class QueryTasksAccTest extends AbstractAccTest {
List<TaskSummary> results =
taskService.createTaskQuery().parentBusinessProcessIdLike("%PBPI%", "doc%3%").list();
assertThat(results).hasSize(32);
assertThat(results).hasSize(33);
for (TaskSummary taskSummary : results) {
assertThat(taskSummary.getExternalId()).isNotNull();
}
@ -185,7 +185,7 @@ class QueryTasksAccTest extends AbstractAccTest {
List<TaskSummary> result2 =
taskService.createTaskQuery().parentBusinessProcessIdIn(parentIds).list();
assertThat(result2).hasSize(32);
assertThat(result2).hasSize(33);
}
@WithAccessId(
@ -195,12 +195,12 @@ class QueryTasksAccTest extends AbstractAccTest {
void testQueryForName() {
List<TaskSummary> results = taskService.createTaskQuery().nameLike("task%").list();
assertThat(results).hasSize(6);
assertThat(results).hasSize(7);
String[] ids = results.stream().map(TaskSummary::getName).toArray(String[]::new);
List<TaskSummary> result2 = taskService.createTaskQuery().nameIn(ids).list();
assertThat(result2).hasSize(6);
assertThat(result2).hasSize(7);
}
@WithAccessId(
@ -220,11 +220,11 @@ class QueryTasksAccTest extends AbstractAccTest {
List<TaskSummary> result3 =
taskService.createTaskQuery().classificationKeyNotIn("T2100", "T2000").list();
assertThat(result3).hasSize(81);
assertThat(result3).hasSize(82);
List<TaskSummary> result4 =
taskService.createTaskQuery().classificationKeyNotIn("L1050", "L1060", "T2100").list();
assertThat(result4).hasSize(6);
assertThat(result4).hasSize(7);
}
@WithAccessId(user = "teamlead_1", groups = "group_1")
@ -277,7 +277,7 @@ class QueryTasksAccTest extends AbstractAccTest {
.createTaskQuery()
.externalIdLike("ETI:000000000000000000000000000000%")
.listValues(TaskQueryColumnName.EXTERNAL_ID, DESCENDING);
assertThat(resultValues).hasSize(70);
assertThat(resultValues).hasSize(71);
long countAllExternalIds = taskService.createTaskQuery().externalIdLike("ETI:%").count();
long countAllIds = taskService.createTaskQuery().count();
@ -302,7 +302,7 @@ class QueryTasksAccTest extends AbstractAccTest {
new Triplet<>("11", new String[] {"%"}, 3),
new Triplet<>("12", new String[] {"%"}, 3),
new Triplet<>("13", new String[] {"%"}, 3),
new Triplet<>("14", new String[] {"%"}, 58),
new Triplet<>("14", new String[] {"%"}, 59),
new Triplet<>("15", new String[] {"%"}, 3),
new Triplet<>("16", new String[] {"%"}, 3));
@ -460,7 +460,7 @@ class QueryTasksAccTest extends AbstractAccTest {
@Test
void testQueryForNoteLike() {
List<TaskSummary> results = taskService.createTaskQuery().noteLike("Some%").list();
assertThat(results).hasSize(6);
assertThat(results).hasSize(7);
}
@WithAccessId(user = "admin")
@ -468,7 +468,7 @@ class QueryTasksAccTest extends AbstractAccTest {
void testQueryForClassificationCategoryIn() {
List<TaskSummary> results =
taskService.createTaskQuery().classificationCategoryIn("MANUAL", "AUTOMATIC").list();
assertThat(results).hasSize(3);
assertThat(results).hasSize(4);
}
@WithAccessId(user = "admin")
@ -484,7 +484,7 @@ class QueryTasksAccTest extends AbstractAccTest {
void testQueryForPrimaryObjectReferenceCompanyLike() {
List<TaskSummary> results =
taskService.createTaskQuery().primaryObjectReferenceCompanyLike("My%").list();
assertThat(results).hasSize(6);
assertThat(results).hasSize(7);
}
@WithAccessId(user = "admin")
@ -492,7 +492,7 @@ class QueryTasksAccTest extends AbstractAccTest {
void testQueryForPrimaryObjectReferenceSystemLike() {
List<TaskSummary> results =
taskService.createTaskQuery().primaryObjectReferenceSystemLike("My%").list();
assertThat(results).hasSize(6);
assertThat(results).hasSize(7);
}
@WithAccessId(user = "admin")
@ -500,7 +500,7 @@ class QueryTasksAccTest extends AbstractAccTest {
void testQueryForPrimaryObjectReferenceSystemInstanceLike() {
List<TaskSummary> results =
taskService.createTaskQuery().primaryObjectReferenceSystemInstanceLike("My%").list();
assertThat(results).hasSize(6);
assertThat(results).hasSize(7);
}
@WithAccessId(user = "admin")
@ -508,14 +508,14 @@ class QueryTasksAccTest extends AbstractAccTest {
void testQueryForPrimaryObjectReferenceTypeLike() {
List<TaskSummary> results =
taskService.createTaskQuery().primaryObjectReferenceTypeLike("My%").list();
assertThat(results).hasSize(6);
assertThat(results).hasSize(7);
}
@WithAccessId(user = "admin")
@Test
void testQueryForReadEquals() {
List<TaskSummary> results = taskService.createTaskQuery().readEquals(true).list();
assertThat(results).hasSize(35);
assertThat(results).hasSize(36);
}
@WithAccessId(user = "admin")
@ -530,7 +530,7 @@ class QueryTasksAccTest extends AbstractAccTest {
void testQueryForBusinessProcessIdIn() {
List<TaskSummary> results =
taskService.createTaskQuery().businessProcessIdIn("PI_0000000000003", "BPI21").list();
assertThat(results).hasSize(8);
assertThat(results).hasSize(9);
}
@WithAccessId(user = "admin")

View File

@ -69,7 +69,7 @@ class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
List<TaskSummary> results =
taskService.createTaskQuery().createdWithin(interval1).orderByCreated(asc).list();
assertThat(results).hasSize(37);
assertThat(results).hasSize(38);
TaskSummary previousSummary = null;
for (TaskSummary taskSummary : results) {
Instant cr = taskSummary.getCreated();
@ -176,7 +176,7 @@ class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
List<TaskSummary> results =
taskService.createTaskQuery().modifiedWithin(interval).orderByModified(asc).list();
assertThat(results).hasSize(6);
assertThat(results).hasSize(7);
TaskSummary previousSummary = null;
for (TaskSummary taskSummary : results) {
Instant cr = taskSummary.getModified();
@ -201,7 +201,7 @@ class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
List<TaskSummary> results =
taskService.createTaskQuery().plannedWithin(interval).orderByPlanned(asc).list();
assertThat(results).hasSize(81);
assertThat(results).hasSize(82);
TaskSummary previousSummary = null;
for (TaskSummary taskSummary : results) {
Instant cr = taskSummary.getPlanned();
@ -226,7 +226,7 @@ class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
List<TaskSummary> results =
taskService.createTaskQuery().dueWithin(interval).orderByPlanned(asc).list();
assertThat(results).hasSize(81);
assertThat(results).hasSize(82);
TaskSummary previousSummary = null;
for (TaskSummary taskSummary : results) {
Instant cr = taskSummary.getDue();

View File

@ -34,6 +34,7 @@ import pro.taskana.task.api.models.Task;
@ExtendWith(JaasExtension.class)
@SuppressWarnings({"checkstyle:LineLength"})
public class ServiceLevelPriorityAccTest extends AbstractAccTest {
private TaskService taskService;
ServiceLevelPriorityAccTest() {
@ -46,12 +47,12 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
@Test
public void should_ThrowException_When_DueAndPlannedAreChangedInconsistently() throws Exception {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
Task task = taskService.getTask("TKI:000000000000000000000000000000000000"); // P1D
task.setDue(Instant.parse("2020-07-02T00:00:00Z"));
task.setPlanned(Instant.parse("2020-07-07T00:00:00Z"));
assertThatThrownBy(() -> taskService.updateTask(task))
.isInstanceOf(InvalidArgumentException.class)
.withFailMessage(
.hasMessage(
"Cannot update a task with given planned 2020-07-07T00:00:00Z and due "
+ "date 2020-07-02T00:00:00Z not matching the service level PT24H.");
}
@ -261,6 +262,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
// |TAI:000000000000000000000000000000000005 | CLI:000000000000000000000000000000000006 | P5D |
// |TAI:000000000000000000000000000000000006 | CLI:000000000000000000000000000000000007 | P6D |
// |TAI:000000000000000000000000000000000007 | CLI:100000000000000000000000000000000008 | P1D |
// |TKI:000000000000000000000000000000000066 | CLI:100000000000000000000000000000000024 | P0D |
// +-----------------------------------------+------------------------------------------+------+
@WithAccessId(user = "admin", groups = "group_2")
@Test
@ -300,14 +302,14 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException,
ConcurrencyException, InvalidStateException, ClassificationNotFoundException,
AttachmentPersistenceException {
String taskId = "TKI:000000000000000000000000000000000002";
String taskId = "TKI:000000000000000000000000000000000002"; // P1D
Instant planned = getInstant("2020-05-03T07:00:00");
Task task = taskService.getTask(taskId);
// test update of due with unchanged planned
task.setDue(planned.plus(Duration.ofDays(8)));
task.setDue(planned.plus(Duration.ofDays(8))); // Monday
task = taskService.updateTask(task);
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-05-08T07:00:00"));
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-05-08T07:00:00")); // Friday
}
@WithAccessId(user = "admin", groups = "group_2")
@ -352,7 +354,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
ConcurrencyException, InvalidStateException, ClassificationNotFoundException,
AttachmentPersistenceException {
String taskId = "TKI:000000000000000000000000000000000002";
final Instant planned = getInstant("2020-05-03T07:00:00");
final Instant planned = getInstant("2020-05-03T07:00:00"); // Sunday
Task task = taskService.getTask(taskId);
task.setPlanned(null);
@ -366,16 +368,15 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
days = converter.convertWorkingDaysToDays(task.getPlanned(), 1);
assertThat(task.getDue()).isEqualTo(task.getPlanned().plus(Duration.ofDays(days)));
task.setPlanned(planned.plus(Duration.ofDays(13)));
task.setPlanned(planned.plus(Duration.ofDays(13))); // Saturday
task.setDue(null);
task = taskService.updateTask(task);
days = converter.convertWorkingDaysToDays(task.getPlanned(), 1);
assertThat(task.getDue()).isEqualTo(task.getPlanned().plus(Duration.ofDays(days)));
task.setDue(planned.plus(Duration.ofDays(13))); // due = 2020-05-16, i.e. saturday
task.setDue(planned.plus(Duration.ofDays(13))); // Saturday
task.setPlanned(null);
task = taskService.updateTask(task);
days = converter.convertWorkingDaysToDays(task.getDue(), -1);
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-05-14T07:00:00"));
assertThat(task.getDue()).isEqualTo(getInstant("2020-05-15T07:00:00"));
}
@ -410,4 +411,93 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
task = taskService.updateTask(task);
assertThat(task.getDue()).isEqualTo(getInstant("2020-03-20T07:00:00")); // friday
}
@WithAccessId(user = "user1_4", groups = "group_1")
@Test
void should_UpdateTaskPlannedOrDue_When_PlannedOrDueAreOnWeekends_ServiceLevel_P0D()
throws NotAuthorizedException, TaskNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, InvalidStateException, ConcurrencyException,
AttachmentPersistenceException {
Task task = taskService.getTask("TKI:000000000000000000000000000000000066"); // P0D
// nothing changed
task = taskService.updateTask(task);
assertThat(task.getDue()).isEqualTo(getInstant("2018-01-29T15:55:00")); // Monday
assertThat(task.getPlanned()).isEqualTo(getInstant("2018-01-29T15:55:00")); // Monday
// planned changed, due did not change
task.setPlanned(getInstant("2020-03-21T07:00:00")); // Saturday
task = taskService.updateTask(task);
assertThat(task.getDue()).isEqualTo(getInstant("2020-03-23T07:00:00")); // Monday
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-03-23T07:00:00")); // Monday
// due changed, planned did not change
task.setDue(getInstant("2020-04-12T07:00:00")); // Sunday
task = taskService.updateTask(task);
assertThat(task.getPlanned())
.isEqualTo(getInstant("2020-04-09T07:00:00")); // Thursday (skip Good Friday)
assertThat(task.getDue()).isEqualTo(getInstant("2020-04-09T07:00:00"));
// due changed, planned is null
task.setDue(getInstant("2020-04-11T07:00:00")); // Saturday
task.setPlanned(null);
task = taskService.updateTask(task);
assertThat(task.getPlanned())
.isEqualTo(getInstant("2020-04-09T07:00:00")); // Thursday (skip Good Friday)
assertThat(task.getDue()).isEqualTo(getInstant("2020-04-09T07:00:00"));
// planned changed, due is null
task.setPlanned(getInstant("2020-03-22T07:00:00")); // Sunday
task.setDue(null);
task = taskService.updateTask(task);
assertThat(task.getDue()).isEqualTo(getInstant("2020-03-23T07:00:00")); // Monday
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-03-23T07:00:00")); // Monday
// both changed, not null (due at weekend)
task.setPlanned(getInstant("2020-03-20T07:00:00")); // Friday
task.setDue(getInstant("2020-03-22T07:00:00")); // Sunday
task = taskService.updateTask(task);
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-03-20T07:00:00")); // Friday
assertThat(task.getDue()).isEqualTo(getInstant("2020-03-20T07:00:00")); // Friday
// both changed, not null (planned at weekend)
task.setPlanned(getInstant("2020-03-22T07:00:00")); // Sunday
task.setDue(getInstant("2020-03-23T07:00:00")); // Monday
task = taskService.updateTask(task);
assertThat(task.getDue()).isEqualTo(getInstant("2020-03-23T07:00:00")); // Monday
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-03-23T07:00:00")); // Monday
// both changed, not null (both at weekend) within SLA
task.setPlanned(getInstant("2020-03-22T07:00:00")); // Sunday
task.setDue(getInstant("2020-03-22T07:00:00")); // Sunday
task = taskService.updateTask(task);
assertThat(task.getDue()).isEqualTo(getInstant("2020-03-20T07:00:00")); // Friday
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-03-20T07:00:00")); // Friday
// both changed, not null (planned > due)
task.setPlanned(getInstant("2020-03-24T07:00:00")); // Tuesday
task.setDue(getInstant("2020-03-23T07:00:00")); // Monday
Task finalTask = task;
assertThatThrownBy(() -> taskService.updateTask(finalTask))
.isInstanceOf(InvalidArgumentException.class)
.hasMessage(
"Cannot update a task with given planned 2020-03-24T07:00:00Z and "
+ "due date 2020-03-23T07:00:00Z not matching the service level PT0S.");
}
@WithAccessId(user = "user_1_2", groups = "group_1")
@Test
void should_notThrowServiceLevelViolation_IfWeekendOrHolidaysBetweenDates()
throws NotAuthorizedException, TaskNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, InvalidStateException, ConcurrencyException,
AttachmentPersistenceException {
Task task = taskService.getTask("TKI:000000000000000000000000000000000002"); // P1D
// SLA is broken but only with holidays in between
task.setDue(getInstant("2020-04-14T07:00:00")); // Tuesday after Easter
task.setPlanned(getInstant("2020-04-09T07:00:00")); // Thursday before Easter
task = taskService.updateTask(task);
assertThat(task.getDue()).isEqualTo(getInstant("2020-04-14T07:00:00")); // Tuesday
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-04-09T07:00:00")); // Thursday
}
}

View File

@ -174,7 +174,7 @@ public class SetOwnerAccTest extends AbstractAccTest {
allTaskSummaries.stream().map(TaskSummary::getId).collect(Collectors.toList());
BulkOperationResults<String, TaskanaException> results =
taskanaEngine.getTaskService().setOwnerOfTasks("theWorkaholic", allTaskIds);
assertThat(allTaskSummaries).hasSize(83);
assertThat(allTaskSummaries).hasSize(84);
assertThat(results.containsErrors()).isTrue();
Condition<Object> invalidStateException =
@ -183,10 +183,10 @@ public class SetOwnerAccTest extends AbstractAccTest {
new Condition<>(
c -> c.getClass() == NotAuthorizedException.class, "NotAuthorizedException");
assertThat(results.getErrorMap())
.hasSize(58)
.hasSize(59)
.extractingFromEntries(Entry::getValue)
.hasOnlyElementsOfTypes(InvalidStateException.class, NotAuthorizedException.class)
.areExactly(35, invalidStateException)
.areExactly(36, invalidStateException)
.areExactly(23, notAuthorizedException);
}
@ -199,10 +199,10 @@ public class SetOwnerAccTest extends AbstractAccTest {
allTaskSummaries.stream().map(TaskSummary::getId).collect(Collectors.toList());
BulkOperationResults<String, TaskanaException> results =
taskanaEngine.getTaskService().setOwnerOfTasks("theWorkaholic", allTaskIds);
assertThat(allTaskSummaries).hasSize(83);
assertThat(allTaskSummaries).hasSize(84);
assertThat(results.containsErrors()).isTrue();
assertThat(results.getErrorMap())
.hasSize(36)
.hasSize(37)
.extractingFromEntries(Entry::getValue)
.hasOnlyElementsOfType(InvalidStateException.class);
}

View File

@ -65,14 +65,14 @@ class TerminateTaskAccTest extends AbstractAccTest {
throws NotAuthorizedException, TaskNotFoundException, InvalidStateException {
List<TaskSummary> taskSummaries =
taskService.createTaskQuery().stateIn(TaskState.CLAIMED).list();
assertThat(taskSummaries.size()).isEqualTo(19);
assertThat(taskSummaries.size()).isEqualTo(20);
long numTasksTerminated = taskService.createTaskQuery().stateIn(TaskState.TERMINATED).count();
assertThat(numTasksTerminated).isEqualTo(5);
taskService.terminateTask(taskSummaries.get(0).getId());
long numTasksClaimed = taskService.createTaskQuery().stateIn(TaskState.CLAIMED).count();
assertThat(numTasksClaimed).isEqualTo(18);
assertThat(numTasksClaimed).isEqualTo(19);
numTasksTerminated = taskService.createTaskQuery().stateIn(TaskState.TERMINATED).count();
assertThat(numTasksTerminated).isEqualTo(6);
}

View File

@ -30,9 +30,7 @@ import pro.taskana.task.api.models.Task;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket;
/**
* Acceptance test for all "transfer task" scenarios.
*/
/** Acceptance test for all "transfer task" scenarios. */
@ExtendWith(JaasExtension.class)
class TransferTaskAccTest extends AbstractAccTest {
@ -44,7 +42,7 @@ class TransferTaskAccTest extends AbstractAccTest {
@Test
void should_TransferTaskToWorkbasket_When_WorkbasketIdIsProvided()
throws NotAuthorizedException, WorkbasketNotFoundException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000003");
taskService.claim(task.getId());
@ -64,7 +62,7 @@ class TransferTaskAccTest extends AbstractAccTest {
@TestTemplate
void should_TransferTask_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws NotAuthorizedException, WorkbasketNotFoundException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000003");
taskService.claim(task.getId());
@ -83,7 +81,7 @@ class TransferTaskAccTest extends AbstractAccTest {
@Test
void should_TransferTaskToWorkbasket_When_WorkbasketKeyAndDomainIsProvided()
throws NotAuthorizedException, WorkbasketNotFoundException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000003");
taskService.claim(task.getId());
@ -102,7 +100,7 @@ class TransferTaskAccTest extends AbstractAccTest {
@Test
void should_ChangeDomain_When_TransferingTaskToWorkbasketWithDifferentDomain()
throws NotAuthorizedException, WorkbasketNotFoundException, TaskNotFoundException,
InvalidStateException {
InvalidStateException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
String domain1 = task.getDomain();
@ -131,7 +129,7 @@ class TransferTaskAccTest extends AbstractAccTest {
@Test
void should_ThrowException_When_DestinationWorkbasketDoesNotExist()
throws NotAuthorizedException, TaskNotFoundException, InvalidStateException,
InvalidOwnerException {
InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000003");
taskService.claim(task.getId());
@ -188,7 +186,7 @@ class TransferTaskAccTest extends AbstractAccTest {
@Test
void should_BulkTransferTasks_When_WorkbasketIdIsProvided()
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
TaskNotFoundException {
TaskNotFoundException {
final Instant before = Instant.now();
TaskService taskService = taskanaEngine.getTaskService();
ArrayList<String> taskIdList = new ArrayList<>();
@ -225,7 +223,7 @@ class TransferTaskAccTest extends AbstractAccTest {
@Test
void should_BulkTransferOnlyValidTasks_When_SomeTasksToTransferCauseExceptions()
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
TaskNotFoundException {
TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
final Workbasket wb =
taskanaEngine.getWorkbasketService().getWorkbasket("USER_1_1", "DOMAIN_A");
@ -305,9 +303,10 @@ class TransferTaskAccTest extends AbstractAccTest {
TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIds = Collections.singletonList("TKI:000000000000000000000000000000000006");
ThrowingCallable call = () -> {
taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIds);
};
ThrowingCallable call =
() -> {
taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIds);
};
assertThatCode(call).doesNotThrowAnyException();
}
@ -353,7 +352,7 @@ class TransferTaskAccTest extends AbstractAccTest {
@Test
void should_BulkTransferTasks_When_WorkbasketKeyAndDomainIsProvided()
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidArgumentException,
TaskNotFoundException {
TaskNotFoundException {
final Instant before = Instant.now();
TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIdList = new ArrayList<>();

View File

@ -31,7 +31,7 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
@Test
void should_UpdateTaskComment_For_TaskComment()
throws TaskCommentNotFoundException, NotAuthorizedException, ConcurrencyException,
TaskNotFoundException, InvalidArgumentException {
TaskNotFoundException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
@ -55,7 +55,7 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
@Test
void should_FailToUpdateTaskComment_When_UserHasNoAuthorization()
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
InvalidArgumentException {
InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
@ -82,31 +82,28 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
@Test
void should_FailToUpdateTaskComment_When_UserTriesToUpdateTaskByManipulatingOwner()
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
InvalidArgumentException {
InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
TaskCommentImpl taskCommentToUpdate = (TaskCommentImpl)
taskService.getTaskComment(
"TCI:000000000000000000000000000000000001");
TaskCommentImpl taskCommentToUpdate =
(TaskCommentImpl) taskService.getTaskComment("TCI:000000000000000000000000000000000001");
taskCommentToUpdate.setTextField("updated textfield");
taskCommentToUpdate.setCreator("user_1_2");
ThrowingCallable updateTaskCommentCall =
() -> {
taskService.updateTaskComment(taskCommentToUpdate);
};
assertThatThrownBy(updateTaskCommentCall).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "user_1_1", groups = "group_1")
@Test
void should_FailToUpdateTaskComment_When_TaskCommentWasModifiedConcurrently()
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
ConcurrencyException, InvalidArgumentException {
ConcurrencyException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();

View File

@ -1,6 +1,5 @@
package acceptance.workbasket;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
@ -14,9 +13,7 @@ import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/**
* Acceptance test for all "set workbasket access item" scenarios.
*/
/** Acceptance test for all "set workbasket access item" scenarios. */
@ExtendWith(JaasExtension.class)
public class CreateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@ -31,9 +28,10 @@ public class CreateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
accessItem.setPermAppend(true);
accessItem.setPermCustom11(true);
accessItem.setPermRead(true);
ThrowingCallable call = () -> {
workbasketService.createWorkbasketAccessItem(accessItem);
};
ThrowingCallable call =
() -> {
workbasketService.createWorkbasketAccessItem(accessItem);
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
}

View File

@ -27,9 +27,7 @@ import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/**
* Acceptance test which does test the deletion of a workbasket and all wanted failures.
*/
/** Acceptance test which does test the deletion of a workbasket and all wanted failures. */
@ExtendWith(JaasExtension.class)
class DeleteWorkbasketAccTest extends AbstractAccTest {
@ -167,7 +165,7 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@Test
void testCascadingDeleteOfAccessItems()
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidArgumentException,
WorkbasketAccessItemAlreadyExistException {
WorkbasketAccessItemAlreadyExistException {
Workbasket wb = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000008");
String wbId = wb.getId();
// create 2 access Items
@ -201,8 +199,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@Test
void testMarkWorkbasketForDeletion()
throws WorkbasketInUseException, NotAuthorizedException, WorkbasketNotFoundException,
InvalidArgumentException, InvalidOwnerException, InvalidStateException,
TaskNotFoundException {
InvalidArgumentException, InvalidOwnerException, InvalidStateException,
TaskNotFoundException {
final Workbasket wb =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000006");
@ -212,6 +210,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
taskService.forceCompleteTask(task.getId());
task = (TaskImpl) taskService.getTask("TKI:000000000000000000000000000000000002");
taskService.forceCompleteTask(task.getId());
task = (TaskImpl) taskService.getTask("TKI:000000000000000000000000000000000066");
taskService.forceCompleteTask(task.getId());
boolean markedForDeletion = workbasketService.deleteWorkbasket(wb.getId());
assertThat(markedForDeletion).isFalse();

View File

@ -12,9 +12,7 @@ import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService;
/**
* Acceptance test for all "delete workbasket authorizations" scenarios.
*/
/** Acceptance test for all "delete workbasket authorizations" scenarios. */
@ExtendWith(JaasExtension.class)
public class DeleteWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@ -39,6 +37,4 @@ public class DeleteWorkbasketAuthorizationsAccTest extends AbstractAccTest {
assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class);
}
}

View File

@ -24,9 +24,7 @@ import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket;
import pro.taskana.workbasket.api.models.WorkbasketSummary;
/**
* Acceptance test for all "get workbasket" scenarios.
*/
/** Acceptance test for all "get workbasket" scenarios. */
@ExtendWith(JaasExtension.class)
class DistributionTargetsAccTest extends AbstractAccTest {
@ -122,10 +120,9 @@ class DistributionTargetsAccTest extends AbstractAccTest {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
String existingWb = "WBI:100000000000000000000000000000000001";
List<WorkbasketSummary> distributionTargets = workbasketService
.getDistributionTargets(existingWb);
List<WorkbasketSummary> distributionTargets =
workbasketService.getDistributionTargets(existingWb);
assertThat(distributionTargets).hasSize(4);
}
@WithAccessId(user = "user_1_1", groups = "group_1")

View File

@ -55,7 +55,6 @@ class GetWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "admin")
@WithAccessId(user = "businessadmin")
@WithAccessId(user = "taskadmin")
@TestTemplate
void should_ReturnWorkbasketByKeyAndDomain_When_NoExplicitPermissionButUserHasAdministrativeRole()
throws NotAuthorizedException, WorkbasketNotFoundException {

View File

@ -12,9 +12,7 @@ import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService;
/**
* Acceptance test for all "get workbasket authorizations" scenarios.
*/
/** Acceptance test for all "get workbasket authorizations" scenarios. */
@ExtendWith(JaasExtension.class)
public class GetWorkbasketAuthorizationsAccTest extends AbstractAccTest {

View File

@ -21,9 +21,7 @@ import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket;
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
/**
* Acceptance test for all "update workbasket" scenarios.
*/
/** Acceptance test for all "update workbasket" scenarios. */
@ExtendWith(JaasExtension.class)
public class UpdateWorkbasketAccTest extends AbstractAccTest {

View File

@ -29,9 +29,7 @@ import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
/**
* Acceptance test for all "update workbasket authorizations" scenarios.
*/
/** Acceptance test for all "update workbasket authorizations" scenarios. */
@ExtendWith(JaasExtension.class)
class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@ -66,7 +64,7 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@Test
void testUpdateWorkbasketAccessItemSucceeds()
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException,
WorkbasketAccessItemAlreadyExistException {
WorkbasketAccessItemAlreadyExistException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem(
@ -102,7 +100,7 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@Test
void testUpdateWorkbasketAccessItemRejected()
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
WorkbasketAccessItemAlreadyExistException {
WorkbasketAccessItemAlreadyExistException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem(
@ -151,7 +149,7 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@Test
void testUpdatedAccessItemLeadsToNotAuthorizedException()
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
ClassificationNotFoundException, TaskAlreadyExistException {
ClassificationNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();

View File

@ -63,7 +63,7 @@ class ClassificationServiceImplIntAutoCommitTest {
@Test
void testFindAllClassifications()
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
InvalidArgumentException {
InvalidArgumentException {
Classification classification0 = classificationService.newClassification("TEST1", "", "TASK");
classificationService.createClassification(classification0);
Classification classification1 = classificationService.newClassification("TEST2", "", "TASK");
@ -78,8 +78,8 @@ class ClassificationServiceImplIntAutoCommitTest {
@Test
void testModifiedClassification()
throws ClassificationAlreadyExistException, ClassificationNotFoundException,
NotAuthorizedException, ConcurrencyException, DomainNotFoundException,
InvalidArgumentException {
NotAuthorizedException, ConcurrencyException, DomainNotFoundException,
InvalidArgumentException {
final String description = "TEST SOMETHING";
Classification classification =
classificationService.newClassification("TEST434", "DOMAIN_A", "TASK");
@ -97,7 +97,7 @@ class ClassificationServiceImplIntAutoCommitTest {
@Test
void testInsertClassification()
throws NotAuthorizedException, ClassificationAlreadyExistException, InvalidArgumentException,
DomainNotFoundException {
DomainNotFoundException {
Classification classification =
classificationService.newClassification("TEST1333", "DOMAIN_A", "TASK");
classificationService.createClassification(classification);
@ -115,8 +115,8 @@ class ClassificationServiceImplIntAutoCommitTest {
@Test
void testUpdateClassification()
throws NotAuthorizedException, ClassificationAlreadyExistException,
ClassificationNotFoundException, ConcurrencyException, DomainNotFoundException,
InvalidArgumentException {
ClassificationNotFoundException, ConcurrencyException, DomainNotFoundException,
InvalidArgumentException {
Classification classification =
classificationService.newClassification("TEST32451", "DOMAIN_A", "TASK");
classification = classificationService.createClassification(classification);
@ -139,8 +139,8 @@ class ClassificationServiceImplIntAutoCommitTest {
@Test
void testDefaultSettings()
throws NotAuthorizedException, ClassificationAlreadyExistException,
ClassificationNotFoundException, ConcurrencyException, DomainNotFoundException,
InvalidArgumentException {
ClassificationNotFoundException, ConcurrencyException, DomainNotFoundException,
InvalidArgumentException {
Classification classification =
classificationService.newClassification("TEST7771", "DOMAIN_A", "TASK");
classification = classificationService.createClassification(classification);

View File

@ -249,8 +249,7 @@ public class JaasExtensionTest {
// WITH DynamicContainer
@TestFactory
DynamicContainer
should_NotSetAccessIdForDynamicContainer_When_AnnotationIsMissing() {
DynamicContainer should_NotSetAccessIdForDynamicContainer_When_AnnotationIsMissing() {
return dynamicContainer("dynamic container", Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST));
}
@ -265,8 +264,7 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
DynamicContainer
should_SetMultipleAccessIdForDynamicContainer_When_AnnotationsExist() {
DynamicContainer should_SetMultipleAccessIdForDynamicContainer_When_AnnotationsExist() {
return dynamicContainer(
"dynamic container", Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST));
}
@ -274,8 +272,7 @@ public class JaasExtensionTest {
// WITH nested DynamicContainer
@TestFactory
DynamicContainer
should_NotSetAccessIdForNestedDynamicContainer_When_AnnotationIsMissing() {
DynamicContainer should_NotSetAccessIdForNestedDynamicContainer_When_AnnotationIsMissing() {
DynamicContainer container =
dynamicContainer("inside container", Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST));
return dynamicContainer("outside container", Stream.of(container, NULL_DYNAMIC_TEST));
@ -283,8 +280,7 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
DynamicContainer
should_SetAccessIdForNestedDynamicContainer_When_AnnotationExists() {
DynamicContainer should_SetAccessIdForNestedDynamicContainer_When_AnnotationExists() {
DynamicContainer container =
dynamicContainer(
"nested container",
@ -296,8 +292,7 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
DynamicContainer
should_SetMultipleAccessIdForNestedDynamicContainer_When_AnnotationsExist() {
DynamicContainer should_SetMultipleAccessIdForNestedDynamicContainer_When_AnnotationsExist() {
DynamicContainer container =
dynamicContainer(
"inside container", Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST));
@ -309,23 +304,20 @@ public class JaasExtensionTest {
// region RETURNING Stream<DynamicNode>
@TestFactory
Stream<DynamicTest>
should_NotSetAccessIdForDynamicTestInStream_When_AnnotationIsMissing() {
Stream<DynamicTest> should_NotSetAccessIdForDynamicTestInStream_When_AnnotationIsMissing() {
return Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST);
}
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
Stream<DynamicTest>
should_SetAccessIdForDynamicTestInStream_When_AnnotationExists() {
Stream<DynamicTest> should_SetAccessIdForDynamicTestInStream_When_AnnotationExists() {
return Stream.of(DYNAMIC_TEST_USER_DYNAMIC_TEST, DYNAMIC_TEST_USER_DYNAMIC_TEST);
}
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
Stream<DynamicTest>
should_SetMultipleAccessIdForDynamicTestInStream_When_AnnotationsExist() {
Stream<DynamicTest> should_SetMultipleAccessIdForDynamicTestInStream_When_AnnotationsExist() {
return Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST);
}
@ -342,8 +334,7 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
Stream<DynamicContainer>
should_SetAccessIdForDynamicContainerInStream_When_AnnotationExists() {
Stream<DynamicContainer> should_SetAccessIdForDynamicContainerInStream_When_AnnotationExists() {
Supplier<DynamicContainer> supplier =
() ->
dynamicContainer(
@ -412,15 +403,13 @@ public class JaasExtensionTest {
// region RETURNING Iterable<DynamicNode>
@TestFactory
Iterable<DynamicTest>
should_NotSetAccessIdForDynamicTestInIterable_When_AnnotationIsMissing() {
Iterable<DynamicTest> should_NotSetAccessIdForDynamicTestInIterable_When_AnnotationIsMissing() {
return Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST).collect(Collectors.toList());
}
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
Iterable<DynamicTest>
should_SetAccessIdForDynamicTestInIterable_When_AnnotationExists() {
Iterable<DynamicTest> should_SetAccessIdForDynamicTestInIterable_When_AnnotationExists() {
return Stream.of(DYNAMIC_TEST_USER_DYNAMIC_TEST, DYNAMIC_TEST_USER_DYNAMIC_TEST)
.collect(Collectors.toList());
}
@ -428,8 +417,7 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
Iterable<DynamicTest>
should_SetMultipleAccessIdForDynamicTestInIterable_When_AnnotationsExist() {
Iterable<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterable_When_AnnotationsExist() {
return Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST).collect(Collectors.toList());
}
@ -516,23 +504,20 @@ public class JaasExtensionTest {
// region RETURNING Iterator<DynamicNode>
@TestFactory
Iterator<DynamicTest>
should_NotSetAccessIdForDynamicTestInIterator_When_AnnotationIsMissing() {
Iterator<DynamicTest> should_NotSetAccessIdForDynamicTestInIterator_When_AnnotationIsMissing() {
return Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST).iterator();
}
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
Iterator<DynamicTest>
should_SetAccessIdForDynamicTestInIterator_When_AnnotationExists() {
Iterator<DynamicTest> should_SetAccessIdForDynamicTestInIterator_When_AnnotationExists() {
return Stream.of(DYNAMIC_TEST_USER_DYNAMIC_TEST, DYNAMIC_TEST_USER_DYNAMIC_TEST).iterator();
}
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
Iterator<DynamicTest>
should_SetMultipleAccessIdForDynamicTestInIterator_When_AnnotationsExist() {
Iterator<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterator_When_AnnotationsExist() {
return Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST).iterator();
}
@ -619,8 +604,7 @@ public class JaasExtensionTest {
// region RETURNING DynamicNode[]
@TestFactory
DynamicTest[]
should_NotSetAccessIdForDynamicTestInArray_When_AnnotationIsMissing() {
DynamicTest[] should_NotSetAccessIdForDynamicTestInArray_When_AnnotationIsMissing() {
return Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST).toArray(DynamicTest[]::new);
}
@ -634,16 +618,14 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
DynamicTest[]
should_SetMultipleAccessIdForDynamicTestInArray_When_AnnotationsExist() {
DynamicTest[] should_SetMultipleAccessIdForDynamicTestInArray_When_AnnotationsExist() {
return Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST).toArray(DynamicTest[]::new);
}
// WITH DynamicContainer
@TestFactory
DynamicContainer[]
should_NotSetAccessIdForDynamicContainerInArray_When_AnnotationIsMissing() {
DynamicContainer[] should_NotSetAccessIdForDynamicContainerInArray_When_AnnotationIsMissing() {
Supplier<DynamicContainer> supplier =
() ->
dynamicContainer("dynamic container", Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST));
@ -652,8 +634,7 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
DynamicContainer[]
should_SetAccessIdForDynamicContainerInArray_When_AnnotationExists() {
DynamicContainer[] should_SetAccessIdForDynamicContainerInArray_When_AnnotationExists() {
Supplier<DynamicContainer> supplier =
() ->
dynamicContainer(
@ -665,8 +646,7 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
DynamicContainer[]
should_SetMultipleAccessIdForDynamicContainerInArray_When_AnnotationsExist() {
DynamicContainer[] should_SetMultipleAccessIdForDynamicContainerInArray_When_AnnotationsExist() {
Supplier<DynamicContainer> supplier =
() ->
dynamicContainer(
@ -688,8 +668,7 @@ public class JaasExtensionTest {
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@TestFactory
DynamicContainer[]
should_SetAccessIdForNestedDynamicContainerInArray_When_AnnotationExists() {
DynamicContainer[] should_SetAccessIdForNestedDynamicContainerInArray_When_AnnotationExists() {
Supplier<DynamicContainer> supplier =
() ->
dynamicContainer(

View File

@ -18,6 +18,7 @@ INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000019', 'T
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000020', 'L19001', '', '', 'EXTERNAL', 'TASK', '', FALSE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'Beratungszustimmung', 'Beratungszustimmung', 1, 'P1D', '', 'VNR', '', '', '', '', '', '', '');
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000022', 'A13', 'CLI:000000000000000000000000000000000011', 'T6310', 'AUTOMATIC', 'TASK', '', FALSE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'Beratungsprotokoll', 'Beratungsprotokoll', 1, 'P1D', '', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', '');
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000023', 'T2000', '', '', 'MANUAL', 'TASK', '', FALSE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'T-Vertragstermin', 'T-Vertragstermin', 1, 'P1D', 'z', 'VNR,KOLVNR,RVNR', 'CUSTOM2', 'Custom3', 'custom4', 'custom5', 'custom6', 'custom7', 'custom8');
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000024', 'T2001', '', '', 'MANUAL', 'TASK', '', FALSE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'T-Vertragstermin', 'T-Vertragstermin', 1, 'P0D', 'z', 'VNR,KOLVNR,RVNR', 'CUSTOM2', 'Custom3', 'custom4', 'custom5', 'custom6', 'custom7', 'custom8');
INSERT INTO CLASSIFICATION VALUES('CLI:300000000000000000000000000000000017', 'L3060', '', '', 'EXTERNAL', 'TASK', '', FALSE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'Widerruf neu', 'Widerruf neu', 1, 'P1D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '');
-- DOMAIN_A CLASSIFICATIONS
@ -34,6 +35,7 @@ INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000011', 'T
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000013', 'DOCTYPE_DEFAULT', '', '', 'EXTERNAL', 'DOCUMENT', 'DOMAIN_A', TRUE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'EP allgemein', 'EP allgemein', 99, 'P2000D', '', 'VNR', '', '', '', '', '', '', '');
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000014', 'L10000', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'BUZ-Leistungsfall', 'BUZ-Leistungsfall', 1, 'P1D', '', 'VNR,RVNR,KOLVNR', 'VNR', 'VNR', 'VNR', '', '', '', '');
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000016', 'T2000', '', '', 'MANUAL', 'TASK', 'DOMAIN_A', TRUE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'T-Vertragstermin', 'T-Vertragstermin', 1, 'P1D', 'z', 'VNR,KOLVNR,RVNR', 'CUSTOM2', 'Custom3', 'custom4', 'custom5', 'custom6', 'custom7', 'custom8');
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000024', 'T2001', '', '', 'MANUAL', 'TASK', 'DOMAIN_A', TRUE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'T-Vertragstermin', 'T-Vertragstermin', 1, 'P0D', 'z', 'VNR,KOLVNR,RVNR', 'CUSTOM2', 'Custom3', 'custom4', 'custom5', 'custom6', 'custom7', 'custom8');
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000017', 'L1060', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'Widerruf neu', 'Widerruf neu', 1, 'P1D', 'specialPoint', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '');
INSERT INTO CLASSIFICATION VALUES('CLI:400000000000000000000000000000000017', 'L3060', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', FALSE, RELATIVE_DATE(0) , RELATIVE_DATE(0) , 'Widerruf neu', 'Widerruf neu', 1, 'P1D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '');

View File

@ -2,6 +2,7 @@
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000000', 'ETI:000000000000000000000000000000000000', '2018-01-29 15:55:00', '2018-01-30 15:55:00', null , '2018-01-30 15:55:00', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Task99' , 'creator_user_id' , 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note' , 1 , 'CLAIMED' , 'MANUAL' , 'T2000' , 'CLI:100000000000000000000000000000000016', 'WBI:100000000000000000000000000000000006' , 'USER_1_1' , 'DOMAIN_A', 'BPI21' , 'PBPI21' , 'user_1_1' , 'MyCompany1', 'MySystem1', 'MyInstance1' , 'MyType1', 'MyValue1' , true , false , null , 'NONE' , null , 'custom1' , 'custom2' , 'custom3' , 'custom4' , 'custom5' , 'custom6' , 'custom7' , 'custom8' , 'custom9' , 'custom10' , 'custom11' , 'custom12' , 'custom13' , 'abc' , 'custom15' , 'custom16' );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000001', 'ETI:000000000000000000000000000000000001', '2018-01-29 15:55:01', '2018-01-30 15:55:00', null , '2018-01-30 15:55:01', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Task01' , 'creator_user_id' , 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note' , 2 , 'CLAIMED' , 'EXTERN' , 'L110102' , 'CLI:100000000000000000000000000000000005', 'WBI:100000000000000000000000000000000006' , 'USER_1_1' , 'DOMAIN_A', 'BPI21' , 'PBPI21' , 'user_1_1' , 'MyCompany1', 'MySystem1', 'MyInstance1' , 'MyType1', 'MyValue1' , true , false , null , 'NONE' , null , 'pqr' , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000002', 'ETI:000000000000000000000000000000000002', '2018-01-29 15:55:02', '2018-01-30 15:55:00', null , '2018-01-30 15:55:02', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Task02' , 'creator_user_id' , 'Lorem ipsum was n Quatsch t. Aber stimmt.', 'Some custom Note' , 2 , 'CLAIMED' , 'MANUAL' , 'T2000' , 'CLI:100000000000000000000000000000000016', 'WBI:100000000000000000000000000000000006' , 'USER_1_1' , 'DOMAIN_A', 'BPI21' , 'PBPI21' , 'user_1_1' , 'MyCompany1', 'MySystem1', 'MyInstance1' , 'MyType1', 'MyValue1' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000066', 'ETI:000000000000000000000000000000000066', '2018-01-29 15:55:02', '2018-01-29 15:55:00', null , '2018-01-30 15:55:02', '2018-01-29 15:55:00', '2018-01-29 15:55:00', 'Task03' , 'creator_user_id' , 'Lorem ipsum was n Quatsch t. Aber stimmt.', 'Some custom Note' , 2 , 'CLAIMED' , 'MANUAL' , 'T2001' , 'CLI:100000000000000000000000000000000024', 'WBI:100000000000000000000000000000000006' , 'USER_1_1' , 'DOMAIN_A', 'BPI21' , 'PBPI21' , 'user_1_1' , 'MyCompany1', 'MySystem1', 'MyInstance1' , 'MyType1', 'MyValue1' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000003', 'ETI:000000000000000000000000000000000003', '2018-01-29 15:55:03', null , null , '2018-01-29 15:55:03', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000003' , 'DOC_0000000000000000003' , null , '00' , 'PASystem' , '00' , 'VNR' , '11223344' , false , false , null , 'NONE' , null , 'efg' , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000004', 'ETI:000000000000000000000000000000000004', '2018-01-29 15:55:04', null , null , '2018-01-29 15:55:04', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000004' , 'DOC_0000000000000000004' , null , '00' , 'PASystem' , '00' , 'VNR' , '11223344' , false , false , null , 'NONE' , null , null , 'ade' , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000005', 'ETI:000000000000000000000000000000000005', '2018-01-29 15:55:05', null , null , '2018-01-29 15:55:05', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000005' , 'DOC_0000000000000000005' , null , '00' , 'PASystem' , '00' , 'VNR' , '11223344' , false , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );