Review findings

This commit is contained in:
Joerg Heffner 2020-06-22 09:35:46 +02:00 committed by gitgoodjhe
parent d8ad7a7fb9
commit 4bba93c5a9
32 changed files with 178 additions and 133 deletions

View File

@ -68,11 +68,12 @@ public class SimpleHistoryServiceImpl implements TaskanaHistory {
taskanaHistoryEngine.checkRoleMembership(TaskanaRole.ADMIN); taskanaHistoryEngine.checkRoleMembership(TaskanaRole.ADMIN);
if (taskIds == null) {
throw new InvalidArgumentException("List of taskIds must not be null.");
}
try { try {
taskanaHistoryEngine.openConnection(); taskanaHistoryEngine.openConnection();
if (taskIds == null) {
throw new InvalidArgumentException("List of taskIds must not be null.");
}
historyEventMapper.deleteMultipleByTaskIds(taskIds); historyEventMapper.deleteMultipleByTaskIds(taskIds);

View File

@ -24,20 +24,19 @@ import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl; import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.simplehistory.impl.TaskanaHistoryEngineImpl; import pro.taskana.simplehistory.impl.TaskanaHistoryEngineImpl;
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper; import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
import pro.taskana.task.api.models.ObjectReference;
/** Set up database for tests. */ /** Set up database for tests. */
public abstract class AbstractAccTest { public abstract class AbstractAccTest {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAccTest.class); private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAccTest.class);
private static final String ID_PREFIX_HISTORY_EVENT = "HEI"; private static final String ID_PREFIX_HISTORY_EVENT = "HEI";
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
protected static TaskanaHistoryEngineImpl taskanaHistoryEngine;
protected static TaskanaEngine taskanaEngine;
private static final String USER_HOME_DIRECTORY = System.getProperty("user.home"); private static final String USER_HOME_DIRECTORY = System.getProperty("user.home");
private static final int POOL_TIME_TO_WAIT = 50; private static final int POOL_TIME_TO_WAIT = 50;
private static final DataSource DATA_SOURCE; private static final DataSource DATA_SOURCE;
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
protected static TaskanaHistoryEngineImpl taskanaHistoryEngine;
protected static TaskanaEngine taskanaEngine;
private static SimpleHistoryServiceImpl historyService; private static SimpleHistoryServiceImpl historyService;
private static String schemaName; private static String schemaName;
@ -73,7 +72,9 @@ public abstract class AbstractAccTest {
String previousWorkbasketId, String previousWorkbasketId,
String userid, String userid,
String details) { String details) {
HistoryEventImpl historyEvent = new HistoryEventImpl(userid, details); HistoryEventImpl historyEvent =
new HistoryEventImpl(
IdGenerator.generateWithPrefix(ID_PREFIX_HISTORY_EVENT), userid, details);
historyEvent.setWorkbasketKey(workbasketKey); historyEvent.setWorkbasketKey(workbasketKey);
historyEvent.setTaskId(taskId); historyEvent.setTaskId(taskId);
historyEvent.setEventType(type); historyEvent.setEventType(type);
@ -132,12 +133,28 @@ public abstract class AbstractAccTest {
protected static SimpleHistoryServiceImpl getHistoryService() { protected static SimpleHistoryServiceImpl getHistoryService() {
return historyService; return historyService;
* @param id the id of the event }
String id,
HistoryEventImpl historyEvent = protected HistoryQueryMapper getHistoryQueryMapper()
new HistoryEventImpl( throws NoSuchFieldException, IllegalAccessException {
IdGenerator.generateWithPrefix(ID_PREFIX_HISTORY_EVENT), userid, details);
historyEvent.setId(id); Field sessionManagerField = TaskanaHistoryEngineImpl.class.getDeclaredField("sessionManager");
sessionManagerField.setAccessible(true);
SqlSessionManager sqlSessionManager =
(SqlSessionManager) sessionManagerField.get(taskanaHistoryEngine);
return sqlSessionManager.getMapper(HistoryQueryMapper.class);
}
protected ObjectReference createObjectRef(
String company, String system, String systemInstance, String type, String value) {
ObjectReference objectRef = new ObjectReference();
objectRef.setCompany(company);
objectRef.setSystem(system);
objectRef.setSystemInstance(systemInstance);
objectRef.setType(type);
objectRef.setValue(value);
return objectRef;
} }
@BeforeAll @BeforeAll
@ -257,15 +274,4 @@ public abstract class AbstractAccTest {
return schemaName; return schemaName;
} }
protected HistoryQueryMapper getHistoryQueryMapper()
throws NoSuchFieldException, IllegalAccessException {
Field sessionManagerField = TaskanaHistoryEngineImpl.class.getDeclaredField("sessionManager");
sessionManagerField.setAccessible(true);
SqlSessionManager sqlSessionManager =
(SqlSessionManager) sessionManagerField.get(taskanaHistoryEngine);
return sqlSessionManager.getMapper(HistoryQueryMapper.class);
}
} }

View File

@ -43,7 +43,7 @@ class CreateHistoryEventOnCancelClaimAccTest extends AbstractAccTest {
historyQueryMapper.queryHistoryEvent( historyQueryMapper.queryHistoryEvent(
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId)); (HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId));
assertThat(listEvents).hasSize(0); assertThat(listEvents).isEmpty();
assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.CLAIMED); assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.CLAIMED);
Task task = taskService.forceCancelClaim(taskId); Task task = taskService.forceCancelClaim(taskId);

View File

@ -43,7 +43,7 @@ class CreateHistoryEventOnClaimAccTest extends AbstractAccTest {
historyQueryMapper.queryHistoryEvent( historyQueryMapper.queryHistoryEvent(
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId)); (HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId));
assertThat(listEvents).hasSize(0); assertThat(listEvents).isEmpty();
assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.READY); assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.READY);
Task task = taskService.claim(taskId); Task task = taskService.claim(taskId);

View File

@ -16,6 +16,7 @@ import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper; import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.models.Task;
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class CreateHistoryEventOnCompletionAccTest extends AbstractAccTest { class CreateHistoryEventOnCompletionAccTest extends AbstractAccTest {
@ -42,10 +43,11 @@ class CreateHistoryEventOnCompletionAccTest extends AbstractAccTest {
historyQueryMapper.queryHistoryEvent( historyQueryMapper.queryHistoryEvent(
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId)); (HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId));
assertThat(listEvents).hasSize(0); assertThat(listEvents).isEmpty();
assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.CLAIMED); assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.CLAIMED);
taskService.forceCompleteTask(taskId); Task task = taskService.forceCompleteTask(taskId);
assertThat(task.getState()).isEqualTo(TaskState.COMPLETED);
listEvents = listEvents =
historyQueryMapper.queryHistoryEvent( historyQueryMapper.queryHistoryEvent(

View File

@ -31,17 +31,6 @@ class CreateHistoryEventOnTaskCreationAccTest extends AbstractAccTest {
historyService = getHistoryService(); historyService = getHistoryService();
} }
protected ObjectReference createObjectRef(
String company, String system, String systemInstance, String type, String value) {
ObjectReference objectRef = new ObjectReference();
objectRef.setCompany(company);
objectRef.setSystem(system);
objectRef.setSystemInstance(systemInstance);
objectRef.setType(type);
objectRef.setValue(value);
return objectRef;
}
@Test @Test
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
void should_CreateCreatedHistoryEvent_When_TaskIsCreated() throws Exception { void should_CreateCreatedHistoryEvent_When_TaskIsCreated() throws Exception {

View File

@ -41,7 +41,7 @@ class CreateHistoryEventOnTransferAccTest extends AbstractAccTest {
historyQueryMapper.queryHistoryEvent( historyQueryMapper.queryHistoryEvent(
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId)); (HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId));
assertThat(listEvents).hasSize(0); assertThat(listEvents).isEmpty();
taskService.transfer(taskId, "WBI:100000000000000000000000000000000006"); taskService.transfer(taskId, "WBI:100000000000000000000000000000000006");

View File

@ -61,7 +61,7 @@ class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
listEvents = listEvents =
historyQueryMapper.queryHistoryEvent( historyQueryMapper.queryHistoryEvent(
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskid)); (HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskid));
assertThat(listEvents).hasSize(0); assertThat(listEvents).isEmpty();
} }
@Test @Test
@ -99,7 +99,7 @@ class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
listEvents = listEvents =
historyQueryMapper.queryHistoryEvent( historyQueryMapper.queryHistoryEvent(
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId_1, taskId_2)); (HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId_1, taskId_2));
assertThat(listEvents).hasSize(0); assertThat(listEvents).isEmpty();
} }
@Test @Test

View File

@ -7,11 +7,10 @@ import org.junit.jupiter.api.Test;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent; import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
class GetHistoryEventAccTest extends AbstractAccTest { class GetHistoryEventAccTest extends AbstractAccTest {
@Test @Test
void should_ReturnSpecificTaskHistoryEventWithDetails_For_HistoryEventId() void should_ReturnSpecificTaskHistoryEventWithDetails_For_HistoryEventId() throws Exception {
String detailsJson = String detailsJson =
"{\"changes\":[{" "{\"changes\":[{"

View File

@ -125,7 +125,7 @@ class QueryHistoryAccTest extends AbstractAccTest {
TimeInterval timeInterval = new TimeInterval(Instant.now().minusSeconds(10), Instant.now()); TimeInterval timeInterval = new TimeInterval(Instant.now().minusSeconds(10), Instant.now());
returnValues = getHistoryService().createHistoryQuery().createdWithin(timeInterval).list(); returnValues = getHistoryService().createHistoryQuery().createdWithin(timeInterval).list();
assertThat(returnValues).hasSize(0); assertThat(returnValues).isEmpty();
returnValues = getHistoryService().createHistoryQuery().userIdIn("admin").list(); returnValues = getHistoryService().createHistoryQuery().userIdIn("admin").list();
assertThat(returnValues).hasSize(7); assertThat(returnValues).hasSize(7);

View File

@ -35,13 +35,7 @@ class TaskanaEngineConfigurationTest extends AbstractAccTest {
getHistoryService() getHistoryService()
.create( .create(
AbstractAccTest.createHistoryEvent( AbstractAccTest.createHistoryEvent(
"HEI:000000000000000000000000000000000000", "wbKey1", "taskId1", "type1", "Some comment", "wbKey2", "someUserId"));
"wbKey1",
"taskId1",
"type1",
"Some comment",
"wbKey2",
"someUserId"));
count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count(); count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
assertThat(count).isOne(); assertThat(count).isOne();
} }

View File

@ -56,13 +56,7 @@ class SimpleHistoryServiceImplTest {
void testCreateEvent() throws Exception { void testCreateEvent() throws Exception {
HistoryEventImpl expectedWb = HistoryEventImpl expectedWb =
AbstractAccTest.createHistoryEvent( AbstractAccTest.createHistoryEvent(
"HEI:000000000000000000000000000000000000", "wbKey1", "taskId1", "type1", "wbKey2", "someUserId", "someDetails");
"wbKey1",
"taskId1",
"type1",
"wbKey2",
"someUserId",
"someDetails");
cutSpy.create(expectedWb); cutSpy.create(expectedWb);
verify(taskanaHistoryEngineMock, times(1)).openConnection(); verify(taskanaHistoryEngineMock, times(1)).openConnection();
@ -76,13 +70,7 @@ class SimpleHistoryServiceImplTest {
List<HistoryEventImpl> returnList = new ArrayList<>(); List<HistoryEventImpl> returnList = new ArrayList<>();
returnList.add( returnList.add(
AbstractAccTest.createHistoryEvent( AbstractAccTest.createHistoryEvent(
"HEI:000000000000000000000000000000000000", "wbKey1", "taskId1", "type1", "wbKey2", "someUserId", "someDetails"));
"wbKey1",
"taskId1",
"type1",
"wbKey2",
"someUserId",
"someDetails"));
when(historyQueryMapperMock.queryHistoryEvent(any())).thenReturn(returnList); when(historyQueryMapperMock.queryHistoryEvent(any())).thenReturn(returnList);
final List<HistoryEventImpl> result = cutSpy.createHistoryQuery().taskIdIn("taskId1").list(); final List<HistoryEventImpl> result = cutSpy.createHistoryQuery().taskIdIn("taskId1").list();

View File

@ -48,7 +48,7 @@ public class TaskanaEngineConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class);
// must match the VERSION value in table // must match the VERSION value in table
private static final String TASKANA_SCHEMA_VERSION = "3.0.0"; private static final String TASKANA_SCHEMA_VERSION = "4.0.0";
private static final String TASKANA_PROPERTIES = "/taskana.properties"; private static final String TASKANA_PROPERTIES = "/taskana.properties";
private static final String TASKANA_PROPERTY_SEPARATOR = "|"; private static final String TASKANA_PROPERTY_SEPARATOR = "|";
private static final String TASKANA_JOB_BATCH_SIZE = "taskana.jobs.batchSize"; private static final String TASKANA_JOB_BATCH_SIZE = "taskana.jobs.batchSize";

View File

@ -71,7 +71,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
private static final String DEFAULT = "default"; private static final String DEFAULT = "default";
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class);
private static final SessionStack SESSION_STACK = new SessionStack(); private static final SessionStack SESSION_STACK = new SessionStack();
private final HistoryEventProducer historyEventProducer; private HistoryEventManager historyEventManager;
private final TaskRoutingManager taskRoutingManager; private final TaskRoutingManager taskRoutingManager;
private final InternalTaskanaEngineImpl internalTaskanaEngineImpl; private final InternalTaskanaEngineImpl internalTaskanaEngineImpl;
private final WorkingDaysToDaysConverter workingDaysToDaysConverter; private final WorkingDaysToDaysConverter workingDaysToDaysConverter;
@ -80,7 +80,6 @@ public class TaskanaEngineImpl implements TaskanaEngine {
protected SqlSessionManager sessionManager; protected SqlSessionManager sessionManager;
protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE; protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE;
protected Connection connection = null; protected Connection connection = null;
private HistoryEventManager historyEventManager;
protected TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) { protected TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) {
this.taskanaEngineConfiguration = taskanaEngineConfiguration; this.taskanaEngineConfiguration = taskanaEngineConfiguration;

View File

@ -26,7 +26,7 @@ public interface TaskanaHistory {
void create(TaskanaHistoryEvent event); void create(TaskanaHistoryEvent event);
/** /**
* Delete history events by taskIds. * Delete history events by taskIds. Invalid/non-existing taskIds will be ignored
* *
* @param taskIds the task ids for which all history events must be deleted * @param taskIds the task ids for which all history events must be deleted
* @throws InvalidArgumentException If the list of taskIds is null * @throws InvalidArgumentException If the list of taskIds is null

View File

@ -1395,7 +1395,7 @@ public class TaskServiceImpl implements TaskService {
if (taskanaEngine.getEngine().isHistoryEnabled() if (taskanaEngine.getEngine().isHistoryEnabled()
&& taskanaEngine.getEngine().getConfiguration().isDeleteHistoryOnTaskDeletionEnabled()) { && taskanaEngine.getEngine().getConfiguration().isDeleteHistoryOnTaskDeletionEnabled()) {
historyEventManager.deleteEvents(Arrays.asList(taskId)); historyEventManager.deleteEvents(Collections.singletonList(taskId));
} }
LOGGER.debug("Task {} deleted.", taskId); LOGGER.debug("Task {} deleted.", taskId);

View File

@ -7,7 +7,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
-- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION -- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('3.0.0', CURRENT_TIMESTAMP); INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('4.0.0', CURRENT_TIMESTAMP);
CREATE TABLE CLASSIFICATION( CREATE TABLE CLASSIFICATION(
ID VARCHAR(40) NOT NULL, ID VARCHAR(40) NOT NULL,

View File

@ -0,0 +1,8 @@
-- this script updates the tables TASKANA_SCHEMA_VERSION and HISTORY_EVENTS.
SET SCHEMA %schemaName%;
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('4.0.0', CURRENT_TIMESTAMP);
ALTER TABLE HISTORY_EVENTS ALTER COLUMN ID SET DATA TYPE VARCHAR(40);
REORG TABLE HISTORY_EVENTS;

View File

@ -14,7 +14,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
-- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION -- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('3.0.0', CURRENT_TIMESTAMP); INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('4.0.0', CURRENT_TIMESTAMP);
CREATE TABLE CLASSIFICATION( CREATE TABLE CLASSIFICATION(
ID VARCHAR(40) NOT NULL, ID VARCHAR(40) NOT NULL,

View File

@ -0,0 +1,7 @@
-- this script updates the tables TASKANA_SCHEMA_VERSION and HISTORY_EVENTS.
SET SCHEMA %schemaName%;
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('4.0.0', CURRENT_TIMESTAMP);
ALTER TABLE HISTORY_EVENTS ALTER COLUMN ID VARCHAR(40);

View File

@ -9,7 +9,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
-- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION -- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('3.0.0', CURRENT_TIMESTAMP); INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('4.0.0', CURRENT_TIMESTAMP);
CREATE TABLE CLASSIFICATION( CREATE TABLE CLASSIFICATION(
ID VARCHAR(40) NOT NULL, ID VARCHAR(40) NOT NULL,

View File

@ -1,6 +1,6 @@
-- this script updates the tables TASKANA_SCHEMA_VERSION and HISTORY_EVENTS. -- this script updates the tables TASKANA_SCHEMA_VERSION and HISTORY_EVENTS.
SET SCHEMA %schemaName%; SET search_path %schemaName%;
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('3.0.0', CURRENT_TIMESTAMP); INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('3.0.0', CURRENT_TIMESTAMP);

View File

@ -0,0 +1,7 @@
-- this script updates the tables TASKANA_SCHEMA_VERSION and HISTORY_EVENTS.
SET search_path %schemaName%;
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('4.0.0', CURRENT_TIMESTAMP);
ALTER TABLE HISTORY_EVENTS ALTER COLUMN ID VARCHAR(40);

View File

@ -24,9 +24,7 @@ import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.AttachmentMapper; import pro.taskana.task.internal.AttachmentMapper;
/** /** Acceptance test for all "delete task" scenarios. */
* Acceptance test for all "delete task" scenarios.
*/
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class DeleteTaskAccTest extends AbstractAccTest { class DeleteTaskAccTest extends AbstractAccTest {
@ -48,9 +46,7 @@ class DeleteTaskAccTest extends AbstractAccTest {
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@Test @Test
void should_deleteAttachments_When_MultipleTasksAreDeleted() void should_deleteAttachments_When_MultipleTasksAreDeleted() throws Exception {
throws NotAuthorizedException, InvalidArgumentException, NoSuchFieldException,
IllegalAccessException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
@ -58,24 +54,41 @@ class DeleteTaskAccTest extends AbstractAccTest {
AttachmentMapper attachmentMapper = AttachmentMapper attachmentMapper =
engineProxy.getEngine().getSqlSession().getMapper(AttachmentMapper.class); engineProxy.getEngine().getSqlSession().getMapper(AttachmentMapper.class);
assertThat(attachmentMapper.findAttachmentSummariesByTaskIds(Arrays.asList( try {
"TKI:000000000000000000000000000000000067", "TKI:000000000000000000000000000000000068")))
.hasSize(4);
taskService.deleteTasks(Arrays.asList("TKI:000000000000000000000000000000000067", engineProxy.openConnection();
"TKI:000000000000000000000000000000000068"));
assertThat(attachmentMapper.findAttachmentSummariesByTaskIds(Arrays.asList( assertThat(
"TKI:000000000000000000000000000000000067", "TKI:000000000000000000000000000000000068"))) attachmentMapper.findAttachmentSummariesByTaskIds(
.hasSize(0); Arrays.asList(
"TKI:000000000000000000000000000000000067",
"TKI:000000000000000000000000000000000068")))
.hasSize(4);
} finally {
engineProxy.returnConnection();
}
taskService.deleteTasks(
Arrays.asList(
"TKI:000000000000000000000000000000000067",
"TKI:000000000000000000000000000000000068"));
try {
assertThat(
attachmentMapper.findAttachmentSummariesByTaskIds(
Arrays.asList(
"TKI:000000000000000000000000000000000067",
"TKI:000000000000000000000000000000000068")))
.isEmpty();
} finally {
engineProxy.returnConnection();
}
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@Test @Test
void should_deleteAttachments_When_SingleTaskIsDeleted() void should_deleteAttachments_When_SingleTaskIsDeleted() throws Exception {
throws NotAuthorizedException, NoSuchFieldException,
IllegalAccessException, InvalidStateException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
@ -83,15 +96,28 @@ class DeleteTaskAccTest extends AbstractAccTest {
AttachmentMapper attachmentMapper = AttachmentMapper attachmentMapper =
engineProxy.getSqlSession().getMapper(AttachmentMapper.class); engineProxy.getSqlSession().getMapper(AttachmentMapper.class);
assertThat(attachmentMapper.findAttachmentsByTaskId("TKI:000000000000000000000000000000000069")) try {
.hasSize(1);
taskService.deleteTask( engineProxy.openConnection();
"TKI:000000000000000000000000000000000069");
assertThat(attachmentMapper.findAttachmentsByTaskId("TKI:000000000000000000000000000000000069")) assertThat(
.hasSize(0); attachmentMapper.findAttachmentsByTaskId("TKI:000000000000000000000000000000000069"))
.hasSize(1);
} finally {
engineProxy.returnConnection();
}
taskService.deleteTask("TKI:000000000000000000000000000000000069");
try {
assertThat(
attachmentMapper.findAttachmentsByTaskId("TKI:000000000000000000000000000000000069"))
.isEmpty();
} finally {
engineProxy.returnConnection();
}
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")

View File

@ -281,7 +281,7 @@ class QueryTasksAccTest extends AbstractAccTest {
new Triplet<>("11", new String[] {"%"}, 3), new Triplet<>("11", new String[] {"%"}, 3),
new Triplet<>("12", new String[] {"%"}, 3), new Triplet<>("12", new String[] {"%"}, 3),
new Triplet<>("13", new String[] {"%"}, 3), new Triplet<>("13", new String[] {"%"}, 3),
new Triplet<>("14", new String[] {"%"}, 84), new Triplet<>("14", new String[] {"%"}, 87),
new Triplet<>("15", new String[] {"%"}, 3), new Triplet<>("15", new String[] {"%"}, 3),
new Triplet<>("16", new String[] {"%"}, 3)); new Triplet<>("16", new String[] {"%"}, 3));
@ -392,9 +392,9 @@ class QueryTasksAccTest extends AbstractAccTest {
void testQueryAllPaged() { void testQueryAllPaged() {
TaskQuery taskQuery = taskService.createTaskQuery(); TaskQuery taskQuery = taskService.createTaskQuery();
long numberOfTasks = taskQuery.count(); long numberOfTasks = taskQuery.count();
assertThat(numberOfTasks).isEqualTo(84); assertThat(numberOfTasks).isEqualTo(87);
List<TaskSummary> tasks = taskQuery.orderByDue(DESCENDING).list(); List<TaskSummary> tasks = taskQuery.orderByDue(DESCENDING).list();
assertThat(tasks).hasSize(84); assertThat(tasks).hasSize(87);
List<TaskSummary> tasksp = taskQuery.orderByDue(DESCENDING).listPage(4, 5); List<TaskSummary> tasksp = taskQuery.orderByDue(DESCENDING).listPage(4, 5);
assertThat(tasksp).hasSize(5); assertThat(tasksp).hasSize(5);
tasksp = taskQuery.orderByDue(DESCENDING).listPage(5, 5); tasksp = taskQuery.orderByDue(DESCENDING).listPage(5, 5);

View File

@ -39,7 +39,7 @@ class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
.createTaskQuery() .createTaskQuery()
.workbasketKeyDomainIn(workbasketIdentifiers.toArray(new KeyDomain[0])) .workbasketKeyDomainIn(workbasketIdentifiers.toArray(new KeyDomain[0]))
.list(); .list();
assertThat(results).hasSize(55); assertThat(results).hasSize(30);
String[] ids = String[] ids =
results.stream() results.stream()
@ -48,7 +48,7 @@ class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
.toArray(new String[0]); .toArray(new String[0]);
List<TaskSummary> result2 = taskService.createTaskQuery().workbasketIdIn(ids).list(); List<TaskSummary> result2 = taskService.createTaskQuery().workbasketIdIn(ids).list();
assertThat(result2).hasSize(59); assertThat(result2).hasSize(30);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")

View File

@ -173,11 +173,11 @@ class SetOwnerAccTest extends AbstractAccTest {
new Condition<>( new Condition<>(
c -> c.getClass() == NotAuthorizedException.class, "NotAuthorizedException"); c -> c.getClass() == NotAuthorizedException.class, "NotAuthorizedException");
assertThat(results.getErrorMap()) assertThat(results.getErrorMap())
.hasSize(62) .hasSize(85)
.extractingFromEntries(Entry::getValue) .extractingFromEntries(Entry::getValue)
.hasOnlyElementsOfTypes(InvalidStateException.class, NotAuthorizedException.class) .hasOnlyElementsOfTypes(InvalidStateException.class, NotAuthorizedException.class)
.areExactly(39, invalidStateException) .areExactly(28, invalidStateException)
.areExactly(54, notAuthorizedException); .areExactly(57, notAuthorizedException);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")

View File

@ -47,9 +47,9 @@ INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000037', 'ETI:0000000
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000038', 'ETI:000000000000000000000000000000000038', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000007' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000038' , 'DOC_0000000000000000038' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , 'al' , '11' , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000038', 'ETI:000000000000000000000000000000000038', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000007' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000038' , 'DOC_0000000000000000038' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , 'al' , '11' , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000039', 'ETI:000000000000000000000000000000000039', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000007' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000039' , 'DOC_0000000000000000039' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000039', 'ETI:000000000000000000000000000000000039', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000007' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000039' , 'DOC_0000000000000000039' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000040', 'ETI:000000000000000000000000000000000040', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000007' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000040' , 'DOC_0000000000000000040' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000040', 'ETI:000000000000000000000000000000000040', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000007' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000040' , 'DOC_0000000000000000040' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000067', 'ETI:000000000000000000000000000000000067', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'T2000' , 'CLI:100000000000000000000000000000000016', 'WBI:100000000000000000000000000000000006' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000067' , 'DOC_0000000000000000067' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000067', 'ETI:000000000000000000000000000000000067', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'T2000' , 'CLI:100000000000000000000000000000000016', 'WBI:100000000000000000000000000000000006' , 'USER-1-1' , 'DOMAIN_A', 'PI_0000000000067' , 'DOC_0000000000000000067' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000068', 'ETI:000000000000000000000000000000000068', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'T2000' , 'CLI:100000000000000000000000000000000016', 'WBI:100000000000000000000000000000000006' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000068' , 'DOC_0000000000000000068' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000068', 'ETI:000000000000000000000000000000000068', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'T2000' , 'CLI:100000000000000000000000000000000016', 'WBI:100000000000000000000000000000000006' , 'USER-1-1' , 'DOMAIN_A', 'PI_0000000000068' , 'DOC_0000000000000000068' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000069', 'ETI:000000000000000000000000000000000069', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'T2000' , 'CLI:100000000000000000000000000000000016', 'WBI:100000000000000000000000000000000006' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000068' , 'DOC_0000000000000000068' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000069', 'ETI:000000000000000000000000000000000069', '2018-01-29 15:55:24', '2018-01-30 15:55:24', '2018-01-30 16:55:24', '2018-01-30 16:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'T2000' , 'CLI:100000000000000000000000000000000016', 'WBI:100000000000000000000000000000000006' , 'USER-1-1' , 'DOMAIN_A', 'PI_0000000000068' , 'DOC_0000000000000000068' , 'user-1-2' , '00' , 'PASystem' , '00' , 'SDNR' , '00011122' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
-- Tasks for QueryTasksWithSortingTest -- Tasks for QueryTasksWithSortingTest
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000041', 'ETI:000000000000000000000000000000000041', '2018-01-29 15:55:00', '2018-01-30 15:55:00', null , '2018-01-30 15:55:00', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Task99' , 'creator_user_id' , 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note' , 1 , 'CLAIMED' , 'AUTOMATIC' , 'T6310' , 'CLI:000000000000000000000000000000000011', 'WBI:100000000000000000000000000000000015' , 'USER-B-2' , 'DOMAIN_B', 'BPI21' , 'PBPI21' , 'user-b-1' , 'MyCompany1', 'MySystem1', 'MyInstance1' , 'MyType1', 'MyValue1' , true , false , null , 'NONE' , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000041', 'ETI:000000000000000000000000000000000041', '2018-01-29 15:55:00', '2018-01-30 15:55:00', null , '2018-01-30 15:55:00', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Task99' , 'creator_user_id' , 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note' , 1 , 'CLAIMED' , 'AUTOMATIC' , 'T6310' , 'CLI:000000000000000000000000000000000011', 'WBI:100000000000000000000000000000000015' , 'USER-B-2' , 'DOMAIN_B', 'BPI21' , 'PBPI21' , 'user-b-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 );

View File

@ -8,6 +8,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedModel.PageMetadata; import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
@ -138,7 +139,7 @@ public class TaskController extends AbstractPagingController {
@DeleteMapping(path = Mapping.URL_TASKS) @DeleteMapping(path = Mapping.URL_TASKS)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<CollectionModel<TaskSummaryRepresentationModel>> deleteTasks( public ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> deleteTasks(
@RequestParam MultiValueMap<String, String> params) @RequestParam MultiValueMap<String, String> params)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
@ -161,10 +162,9 @@ public class TaskController extends AbstractPagingController {
.filter(summary -> !result.getFailedIds().contains(summary.getId())) .filter(summary -> !result.getFailedIds().contains(summary.getId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
ResponseEntity<CollectionModel<TaskSummaryRepresentationModel>> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
ResponseEntity.ok( ResponseEntity.ok(
taskSummaryRepresentationModelAssembler.toCollectionModel( taskSummaryRepresentationModelAssembler.toPageModel(successfullyDeletedTaskSummaries));
successfullyDeletedTaskSummaries));
LOGGER.debug("Exit from deleteTasks(), returning {}", response); LOGGER.debug("Exit from deleteTasks(), returning {}", response);
@ -481,23 +481,16 @@ public class TaskController extends AbstractPagingController {
params.remove(EXTERNAL_ID); params.remove(EXTERNAL_ID);
} }
for (int i = 1; i < 17; i++) {
if (params.containsKey(CUSTOM + i)) {
taskQuery.customAttributeIn(String.valueOf(i), params.get(CUSTOM + i).get(0));
params.remove(CUSTOM + i);
}
}
for (int i = 1; i <= 16; i++) { for (int i = 1; i <= 16; i++) {
if (params.containsKey(CUSTOM + i)) { if (params.containsKey(CUSTOM + i)) {
String[] customValues = extractCommaSeparatedFields(params.get(CUSTOM + i)); String[] customValues = extractCommaSeparatedFields(params.get(CUSTOM + i));
taskQuery.customAttributeIn(String.valueOf(i), customValues); taskQuery.customAttributeIn(String.valueOf(i), customValues);
if (LOGGER.isDebugEnabled()) { params.remove(CUSTOM + i);
params.remove(CUSTOM + i);
LOGGER.debug("Exit from applyFilterParams(), returning {}", taskQuery);
}
} }
} }
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", taskQuery);
}
return taskQuery; return taskQuery;
} }

View File

@ -588,6 +588,24 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
} }
@Test
void deleteTasksDocTest() throws Exception {
this.mockMvc
.perform(
RestDocumentationRequestBuilders.get(
restHelper.toUrl(Mapping.URL_TASKS)
+ "?task-id=TKI:000000000000000000000000000000000036,"
+ "TKI:000000000000000000000000000000000037,"
+ "TKI:000000000000000000000000000000000038"
+ "&custom14=abc")
.accept("application/hal+json")
.header("Authorization", ADMIN_CREDENTIALS))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(
MockMvcRestDocumentation.document(
"DeleteTasksDocTest", responseFields(allTasksFieldDescriptors)));
}
@Test @Test
void claimTaskDocTest() throws Exception { void claimTaskDocTest() throws Exception {

View File

@ -18,7 +18,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
@ -241,10 +240,9 @@ class TaskControllerIntTest {
assertThat(response.getBody().getContent()).hasSize(4); assertThat(response.getBody().getContent()).hasSize(4);
} }
@Test @Test
void should_DeleteAllTasks_For_ProvidedParams() { void should_DeleteAllTasks_For_ProvidedParams() {
ResponseEntity<CollectionModel<TaskSummaryRepresentationModel>> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?task-id=TKI:000000000000000000000000000000000036," + "?task-id=TKI:000000000000000000000000000000000036,"
@ -253,12 +251,10 @@ class TaskControllerIntTest {
+ "&custom14=abc", + "&custom14=abc",
HttpMethod.DELETE, HttpMethod.DELETE,
new HttpEntity<String>(restHelper.getHeadersAdmin()), new HttpEntity<String>(restHelper.getHeadersAdmin()),
new ParameterizedTypeReference<CollectionModel<TaskSummaryRepresentationModel>>() { new ParameterizedTypeReference<TaskanaPagedModel<TaskSummaryRepresentationModel>>() {});
});
; ;
assertThat(response.getBody()).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF)) assertThat((response.getBody()).getLink(IanaLinkRelations.SELF)).isNotNull();
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(3); assertThat(response.getBody().getContent()).hasSize(3);
} }

View File

@ -304,6 +304,18 @@ include::{snippets}/DeleteTaskDocTest/http-request.adoc[]
include::{snippets}/DeleteTaskDocTest/http-response.adoc[] include::{snippets}/DeleteTaskDocTest/http-response.adoc[]
=== Delete multiple tasks
A `DELETE` request is used to delete multiple tasks.
==== Example request
include::{snippets}/DeleteTasksDocTest/http-request.adoc[]
==== Example response
include::{snippets}/DeleteTasksDocTest/http-response.adoc[]
=== Transfer a task to another workbasket === Transfer a task to another workbasket
A `POST` request is used to transfer a task from one to another workbasket. A `POST` request is used to transfer a task from one to another workbasket.