TSK-1866: Refactor UpdateClassificationAccTest to use Test-API
Compressed UpdateTaskPriority/ServiceLevel-Test. Check error messages. Cleaned comments. Reordered some methods. Move test to taskana-core-test according to new structure.
This commit is contained in:
parent
48d85e0ee7
commit
131c1f0cb9
|
@ -0,0 +1,815 @@
|
||||||
|
package acceptance.classification.update;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
import static pro.taskana.testapi.DefaultTestEntities.defaultTestClassification;
|
||||||
|
import static pro.taskana.testapi.DefaultTestEntities.defaultTestObjectReference;
|
||||||
|
import static pro.taskana.testapi.DefaultTestEntities.defaultTestWorkbasket;
|
||||||
|
import static pro.taskana.testapi.builder.TaskBuilder.newTask;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.DynamicTest;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.TestFactory;
|
||||||
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
import org.junit.jupiter.api.TestTemplate;
|
||||||
|
import org.junit.jupiter.api.function.ThrowingConsumer;
|
||||||
|
|
||||||
|
import pro.taskana.classification.api.ClassificationCustomField;
|
||||||
|
import pro.taskana.classification.api.ClassificationService;
|
||||||
|
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
|
||||||
|
import pro.taskana.classification.api.models.Classification;
|
||||||
|
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||||
|
import pro.taskana.classification.internal.models.ClassificationImpl;
|
||||||
|
import pro.taskana.common.api.TaskanaEngine;
|
||||||
|
import pro.taskana.common.api.TaskanaRole;
|
||||||
|
import pro.taskana.common.api.WorkingDaysToDaysConverter;
|
||||||
|
import pro.taskana.common.api.exceptions.ConcurrencyException;
|
||||||
|
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||||
|
import pro.taskana.common.api.exceptions.MismatchedRoleException;
|
||||||
|
import pro.taskana.common.api.security.CurrentUserContext;
|
||||||
|
import pro.taskana.common.internal.jobs.JobRunner;
|
||||||
|
import pro.taskana.common.internal.util.Pair;
|
||||||
|
import pro.taskana.task.api.TaskService;
|
||||||
|
import pro.taskana.task.api.models.Attachment;
|
||||||
|
import pro.taskana.task.api.models.Task;
|
||||||
|
import pro.taskana.task.internal.models.TaskImpl;
|
||||||
|
import pro.taskana.testapi.TaskanaInject;
|
||||||
|
import pro.taskana.testapi.TaskanaIntegrationTest;
|
||||||
|
import pro.taskana.testapi.builder.WorkbasketAccessItemBuilder;
|
||||||
|
import pro.taskana.testapi.security.WithAccessId;
|
||||||
|
import pro.taskana.workbasket.api.WorkbasketPermission;
|
||||||
|
import pro.taskana.workbasket.api.WorkbasketService;
|
||||||
|
import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
||||||
|
|
||||||
|
/** Acceptance test for all "update classification" scenarios. */
|
||||||
|
@TaskanaIntegrationTest
|
||||||
|
class UpdateClassificationAccTest {
|
||||||
|
@TaskanaInject ClassificationService classificationService;
|
||||||
|
@TaskanaInject TaskanaEngine taskanaEngine;
|
||||||
|
@TaskanaInject TaskService taskService;
|
||||||
|
@TaskanaInject WorkbasketService workbasketService;
|
||||||
|
@TaskanaInject WorkingDaysToDaysConverter converter;
|
||||||
|
@TaskanaInject CurrentUserContext currentUserContext;
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_SetFieldsCorrectly_When_TryingToUpdateClassification() throws Exception {
|
||||||
|
Classification parentClassification =
|
||||||
|
defaultTestClassification().buildAndStore(classificationService);
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification().type("TASK").buildAndStore(classificationService);
|
||||||
|
final Instant createdBefore = classification.getCreated();
|
||||||
|
final Instant modifiedBefore = classification.getModified();
|
||||||
|
|
||||||
|
classification.setApplicationEntryPoint("newEntrypoint");
|
||||||
|
classification.setCategory("PROCESS");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_1, "newCustom1");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_2, "newCustom2");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_3, "newCustom3");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_4, "newCustom4");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_5, "newCustom5");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_6, "newCustom6");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_7, "newCustom7");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_8, "newCustom8");
|
||||||
|
classification.setDescription("newDescription");
|
||||||
|
classification.setIsValidInDomain(false);
|
||||||
|
classification.setName("newName");
|
||||||
|
classification.setParentId(parentClassification.getId());
|
||||||
|
classification.setParentKey(parentClassification.getKey());
|
||||||
|
classification.setPriority(1000);
|
||||||
|
classification.setServiceLevel("P3D");
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
|
||||||
|
Classification updatedClassification =
|
||||||
|
classificationService.getClassification(classification.getKey(), "DOMAIN_A");
|
||||||
|
ClassificationImpl expectedClassification =
|
||||||
|
(ClassificationImpl)
|
||||||
|
defaultTestClassification()
|
||||||
|
.type("TASK")
|
||||||
|
.applicationEntryPoint("newEntrypoint")
|
||||||
|
.category("PROCESS")
|
||||||
|
.customAttribute(ClassificationCustomField.CUSTOM_1, "newCustom1")
|
||||||
|
.customAttribute(ClassificationCustomField.CUSTOM_2, "newCustom2")
|
||||||
|
.customAttribute(ClassificationCustomField.CUSTOM_3, "newCustom3")
|
||||||
|
.customAttribute(ClassificationCustomField.CUSTOM_4, "newCustom4")
|
||||||
|
.customAttribute(ClassificationCustomField.CUSTOM_5, "newCustom5")
|
||||||
|
.customAttribute(ClassificationCustomField.CUSTOM_6, "newCustom6")
|
||||||
|
.customAttribute(ClassificationCustomField.CUSTOM_7, "newCustom7")
|
||||||
|
.customAttribute(ClassificationCustomField.CUSTOM_8, "newCustom8")
|
||||||
|
.description("newDescription")
|
||||||
|
.isValidInDomain(false)
|
||||||
|
.name("newName")
|
||||||
|
.parentId(parentClassification.getId())
|
||||||
|
.parentKey(parentClassification.getKey())
|
||||||
|
.priority(1000)
|
||||||
|
.serviceLevel("P3D")
|
||||||
|
.created(createdBefore)
|
||||||
|
.modified(updatedClassification.getModified())
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
expectedClassification.setKey(updatedClassification.getKey());
|
||||||
|
expectedClassification.setId(updatedClassification.getId());
|
||||||
|
|
||||||
|
assertThat(expectedClassification).hasNoNullFieldsOrProperties();
|
||||||
|
assertThat(modifiedBefore).isBefore(classification.getModified());
|
||||||
|
assertThat(updatedClassification).isEqualTo(expectedClassification);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createTaskWithExistingClassification(ClassificationSummary classificationSummary)
|
||||||
|
throws Exception {
|
||||||
|
WorkbasketSummary workbasketSummary =
|
||||||
|
defaultTestWorkbasket().buildAndStoreAsSummary(workbasketService);
|
||||||
|
WorkbasketAccessItemBuilder.newWorkbasketAccessItem()
|
||||||
|
.workbasketId(workbasketSummary.getId())
|
||||||
|
.accessId(currentUserContext.getUserid())
|
||||||
|
.permission(WorkbasketPermission.OPEN)
|
||||||
|
.permission(WorkbasketPermission.READ)
|
||||||
|
.permission(WorkbasketPermission.APPEND)
|
||||||
|
.buildAndStore(workbasketService, "businessadmin");
|
||||||
|
|
||||||
|
return newTask()
|
||||||
|
.classificationSummary(classificationSummary)
|
||||||
|
.workbasketSummary(workbasketSummary)
|
||||||
|
.primaryObjRef(defaultTestObjectReference().build())
|
||||||
|
.buildAndStore(taskService)
|
||||||
|
.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> createTasksWithExistingClassificationInAttachment(
|
||||||
|
ClassificationSummary classificationSummary, String serviceLevel, int priority, int amount)
|
||||||
|
throws Exception {
|
||||||
|
List<String> taskList = new ArrayList<>();
|
||||||
|
WorkbasketSummary workbasketSummary =
|
||||||
|
defaultTestWorkbasket().buildAndStoreAsSummary(workbasketService);
|
||||||
|
WorkbasketAccessItemBuilder.newWorkbasketAccessItem()
|
||||||
|
.workbasketId(workbasketSummary.getId())
|
||||||
|
.accessId(currentUserContext.getUserid())
|
||||||
|
.permission(WorkbasketPermission.OPEN)
|
||||||
|
.permission(WorkbasketPermission.READ)
|
||||||
|
.permission(WorkbasketPermission.APPEND)
|
||||||
|
.buildAndStore(workbasketService, "businessadmin");
|
||||||
|
ClassificationSummary classificationSummaryWithSpecifiedServiceLevel =
|
||||||
|
defaultTestClassification()
|
||||||
|
.serviceLevel(serviceLevel)
|
||||||
|
.priority(priority)
|
||||||
|
.buildAndStoreAsSummary(classificationService);
|
||||||
|
for (int i = 0; i < amount; i++) {
|
||||||
|
Attachment attachment = taskService.newAttachment();
|
||||||
|
attachment.setClassificationSummary(classificationSummary);
|
||||||
|
attachment.setObjectReference(defaultTestObjectReference().build());
|
||||||
|
taskList.add(
|
||||||
|
newTask()
|
||||||
|
.classificationSummary(classificationSummaryWithSpecifiedServiceLevel)
|
||||||
|
.workbasketSummary(workbasketSummary)
|
||||||
|
.primaryObjRef(defaultTestObjectReference().build())
|
||||||
|
.attachments(attachment)
|
||||||
|
.buildAndStore(taskService)
|
||||||
|
.getId());
|
||||||
|
}
|
||||||
|
return taskList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestInstance(Lifecycle.PER_CLASS)
|
||||||
|
@Nested
|
||||||
|
class UpdatePriorityAndServiceLevelTest {
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_NotThrowException_When_UpdatingClassificationWithEmptyServiceLevel()
|
||||||
|
throws Exception {
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification().serviceLevel("P1D").buildAndStore(classificationService);
|
||||||
|
classification.setServiceLevel("");
|
||||||
|
assertThatCode(() -> classificationService.updateClassification(classification))
|
||||||
|
.doesNotThrowAnyException();
|
||||||
|
assertThat(classificationService.getClassification(classification.getId()).getServiceLevel())
|
||||||
|
.isEqualTo("P0D");
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@TestFactory
|
||||||
|
Stream<DynamicTest>
|
||||||
|
should_SetDefaultServiceLevel_When_TryingToUpdateClassificationWithMissingServiceLevel()
|
||||||
|
throws Exception {
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification().serviceLevel("P1D").buildAndStore(classificationService);
|
||||||
|
List<Pair<Classification, String>> inputList =
|
||||||
|
List.of(Pair.of(classification, null), Pair.of(classification, ""));
|
||||||
|
|
||||||
|
ThrowingConsumer<Pair<Classification, String>> test =
|
||||||
|
input -> {
|
||||||
|
input.getLeft().setServiceLevel(input.getRight());
|
||||||
|
classificationService.updateClassification(input.getLeft());
|
||||||
|
assertThat(
|
||||||
|
classificationService
|
||||||
|
.getClassification(input.getLeft().getId())
|
||||||
|
.getServiceLevel())
|
||||||
|
.isEqualTo("P0D");
|
||||||
|
};
|
||||||
|
|
||||||
|
return DynamicTest.stream(
|
||||||
|
inputList.iterator(), i -> String.format("for %s", i.getRight()), test);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_UpdateTaskServiceLevel_When_UpdateClassificationInTask() throws Exception {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1)
|
||||||
|
.serviceLevel("P13D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
final List<String> directLinkedTask =
|
||||||
|
List.of(createTaskWithExistingClassification(classification.asSummary()));
|
||||||
|
|
||||||
|
classification.setServiceLevel("P15D");
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(before, directLinkedTask, taskService, converter, 15, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_UpdateTaskPriority_When_UpdateClassificationInTask() throws Exception {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1)
|
||||||
|
.serviceLevel("P13D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
final List<String> directLinkedTask =
|
||||||
|
List.of(createTaskWithExistingClassification(classification.asSummary()));
|
||||||
|
|
||||||
|
classification.setPriority(1000);
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(before, directLinkedTask, taskService, converter, 13, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_UpdateTaskPriorityAndServiceLevel_When_UpdateClassificationInTask()
|
||||||
|
throws Exception {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1)
|
||||||
|
.serviceLevel("P13D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
final List<String> directLinkedTask =
|
||||||
|
List.of(createTaskWithExistingClassification(classification.asSummary()));
|
||||||
|
|
||||||
|
classification.setServiceLevel("P15D");
|
||||||
|
classification.setPriority(1000);
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(before, directLinkedTask, taskService, converter, 15, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@TestFactory
|
||||||
|
Stream<DynamicTest> should_UpdateTaskServiceLevel_When_UpdateClassificationInAttachment() {
|
||||||
|
List<Pair<String, Integer>> inputs =
|
||||||
|
List.of(Pair.of("P5D", 2), Pair.of("P8D", 3), Pair.of("P16D", 4));
|
||||||
|
|
||||||
|
List<Pair<Integer, Integer>> outputs = List.of(Pair.of(1, 2), Pair.of(1, 3), Pair.of(1, 4));
|
||||||
|
|
||||||
|
List<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> zippedTestInputList =
|
||||||
|
IntStream.range(0, inputs.size())
|
||||||
|
.mapToObj(i -> Pair.of(inputs.get(i), outputs.get(i)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
ThrowingConsumer<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> test =
|
||||||
|
input -> {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1)
|
||||||
|
.serviceLevel("P15D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
ClassificationSummary classificationSummary = classification.asSummary();
|
||||||
|
final List<String> indirectLinkedTasks =
|
||||||
|
createTasksWithExistingClassificationInAttachment(
|
||||||
|
classificationSummary,
|
||||||
|
input.getLeft().getLeft(),
|
||||||
|
input.getLeft().getRight(),
|
||||||
|
5);
|
||||||
|
|
||||||
|
classification.setServiceLevel("P1D");
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(
|
||||||
|
before,
|
||||||
|
indirectLinkedTasks,
|
||||||
|
taskService,
|
||||||
|
converter,
|
||||||
|
input.getRight().getLeft(),
|
||||||
|
input.getRight().getRight());
|
||||||
|
};
|
||||||
|
|
||||||
|
return DynamicTest.stream(
|
||||||
|
zippedTestInputList.iterator(),
|
||||||
|
i ->
|
||||||
|
String.format(
|
||||||
|
"for Task with ServiceLevel %s and Priority %s",
|
||||||
|
i.getLeft().getLeft(), i.getLeft().getRight()),
|
||||||
|
test);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@TestFactory
|
||||||
|
Stream<DynamicTest> should_NotUpdateTaskServiceLevel_When_UpdateClassificationInAttachment() {
|
||||||
|
List<Pair<String, Integer>> inputs =
|
||||||
|
List.of(Pair.of("P5D", 2), Pair.of("P8D", 3), Pair.of("P14D", 4));
|
||||||
|
|
||||||
|
List<Pair<Integer, Integer>> outputs = List.of(Pair.of(5, 2), Pair.of(8, 3), Pair.of(14, 4));
|
||||||
|
|
||||||
|
List<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> zippedTestInputList =
|
||||||
|
IntStream.range(0, inputs.size())
|
||||||
|
.mapToObj(i -> Pair.of(inputs.get(i), outputs.get(i)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
ThrowingConsumer<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> test =
|
||||||
|
input -> {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1)
|
||||||
|
.serviceLevel("P1D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
ClassificationSummary classificationSummary = classification.asSummary();
|
||||||
|
final List<String> indirectLinkedTasks =
|
||||||
|
createTasksWithExistingClassificationInAttachment(
|
||||||
|
classificationSummary,
|
||||||
|
input.getLeft().getLeft(),
|
||||||
|
input.getLeft().getRight(),
|
||||||
|
5);
|
||||||
|
|
||||||
|
classification.setServiceLevel("P15D");
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(
|
||||||
|
before,
|
||||||
|
indirectLinkedTasks,
|
||||||
|
taskService,
|
||||||
|
converter,
|
||||||
|
input.getRight().getLeft(),
|
||||||
|
input.getRight().getRight());
|
||||||
|
};
|
||||||
|
|
||||||
|
return DynamicTest.stream(
|
||||||
|
zippedTestInputList.iterator(),
|
||||||
|
i ->
|
||||||
|
String.format(
|
||||||
|
"for Task with ServiceLevel %s and Priority %s",
|
||||||
|
i.getLeft().getLeft(), i.getLeft().getRight()),
|
||||||
|
test);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@TestFactory
|
||||||
|
Stream<DynamicTest> should_UpdateTaskPriority_When_UpdateClassificationInAttachment() {
|
||||||
|
List<Pair<String, Integer>> inputs =
|
||||||
|
List.of(Pair.of("P1D", 1), Pair.of("P8D", 2), Pair.of("P14D", 999));
|
||||||
|
|
||||||
|
List<Pair<Integer, Integer>> outputs =
|
||||||
|
List.of(Pair.of(1, 1000), Pair.of(8, 1000), Pair.of(14, 1000));
|
||||||
|
|
||||||
|
List<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> zippedTestInputList =
|
||||||
|
IntStream.range(0, inputs.size())
|
||||||
|
.mapToObj(i -> Pair.of(inputs.get(i), outputs.get(i)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
ThrowingConsumer<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> test =
|
||||||
|
input -> {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1)
|
||||||
|
.serviceLevel("P13D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
ClassificationSummary classificationSummary = classification.asSummary();
|
||||||
|
final List<String> indirectLinkedTasks =
|
||||||
|
createTasksWithExistingClassificationInAttachment(
|
||||||
|
classificationSummary,
|
||||||
|
input.getLeft().getLeft(),
|
||||||
|
input.getLeft().getRight(),
|
||||||
|
5);
|
||||||
|
|
||||||
|
classification.setServiceLevel("P15D");
|
||||||
|
classification.setPriority(1000);
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(
|
||||||
|
before,
|
||||||
|
indirectLinkedTasks,
|
||||||
|
taskService,
|
||||||
|
converter,
|
||||||
|
input.getRight().getLeft(),
|
||||||
|
input.getRight().getRight());
|
||||||
|
};
|
||||||
|
|
||||||
|
return DynamicTest.stream(
|
||||||
|
zippedTestInputList.iterator(),
|
||||||
|
i ->
|
||||||
|
String.format(
|
||||||
|
"for Task with ServiceLevel %s and Priority %s",
|
||||||
|
i.getLeft().getLeft(), i.getLeft().getRight()),
|
||||||
|
test);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@TestFactory
|
||||||
|
Stream<DynamicTest> should_NotUpdateTaskPriority_When_UpdateClassificationInAttachment() {
|
||||||
|
List<Pair<String, Integer>> inputs =
|
||||||
|
List.of(Pair.of("P1D", 2), Pair.of("P8D", 3), Pair.of("P14D", 999));
|
||||||
|
|
||||||
|
List<Pair<Integer, Integer>> outputs =
|
||||||
|
List.of(Pair.of(1, 2), Pair.of(8, 3), Pair.of(14, 999));
|
||||||
|
|
||||||
|
List<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> zippedTestInputList =
|
||||||
|
IntStream.range(0, inputs.size())
|
||||||
|
.mapToObj(i -> Pair.of(inputs.get(i), outputs.get(i)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
ThrowingConsumer<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> test =
|
||||||
|
input -> {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1000)
|
||||||
|
.serviceLevel("P13D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
ClassificationSummary classificationSummary = classification.asSummary();
|
||||||
|
final List<String> indirectLinkedTasks =
|
||||||
|
createTasksWithExistingClassificationInAttachment(
|
||||||
|
classificationSummary,
|
||||||
|
input.getLeft().getLeft(),
|
||||||
|
input.getLeft().getRight(),
|
||||||
|
5);
|
||||||
|
|
||||||
|
classification.setServiceLevel("P15D");
|
||||||
|
classification.setPriority(1);
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(
|
||||||
|
before,
|
||||||
|
indirectLinkedTasks,
|
||||||
|
taskService,
|
||||||
|
converter,
|
||||||
|
input.getRight().getLeft(),
|
||||||
|
input.getRight().getRight());
|
||||||
|
};
|
||||||
|
|
||||||
|
return DynamicTest.stream(
|
||||||
|
zippedTestInputList.iterator(),
|
||||||
|
i ->
|
||||||
|
String.format(
|
||||||
|
"for Task with ServiceLevel %s and Priority %s",
|
||||||
|
i.getLeft().getLeft(), i.getLeft().getRight()),
|
||||||
|
test);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@TestFactory
|
||||||
|
Stream<DynamicTest>
|
||||||
|
should_UpdateTaskPriorityAndServiceLevel_When_UpdateClassificationInAttachment() {
|
||||||
|
List<Pair<String, Integer>> inputs = List.of(Pair.of("P1D", 5), Pair.of("P14D", 98));
|
||||||
|
|
||||||
|
List<Pair<Integer, Integer>> outputs = List.of(Pair.of(1, 99), Pair.of(1, 99));
|
||||||
|
|
||||||
|
List<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> zippedTestInputList =
|
||||||
|
IntStream.range(0, inputs.size())
|
||||||
|
.mapToObj(i -> Pair.of(inputs.get(i), outputs.get(i)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
ThrowingConsumer<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> test =
|
||||||
|
input -> {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1)
|
||||||
|
.serviceLevel("P13D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
ClassificationSummary classificationSummary = classification.asSummary();
|
||||||
|
final List<String> indirectLinkedTasks =
|
||||||
|
createTasksWithExistingClassificationInAttachment(
|
||||||
|
classificationSummary,
|
||||||
|
input.getLeft().getLeft(),
|
||||||
|
input.getLeft().getRight(),
|
||||||
|
3);
|
||||||
|
|
||||||
|
classification.setServiceLevel("P1D");
|
||||||
|
classification.setPriority(99);
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(
|
||||||
|
before,
|
||||||
|
indirectLinkedTasks,
|
||||||
|
taskService,
|
||||||
|
converter,
|
||||||
|
input.getRight().getLeft(),
|
||||||
|
input.getRight().getRight());
|
||||||
|
};
|
||||||
|
|
||||||
|
return DynamicTest.stream(
|
||||||
|
zippedTestInputList.iterator(),
|
||||||
|
i ->
|
||||||
|
String.format(
|
||||||
|
"for Task with ServiceLevel %s and Priority %s",
|
||||||
|
i.getLeft().getLeft(), i.getLeft().getRight()),
|
||||||
|
test);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@TestFactory
|
||||||
|
Stream<DynamicTest>
|
||||||
|
should_NotUpdateTaskPriorityAndServiceLevel_When_UpdateClassificationInAttachment() {
|
||||||
|
List<Pair<String, Integer>> inputs = List.of(Pair.of("P1D", 5), Pair.of("P14D", 98));
|
||||||
|
|
||||||
|
List<Pair<Integer, Integer>> outputs = List.of(Pair.of(1, 5), Pair.of(14, 98));
|
||||||
|
|
||||||
|
List<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> zippedTestInputList =
|
||||||
|
IntStream.range(0, inputs.size())
|
||||||
|
.mapToObj(i -> Pair.of(inputs.get(i), outputs.get(i)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
ThrowingConsumer<Pair<Pair<String, Integer>, Pair<Integer, Integer>>> test =
|
||||||
|
input -> {
|
||||||
|
final Instant before = Instant.now();
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.priority(1000)
|
||||||
|
.serviceLevel("P1D")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
ClassificationSummary classificationSummary = classification.asSummary();
|
||||||
|
final List<String> indirectLinkedTasks =
|
||||||
|
createTasksWithExistingClassificationInAttachment(
|
||||||
|
classificationSummary,
|
||||||
|
input.getLeft().getLeft(),
|
||||||
|
input.getLeft().getRight(),
|
||||||
|
3);
|
||||||
|
|
||||||
|
classification.setServiceLevel("P15D");
|
||||||
|
classification.setPriority(1);
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
runAssociatedJobs();
|
||||||
|
|
||||||
|
validateTaskProperties(
|
||||||
|
before,
|
||||||
|
indirectLinkedTasks,
|
||||||
|
taskService,
|
||||||
|
converter,
|
||||||
|
input.getRight().getLeft(),
|
||||||
|
input.getRight().getRight());
|
||||||
|
};
|
||||||
|
|
||||||
|
return DynamicTest.stream(
|
||||||
|
zippedTestInputList.iterator(),
|
||||||
|
i ->
|
||||||
|
String.format(
|
||||||
|
"for Task with ServiceLevel %s and Priority %s",
|
||||||
|
i.getLeft().getLeft(), i.getLeft().getRight()),
|
||||||
|
test);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runAssociatedJobs() throws Exception {
|
||||||
|
Thread.sleep(10);
|
||||||
|
// run the ClassificationChangedJob
|
||||||
|
JobRunner runner = new JobRunner(taskanaEngine);
|
||||||
|
// run the TaskRefreshJob that was scheduled by the ClassificationChangedJob.
|
||||||
|
runner.runJobs();
|
||||||
|
Thread.sleep(
|
||||||
|
10); // otherwise the next runJobs call intermittently doesn't find the Job created
|
||||||
|
// by the previous step (it searches with DueDate < CurrentTime)
|
||||||
|
runner.runJobs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateTaskProperties(
|
||||||
|
Instant before,
|
||||||
|
List<String> tasksUpdated,
|
||||||
|
TaskService taskService,
|
||||||
|
WorkingDaysToDaysConverter converter,
|
||||||
|
int serviceLevel,
|
||||||
|
int priority)
|
||||||
|
throws Exception {
|
||||||
|
for (String taskId : tasksUpdated) {
|
||||||
|
Task task = taskService.getTask(taskId);
|
||||||
|
|
||||||
|
Instant expDue =
|
||||||
|
converter.addWorkingDaysToInstant(task.getPlanned(), Duration.ofDays(serviceLevel));
|
||||||
|
assertThat(task.getModified())
|
||||||
|
.describedAs("Task " + task.getId() + " has not been refreshed.")
|
||||||
|
.isAfter(before);
|
||||||
|
assertThat(task.getDue()).isEqualTo(expDue);
|
||||||
|
assertThat(task.getPriority()).isEqualTo(priority);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestInstance(Lifecycle.PER_CLASS)
|
||||||
|
@Nested
|
||||||
|
class UpdateClassificationExceptionTest {
|
||||||
|
/**
|
||||||
|
* This BeforeAll method is needed for this {@linkplain
|
||||||
|
* #should_ThrowException_When_UserIsNotAuthorized test} and {@linkplain
|
||||||
|
* #should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin test} since it can't create an
|
||||||
|
* own classification.
|
||||||
|
*
|
||||||
|
* @throws Exception for errors in the building or reading process of entities.
|
||||||
|
*/
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@BeforeAll
|
||||||
|
void createClassifications() throws Exception {
|
||||||
|
defaultTestClassification()
|
||||||
|
.key("BeforeAllClassification")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_ThrowException_When_UserIsNotAuthorized() throws Exception {
|
||||||
|
Classification classification =
|
||||||
|
classificationService.getClassification("BeforeAllClassification", "DOMAIN_A");
|
||||||
|
classification.setCustomField(ClassificationCustomField.CUSTOM_1, "newCustom1");
|
||||||
|
|
||||||
|
MismatchedRoleException expectedException =
|
||||||
|
new MismatchedRoleException(
|
||||||
|
currentUserContext.getUserid(), TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||||
|
assertThatThrownBy(() -> classificationService.updateClassification(classification))
|
||||||
|
.usingRecursiveComparison()
|
||||||
|
.isEqualTo(expectedException);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "taskadmin")
|
||||||
|
@WithAccessId(user = "user-1-1")
|
||||||
|
@TestTemplate
|
||||||
|
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() throws Exception {
|
||||||
|
Classification classification =
|
||||||
|
classificationService.getClassification("BeforeAllClassification", "DOMAIN_A");
|
||||||
|
|
||||||
|
classification.setApplicationEntryPoint("updated EntryPoint");
|
||||||
|
classification.setName("updated Name");
|
||||||
|
|
||||||
|
MismatchedRoleException expectedException =
|
||||||
|
new MismatchedRoleException(
|
||||||
|
currentUserContext.getUserid(), TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||||
|
assertThatThrownBy(() -> classificationService.updateClassification(classification))
|
||||||
|
.usingRecursiveComparison()
|
||||||
|
.isEqualTo(expectedException);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_ThrowException_When_UpdatingClassificationConcurrently() throws Exception {
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification().buildAndStore(classificationService);
|
||||||
|
final Classification classificationSecondUpdate =
|
||||||
|
classificationService.getClassification(
|
||||||
|
classification.getKey(), classification.getDomain());
|
||||||
|
|
||||||
|
classification.setApplicationEntryPoint("Application Entry Point");
|
||||||
|
classification.setDescription("Description");
|
||||||
|
classification.setName("Name");
|
||||||
|
Thread.sleep(20); // to avoid identity of modified timestamps between classification and base
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
classificationSecondUpdate.setName("Name again");
|
||||||
|
classificationSecondUpdate.setDescription("Description again");
|
||||||
|
|
||||||
|
ConcurrencyException expectedException =
|
||||||
|
new ConcurrencyException(classificationSecondUpdate.getId());
|
||||||
|
assertThatThrownBy(
|
||||||
|
() -> classificationService.updateClassification(classificationSecondUpdate))
|
||||||
|
.usingRecursiveComparison()
|
||||||
|
.isEqualTo(expectedException);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_ThrowException_When_TryingToUpdateClassificationWithInvalidParentId()
|
||||||
|
throws Exception {
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification().buildAndStore(classificationService);
|
||||||
|
|
||||||
|
classification.setParentId("NON EXISTING ID");
|
||||||
|
|
||||||
|
ClassificationNotFoundException expectedException =
|
||||||
|
new ClassificationNotFoundException("NON EXISTING ID");
|
||||||
|
assertThatThrownBy(() -> classificationService.updateClassification(classification))
|
||||||
|
.usingRecursiveComparison()
|
||||||
|
.isEqualTo(expectedException);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_ThrowException_When_TryingToUpdateClassificationWithInvalidParentKey()
|
||||||
|
throws Exception {
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification().buildAndStore(classificationService);
|
||||||
|
|
||||||
|
classification.setParentKey("NON EXISTING KEY");
|
||||||
|
|
||||||
|
ClassificationNotFoundException expectedException =
|
||||||
|
new ClassificationNotFoundException("NON EXISTING KEY", "DOMAIN_A");
|
||||||
|
assertThatThrownBy(() -> classificationService.updateClassification(classification))
|
||||||
|
.usingRecursiveComparison()
|
||||||
|
.isEqualTo(expectedException);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_ThrowException_When_TryingToUpdateClassificationWithOwnKeyAsParentKey()
|
||||||
|
throws Exception {
|
||||||
|
Classification classification =
|
||||||
|
defaultTestClassification().buildAndStore(classificationService);
|
||||||
|
|
||||||
|
classification.setParentKey(classification.getKey());
|
||||||
|
|
||||||
|
InvalidArgumentException expectedException =
|
||||||
|
new InvalidArgumentException(
|
||||||
|
String.format(
|
||||||
|
"The Classification '%s' has the same key and parent key",
|
||||||
|
classification.getName()));
|
||||||
|
assertThatThrownBy(() -> classificationService.updateClassification(classification))
|
||||||
|
.usingRecursiveComparison()
|
||||||
|
.isEqualTo(expectedException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestInstance(Lifecycle.PER_CLASS)
|
||||||
|
@Nested
|
||||||
|
class UpdateClassificationCategoryTest {
|
||||||
|
Classification classification;
|
||||||
|
Task task;
|
||||||
|
Instant createdBefore;
|
||||||
|
Instant modifiedBefore;
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@BeforeEach
|
||||||
|
void createClassificationAndTask() throws Exception {
|
||||||
|
classification =
|
||||||
|
defaultTestClassification()
|
||||||
|
.category("MANUAL")
|
||||||
|
.type("TASK")
|
||||||
|
.buildAndStore(classificationService);
|
||||||
|
createdBefore = classification.getCreated();
|
||||||
|
modifiedBefore = classification.getModified();
|
||||||
|
String taskId = createTaskWithExistingClassification(classification.asSummary());
|
||||||
|
task = taskService.getTask(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_UpdateTask_When_UpdatingClassificationCategory() throws Exception {
|
||||||
|
classification.setCategory("PROCESS");
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
final Task updatedTask = taskService.getTask(task.getId());
|
||||||
|
|
||||||
|
TaskImpl expectedUpdatedTask = (TaskImpl) task.copy();
|
||||||
|
expectedUpdatedTask.setId(task.getId());
|
||||||
|
expectedUpdatedTask.setClassificationCategory("PROCESS");
|
||||||
|
expectedUpdatedTask.setClassificationSummary(
|
||||||
|
classificationService.getClassification(classification.getId()).asSummary());
|
||||||
|
expectedUpdatedTask.setExternalId(task.getExternalId());
|
||||||
|
assertThat(expectedUpdatedTask)
|
||||||
|
.usingRecursiveComparison()
|
||||||
|
.ignoringFields("modified")
|
||||||
|
.isEqualTo(updatedTask);
|
||||||
|
assertThat(expectedUpdatedTask.getModified()).isAfterOrEqualTo(modifiedBefore);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(user = "businessadmin")
|
||||||
|
@Test
|
||||||
|
void should_UpdateClassification_When_UpdatingClassificationCategory() throws Exception {
|
||||||
|
classification.setCategory("PROCESS");
|
||||||
|
classificationService.updateClassification(classification);
|
||||||
|
|
||||||
|
Classification updatedClassification =
|
||||||
|
classificationService.getClassification(classification.getId());
|
||||||
|
assertThat(updatedClassification)
|
||||||
|
.usingRecursiveComparison()
|
||||||
|
.ignoringFields("modified")
|
||||||
|
.isEqualTo(classification);
|
||||||
|
assertThat(updatedClassification.getModified()).isAfterOrEqualTo(modifiedBefore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,525 +0,0 @@
|
||||||
package acceptance.classification.update;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
||||||
|
|
||||||
import acceptance.AbstractAccTest;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
|
||||||
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestTemplate;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
|
|
||||||
import pro.taskana.classification.api.ClassificationCustomField;
|
|
||||||
import pro.taskana.classification.api.ClassificationService;
|
|
||||||
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
|
|
||||||
import pro.taskana.classification.api.models.Classification;
|
|
||||||
import pro.taskana.common.api.WorkingDaysToDaysConverter;
|
|
||||||
import pro.taskana.common.api.exceptions.ConcurrencyException;
|
|
||||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
|
||||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
|
||||||
import pro.taskana.common.internal.jobs.JobRunner;
|
|
||||||
import pro.taskana.common.test.security.JaasExtension;
|
|
||||||
import pro.taskana.common.test.security.WithAccessId;
|
|
||||||
import pro.taskana.task.api.TaskService;
|
|
||||||
import pro.taskana.task.api.models.Task;
|
|
||||||
import pro.taskana.task.internal.models.TaskImpl;
|
|
||||||
|
|
||||||
/** Acceptance test for all "update classification" scenarios. */
|
|
||||||
@ExtendWith(JaasExtension.class)
|
|
||||||
class UpdateClassificationAccTest extends AbstractAccTest {
|
|
||||||
|
|
||||||
private final ClassificationService classificationService =
|
|
||||||
taskanaEngine.getClassificationService();
|
|
||||||
|
|
||||||
@WithAccessId(user = "admin")
|
|
||||||
@Test
|
|
||||||
void should_SetDefaultServiceLevel_When_TryingToUpdateClassificationWithMissingServiceLevel()
|
|
||||||
throws Exception {
|
|
||||||
Classification classification =
|
|
||||||
classificationService.newClassification("Key1230", "DOMAIN_A", "TASK");
|
|
||||||
classification.setServiceLevel("P1D");
|
|
||||||
classification = classificationService.createClassification(classification);
|
|
||||||
classification.setServiceLevel(null);
|
|
||||||
classification = classificationService.updateClassification(classification);
|
|
||||||
assertThat(classification.getServiceLevel()).isEqualTo("P0D");
|
|
||||||
classification.setServiceLevel("");
|
|
||||||
classification = classificationService.updateClassification(classification);
|
|
||||||
assertThat(classification.getServiceLevel()).isEqualTo("P0D");
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "businessadmin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassification() throws Exception {
|
|
||||||
String newName = "updated Name";
|
|
||||||
String newEntryPoint = "updated EntryPoint";
|
|
||||||
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
final Instant createdBefore = classification.getCreated();
|
|
||||||
final Instant modifiedBefore = classification.getModified();
|
|
||||||
|
|
||||||
classification.setApplicationEntryPoint(newEntryPoint);
|
|
||||||
classification.setCategory("PROCESS");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_1, "newCustom1");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_2, "newCustom2");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_3, "newCustom3");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_4, "newCustom4");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_5, "newCustom5");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_6, "newCustom6");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_7, "newCustom7");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_8, "newCustom8");
|
|
||||||
classification.setDescription("newDescription");
|
|
||||||
classification.setIsValidInDomain(false);
|
|
||||||
classification.setName(newName);
|
|
||||||
classification.setParentId("CLI:100000000000000000000000000000000004");
|
|
||||||
classification.setParentKey("L11010");
|
|
||||||
classification.setPriority(1000);
|
|
||||||
classification.setServiceLevel("P3D");
|
|
||||||
|
|
||||||
classificationService.updateClassification(classification);
|
|
||||||
|
|
||||||
// Get and check the new value
|
|
||||||
Classification updatedClassification =
|
|
||||||
classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
assertThat(updatedClassification).isNotNull();
|
|
||||||
assertThat(updatedClassification.getName()).isEqualTo(newName);
|
|
||||||
assertThat(updatedClassification.getApplicationEntryPoint()).isEqualTo(newEntryPoint);
|
|
||||||
assertThat(updatedClassification.getCreated()).isEqualTo(createdBefore);
|
|
||||||
assertThat(modifiedBefore).isBefore(updatedClassification.getModified());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void should_ThrowException_When_UserIsNotAuthorized() throws Exception {
|
|
||||||
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
classification.setCustomField(ClassificationCustomField.CUSTOM_1, "newCustom1");
|
|
||||||
ThrowingCallable call = () -> classificationService.updateClassification(classification);
|
|
||||||
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "taskadmin")
|
|
||||||
@WithAccessId(user = "user-1-1")
|
|
||||||
@TestTemplate
|
|
||||||
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() throws Exception {
|
|
||||||
|
|
||||||
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
|
|
||||||
classification.setApplicationEntryPoint("updated EntryPoint");
|
|
||||||
classification.setName("updated Name");
|
|
||||||
|
|
||||||
ThrowingCallable updateClassificationCall =
|
|
||||||
() -> classificationService.updateClassification(classification);
|
|
||||||
assertThatThrownBy(updateClassificationCall).isInstanceOf(NotAuthorizedException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "businessadmin", groups = "user-1-1") // to read the task
|
|
||||||
@Test
|
|
||||||
void testUpdateTaskOnClassificationKeyCategoryChange() throws Exception {
|
|
||||||
setupTest();
|
|
||||||
TaskImpl beforeTask =
|
|
||||||
(TaskImpl)
|
|
||||||
taskanaEngine.getTaskService().getTask("TKI:000000000000000000000000000000000000");
|
|
||||||
|
|
||||||
Classification classification =
|
|
||||||
classificationService.getClassification(
|
|
||||||
beforeTask.getClassificationSummary().getKey(), beforeTask.getDomain());
|
|
||||||
classification.setCategory("PROCESS");
|
|
||||||
final Instant createdBefore = classification.getCreated();
|
|
||||||
final Instant modifiedBefore = classification.getModified();
|
|
||||||
classification = taskanaEngine.getClassificationService().updateClassification(classification);
|
|
||||||
|
|
||||||
TaskImpl updatedTask =
|
|
||||||
(TaskImpl)
|
|
||||||
taskanaEngine.getTaskService().getTask("TKI:000000000000000000000000000000000000");
|
|
||||||
assertThat(beforeTask.getClassificationCategory())
|
|
||||||
.isNotEqualTo(updatedTask.getClassificationCategory());
|
|
||||||
assertThat(beforeTask.getClassificationSummary().getCategory())
|
|
||||||
.isNotEqualTo(updatedTask.getClassificationSummary().getCategory());
|
|
||||||
assertThat(updatedTask.getClassificationCategory()).isEqualTo("PROCESS");
|
|
||||||
assertThat(updatedTask.getClassificationSummary().getCategory()).isEqualTo("PROCESS");
|
|
||||||
assertThat(classification.getCreated()).isEqualTo(createdBefore);
|
|
||||||
// isBeforeOrEquals in case of too fast execution
|
|
||||||
assertThat(modifiedBefore).isBeforeOrEqualTo(classification.getModified());
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "businessadmin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassificationNotLatestAnymore() throws Exception {
|
|
||||||
Classification base = classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
final Classification classification =
|
|
||||||
classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
|
|
||||||
// UPDATE BASE
|
|
||||||
base.setApplicationEntryPoint("SOME CHANGED POINT");
|
|
||||||
base.setDescription("AN OTHER DESCRIPTION");
|
|
||||||
base.setName("I AM UPDATED");
|
|
||||||
Thread.sleep(20); // to avoid identity of modified timestamps between classification and base
|
|
||||||
classificationService.updateClassification(base);
|
|
||||||
|
|
||||||
classification.setName("NOW IT'S MY TURN");
|
|
||||||
classification.setDescription("IT SHOULD BE TO LATE...");
|
|
||||||
ThrowingCallable call = () -> classificationService.updateClassification(classification);
|
|
||||||
assertThatThrownBy(call).isInstanceOf(ConcurrencyException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "businessadmin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassificationParentIdToInvalid() throws Exception {
|
|
||||||
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
classification.setParentId("ID WHICH CANT BE FOUND");
|
|
||||||
ThrowingCallable call = () -> classificationService.updateClassification(classification);
|
|
||||||
assertThatThrownBy(call).isInstanceOf(ClassificationNotFoundException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "businessadmin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassificationParentKeyToInvalid() throws Exception {
|
|
||||||
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
classification.setParentKey("KEY WHICH CANT BE FOUND");
|
|
||||||
ThrowingCallable call = () -> classificationService.updateClassification(classification);
|
|
||||||
assertThatThrownBy(call).isInstanceOf(ClassificationNotFoundException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "admin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassificationPrioServiceLevel() throws Exception {
|
|
||||||
final Instant before = Instant.now();
|
|
||||||
Classification classification =
|
|
||||||
classificationService.getClassification("CLI:100000000000000000000000000000000003");
|
|
||||||
final Instant modifiedBefore = classification.getModified();
|
|
||||||
classification.setPriority(1000);
|
|
||||||
classification.setServiceLevel("P15D");
|
|
||||||
|
|
||||||
updateClassificationAndRunAssociatedJobs(classification);
|
|
||||||
// Get and check the new value
|
|
||||||
Classification updatedClassification =
|
|
||||||
classificationService.getClassification("CLI:100000000000000000000000000000000003");
|
|
||||||
assertThat(updatedClassification).isNotNull();
|
|
||||||
|
|
||||||
assertThat(modifiedBefore.isAfter(updatedClassification.getModified())).isFalse();
|
|
||||||
// TODO - resume old behaviour after attachment query is possible.
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
|
||||||
|
|
||||||
List<String> tasksWithP1D =
|
|
||||||
List.of(
|
|
||||||
"TKI:000000000000000000000000000000000054",
|
|
||||||
"TKI:000000000000000000000000000000000055",
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TKI:000000000000000000000000000000000053");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithP1D, taskService, converter, 1, 1000);
|
|
||||||
|
|
||||||
List<String> tasksWithP8D = List.of("TKI:000000000000000000000000000000000008");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithP8D, taskService, converter, 8, 1000);
|
|
||||||
|
|
||||||
List<String> tasksWithP14D = List.of("TKI:000000000000000000000000000000000010");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithP14D, taskService, converter, 14, 1000);
|
|
||||||
|
|
||||||
List<String> tasksWithP15D =
|
|
||||||
List.of(
|
|
||||||
"TKI:000000000000000000000000000000000003",
|
|
||||||
"TKI:000000000000000000000000000000000004",
|
|
||||||
"TKI:000000000000000000000000000000000005",
|
|
||||||
"TKI:000000000000000000000000000000000006",
|
|
||||||
"TKI:000000000000000000000000000000000007",
|
|
||||||
"TKI:000000000000000000000000000000000009",
|
|
||||||
"TKI:000000000000000000000000000000000012",
|
|
||||||
"TKI:000000000000000000000000000000000013",
|
|
||||||
"TKI:000000000000000000000000000000000014",
|
|
||||||
"TKI:000000000000000000000000000000000015",
|
|
||||||
"TKI:000000000000000000000000000000000016",
|
|
||||||
"TKI:000000000000000000000000000000000017",
|
|
||||||
"TKI:000000000000000000000000000000000018",
|
|
||||||
"TKI:000000000000000000000000000000000019",
|
|
||||||
"TKI:000000000000000000000000000000000020",
|
|
||||||
"TKI:000000000000000000000000000000000021",
|
|
||||||
"TKI:000000000000000000000000000000000022",
|
|
||||||
"TKI:000000000000000000000000000000000023",
|
|
||||||
"TKI:000000000000000000000000000000000024",
|
|
||||||
"TKI:000000000000000000000000000000000025",
|
|
||||||
"TKI:000000000000000000000000000000000026",
|
|
||||||
"TKI:000000000000000000000000000000000027",
|
|
||||||
"TKI:000000000000000000000000000000000028",
|
|
||||||
"TKI:000000000000000000000000000000000029",
|
|
||||||
"TKI:000000000000000000000000000000000030",
|
|
||||||
"TKI:000000000000000000000000000000000031",
|
|
||||||
"TKI:000000000000000000000000000000000032",
|
|
||||||
"TKI:000000000000000000000000000000000033",
|
|
||||||
"TKI:000000000000000000000000000000000034",
|
|
||||||
"TKI:000000000000000000000000000000000035",
|
|
||||||
"TKI:000000000000000000000000000000000100",
|
|
||||||
"TKI:000000000000000000000000000000000101",
|
|
||||||
"TKI:000000000000000000000000000000000102",
|
|
||||||
"TKI:000000000000000000000000000000000103");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithP15D, taskService, converter, 15, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "businessadmin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassificationWithSameKeyAndParentKey() throws Exception {
|
|
||||||
|
|
||||||
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
|
|
||||||
|
|
||||||
classification.setParentKey(classification.getKey());
|
|
||||||
ThrowingCallable call = () -> classificationService.updateClassification(classification);
|
|
||||||
assertThatThrownBy(call).isInstanceOf(InvalidArgumentException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "businessadmin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassificationWithEmptyServiceLevel() throws Exception {
|
|
||||||
|
|
||||||
Classification classification =
|
|
||||||
classificationService.newClassification("Key=0818", "DOMAIN_A", "TASK");
|
|
||||||
classification.setServiceLevel("P1D");
|
|
||||||
Classification created = classificationService.createClassification(classification);
|
|
||||||
created.setServiceLevel("");
|
|
||||||
|
|
||||||
assertThatCode(() -> classificationService.updateClassification(created))
|
|
||||||
.doesNotThrowAnyException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "admin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassificationChangePriority() throws Exception {
|
|
||||||
final Instant before = Instant.now();
|
|
||||||
Classification classification =
|
|
||||||
classificationService.getClassification("CLI:100000000000000000000000000000000003");
|
|
||||||
final Instant modifiedBefore = classification.getModified();
|
|
||||||
|
|
||||||
classification.setPriority(99);
|
|
||||||
classification.setServiceLevel("P1D");
|
|
||||||
|
|
||||||
updateClassificationAndRunAssociatedJobs(classification);
|
|
||||||
// Get and check the new value
|
|
||||||
Classification updatedClassification =
|
|
||||||
classificationService.getClassification("CLI:100000000000000000000000000000000003");
|
|
||||||
assertThat(updatedClassification).isNotNull();
|
|
||||||
assertThat(modifiedBefore.isAfter(updatedClassification.getModified())).isFalse();
|
|
||||||
// TODO - resume old behaviour after attachment query is possible.
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
|
||||||
|
|
||||||
List<String> tasksWithPrio99 =
|
|
||||||
List.of(
|
|
||||||
"TKI:000000000000000000000000000000000003",
|
|
||||||
"TKI:000000000000000000000000000000000004",
|
|
||||||
"TKI:000000000000000000000000000000000005",
|
|
||||||
"TKI:000000000000000000000000000000000006",
|
|
||||||
"TKI:000000000000000000000000000000000007",
|
|
||||||
"TKI:000000000000000000000000000000000009",
|
|
||||||
"TKI:000000000000000000000000000000000012",
|
|
||||||
"TKI:000000000000000000000000000000000013",
|
|
||||||
"TKI:000000000000000000000000000000000014",
|
|
||||||
"TKI:000000000000000000000000000000000015",
|
|
||||||
"TKI:000000000000000000000000000000000016",
|
|
||||||
"TKI:000000000000000000000000000000000017",
|
|
||||||
"TKI:000000000000000000000000000000000018",
|
|
||||||
"TKI:000000000000000000000000000000000019",
|
|
||||||
"TKI:000000000000000000000000000000000020",
|
|
||||||
"TKI:000000000000000000000000000000000021",
|
|
||||||
"TKI:000000000000000000000000000000000022",
|
|
||||||
"TKI:000000000000000000000000000000000023",
|
|
||||||
"TKI:000000000000000000000000000000000024",
|
|
||||||
"TKI:000000000000000000000000000000000025",
|
|
||||||
"TKI:000000000000000000000000000000000026",
|
|
||||||
"TKI:000000000000000000000000000000000027",
|
|
||||||
"TKI:000000000000000000000000000000000028",
|
|
||||||
"TKI:000000000000000000000000000000000029",
|
|
||||||
"TKI:000000000000000000000000000000000030",
|
|
||||||
"TKI:000000000000000000000000000000000031",
|
|
||||||
"TKI:000000000000000000000000000000000032",
|
|
||||||
"TKI:000000000000000000000000000000000033",
|
|
||||||
"TKI:000000000000000000000000000000000034",
|
|
||||||
"TKI:000000000000000000000000000000000035",
|
|
||||||
"TKI:000000000000000000000000000000000100",
|
|
||||||
"TKI:000000000000000000000000000000000101",
|
|
||||||
"TKI:000000000000000000000000000000000102",
|
|
||||||
"TKI:000000000000000000000000000000000103",
|
|
||||||
"TKI:200000000000000000000000000000000007",
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TKI:000000000000000000000000000000000052",
|
|
||||||
"TKI:000000000000000000000000000000000053",
|
|
||||||
"TKI:000000000000000000000000000000000054",
|
|
||||||
"TKI:000000000000000000000000000000000008",
|
|
||||||
"TKI:000000000000000000000000000000000009",
|
|
||||||
"TKI:000000000000000000000000000000000010");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithPrio99, taskService, converter, 1, 99);
|
|
||||||
|
|
||||||
List<String> tasksWithPrio101 = List.of("TKI:000000000000000000000000000000000011");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithPrio101, taskService, converter, 1, 101);
|
|
||||||
|
|
||||||
updatedClassification.setPriority(7);
|
|
||||||
updateClassificationAndRunAssociatedJobs(updatedClassification);
|
|
||||||
|
|
||||||
List<String> tasksWithPrio7 =
|
|
||||||
List.of(
|
|
||||||
"TKI:000000000000000000000000000000000003",
|
|
||||||
"TKI:000000000000000000000000000000000004",
|
|
||||||
"TKI:000000000000000000000000000000000005",
|
|
||||||
"TKI:000000000000000000000000000000000006",
|
|
||||||
"TKI:000000000000000000000000000000000007",
|
|
||||||
"TKI:000000000000000000000000000000000009",
|
|
||||||
"TKI:000000000000000000000000000000000010",
|
|
||||||
"TKI:000000000000000000000000000000000012",
|
|
||||||
"TKI:000000000000000000000000000000000013",
|
|
||||||
"TKI:000000000000000000000000000000000014",
|
|
||||||
"TKI:000000000000000000000000000000000015",
|
|
||||||
"TKI:000000000000000000000000000000000016",
|
|
||||||
"TKI:000000000000000000000000000000000017",
|
|
||||||
"TKI:000000000000000000000000000000000018",
|
|
||||||
"TKI:000000000000000000000000000000000019",
|
|
||||||
"TKI:000000000000000000000000000000000020",
|
|
||||||
"TKI:000000000000000000000000000000000021",
|
|
||||||
"TKI:000000000000000000000000000000000022",
|
|
||||||
"TKI:000000000000000000000000000000000023",
|
|
||||||
"TKI:000000000000000000000000000000000024",
|
|
||||||
"TKI:000000000000000000000000000000000025",
|
|
||||||
"TKI:000000000000000000000000000000000026",
|
|
||||||
"TKI:000000000000000000000000000000000027",
|
|
||||||
"TKI:000000000000000000000000000000000028",
|
|
||||||
"TKI:000000000000000000000000000000000029",
|
|
||||||
"TKI:000000000000000000000000000000000030",
|
|
||||||
"TKI:000000000000000000000000000000000031",
|
|
||||||
"TKI:000000000000000000000000000000000032",
|
|
||||||
"TKI:000000000000000000000000000000000033",
|
|
||||||
"TKI:000000000000000000000000000000000034",
|
|
||||||
"TKI:000000000000000000000000000000000035",
|
|
||||||
"TKI:000000000000000000000000000000000100",
|
|
||||||
"TKI:000000000000000000000000000000000101",
|
|
||||||
"TKI:000000000000000000000000000000000102",
|
|
||||||
"TKI:000000000000000000000000000000000103",
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TKI:000000000000000000000000000000000052",
|
|
||||||
"TKI:000000000000000000000000000000000053",
|
|
||||||
"TKI:000000000000000000000000000000000054",
|
|
||||||
"TKI:000000000000000000000000000000000055",
|
|
||||||
"TKI:200000000000000000000000000000000007");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithPrio7, taskService, converter, 1, 7);
|
|
||||||
|
|
||||||
List<String> tasksWithPrio9 = List.of("TKI:000000000000000000000000000000000008");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithPrio9, taskService, converter, 1, 9);
|
|
||||||
|
|
||||||
tasksWithPrio101 = List.of("TKI:000000000000000000000000000000000011");
|
|
||||||
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithPrio101, taskService, converter, 1, 101);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "admin")
|
|
||||||
@Test
|
|
||||||
void testUpdateClassificationChangeServiceLevel() throws Exception {
|
|
||||||
final Instant before = Instant.now();
|
|
||||||
Classification classification =
|
|
||||||
classificationService.getClassification("CLI:100000000000000000000000000000000003");
|
|
||||||
final Instant modifiedBefore = classification.getModified();
|
|
||||||
|
|
||||||
classification.setPriority(555);
|
|
||||||
classification.setServiceLevel("P12D");
|
|
||||||
|
|
||||||
updateClassificationAndRunAssociatedJobs(classification);
|
|
||||||
// Get and check the new value
|
|
||||||
Classification updatedClassification =
|
|
||||||
classificationService.getClassification("CLI:100000000000000000000000000000000003");
|
|
||||||
assertThat(updatedClassification).isNotNull();
|
|
||||||
assertThat(updatedClassification.getModified()).isAfter(modifiedBefore);
|
|
||||||
// TODO - resume old behaviour after attachment query is possible.
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
|
||||||
List<String> tasksWithPD12 =
|
|
||||||
List.of(
|
|
||||||
"TKI:000000000000000000000000000000000003",
|
|
||||||
"TKI:000000000000000000000000000000000004",
|
|
||||||
"TKI:000000000000000000000000000000000005",
|
|
||||||
"TKI:000000000000000000000000000000000006",
|
|
||||||
"TKI:000000000000000000000000000000000007",
|
|
||||||
"TKI:000000000000000000000000000000000009",
|
|
||||||
"TKI:000000000000000000000000000000000010",
|
|
||||||
"TKI:000000000000000000000000000000000012",
|
|
||||||
"TKI:000000000000000000000000000000000013",
|
|
||||||
"TKI:000000000000000000000000000000000014",
|
|
||||||
"TKI:000000000000000000000000000000000015",
|
|
||||||
"TKI:000000000000000000000000000000000016",
|
|
||||||
"TKI:000000000000000000000000000000000017",
|
|
||||||
"TKI:000000000000000000000000000000000018",
|
|
||||||
"TKI:000000000000000000000000000000000019",
|
|
||||||
"TKI:000000000000000000000000000000000020",
|
|
||||||
"TKI:000000000000000000000000000000000021",
|
|
||||||
"TKI:000000000000000000000000000000000022",
|
|
||||||
"TKI:000000000000000000000000000000000023",
|
|
||||||
"TKI:000000000000000000000000000000000024",
|
|
||||||
"TKI:000000000000000000000000000000000025",
|
|
||||||
"TKI:000000000000000000000000000000000026",
|
|
||||||
"TKI:000000000000000000000000000000000027",
|
|
||||||
"TKI:000000000000000000000000000000000028",
|
|
||||||
"TKI:000000000000000000000000000000000029",
|
|
||||||
"TKI:000000000000000000000000000000000030",
|
|
||||||
"TKI:000000000000000000000000000000000031",
|
|
||||||
"TKI:000000000000000000000000000000000032",
|
|
||||||
"TKI:000000000000000000000000000000000033",
|
|
||||||
"TKI:000000000000000000000000000000000034",
|
|
||||||
"TKI:000000000000000000000000000000000035",
|
|
||||||
"TKI:000000000000000000000000000000000100",
|
|
||||||
"TKI:000000000000000000000000000000000101",
|
|
||||||
"TKI:000000000000000000000000000000000102",
|
|
||||||
"TKI:000000000000000000000000000000000103",
|
|
||||||
"TKI:200000000000000000000000000000000007");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithPD12, taskService, converter, 12, 555);
|
|
||||||
|
|
||||||
List<String> tasksWithPD8 = List.of("TKI:000000000000000000000000000000000008");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithPD8, taskService, converter, 8, 555);
|
|
||||||
|
|
||||||
List<String> tasksWithPD1 =
|
|
||||||
List.of(
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TKI:000000000000000000000000000000000052",
|
|
||||||
"TKI:000000000000000000000000000000000053",
|
|
||||||
"TKI:000000000000000000000000000000000054",
|
|
||||||
"TKI:000000000000000000000000000000000055");
|
|
||||||
validateTaskPropertiesAfterClassificationChange(
|
|
||||||
before, tasksWithPD1, taskService, converter, 1, 555);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateClassificationAndRunAssociatedJobs(Classification classification)
|
|
||||||
throws Exception {
|
|
||||||
classificationService.updateClassification(classification);
|
|
||||||
Thread.sleep(10);
|
|
||||||
// run the ClassificationChangedJob
|
|
||||||
JobRunner runner = new JobRunner(taskanaEngine);
|
|
||||||
// run the TaskRefreshJob that was scheduled by the ClassificationChangedJob.
|
|
||||||
runner.runJobs();
|
|
||||||
Thread.sleep(10); // otherwise the next runJobs call intermittently doesn't find the Job created
|
|
||||||
// by the previous step (it searches with DueDate < CurrentTime)
|
|
||||||
runner.runJobs();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateTaskPropertiesAfterClassificationChange(
|
|
||||||
Instant before,
|
|
||||||
List<String> tasksUpdated,
|
|
||||||
TaskService taskService,
|
|
||||||
WorkingDaysToDaysConverter converter,
|
|
||||||
int serviceLevel,
|
|
||||||
int priority)
|
|
||||||
throws Exception {
|
|
||||||
for (String taskId : tasksUpdated) {
|
|
||||||
Task task = taskService.getTask(taskId);
|
|
||||||
|
|
||||||
assertThat(task.getModified())
|
|
||||||
.describedAs("Task " + task.getId() + " has not been refreshed.")
|
|
||||||
.isAfter(before);
|
|
||||||
Instant expDue =
|
|
||||||
converter.addWorkingDaysToInstant(task.getPlanned(), Duration.ofDays(serviceLevel));
|
|
||||||
|
|
||||||
assertThat(task.getDue()).isEqualTo(expDue);
|
|
||||||
assertThat(task.getPriority()).isEqualTo(priority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue