TSK-1177 update Planned - Holger's comments

This commit is contained in:
BerndBreier 2020-04-06 15:48:06 +02:00 committed by Holger Hagen
parent 520eb4e295
commit 2038999ee7
2 changed files with 72 additions and 82 deletions

View File

@ -40,11 +40,27 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
taskService = taskanaEngine.getTaskService();
}
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void should_ThrowException_When_DueAndPlannedAreChangedInconsistently() throws Exception {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
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(
"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.");
}
@WithAccessId(
userName = "user_3_2",
groupNames = {"group_2"})
@Test
void should_SetPlanned_when_setPlannedRequestContainsDuplicateTaskIds()
void should_SetPlanned_When_SetPlannedRequestContainsDuplicateTaskIds()
throws NotAuthorizedException, TaskNotFoundException {
// This test works with the following tasks (w/o attachments) and classifications
@ -83,7 +99,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "user_3_2",
groupNames = {"group_2"})
@Test
void should_setPlanned_when_RequestContainsDuplicatesAndNotExistingTaskIds()
void should_SetPlanned_When_RequestContainsDuplicatesAndNotExistingTaskIds()
throws NotAuthorizedException, TaskNotFoundException {
String tkId1 = "TKI:000000000000000000000000000000000058";
@ -112,7 +128,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_2"})
@Test
void should_SetPlanned_when_RequestContainsRasksWithAttachments()
void should_SetPlanned_When_RequestContainsTasksWithAttachments()
throws NotAuthorizedException, TaskNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, InvalidStateException, ConcurrencyException,
AttachmentPersistenceException {
@ -193,7 +209,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "user_3_2",
groupNames = {"group_2"})
@Test
void should_ReturnBulkLog_when_UserIsNotAuthorizedForTasks() {
void should_ReturnBulkLog_When_UserIsNotAuthorizedForTasks() {
String tkId1 = "TKI:000000000000000000000000000000000008";
String tkId2 = "TKI:000000000000000000000000000000000009";
String tkId3 = "TKI:000000000000000000000000000000000008";
@ -215,7 +231,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "admin",
groupNames = {"group_2"})
@Test
void should_SetPlannedPropertyOfTasks_when_RequestedByAdminUser()
void should_SetPlannedPropertyOfTasks_When_RequestedByAdminUser()
throws NotAuthorizedException, TaskNotFoundException {
String tkId1 = "TKI:000000000000000000000000000000000008";
String tkId2 = "TKI:000000000000000000000000000000000009";
@ -242,7 +258,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "admin",
groupNames = {"group_2"})
@Test
void should_DoNothing_when_SetPlannedIsCalledWithEmptyTasksList() {
void should_DoNothing_When_SetPlannedIsCalledWithEmptyTasksList() {
Instant planned = getInstant("2020-05-03T07:00:00");
BulkOperationResults<String, TaskanaException> results =
taskService.setPlannedPropertyOfTasks(planned, new ArrayList<>());
@ -261,7 +277,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "admin",
groupNames = {"group_2"})
@Test
void should_SetPlannedPropertyWithBulkUpdate_when_RequestContainsASingleTask()
void should_SetPlannedPropertyWithBulkUpdate_When_RequestContainsASingleTask()
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException {
String taskId = "TKI:000000000000000000000000000000000002";
Instant planned = getInstant("2020-05-03T07:00:00");
@ -279,7 +295,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "admin",
groupNames = {"group_2"})
@Test
void should_SetPlannedPropertyOnSingle_when_UpdateTaskWasCalled()
void should_SetPlannedPropertyOnSingle_When_UpdateTaskWasCalled()
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException,
ConcurrencyException, InvalidStateException, ClassificationNotFoundException,
AttachmentPersistenceException {
@ -297,7 +313,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "admin",
groupNames = {"group_2"})
@Test
void should_SetDueOrPlannedProperty_when_TaskUpdateIsCalled()
void should_SetPlanned_When_OnlyDueWasChanged()
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException,
ConcurrencyException, InvalidStateException, ClassificationNotFoundException,
AttachmentPersistenceException {
@ -309,16 +325,19 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
task.setDue(planned.plus(Duration.ofDays(8)));
task = taskService.updateTask(task);
assertThat(task.getPlanned()).isEqualTo(getInstant("2020-05-08T07:00:00"));
}
// test update of due with changed planned and due that fails
task.setPlanned(planned.plus(Duration.ofDays(12)));
task.setDue(planned.plus(Duration.ofDays(22)));
final Task finalTask = task;
assertThatThrownBy(() -> taskService.updateTask(finalTask))
.isInstanceOf(InvalidArgumentException.class);
// update due and planned as expected.
task = taskService.getTask(taskId);
@WithAccessId(
userName = "admin",
groupNames = {"group_2"})
@Test
void should_SetDue_When_OnlyPlannedWasChanged()
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException,
ConcurrencyException, InvalidStateException, ClassificationNotFoundException,
AttachmentPersistenceException {
String taskId = "TKI:000000000000000000000000000000000002";
Instant planned = getInstant("2020-05-03T07:00:00");
Task task = taskService.getTask(taskId);
task.setDue(planned.plus(Duration.ofDays(3)));
WorkingDaysToDaysConverter converter = WorkingDaysToDaysConverter.initialize();
long days = converter.convertWorkingDaysToDays(task.getDue(), -1);
@ -326,21 +345,32 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
task = taskService.updateTask(task);
days = converter.convertWorkingDaysToDays(task.getDue(), -1);
assertThat(task.getPlanned()).isEqualTo(task.getDue().plus(Duration.ofDays(days)));
// update due and planned as expected.
task = taskService.getTask(taskId);
task.setDue(planned.plus(Duration.ofDays(3)));
task.setPlanned(null);
task = taskService.updateTask(task);
days = converter.convertWorkingDaysToDays(task.getDue(), -1);
assertThat(task.getPlanned()).isEqualTo(task.getDue().plus(Duration.ofDays(days)));
}
@WithAccessId(
userName = "admin",
groupNames = {"group_2"})
@Test
void should_setDue_when_taskUpdateIsCalled()
void should_SetPlanned_When_DueIsChangedAndPlannedIsNulled()
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException,
ConcurrencyException, InvalidStateException, ClassificationNotFoundException,
AttachmentPersistenceException {
String taskId = "TKI:000000000000000000000000000000000002";
Instant planned = getInstant("2020-05-03T07:00:00");
Task task = taskService.getTask(taskId);
task.setDue(planned.plus(Duration.ofDays(3)));
task.setPlanned(null);
task = taskService.updateTask(task);
WorkingDaysToDaysConverter converter = WorkingDaysToDaysConverter.initialize();
long days = converter.convertWorkingDaysToDays(task.getDue(), -1);
assertThat(task.getPlanned()).isEqualTo(task.getDue().plus(Duration.ofDays(days)));
}
@WithAccessId(
userName = "admin",
groupNames = {"group_2"})
@Test
void should_SetDue_When_TaskUpdateIsCalled()
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException,
ConcurrencyException, InvalidStateException, ClassificationNotFoundException,
AttachmentPersistenceException {
@ -377,20 +407,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
userName = "user_1_2",
groupNames = {"group_1"})
@Test
void should_throwException_when_DueAndPlannedAreChangedInconsistently()
throws NotAuthorizedException, TaskNotFoundException {
Task task = taskService.getTask("TKI:000000000000000000000000000000000030");
task.setPlanned(getInstant("2020-04-21T07:00:00"));
task.setDue(getInstant("2020-04-21T10:00:00"));
assertThatThrownBy(() -> taskService.updateTask(task))
.isInstanceOf(InvalidArgumentException.class);
}
@WithAccessId(
userName = "user_1_2",
groupNames = {"group_1"})
@Test
void should_UpdateTaskPlannedOrDue_when_PlannedOrDueAreWeekendDays()
void should_UpdateTaskPlannedOrDue_When_PlannedOrDueAreWeekendDays()
throws NotAuthorizedException, TaskNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, InvalidStateException, ConcurrencyException,
AttachmentPersistenceException {

View File

@ -43,35 +43,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void should_updatePlanned_when_onlyDueWasChanged() throws Exception {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setDue(Instant.parse("2020-07-02T01:00:00Z"));
Task task1 = taskService.updateTask(task);
assertThat(task1.getPlanned()).isEqualTo(Instant.parse("2020-07-01T01:00:00Z"));
}
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void should_throwException_when_DueAndPlannedWasChangedInconsistently() throws Exception {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
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(
"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.");
}
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
@Test
void should_UpdatePrimaryObjectReferenceOfTask_when_requested()
void should_UpdatePrimaryObjectReferenceOfTask_When_Requested()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException,
InvalidStateException {
@ -102,7 +74,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
void should_ThrowException_when_MandatoryPrimaryObjectReferenceIsNotSetOrIncomplete()
void should_ThrowException_When_MandatoryPrimaryObjectReferenceIsNotSetOrIncomplete()
throws NotAuthorizedException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
@ -144,7 +116,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
void should_ThrowException_when_TaskHasAlreadyBeenUpdated()
void should_ThrowException_When_TaskHasAlreadyBeenUpdated()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException,
InvalidStateException, InterruptedException {
@ -167,10 +139,10 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
void should_UpdateTaskProperties_when_ClassificationOfTaskIsChanged()
void should_UpdateTaskProperties_When_ClassificationOfTaskIsChanged()
throws TaskNotFoundException, ClassificationNotFoundException, InvalidArgumentException,
ConcurrencyException, NotAuthorizedException, AttachmentPersistenceException,
InvalidStateException, SQLException {
ConcurrencyException, NotAuthorizedException, AttachmentPersistenceException,
InvalidStateException, SQLException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
@ -193,7 +165,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_2",
groupNames = {"group_1"})
@Test
void should_UpdateReadFlagOfTask_whenSetTaskReadIsCalled()
void should_UpdateReadFlagOfTask_When_SetTaskReadIsCalled()
throws TaskNotFoundException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
@ -218,7 +190,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
void should_UpdateTask_when_CustomPropertiesOfTaskWereChanged()
void should_UpdateTask_When_CustomPropertiesOfTaskWereChanged()
throws TaskNotFoundException, ClassificationNotFoundException, InvalidArgumentException,
ConcurrencyException, NotAuthorizedException, AttachmentPersistenceException,
InvalidStateException {
@ -235,7 +207,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
void should_ThrowException_when_ModificationOfWorkbasketKeyIsAttempted()
void should_ThrowException_When_ModificationOfWorkbasketKeyIsAttempted()
throws NotAuthorizedException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
@ -250,7 +222,8 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
void should_UpdateTask_when_ObjectReferenceWasChanged() throws InvalidArgumentException {
void should_UpdateNoTasks_When_UpdateTasksWithUnmatchedObjectReferenceWasCalled()
throws InvalidArgumentException {
ObjectReference por = new ObjectReference();
por.setCompany("00");
por.setSystem("PASystem");
@ -272,7 +245,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
void should_UpdateTask_when_PrimaryObjectReferenceWasChanged()
void should_UpdateTasks_When_MatchingPrimaryObjectReferenceWasChanged()
throws InvalidArgumentException, TaskNotFoundException, NotAuthorizedException {
ObjectReference por = new ObjectReference();
por.setCompany("00");
@ -302,7 +275,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
void should_UpdateTaskCustomAttributes_when_UpdateTasksIsCalled()
void should_UpdateTaskCustomAttributes_When_UpdateTasksIsCalled()
throws InvalidArgumentException, TaskNotFoundException, NotAuthorizedException {
List<String> taskIds =
Arrays.asList(
@ -332,7 +305,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
void should_UpdateCallbackInfo_when_requestedByApi()
void should_UpdateCallbackInfo_When_RequestedByApi()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException, InvalidStateException {