Review findings
This commit is contained in:
parent
d8ad7a7fb9
commit
4bba93c5a9
|
@ -68,12 +68,13 @@ public class SimpleHistoryServiceImpl implements TaskanaHistory {
|
|||
|
||||
taskanaHistoryEngine.checkRoleMembership(TaskanaRole.ADMIN);
|
||||
|
||||
try {
|
||||
taskanaHistoryEngine.openConnection();
|
||||
if (taskIds == null) {
|
||||
throw new InvalidArgumentException("List of taskIds must not be null.");
|
||||
}
|
||||
|
||||
try {
|
||||
taskanaHistoryEngine.openConnection();
|
||||
|
||||
historyEventMapper.deleteMultipleByTaskIds(taskIds);
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
|
|
@ -24,20 +24,19 @@ import pro.taskana.simplehistory.impl.HistoryEventImpl;
|
|||
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
|
||||
import pro.taskana.simplehistory.impl.TaskanaHistoryEngineImpl;
|
||||
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
|
||||
/** Set up database for tests. */
|
||||
public abstract class AbstractAccTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAccTest.class);
|
||||
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 int POOL_TIME_TO_WAIT = 50;
|
||||
private static final DataSource DATA_SOURCE;
|
||||
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaHistoryEngineImpl taskanaHistoryEngine;
|
||||
protected static TaskanaEngine taskanaEngine;
|
||||
private static SimpleHistoryServiceImpl historyService;
|
||||
private static String schemaName;
|
||||
|
||||
|
@ -73,7 +72,9 @@ public abstract class AbstractAccTest {
|
|||
String previousWorkbasketId,
|
||||
String userid,
|
||||
String details) {
|
||||
HistoryEventImpl historyEvent = new HistoryEventImpl(userid, details);
|
||||
HistoryEventImpl historyEvent =
|
||||
new HistoryEventImpl(
|
||||
IdGenerator.generateWithPrefix(ID_PREFIX_HISTORY_EVENT), userid, details);
|
||||
historyEvent.setWorkbasketKey(workbasketKey);
|
||||
historyEvent.setTaskId(taskId);
|
||||
historyEvent.setEventType(type);
|
||||
|
@ -132,12 +133,28 @@ public abstract class AbstractAccTest {
|
|||
|
||||
protected static SimpleHistoryServiceImpl getHistoryService() {
|
||||
return historyService;
|
||||
* @param id the id of the event
|
||||
String id,
|
||||
HistoryEventImpl historyEvent =
|
||||
new HistoryEventImpl(
|
||||
IdGenerator.generateWithPrefix(ID_PREFIX_HISTORY_EVENT), userid, details);
|
||||
historyEvent.setId(id);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -257,15 +274,4 @@ public abstract class AbstractAccTest {
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class CreateHistoryEventOnCancelClaimAccTest extends AbstractAccTest {
|
|||
historyQueryMapper.queryHistoryEvent(
|
||||
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId));
|
||||
|
||||
assertThat(listEvents).hasSize(0);
|
||||
assertThat(listEvents).isEmpty();
|
||||
|
||||
assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.CLAIMED);
|
||||
Task task = taskService.forceCancelClaim(taskId);
|
||||
|
|
|
@ -43,7 +43,7 @@ class CreateHistoryEventOnClaimAccTest extends AbstractAccTest {
|
|||
historyQueryMapper.queryHistoryEvent(
|
||||
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId));
|
||||
|
||||
assertThat(listEvents).hasSize(0);
|
||||
assertThat(listEvents).isEmpty();
|
||||
|
||||
assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.READY);
|
||||
Task task = taskService.claim(taskId);
|
||||
|
|
|
@ -16,6 +16,7 @@ import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
|
|||
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.TaskState;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
@ExtendWith(JaasExtension.class)
|
||||
class CreateHistoryEventOnCompletionAccTest extends AbstractAccTest {
|
||||
|
@ -42,10 +43,11 @@ class CreateHistoryEventOnCompletionAccTest extends AbstractAccTest {
|
|||
historyQueryMapper.queryHistoryEvent(
|
||||
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId));
|
||||
|
||||
assertThat(listEvents).hasSize(0);
|
||||
assertThat(listEvents).isEmpty();
|
||||
|
||||
assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.CLAIMED);
|
||||
taskService.forceCompleteTask(taskId);
|
||||
Task task = taskService.forceCompleteTask(taskId);
|
||||
assertThat(task.getState()).isEqualTo(TaskState.COMPLETED);
|
||||
|
||||
listEvents =
|
||||
historyQueryMapper.queryHistoryEvent(
|
||||
|
|
|
@ -31,17 +31,6 @@ class CreateHistoryEventOnTaskCreationAccTest extends AbstractAccTest {
|
|||
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
|
||||
@WithAccessId(user = "admin")
|
||||
void should_CreateCreatedHistoryEvent_When_TaskIsCreated() throws Exception {
|
||||
|
|
|
@ -41,7 +41,7 @@ class CreateHistoryEventOnTransferAccTest extends AbstractAccTest {
|
|||
historyQueryMapper.queryHistoryEvent(
|
||||
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId));
|
||||
|
||||
assertThat(listEvents).hasSize(0);
|
||||
assertThat(listEvents).isEmpty();
|
||||
|
||||
taskService.transfer(taskId, "WBI:100000000000000000000000000000000006");
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
|
|||
listEvents =
|
||||
historyQueryMapper.queryHistoryEvent(
|
||||
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskid));
|
||||
assertThat(listEvents).hasSize(0);
|
||||
assertThat(listEvents).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -99,7 +99,7 @@ class DeleteHistoryEventsOnTaskDeletionAccTest extends AbstractAccTest {
|
|||
listEvents =
|
||||
historyQueryMapper.queryHistoryEvent(
|
||||
(HistoryQueryImpl) historyService.createHistoryQuery().taskIdIn(taskId_1, taskId_2));
|
||||
assertThat(listEvents).hasSize(0);
|
||||
assertThat(listEvents).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -7,11 +7,10 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
|
||||
|
||||
|
||||
class GetHistoryEventAccTest extends AbstractAccTest {
|
||||
|
||||
@Test
|
||||
void should_ReturnSpecificTaskHistoryEventWithDetails_For_HistoryEventId()
|
||||
void should_ReturnSpecificTaskHistoryEventWithDetails_For_HistoryEventId() throws Exception {
|
||||
|
||||
String detailsJson =
|
||||
"{\"changes\":[{"
|
||||
|
|
|
@ -125,7 +125,7 @@ class QueryHistoryAccTest extends AbstractAccTest {
|
|||
|
||||
TimeInterval timeInterval = new TimeInterval(Instant.now().minusSeconds(10), Instant.now());
|
||||
returnValues = getHistoryService().createHistoryQuery().createdWithin(timeInterval).list();
|
||||
assertThat(returnValues).hasSize(0);
|
||||
assertThat(returnValues).isEmpty();
|
||||
|
||||
returnValues = getHistoryService().createHistoryQuery().userIdIn("admin").list();
|
||||
assertThat(returnValues).hasSize(7);
|
||||
|
|
|
@ -35,13 +35,7 @@ class TaskanaEngineConfigurationTest extends AbstractAccTest {
|
|||
getHistoryService()
|
||||
.create(
|
||||
AbstractAccTest.createHistoryEvent(
|
||||
"HEI:000000000000000000000000000000000000",
|
||||
"wbKey1",
|
||||
"taskId1",
|
||||
"type1",
|
||||
"Some comment",
|
||||
"wbKey2",
|
||||
"someUserId"));
|
||||
"wbKey1", "taskId1", "type1", "Some comment", "wbKey2", "someUserId"));
|
||||
count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
|
||||
assertThat(count).isOne();
|
||||
}
|
||||
|
|
|
@ -56,13 +56,7 @@ class SimpleHistoryServiceImplTest {
|
|||
void testCreateEvent() throws Exception {
|
||||
HistoryEventImpl expectedWb =
|
||||
AbstractAccTest.createHistoryEvent(
|
||||
"HEI:000000000000000000000000000000000000",
|
||||
"wbKey1",
|
||||
"taskId1",
|
||||
"type1",
|
||||
"wbKey2",
|
||||
"someUserId",
|
||||
"someDetails");
|
||||
"wbKey1", "taskId1", "type1", "wbKey2", "someUserId", "someDetails");
|
||||
|
||||
cutSpy.create(expectedWb);
|
||||
verify(taskanaHistoryEngineMock, times(1)).openConnection();
|
||||
|
@ -76,13 +70,7 @@ class SimpleHistoryServiceImplTest {
|
|||
List<HistoryEventImpl> returnList = new ArrayList<>();
|
||||
returnList.add(
|
||||
AbstractAccTest.createHistoryEvent(
|
||||
"HEI:000000000000000000000000000000000000",
|
||||
"wbKey1",
|
||||
"taskId1",
|
||||
"type1",
|
||||
"wbKey2",
|
||||
"someUserId",
|
||||
"someDetails"));
|
||||
"wbKey1", "taskId1", "type1", "wbKey2", "someUserId", "someDetails"));
|
||||
when(historyQueryMapperMock.queryHistoryEvent(any())).thenReturn(returnList);
|
||||
|
||||
final List<HistoryEventImpl> result = cutSpy.createHistoryQuery().taskIdIn("taskId1").list();
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TaskanaEngineConfiguration {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class);
|
||||
|
||||
// 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_PROPERTY_SEPARATOR = "|";
|
||||
private static final String TASKANA_JOB_BATCH_SIZE = "taskana.jobs.batchSize";
|
||||
|
|
|
@ -71,7 +71,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
private static final String DEFAULT = "default";
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class);
|
||||
private static final SessionStack SESSION_STACK = new SessionStack();
|
||||
private final HistoryEventProducer historyEventProducer;
|
||||
private HistoryEventManager historyEventManager;
|
||||
private final TaskRoutingManager taskRoutingManager;
|
||||
private final InternalTaskanaEngineImpl internalTaskanaEngineImpl;
|
||||
private final WorkingDaysToDaysConverter workingDaysToDaysConverter;
|
||||
|
@ -80,7 +80,6 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
protected SqlSessionManager sessionManager;
|
||||
protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE;
|
||||
protected Connection connection = null;
|
||||
private HistoryEventManager historyEventManager;
|
||||
|
||||
protected TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface TaskanaHistory {
|
|||
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
|
||||
* @throws InvalidArgumentException If the list of taskIds is null
|
||||
|
|
|
@ -1395,7 +1395,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
if (taskanaEngine.getEngine().isHistoryEnabled()
|
||||
&& taskanaEngine.getEngine().getConfiguration().isDeleteHistoryOnTaskDeletionEnabled()) {
|
||||
historyEventManager.deleteEvents(Arrays.asList(taskId));
|
||||
historyEventManager.deleteEvents(Collections.singletonList(taskId));
|
||||
}
|
||||
|
||||
LOGGER.debug("Task {} deleted.", taskId);
|
||||
|
|
|
@ -7,7 +7,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
|
|||
PRIMARY KEY (ID)
|
||||
);
|
||||
-- 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(
|
||||
ID VARCHAR(40) NOT NULL,
|
||||
|
|
|
@ -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;
|
|
@ -14,7 +14,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
|
|||
PRIMARY KEY (ID)
|
||||
);
|
||||
-- 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(
|
||||
ID VARCHAR(40) NOT NULL,
|
||||
|
|
|
@ -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);
|
|
@ -9,7 +9,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
|
|||
PRIMARY KEY (ID)
|
||||
);
|
||||
-- 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(
|
||||
ID VARCHAR(40) NOT NULL,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- 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);
|
||||
|
||||
|
|
|
@ -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);
|
|
@ -24,9 +24,7 @@ import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.internal.AttachmentMapper;
|
||||
|
||||
/**
|
||||
* Acceptance test for all "delete task" scenarios.
|
||||
*/
|
||||
/** Acceptance test for all "delete task" scenarios. */
|
||||
@ExtendWith(JaasExtension.class)
|
||||
class DeleteTaskAccTest extends AbstractAccTest {
|
||||
|
||||
|
@ -48,9 +46,7 @@ class DeleteTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_deleteAttachments_When_MultipleTasksAreDeleted()
|
||||
throws NotAuthorizedException, InvalidArgumentException, NoSuchFieldException,
|
||||
IllegalAccessException {
|
||||
void should_deleteAttachments_When_MultipleTasksAreDeleted() throws Exception {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
|
@ -58,24 +54,41 @@ class DeleteTaskAccTest extends AbstractAccTest {
|
|||
AttachmentMapper attachmentMapper =
|
||||
engineProxy.getEngine().getSqlSession().getMapper(AttachmentMapper.class);
|
||||
|
||||
assertThat(attachmentMapper.findAttachmentSummariesByTaskIds(Arrays.asList(
|
||||
"TKI:000000000000000000000000000000000067", "TKI:000000000000000000000000000000000068")))
|
||||
try {
|
||||
|
||||
engineProxy.openConnection();
|
||||
|
||||
assertThat(
|
||||
attachmentMapper.findAttachmentSummariesByTaskIds(
|
||||
Arrays.asList(
|
||||
"TKI:000000000000000000000000000000000067",
|
||||
"TKI:000000000000000000000000000000000068")))
|
||||
.hasSize(4);
|
||||
} finally {
|
||||
engineProxy.returnConnection();
|
||||
}
|
||||
|
||||
taskService.deleteTasks(Arrays.asList("TKI:000000000000000000000000000000000067",
|
||||
taskService.deleteTasks(
|
||||
Arrays.asList(
|
||||
"TKI:000000000000000000000000000000000067",
|
||||
"TKI:000000000000000000000000000000000068"));
|
||||
try {
|
||||
|
||||
assertThat(attachmentMapper.findAttachmentSummariesByTaskIds(Arrays.asList(
|
||||
"TKI:000000000000000000000000000000000067", "TKI:000000000000000000000000000000000068")))
|
||||
.hasSize(0);
|
||||
assertThat(
|
||||
attachmentMapper.findAttachmentSummariesByTaskIds(
|
||||
Arrays.asList(
|
||||
"TKI:000000000000000000000000000000000067",
|
||||
"TKI:000000000000000000000000000000000068")))
|
||||
.isEmpty();
|
||||
|
||||
} finally {
|
||||
engineProxy.returnConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_deleteAttachments_When_SingleTaskIsDeleted()
|
||||
throws NotAuthorizedException, NoSuchFieldException,
|
||||
IllegalAccessException, InvalidStateException, TaskNotFoundException {
|
||||
void should_deleteAttachments_When_SingleTaskIsDeleted() throws Exception {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
|
@ -83,15 +96,28 @@ class DeleteTaskAccTest extends AbstractAccTest {
|
|||
AttachmentMapper attachmentMapper =
|
||||
engineProxy.getSqlSession().getMapper(AttachmentMapper.class);
|
||||
|
||||
assertThat(attachmentMapper.findAttachmentsByTaskId("TKI:000000000000000000000000000000000069"))
|
||||
try {
|
||||
|
||||
engineProxy.openConnection();
|
||||
|
||||
assertThat(
|
||||
attachmentMapper.findAttachmentsByTaskId("TKI:000000000000000000000000000000000069"))
|
||||
.hasSize(1);
|
||||
|
||||
taskService.deleteTask(
|
||||
"TKI:000000000000000000000000000000000069");
|
||||
} finally {
|
||||
engineProxy.returnConnection();
|
||||
}
|
||||
|
||||
assertThat(attachmentMapper.findAttachmentsByTaskId("TKI:000000000000000000000000000000000069"))
|
||||
.hasSize(0);
|
||||
taskService.deleteTask("TKI:000000000000000000000000000000000069");
|
||||
|
||||
try {
|
||||
|
||||
assertThat(
|
||||
attachmentMapper.findAttachmentsByTaskId("TKI:000000000000000000000000000000000069"))
|
||||
.isEmpty();
|
||||
} finally {
|
||||
engineProxy.returnConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(user = "businessadmin")
|
||||
|
|
|
@ -281,7 +281,7 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
new Triplet<>("11", new String[] {"%"}, 3),
|
||||
new Triplet<>("12", new String[] {"%"}, 3),
|
||||
new Triplet<>("13", new String[] {"%"}, 3),
|
||||
new Triplet<>("14", new String[] {"%"}, 84),
|
||||
new Triplet<>("14", new String[] {"%"}, 87),
|
||||
new Triplet<>("15", new String[] {"%"}, 3),
|
||||
new Triplet<>("16", new String[] {"%"}, 3));
|
||||
|
||||
|
@ -392,9 +392,9 @@ class QueryTasksAccTest extends AbstractAccTest {
|
|||
void testQueryAllPaged() {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
long numberOfTasks = taskQuery.count();
|
||||
assertThat(numberOfTasks).isEqualTo(84);
|
||||
assertThat(numberOfTasks).isEqualTo(87);
|
||||
List<TaskSummary> tasks = taskQuery.orderByDue(DESCENDING).list();
|
||||
assertThat(tasks).hasSize(84);
|
||||
assertThat(tasks).hasSize(87);
|
||||
List<TaskSummary> tasksp = taskQuery.orderByDue(DESCENDING).listPage(4, 5);
|
||||
assertThat(tasksp).hasSize(5);
|
||||
tasksp = taskQuery.orderByDue(DESCENDING).listPage(5, 5);
|
||||
|
|
|
@ -39,7 +39,7 @@ class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
|
|||
.createTaskQuery()
|
||||
.workbasketKeyDomainIn(workbasketIdentifiers.toArray(new KeyDomain[0]))
|
||||
.list();
|
||||
assertThat(results).hasSize(55);
|
||||
assertThat(results).hasSize(30);
|
||||
|
||||
String[] ids =
|
||||
results.stream()
|
||||
|
@ -48,7 +48,7 @@ class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
|
|||
.toArray(new String[0]);
|
||||
|
||||
List<TaskSummary> result2 = taskService.createTaskQuery().workbasketIdIn(ids).list();
|
||||
assertThat(result2).hasSize(59);
|
||||
assertThat(result2).hasSize(30);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
|
|
|
@ -173,11 +173,11 @@ class SetOwnerAccTest extends AbstractAccTest {
|
|||
new Condition<>(
|
||||
c -> c.getClass() == NotAuthorizedException.class, "NotAuthorizedException");
|
||||
assertThat(results.getErrorMap())
|
||||
.hasSize(62)
|
||||
.hasSize(85)
|
||||
.extractingFromEntries(Entry::getValue)
|
||||
.hasOnlyElementsOfTypes(InvalidStateException.class, NotAuthorizedException.class)
|
||||
.areExactly(39, invalidStateException)
|
||||
.areExactly(54, notAuthorizedException);
|
||||
.areExactly(28, invalidStateException)
|
||||
.areExactly(57, notAuthorizedException);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "admin")
|
||||
|
|
|
@ -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: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: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: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: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: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-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-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
|
||||
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 );
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.Stream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
|
@ -138,7 +139,7 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@DeleteMapping(path = Mapping.URL_TASKS)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<CollectionModel<TaskSummaryRepresentationModel>> deleteTasks(
|
||||
public ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> deleteTasks(
|
||||
@RequestParam MultiValueMap<String, String> params)
|
||||
throws InvalidArgumentException, NotAuthorizedException {
|
||||
|
||||
|
@ -161,10 +162,9 @@ public class TaskController extends AbstractPagingController {
|
|||
.filter(summary -> !result.getFailedIds().contains(summary.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ResponseEntity<CollectionModel<TaskSummaryRepresentationModel>> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
ResponseEntity.ok(
|
||||
taskSummaryRepresentationModelAssembler.toCollectionModel(
|
||||
successfullyDeletedTaskSummaries));
|
||||
taskSummaryRepresentationModelAssembler.toPageModel(successfullyDeletedTaskSummaries));
|
||||
|
||||
LOGGER.debug("Exit from deleteTasks(), returning {}", response);
|
||||
|
||||
|
@ -481,23 +481,16 @@ public class TaskController extends AbstractPagingController {
|
|||
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++) {
|
||||
if (params.containsKey(CUSTOM + i)) {
|
||||
String[] customValues = extractCommaSeparatedFields(params.get(CUSTOM + i));
|
||||
taskQuery.customAttributeIn(String.valueOf(i), customValues);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
params.remove(CUSTOM + i);
|
||||
}
|
||||
}
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from applyFilterParams(), returning {}", taskQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return taskQuery;
|
||||
}
|
||||
|
|
|
@ -588,6 +588,24 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
.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
|
||||
void claimTaskDocTest() throws Exception {
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.CollectionModel;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
@ -241,10 +240,9 @@ class TaskControllerIntTest {
|
|||
assertThat(response.getBody().getContent()).hasSize(4);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void should_DeleteAllTasks_For_ProvidedParams() {
|
||||
ResponseEntity<CollectionModel<TaskSummaryRepresentationModel>> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?task-id=TKI:000000000000000000000000000000000036,"
|
||||
|
@ -253,12 +251,10 @@ class TaskControllerIntTest {
|
|||
+ "&custom14=abc",
|
||||
HttpMethod.DELETE,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
new ParameterizedTypeReference<CollectionModel<TaskSummaryRepresentationModel>>() {
|
||||
});
|
||||
new ParameterizedTypeReference<TaskanaPagedModel<TaskSummaryRepresentationModel>>() {});
|
||||
;
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(3);
|
||||
}
|
||||
|
||||
|
|
|
@ -304,6 +304,18 @@ include::{snippets}/DeleteTaskDocTest/http-request.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
|
||||
|
||||
A `POST` request is used to transfer a task from one to another workbasket.
|
||||
|
|
Loading…
Reference in New Issue