TSK-525: Replace force flags by separate methods

This commit is contained in:
Konstantin Kläger 2018-06-05 08:11:10 +02:00 committed by Holger Hagen
parent fd564b3053
commit 000a728f4e
8 changed files with 4240 additions and 4256 deletions

View File

@ -78,7 +78,7 @@ public class TaskanaRestTest {
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, ClassificationNotFoundException,
NotAuthorizedException {
logger.info(id);
taskanaEjb.getTaskService().completeTask(id, true);
taskanaEjb.getTaskService().forceCompleteTask(id);
}
}

View File

@ -42,12 +42,10 @@ public interface TaskService {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
/**
* Claim an existing task for the current user. Enable forced claim.
* Claim an existing task for the current user even if it is already claimed by someone else.
*
* @param taskId
* the id of the task to be claimed
* @param forceClaim
* if true, claim is performed even if the task is already claimed by someone else
* @return claimed Task
* @throws TaskNotFoundException
* if the task with taskId was not found
@ -58,11 +56,11 @@ public interface TaskService {
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task claim(String taskId, boolean forceClaim)
Task forceClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
/**
* Unclaim a existing Task which was claimed and owned by you before.
* Cancel the claim of an existing task if it was claimed by the current user before.
*
* @param taskId
* id of the task which should be unclaimed.
@ -80,14 +78,10 @@ public interface TaskService {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
/**
* Unclaim a existing Task which was claimed and owned by you before. Also there can be enabled a force flag for
* admins.
* Cancel the claim of an existing task even if it was claimed by another user.
*
* @param taskId
* id of the task which should be unclaimed.
* @param forceCancel
* force the cancellation of claim. If true, the task is unclaimed even if it was claimed by another
* user.
* @return updated unclaimed task
* @throws TaskNotFoundException
* if the task can´t be found or does not exist
@ -98,7 +92,7 @@ public interface TaskService {
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task cancelClaim(String taskId, boolean forceCancel)
Task forceCancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
/**
@ -120,12 +114,10 @@ public interface TaskService {
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException;
/**
* Complete a claimed Task and update State and Timestamps.
* Complete a Task and update State and Timestamps in every case if the Task exists.
*
* @param taskId
* - Id of the Task which should be completed.
* @param isForced
* - Flag which can complete a Task in every case if Task does exist.
* @return Task - updated task after completion.
* @throws InvalidStateException
* when Task wasn´t claimed before.
@ -136,7 +128,7 @@ public interface TaskService {
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task completeTask(String taskId, boolean isForced)
Task forceCompleteTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException;
/**
@ -353,12 +345,10 @@ public interface TaskService {
void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/**
* Deletes the task with the given Id.
* Deletes the task with the given Id even if it is not completed.
*
* @param taskId
* The Id of the task to delete.
* @param forceDelete
* force the deletion. If true, a task is deleted even if it is not in state completed.
* @throws TaskNotFoundException
* If the given Id does not refer to an existing task.
* @throws InvalidStateException
@ -366,7 +356,7 @@ public interface TaskService {
* @throws NotAuthorizedException
* if the current user is not member of role ADMIN
*/
void deleteTask(String taskId, boolean forceDelete)
void forceDeleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/**

View File

@ -93,26 +93,26 @@ public class TaskServiceImpl implements TaskService {
}
@Override
public Task claim(String taskId, boolean forceClaim)
public Task forceClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
return claim(taskId, true);
}
private Task claim(String taskId, boolean forceClaim)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug("entry to claim(id = {}, forceClaim = {}, userId = {})", taskId, forceClaim, userId);
LOGGER.debug("entry to claim(id = {}, userId = {}, forceClaim = {})", taskId, userId, forceClaim);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
TaskState state = task.getState();
if (state == TaskState.COMPLETED) {
LOGGER.warn("Method claim() found that task {} is already completed. Throwing InvalidStateException",
taskId);
throw new InvalidStateException("Task is already completed");
throw new InvalidStateException("Task with id " + taskId + " is already completed.");
}
if (state == TaskState.CLAIMED && !forceClaim && !task.getOwner().equals(userId)) {
LOGGER.warn(
"Method claim() found that task {} is claimed by {} and forceClaim is false. Throwing InvalidOwnerException",
taskId, task.getOwner());
throw new InvalidOwnerException(
"You´re not the owner of this task and it is already claimed by other user " + task.getOwner());
"Task with id " + taskId + " is already claimed by " + task.getOwner() + ".");
}
Instant now = Instant.now();
task.setOwner(userId);
@ -121,7 +121,7 @@ public class TaskServiceImpl implements TaskService {
task.setRead(true);
task.setState(TaskState.CLAIMED);
taskMapper.update(task);
LOGGER.debug("Method claim() claimed task '{}' for user '{}'.", taskId, userId);
LOGGER.debug("Task '{}' claimed by user '{}'.", taskId, userId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from claim()");
@ -136,10 +136,15 @@ public class TaskServiceImpl implements TaskService {
}
@Override
public Task cancelClaim(String taskId, boolean forceUnclaim)
public Task forceCancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
return this.cancelClaim(taskId, true);
}
private Task cancelClaim(String taskId, boolean forceUnclaim)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug("entry to cancelClaim(taskId = {}) with userId = {}, forceFlag = {}", taskId, userId,
LOGGER.debug("entry to cancelClaim(taskId = {}), userId = {}, forceUnclaim = {}", taskId, userId,
forceUnclaim);
TaskImpl task = null;
try {
@ -147,16 +152,11 @@ public class TaskServiceImpl implements TaskService {
task = (TaskImpl) getTask(taskId);
TaskState state = task.getState();
if (state == TaskState.COMPLETED) {
LOGGER.warn(
"Method cancelClaim() found that task {} is already completed. Throwing InvalidStateException",
taskId);
throw new InvalidStateException("Task is already completed");
throw new InvalidStateException("Task with id " + taskId + " is already completed.");
}
if (state == TaskState.CLAIMED && !forceUnclaim && !userId.equals(task.getOwner())) {
LOGGER.warn(
"Method cancelClaim() found that task {} is claimed by {} and forceClaim is false. Throwing InvalidOwnerException",
taskId, task.getOwner());
throw new InvalidOwnerException("Task is already claimed by an other user = " + task.getOwner());
throw new InvalidOwnerException(
"Task with id " + taskId + " is already claimed by " + task.getOwner() + ".");
}
Instant now = Instant.now();
task.setOwner(null);
@ -165,11 +165,10 @@ public class TaskServiceImpl implements TaskService {
task.setRead(true);
task.setState(TaskState.READY);
taskMapper.update(task);
LOGGER.debug("Method cancelClaim() unclaimed task '{}' for user '{}'.", taskId, userId);
LOGGER.debug("Task '{}' unclaimed by user '{}'.", taskId, userId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from cancelClaim(taskId = {}) with userId = {}, forceFlag = {}", taskId, userId,
forceUnclaim);
LOGGER.debug("exit from cancelClaim()");
}
return task;
}
@ -181,9 +180,15 @@ public class TaskServiceImpl implements TaskService {
}
@Override
public Task completeTask(String taskId, boolean isForced)
public Task forceCompleteTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException {
LOGGER.debug("entry to completeTask(id = {}, isForced {})", taskId, isForced);
return completeTask(taskId, true);
}
private Task completeTask(String taskId, boolean isForced)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug("entry to completeTask(id = {}, userId = {}, isForced = {})", taskId, userId, isForced);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
@ -192,29 +197,24 @@ public class TaskServiceImpl implements TaskService {
// check pre-conditions for non-forced invocation
if (!isForced) {
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
LOGGER.warn("Method completeTask() does expect a task which need to be CLAIMED before. TaskId={}",
taskId);
throw new InvalidStateException(taskId);
throw new InvalidStateException("Task with id " + taskId + " has to be claimed before.");
} else if (!CurrentUserContext.getAccessIds().contains(task.getOwner())) {
LOGGER.warn(
"Method completeTask() does expect to be invoced by the task-owner or a administrator. TaskId={}, TaskOwner={}, CurrentUser={}",
taskId, task.getOwner(), CurrentUserContext.getUserid());
throw new InvalidOwnerException(
"TaskOwner is" + task.getOwner() + ", but current User is " + CurrentUserContext.getUserid());
"Owner of task " + taskId + " is " + task.getOwner() + ", but current User is " + userId);
}
} else {
// CLAIM-forced, if task was not already claimed before.
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
task = (TaskImpl) this.claim(taskId, true);
task = (TaskImpl) this.forceClaim(taskId);
}
}
Instant now = Instant.now();
task.setCompleted(now);
task.setModified(now);
task.setState(TaskState.COMPLETED);
task.setOwner(CurrentUserContext.getUserid());
task.setOwner(userId);
taskMapper.update(task);
LOGGER.debug("Method completeTask() completed Task '{}'.", taskId);
LOGGER.debug("Task '{}' completed by user '{}'.", taskId, userId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from completeTask()");
@ -963,27 +963,28 @@ public class TaskServiceImpl implements TaskService {
}
@Override
public void deleteTask(String taskId, boolean forceDelete)
public void forceDeleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
LOGGER.debug("entry to deleteTask(taskId = {} , forceDelete = {} )", taskId, forceDelete);
deleteTask(taskId, true);
}
private void deleteTask(String taskId, boolean forceDelete)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
LOGGER.debug("entry to deleteTask(taskId = {} , forceDelete = {})", taskId, forceDelete);
taskanaEngine.checkRoleMembership(TaskanaRole.ADMIN);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
// reset read flag and set transferred flag
if (!TaskState.COMPLETED.equals(task.getState()) && !forceDelete) {
LOGGER.warn(
"Method deleteTask() found that task {} is not completed and forceDelete is false. Throwing InvalidStateException",
task);
throw new InvalidStateException("Cannot delete Task " + taskId + " because it is not completed");
throw new InvalidStateException("Cannot delete Task " + taskId + " because it is not completed.");
}
taskMapper.delete(taskId);
LOGGER.debug("Method deleteTask() deleted Task {}", taskId);
LOGGER.debug("Task {} deleted.", taskId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteTask(). ");
LOGGER.debug("exit from deleteTask().");
}
}

View File

@ -83,7 +83,7 @@ public class DeleteTaskAccTest extends AbstractAccTest {
taskService.deleteTask(task.getId());
fail("Should not be possible to delete claimed task without force flag");
} catch (InvalidStateException ex) {
taskService.deleteTask(task.getId(), true);
taskService.forceDeleteTask(task.getId());
}
taskService.getTask("TKI:000000000000000000000000000000000027");

View File

@ -159,7 +159,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
taskService.cancelClaim(claimedTask.getId(), true);
taskService.forceCancelClaim(claimedTask.getId());
Task unclaimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
assertNotNull(unclaimedTask);
@ -205,7 +205,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000033");
taskService.completeTask(claimedTask.getId(), true);
taskService.forceCompleteTask(claimedTask.getId());
Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000033");
assertNotNull(completedTask);
@ -241,7 +241,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000035");
taskService.completeTask(claimedTask.getId(), true);
taskService.forceCompleteTask(claimedTask.getId());
Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000035");
assertNotNull(completedTask);

View File

@ -456,9 +456,9 @@ public class TaskServiceImplTest {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1", null);
doReturn(expectedTask).when(cutSpy).claim(expectedTask.getId(), false);
doReturn(expectedTask).when(cutSpy).claim(expectedTask.getId());
cutSpy.claim(expectedTask.getId());
verify(cutSpy, times(1)).claim(expectedTask.getId(), false);
verify(cutSpy, times(1)).claim(expectedTask.getId());
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock);
@ -474,7 +474,7 @@ public class TaskServiceImplTest {
PowerMockito.mockStatic(CurrentUserContext.class);
Mockito.when(CurrentUserContext.getUserid()).thenReturn(expectedOwner);
Task acturalTask = cutSpy.claim(expectedTask.getId(), true);
Task acturalTask = cutSpy.forceClaim(expectedTask.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(expectedTask.getId());
@ -498,7 +498,7 @@ public class TaskServiceImplTest {
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(any());
try {
cut.claim("1", true);
cut.forceClaim("1");
} catch (Exception e) {
verify(taskanaEngineMock, times(2)).openConnection();
verify(taskMapperMock, times(1)).findById(any());
@ -519,7 +519,7 @@ public class TaskServiceImplTest {
doReturn(task).when(cutSpy).getTask(task.getId());
try {
cutSpy.claim("1", true);
cutSpy.forceClaim("1");
} catch (Exception e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
@ -606,9 +606,9 @@ public class TaskServiceImplTest {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1", null);
doReturn(expectedTask).when(cutSpy).cancelClaim(expectedTask.getId(), false);
doReturn(expectedTask).when(cutSpy).cancelClaim(expectedTask.getId());
cutSpy.cancelClaim(expectedTask.getId());
verify(cutSpy, times(1)).cancelClaim(expectedTask.getId(), false);
verify(cutSpy, times(1)).cancelClaim(expectedTask.getId());
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock);
@ -628,7 +628,7 @@ public class TaskServiceImplTest {
PowerMockito.mockStatic(CurrentUserContext.class);
Mockito.when(CurrentUserContext.getUserid()).thenReturn(owner);
Task acturalTask = cutSpy.cancelClaim(expectedTask.getId(), true);
Task acturalTask = cutSpy.forceCancelClaim(expectedTask.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(expectedTask.getId());
@ -658,7 +658,7 @@ public class TaskServiceImplTest {
PowerMockito.mockStatic(CurrentUserContext.class);
Mockito.when(CurrentUserContext.getUserid()).thenReturn(owner);
Task acturalTask = cutSpy.cancelClaim(expectedTask.getId(), true);
Task acturalTask = cutSpy.forceCancelClaim(expectedTask.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(expectedTask.getId());
@ -681,7 +681,6 @@ public class TaskServiceImplTest {
ClassificationNotFoundException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final long sleepTime = 100L;
final boolean isForced = false;
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
Thread.sleep(sleepTime);
@ -690,7 +689,7 @@ public class TaskServiceImplTest {
task.setOwner(CurrentUserContext.getUserid());
doReturn(task).when(taskMapperMock).findById(task.getId());
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(task.getId());
doReturn(task).when(cutSpy).completeTask(task.getId(), isForced);
doReturn(task).when(cutSpy).completeTask(task.getId());
doReturn(classificationQueryImplMock).when(classificationServiceImplMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).idIn(any());
doReturn(new ArrayList<>()).when(classificationQueryImplMock).list();
@ -736,7 +735,6 @@ public class TaskServiceImplTest {
ClassificationNotFoundException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final long sleepTime = 100L;
final boolean isForced = false;
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
// created and modify should be able to be different.
@ -747,7 +745,7 @@ public class TaskServiceImplTest {
doReturn(task).when(cutSpy).getTask(task.getId());
doNothing().when(taskMapperMock).update(task);
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
Task actualTask = cutSpy.completeTask(task.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
@ -767,7 +765,6 @@ public class TaskServiceImplTest {
public void testCompleteTaskNotForcedNotClaimedBefore()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException,
NotAuthorizedException {
final boolean isForced = false;
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
@ -776,7 +773,7 @@ public class TaskServiceImplTest {
doReturn(task).when(cutSpy).getTask(task.getId());
try {
cutSpy.completeTask(task.getId(), isForced);
cutSpy.completeTask(task.getId());
} catch (InvalidStateException e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
@ -793,7 +790,6 @@ public class TaskServiceImplTest {
public void testCompleteTaskNotForcedInvalidOwnerException()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException,
NotAuthorizedException {
final boolean isForced = false;
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
@ -803,7 +799,7 @@ public class TaskServiceImplTest {
doReturn(task).when(cutSpy).getTask(task.getId());
try {
cutSpy.completeTask(task.getId(), isForced);
cutSpy.completeTask(task.getId());
} catch (InvalidOwnerException e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
@ -821,11 +817,10 @@ public class TaskServiceImplTest {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException,
NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final boolean isForced = false;
String taskId = "1";
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(taskId);
try {
cutSpy.completeTask(taskId, isForced);
cutSpy.completeTask(taskId);
} catch (InvalidOwnerException e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(taskId);
@ -842,7 +837,6 @@ public class TaskServiceImplTest {
public void testCompleteForcedAndAlreadyClaimed()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, InterruptedException,
ClassificationNotFoundException, NotAuthorizedException {
final boolean isForced = true;
final long sleepTime = 100L;
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
@ -854,7 +848,7 @@ public class TaskServiceImplTest {
doReturn(task).when(cutSpy).getTask(task.getId());
doNothing().when(taskMapperMock).update(task);
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
Task actualTask = cutSpy.forceCompleteTask(task.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
@ -875,7 +869,6 @@ public class TaskServiceImplTest {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, InterruptedException,
ClassificationNotFoundException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final boolean isForced = true;
final long sleepTime = 100L;
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
@ -887,14 +880,14 @@ public class TaskServiceImplTest {
Thread.sleep(sleepTime);
claimedTask.setState(TaskState.CLAIMED);
claimedTask.setClaimed(Instant.now());
doReturn(claimedTask).when(cutSpy).claim(task.getId(), isForced);
doReturn(claimedTask).when(cutSpy).forceClaim(task.getId());
doNothing().when(taskMapperMock).update(claimedTask);
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
Task actualTask = cutSpy.forceCompleteTask(task.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
verify(cutSpy, times(1)).claim(task.getId(), isForced);
verify(cutSpy, times(1)).forceClaim(task.getId());
verify(taskMapperMock, times(1)).update(claimedTask);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,

View File

@ -43,7 +43,7 @@ public class ExampleBootstrap {
taskService.claim(task.getId());
System.out.println(
"---------------------------> Task claimed: " + taskService.getTask(task.getId()).getOwner());
taskService.completeTask(task.getId(), true);
taskService.forceCompleteTask(task.getId());
System.out.println("---------------------------> Task completed");
}

View File

@ -151,7 +151,7 @@ public class TaskController extends AbstractPagingController {
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> completeTask(@PathVariable String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException {
taskService.completeTask(taskId, true);
taskService.forceCompleteTask(taskId);
Task updatedTask = taskService.getTask(taskId);
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
HttpStatus.OK);
@ -162,7 +162,7 @@ public class TaskController extends AbstractPagingController {
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> deleteTask(@PathVariable String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
taskService.deleteTask(taskId, true);
taskService.forceDeleteTask(taskId);
ResponseEntity<TaskResource> result = new ResponseEntity<>(HttpStatus.OK);
return result;
}