Skip to content

Commit 9ea82b7

Browse files
jamesrdigitgoodjhe
authored andcommitted
Closes #2491: Set Owner of Task when Transferring
1 parent d0f5c41 commit 9ea82b7

File tree

16 files changed

+1033
-83
lines changed

16 files changed

+1033
-83
lines changed

common/taskana-common-data/src/main/resources/sql/sample-data/task.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000000', 'ETI:000000000000000000000000000000000000', RELATIVE_DATE(-1) , RELATIVE_DATE(0) , null , RELATIVE_DATE(0) , RELATIVE_DATE(0) , RELATIVE_DATE(-1) , RELATIVE_DATE(0) , 'Task99' , 'creator_user_id' , 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note' , 1 , -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' , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 3 );
55
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000001', 'ETI:000000000000000000000000000000000001', RELATIVE_DATE(-2) , RELATIVE_DATE(0) , null , RELATIVE_DATE(0) , null , RELATIVE_DATE(-2) , RELATIVE_DATE(0) , 'Task01' , 'creator_user_id' , 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note' , 2 , -1 , '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 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 2 );
66
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000002', 'ETI:000000000000000000000000000000000002', RELATIVE_DATE(-2) , RELATIVE_DATE(0) , null , RELATIVE_DATE(0) , RELATIVE_DATE(0) , RELATIVE_DATE(-2) , RELATIVE_DATE(0) , 'Task02' , 'creator_user_id' , 'Lorem ipsum was n Quatsch t. Aber stimmt.', 'Some custom Note' , 2 , -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 , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 2 );
7-
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000003', 'ETI:000000000000000000000000000000000003','2018-02-01 12:00:00', null , null , '2018-02-01 12:00:00', RELATIVE_DATE(0) , RELATIVE_DATE(-2) , RELATIVE_DATE(0) , 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , '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 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
7+
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000003', 'ETI:000000000000000000000000000000000003','2018-02-01 12:00:00', null , null , '2018-02-01 12:00:00', RELATIVE_DATE(0) , RELATIVE_DATE(-2) , RELATIVE_DATE(0) , 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , '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 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 0 );
88
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000004', 'ETI:000000000000000000000000000000000004', RELATIVE_DATE(-3) , null , null , RELATIVE_DATE(0) , RELATIVE_DATE(0) , RELATIVE_DATE(-3) , RELATIVE_DATE(0) , 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , '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 , '074' , '' , null , null , null , null , null , null , 'abc' , null , null , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 1 );
99
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000005', 'ETI:000000000000000000000000000000000005', RELATIVE_DATE(-4) , null , null , RELATIVE_DATE(0) , RELATIVE_DATE(-3) , RELATIVE_DATE(-4) , RELATIVE_DATE(0) , 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , '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 , '074' , '' , null , null , null , null , null , null , 'abc' , null , null , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 0 );
1010
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000006', 'ETI:000000000000000000000000000000000006', RELATIVE_DATE(-5) , null , null , RELATIVE_DATE(0) , RELATIVE_DATE(-3) , RELATIVE_DATE(-5) , RELATIVE_DATE(0) , 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2000 , -1 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000006' , 'DOC_0000000000000000006' , null , '00' , 'PASystem' , '00' , 'VNR' , '11223344' , false , false , null , 'NONE' , null , null , null , null , null , null , '075' , '' , null , null , null , null , null , null , 'abc' , null , null , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 0 );

history/taskana-simplehistory-provider/src/test/java/acceptance/events/task/CreateHistoryEventOnTaskTransferAccTest.java

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,156 @@ Stream<DynamicTest> should_CreateTransferredHistoryEvents_When_TaskBulkTransfer(
181181
return DynamicTest.stream(testCases.iterator(), Triplet::getLeft, test);
182182
}
183183

184+
@WithAccessId(user = "admin")
185+
@TestFactory
186+
Stream<DynamicTest> should_CreateTransferredHistoryEvent_When_TaskIsTransferredWithOwner() {
187+
List<Quadruple<String, String, String, Consumer<String>>> testCases =
188+
List.of(
189+
/*
190+
The workbasketId of the source Workbasket is parametrized. Putting the tested Tasks
191+
into the same Workbasket would result in changes to the test data. This would require
192+
changing tests that already use the tested Tasks. That's why workbasketId is
193+
parametrized.
194+
*/
195+
Quadruple.of(
196+
"Using WorkbasketId; Task doesn't have an Attachment"
197+
+ " or any secondary Object References",
198+
"TKI:000000000000000000000000000000000005",
199+
"WBI:100000000000000000000000000000000001",
200+
wrap(
201+
(String taskId) ->
202+
taskService.transferWithOwner(
203+
taskId, "WBI:100000000000000000000000000000000007", "user-1-2"))),
204+
Quadruple.of(
205+
"Using WorkbasketId; Task has Attachment and secondary Object Reference",
206+
"TKI:000000000000000000000000000000000001",
207+
"WBI:100000000000000000000000000000000006",
208+
wrap(
209+
(String taskId) ->
210+
taskService.transferWithOwner(
211+
taskId, "WBI:100000000000000000000000000000000007", "user-1-2"))),
212+
Quadruple.of(
213+
"Using WorkbasketKey and Domain",
214+
"TKI:000000000000000000000000000000000006",
215+
"WBI:100000000000000000000000000000000001",
216+
wrap(
217+
(String taskId) ->
218+
taskService.transferWithOwner(
219+
taskId, "USER-1-2", "DOMAIN_A", "user-1-2"))));
220+
ThrowingConsumer<Quadruple<String, String, String, Consumer<String>>> test =
221+
q -> {
222+
String taskId = q.getSecond();
223+
Consumer<String> transferMethod = q.getFourth();
224+
225+
TaskHistoryQueryMapper taskHistoryQueryMapper = getHistoryQueryMapper();
226+
227+
List<TaskHistoryEvent> events =
228+
taskHistoryQueryMapper.queryHistoryEvents(
229+
(TaskHistoryQueryImpl) historyService.createTaskHistoryQuery().taskIdIn(taskId));
230+
231+
assertThat(events).isEmpty();
232+
233+
transferMethod.accept(taskId);
234+
235+
events =
236+
taskHistoryQueryMapper.queryHistoryEvents(
237+
(TaskHistoryQueryImpl) historyService.createTaskHistoryQuery().taskIdIn(taskId));
238+
239+
assertThat(events).hasSize(1);
240+
String sourceWorkbasketId = q.getThird();
241+
assertTransferHistoryEvent(
242+
events.get(0).getId(),
243+
sourceWorkbasketId,
244+
"WBI:100000000000000000000000000000000007",
245+
"admin");
246+
};
247+
return DynamicTest.stream(testCases.iterator(), Quadruple::getFirst, test);
248+
}
249+
250+
@WithAccessId(user = "admin")
251+
@TestFactory
252+
Stream<DynamicTest> should_CreateTransferredHistoryEvents_When_TaskBulkTransferWithOwner() {
253+
List<Triplet<String, Map<String, String>, Consumer<List<String>>>> testCases =
254+
List.of(
255+
/*
256+
The workbasketId of the source Workbasket is parametrized. Putting the tested Tasks
257+
into the same Workbasket would result in changes to the test data. This would require
258+
changing tests that already use the tested Tasks. That's why workbasketId is
259+
parametrized.
260+
*/
261+
Triplet.of(
262+
"Using WorkbasketId",
263+
Map.ofEntries(
264+
Map.entry(
265+
"TKI:000000000000000000000000000000000010",
266+
"WBI:100000000000000000000000000000000001"),
267+
Map.entry(
268+
"TKI:000000000000000000000000000000000011",
269+
"WBI:100000000000000000000000000000000001"),
270+
Map.entry(
271+
"TKI:000000000000000000000000000000000012",
272+
"WBI:100000000000000000000000000000000001")),
273+
wrap(
274+
(List<String> taskIds) ->
275+
taskService.transferTasksWithOwner(
276+
"WBI:100000000000000000000000000000000007", taskIds, "user-1-2"))),
277+
Triplet.of(
278+
"Using WorkbasketKey and Domain",
279+
Map.ofEntries(
280+
Map.entry(
281+
"TKI:000000000000000000000000000000000013",
282+
"WBI:100000000000000000000000000000000001"),
283+
Map.entry(
284+
"TKI:000000000000000000000000000000000014",
285+
"WBI:100000000000000000000000000000000001"),
286+
Map.entry(
287+
"TKI:000000000000000000000000000000000015",
288+
"WBI:100000000000000000000000000000000001")),
289+
wrap(
290+
(List<String> taskIds) ->
291+
taskService.transferTasksWithOwner(
292+
"USER-1-2", "DOMAIN_A", taskIds, "user-1-2"))));
293+
ThrowingConsumer<Triplet<String, Map<String, String>, Consumer<List<String>>>> test =
294+
t -> {
295+
Map<String, String> taskIds = t.getMiddle();
296+
Consumer<List<String>> transferMethod = t.getRight();
297+
298+
TaskHistoryQueryMapper taskHistoryQueryMapper = getHistoryQueryMapper();
299+
300+
List<TaskHistoryEvent> events =
301+
taskHistoryQueryMapper.queryHistoryEvents(
302+
(TaskHistoryQueryImpl)
303+
historyService
304+
.createTaskHistoryQuery()
305+
.taskIdIn(taskIds.keySet().toArray(new String[0])));
306+
307+
assertThat(events).isEmpty();
308+
309+
transferMethod.accept(new ArrayList<>(taskIds.keySet()));
310+
311+
events =
312+
taskHistoryQueryMapper.queryHistoryEvents(
313+
(TaskHistoryQueryImpl)
314+
historyService
315+
.createTaskHistoryQuery()
316+
.taskIdIn(taskIds.keySet().toArray(new String[0])));
317+
318+
assertThat(events)
319+
.extracting(TaskHistoryEvent::getTaskId)
320+
.containsExactlyInAnyOrderElementsOf(taskIds.keySet());
321+
322+
for (TaskHistoryEvent event : events) {
323+
assertTransferHistoryEvent(
324+
event.getId(),
325+
taskIds.get(event.getTaskId()),
326+
"WBI:100000000000000000000000000000000007",
327+
"admin");
328+
}
329+
};
330+
331+
return DynamicTest.stream(testCases.iterator(), Triplet::getLeft, test);
332+
}
333+
184334
private void assertTransferHistoryEvent(
185335
String eventId, String expectedOldValue, String expectedNewValue, String expectedUser)
186336
throws Exception {

lib/taskana-core-test/src/test/java/acceptance/taskcomment/delete/DeleteTaskCommentAccTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import pro.taskana.common.api.TaskanaEngine;
1616
import pro.taskana.common.api.exceptions.InvalidArgumentException;
1717
import pro.taskana.common.api.exceptions.SystemException;
18-
import pro.taskana.common.api.exceptions.TaskanaException;
1918
import pro.taskana.task.api.TaskService;
2019
import pro.taskana.task.api.exceptions.NotAuthorizedOnTaskCommentException;
2120
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
@@ -172,7 +171,7 @@ void should_FailToDeleteTaskComment_When_TaskCommentIdIsNull() throws Exception
172171
void should_FailToDeleteTaskComment_When_CommentIdDoesNotExist() throws Exception {
173172

174173
ThrowingCallable call = () -> taskService.deleteTaskComment("non existing task comment id");
175-
TaskCommentNotFoundException e = catchThrowableOfType(call, TaskCommentNotFoundException.class);
174+
TaskCommentNotFoundException e = catchThrowableOfType(TaskCommentNotFoundException.class, call);
176175
assertThat(e.getTaskCommentId()).isEqualTo("non existing task comment id");
177176
}
178177
}

0 commit comments

Comments
 (0)