|
|
|
@ -1,11 +1,24 @@
|
|
|
|
|
package pro.taskana.impl;
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.core.IsEqual.equalTo;
|
|
|
|
|
import static org.hamcrest.core.IsNot.not;
|
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
|
|
import static org.junit.Assert.assertThat;
|
|
|
|
|
import static org.mockito.ArgumentMatchers.any;
|
|
|
|
|
import static org.mockito.ArgumentMatchers.eq;
|
|
|
|
|
import static org.mockito.Mockito.doNothing;
|
|
|
|
|
import static org.mockito.Mockito.doReturn;
|
|
|
|
|
import static org.mockito.Mockito.doThrow;
|
|
|
|
|
import static org.mockito.Mockito.times;
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
|
|
|
|
|
|
|
|
|
import java.sql.Date;
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.junit.Assert;
|
|
|
|
|
import org.junit.Before;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
@ -20,10 +33,13 @@ import pro.taskana.configuration.TaskanaEngineConfiguration;
|
|
|
|
|
import pro.taskana.exceptions.NotAuthorizedException;
|
|
|
|
|
import pro.taskana.exceptions.TaskNotFoundException;
|
|
|
|
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
|
|
|
|
import pro.taskana.model.DueWorkbasketCounter;
|
|
|
|
|
import pro.taskana.model.ObjectReference;
|
|
|
|
|
import pro.taskana.model.Task;
|
|
|
|
|
import pro.taskana.model.TaskState;
|
|
|
|
|
import pro.taskana.model.TaskStateCounter;
|
|
|
|
|
import pro.taskana.model.Workbasket;
|
|
|
|
|
import pro.taskana.model.WorkbasketAuthorization;
|
|
|
|
|
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
|
|
|
|
import pro.taskana.model.mappings.TaskMapper;
|
|
|
|
|
|
|
|
|
@ -35,29 +51,35 @@ import pro.taskana.model.mappings.TaskMapper;
|
|
|
|
|
public class TaskServiceImplTest {
|
|
|
|
|
|
|
|
|
|
private static final int SLEEP_TIME = 100;
|
|
|
|
|
@Mock
|
|
|
|
|
TaskanaEngineConfiguration taskanaEngineConfiguration;
|
|
|
|
|
|
|
|
|
|
@InjectMocks
|
|
|
|
|
TaskServiceImpl taskServiceImpl;
|
|
|
|
|
private TaskServiceImpl cut;
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
TaskanaEngineImpl taskanaEngine;
|
|
|
|
|
private TaskanaEngineConfiguration taskanaEngineConfigurationMock;
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
TaskanaEngineImpl taskanaEngineImpl;
|
|
|
|
|
private TaskanaEngineImpl taskanaEngineMock;
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
TaskMapper taskMapper;
|
|
|
|
|
private TaskanaEngineImpl taskanaEngineImpl;
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
ObjectReferenceMapper objectReferenceMapper;
|
|
|
|
|
private TaskMapper taskMapperMock;
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
WorkbasketService workbasketService;
|
|
|
|
|
private ObjectReferenceMapper objectReferenceMapperMock;
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
private WorkbasketService workbasketServiceMock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
|
public void setup() {
|
|
|
|
|
MockitoAnnotations.initMocks(this);
|
|
|
|
|
Mockito.when(taskanaEngine.getWorkbasketService()).thenReturn(workbasketService);
|
|
|
|
|
doReturn(workbasketServiceMock).when(taskanaEngineMock).getWorkbasketService();
|
|
|
|
|
try {
|
|
|
|
|
Mockito.doNothing().when(workbasketService).checkAuthorization(any(), any());
|
|
|
|
|
Mockito.doNothing().when(workbasketServiceMock).checkAuthorization(any(), any());
|
|
|
|
|
} catch (NotAuthorizedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -66,144 +88,482 @@ public class TaskServiceImplTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCreateSimpleTask() throws NotAuthorizedException {
|
|
|
|
|
Mockito.doNothing().when(taskMapper).insert(any());
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
task.setName("Unit Test Task");
|
|
|
|
|
task.setWorkbasketId("1");
|
|
|
|
|
task.setBusinessProcessId("BPI1");
|
|
|
|
|
task.setParentBusinessProcessId("PBPI1");
|
|
|
|
|
task = taskServiceImpl.create(task);
|
|
|
|
|
Assert.assertNull(task.getOwner());
|
|
|
|
|
Assert.assertNotNull(task.getCreated());
|
|
|
|
|
Assert.assertNotNull(task.getModified());
|
|
|
|
|
Assert.assertNull(task.getCompleted());
|
|
|
|
|
Assert.assertEquals(task.getWorkbasketId(), "1");
|
|
|
|
|
Assert.assertEquals(task.getBusinessProcessId(), "BPI1");
|
|
|
|
|
Assert.assertEquals(task.getParentBusinessProcessId(), "PBPI1");
|
|
|
|
|
Assert.assertEquals(task.getState(), TaskState.READY);
|
|
|
|
|
public void testCreateSimpleTask() throws NotAuthorizedException, WorkbasketNotFoundException {
|
|
|
|
|
Mockito.doNothing().when(taskMapperMock).insert(any());
|
|
|
|
|
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
|
|
|
|
|
|
|
|
|
Task actualTask = cut.create(expectedTask);
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
|
|
|
|
verify(taskMapperMock, times(1)).insert(expectedTask);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
assertNull(actualTask.getOwner());
|
|
|
|
|
assertNotNull(actualTask.getCreated());
|
|
|
|
|
assertNotNull(actualTask.getModified());
|
|
|
|
|
assertNull(actualTask.getCompleted());
|
|
|
|
|
assertThat(actualTask.getWorkbasketId(), equalTo(expectedTask.getWorkbasketId()));
|
|
|
|
|
assertThat(actualTask.getName(), equalTo(expectedTask.getName()));
|
|
|
|
|
assertThat(actualTask.getState(), equalTo(TaskState.READY));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testClaim() throws Exception {
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
public void testCreateSimpleTaskWithObjectReference() throws NotAuthorizedException, WorkbasketNotFoundException {
|
|
|
|
|
ObjectReference expectedObjectReference = new ObjectReference();
|
|
|
|
|
expectedObjectReference.setId("1");
|
|
|
|
|
expectedObjectReference.setType("DUMMY");
|
|
|
|
|
|
|
|
|
|
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
|
|
|
|
expectedTask.setPrimaryObjRef(new ObjectReference());
|
|
|
|
|
|
|
|
|
|
Mockito.doNothing().when(taskMapperMock).insert(any());
|
|
|
|
|
Mockito.doReturn(expectedObjectReference).when(objectReferenceMapperMock).findByObjectReference(any());
|
|
|
|
|
|
|
|
|
|
Task actualTask = cut.create(expectedTask);
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
|
|
|
|
verify(objectReferenceMapperMock, times(1)).findByObjectReference(any());
|
|
|
|
|
verify(taskMapperMock, times(1)).insert(expectedTask);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
|
|
|
|
|
assertNull(actualTask.getOwner());
|
|
|
|
|
assertNotNull(actualTask.getCreated());
|
|
|
|
|
assertNotNull(actualTask.getModified());
|
|
|
|
|
assertNull(actualTask.getCompleted());
|
|
|
|
|
assertThat(actualTask.getWorkbasketId(), equalTo(expectedTask.getWorkbasketId()));
|
|
|
|
|
assertThat(actualTask.getName(), equalTo(expectedTask.getName()));
|
|
|
|
|
assertThat(actualTask.getState(), equalTo(TaskState.READY));
|
|
|
|
|
assertThat(actualTask.getPrimaryObjRef(), equalTo(expectedObjectReference));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCreateSimpleTaskWithObjectReferenceIsNull() throws NotAuthorizedException, WorkbasketNotFoundException {
|
|
|
|
|
ObjectReference expectedObjectReference = new ObjectReference();
|
|
|
|
|
expectedObjectReference.setId("1");
|
|
|
|
|
expectedObjectReference.setType("DUMMY");
|
|
|
|
|
|
|
|
|
|
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
|
|
|
|
expectedTask.setPrimaryObjRef(expectedObjectReference);
|
|
|
|
|
|
|
|
|
|
Mockito.doNothing().when(taskMapperMock).insert(any());
|
|
|
|
|
Mockito.doNothing().when(objectReferenceMapperMock).insert(any());
|
|
|
|
|
Mockito.doReturn(null).when(objectReferenceMapperMock).findByObjectReference(any());
|
|
|
|
|
|
|
|
|
|
Task actualTask = cut.create(expectedTask);
|
|
|
|
|
expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId()); // get only new ID
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
|
|
|
|
verify(objectReferenceMapperMock, times(1)).findByObjectReference(any());
|
|
|
|
|
verify(objectReferenceMapperMock, times(1)).insert(any());
|
|
|
|
|
verify(taskMapperMock, times(1)).insert(expectedTask);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
|
|
|
|
|
assertNull(actualTask.getOwner());
|
|
|
|
|
assertNotNull(actualTask.getCreated());
|
|
|
|
|
assertNotNull(actualTask.getModified());
|
|
|
|
|
assertNull(actualTask.getCompleted());
|
|
|
|
|
assertThat(actualTask.getWorkbasketId(), equalTo(expectedTask.getWorkbasketId()));
|
|
|
|
|
assertThat(actualTask.getName(), equalTo(expectedTask.getName()));
|
|
|
|
|
assertThat(actualTask.getState(), equalTo(TaskState.READY));
|
|
|
|
|
assertThat(actualTask.getPrimaryObjRef(), equalTo(expectedObjectReference));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = NotAuthorizedException.class)
|
|
|
|
|
public void testCreateThrowingAuthorizedOnWorkbasket() throws NotAuthorizedException, WorkbasketNotFoundException {
|
|
|
|
|
try {
|
|
|
|
|
Mockito.doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(any(), any());
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
task.setWorkbasketId("1");
|
|
|
|
|
|
|
|
|
|
cut.create(task);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = WorkbasketNotFoundException.class)
|
|
|
|
|
public void testCreateThrowsWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException {
|
|
|
|
|
try {
|
|
|
|
|
Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).checkAuthorization(any(), any());
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
task.setWorkbasketId("1");
|
|
|
|
|
|
|
|
|
|
cut.create(task);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testClaimSuccessfulToOwner() throws Exception {
|
|
|
|
|
Task expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
|
|
|
|
Thread.sleep(SLEEP_TIME); // to have different timestamps
|
|
|
|
|
taskServiceImpl.claim(task.getId(), "John Does");
|
|
|
|
|
task = taskServiceImpl.getTaskById(task.getId());
|
|
|
|
|
Assert.assertEquals(task.getState(), TaskState.CLAIMED);
|
|
|
|
|
Assert.assertNotEquals(task.getCreated(), task.getModified());
|
|
|
|
|
Assert.assertNotNull(task.getClaimed());
|
|
|
|
|
Assert.assertEquals(task.getOwner(), "John Does");
|
|
|
|
|
String expectedOwner = "John Does";
|
|
|
|
|
|
|
|
|
|
Task acturalTask = cut.claim(expectedTask.getId(), expectedOwner);
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
|
|
|
|
verify(taskMapperMock, times(1)).update(any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
|
|
|
|
|
assertThat(acturalTask.getState(), equalTo(TaskState.CLAIMED));
|
|
|
|
|
assertThat(acturalTask.getCreated(), not(equalTo(expectedTask.getModified())));
|
|
|
|
|
assertThat(acturalTask.getClaimed(), not(equalTo(null)));
|
|
|
|
|
assertThat(acturalTask.getOwner(), equalTo(expectedOwner));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = TaskNotFoundException.class)
|
|
|
|
|
public void testClaimFailsWithNonExistingTaskId() throws TaskNotFoundException {
|
|
|
|
|
taskServiceImpl.claim("test", "John Doe");
|
|
|
|
|
public void testClaimThrowinTaskNotFoundException() throws TaskNotFoundException {
|
|
|
|
|
try {
|
|
|
|
|
Task expectedTask = null;
|
|
|
|
|
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(any());
|
|
|
|
|
|
|
|
|
|
cut.claim("1", "OWNER");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).findById(any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testComplete() throws Exception {
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
|
|
|
|
|
public void testCompleteTask() throws TaskNotFoundException, InterruptedException {
|
|
|
|
|
Task expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
Thread.sleep(SLEEP_TIME); // to have different timestamps
|
|
|
|
|
taskServiceImpl.complete(task.getId());
|
|
|
|
|
task = taskServiceImpl.getTaskById(task.getId());
|
|
|
|
|
Assert.assertEquals(task.getState(), TaskState.COMPLETED);
|
|
|
|
|
Assert.assertNotEquals(task.getCreated(), task.getModified());
|
|
|
|
|
Assert.assertNotNull(task.getCompleted());
|
|
|
|
|
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
|
|
|
|
|
|
|
|
|
Task actualTask = cut.complete(expectedTask.getId());
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
|
|
|
|
verify(taskMapperMock, times(1)).update(any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
|
|
|
|
|
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
|
|
|
|
assertThat(actualTask.getCreated(), not(equalTo(expectedTask.getModified())));
|
|
|
|
|
assertThat(actualTask.getCompleted(), not(equalTo(null)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = TaskNotFoundException.class)
|
|
|
|
|
public void testCompleteFailsWithNonExistingTaskId() throws TaskNotFoundException {
|
|
|
|
|
taskServiceImpl.complete("test");
|
|
|
|
|
String invalidTaskId = "";
|
|
|
|
|
try {
|
|
|
|
|
cut.complete(invalidTaskId);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).findById(invalidTaskId);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTransferTaskZuDestinationWorkbasket()
|
|
|
|
|
public void testTransferTaskToDestinationWorkbasketWithoutSecurity()
|
|
|
|
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException {
|
|
|
|
|
Workbasket workbasket2 = createWorkbasket2();
|
|
|
|
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
|
|
|
|
Workbasket destinationWorkbasket = createWorkbasket("2");
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
final int workServiceMockCalls = 3;
|
|
|
|
|
task.setRead(true);
|
|
|
|
|
doReturn(destinationWorkbasket).when(workbasketServiceMock).getWorkbasket(destinationWorkbasket.getId());
|
|
|
|
|
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
|
|
|
|
|
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
|
|
|
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
|
|
|
|
doNothing().when(taskMapperMock).update(any());
|
|
|
|
|
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getId(), WorkbasketAuthorization.APPEND);
|
|
|
|
|
doNothing().when(workbasketServiceMock).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
|
|
|
|
|
|
|
|
|
Mockito.when(taskanaEngine.getWorkbasketService().getWorkbasket("2")).thenReturn(workbasket2);
|
|
|
|
|
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(workServiceMockCalls)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(), WorkbasketAuthorization.APPEND);
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getConfiguration();
|
|
|
|
|
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
|
|
|
|
|
verify(taskMapperMock, times(1)).update(any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
|
|
|
|
|
assertThat(actualTask.isRead(), equalTo(false));
|
|
|
|
|
assertThat(actualTask.isTransferred(), equalTo(true));
|
|
|
|
|
assertThat(actualTask.getWorkbasketId(), equalTo(destinationWorkbasket.getId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTransferTaskToDestinationWorkbasketUsingSecurityTrue()
|
|
|
|
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException {
|
|
|
|
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
|
|
|
|
Workbasket destinationWorkbasket = createWorkbasket("2");
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
task.setRead(true);
|
|
|
|
|
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
|
|
|
|
|
doReturn(true).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
|
|
|
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
|
|
|
|
doNothing().when(taskMapperMock).update(any());
|
|
|
|
|
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getId(), WorkbasketAuthorization.APPEND);
|
|
|
|
|
doNothing().when(workbasketServiceMock).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
|
|
|
|
|
|
|
|
|
// taskanaEngine.getConfiguration().isSecurityEnabled())
|
|
|
|
|
Mockito.when(taskanaEngine.getConfiguration()).thenReturn(taskanaEngineConfiguration);
|
|
|
|
|
Mockito.when(taskanaEngineConfiguration.isSecurityEnabled()).thenReturn(false);
|
|
|
|
|
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(taskServiceImpl.getTaskById(task.getId()).getWorkbasketId(), "1");
|
|
|
|
|
taskServiceImpl.transfer(task.getId(), "2");
|
|
|
|
|
Assert.assertEquals(taskServiceImpl.getTaskById(task.getId()).getWorkbasketId(), "2");
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(), WorkbasketAuthorization.APPEND);
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getConfiguration();
|
|
|
|
|
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
|
|
|
|
verify(taskMapperMock, times(1)).update(any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue(task.isTransferred());
|
|
|
|
|
Assert.assertFalse(task.isRead());
|
|
|
|
|
assertThat(actualTask.isRead(), equalTo(false));
|
|
|
|
|
assertThat(actualTask.isTransferred(), equalTo(true));
|
|
|
|
|
assertThat(actualTask.getWorkbasketId(), equalTo(destinationWorkbasket.getId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = WorkbasketNotFoundException.class)
|
|
|
|
|
public void testTransferFailsIfDestinationWorkbasketDoesNotExist_withSecurityDisabled()
|
|
|
|
|
public void testTransferDestinationWorkbasketDoesNotExist()
|
|
|
|
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException {
|
|
|
|
|
Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketService)
|
|
|
|
|
.checkAuthorization(eq("invalidWorkbasketId"), any());
|
|
|
|
|
|
|
|
|
|
String destinationWorkbasketId = "2";
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
|
|
|
|
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
|
|
|
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(taskServiceImpl.getTaskById(task.getId()).getWorkbasketId(), "1");
|
|
|
|
|
taskServiceImpl.transfer(task.getId(), "invalidWorkbasketId");
|
|
|
|
|
try {
|
|
|
|
|
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = WorkbasketNotFoundException.class)
|
|
|
|
|
public void testTransferFailsIfDestinationWorkbasketDoesNotExist_withSecurityEnabled()
|
|
|
|
|
@Test(expected = TaskNotFoundException.class)
|
|
|
|
|
public void testTransferTaskDoesNotExist()
|
|
|
|
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException {
|
|
|
|
|
Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketService).checkAuthorization(eq("invalidWorkbasketId"), any());
|
|
|
|
|
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
|
|
|
|
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(taskServiceImpl.getTaskById(task.getId()).getWorkbasketId(), "1");
|
|
|
|
|
taskServiceImpl.transfer(task.getId(), "invalidWorkbasketId");
|
|
|
|
|
try {
|
|
|
|
|
cutSpy.transfer(task.getId(), "2");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = NotAuthorizedException.class)
|
|
|
|
|
public void testTransferNotAuthorizationOnWorkbasketAppend()
|
|
|
|
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException {
|
|
|
|
|
String destinationWorkbasketId = "2";
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
|
|
|
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
|
|
|
|
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = NotAuthorizedException.class)
|
|
|
|
|
public void testTransferNotAuthorizationOnWorkbasketTransfer()
|
|
|
|
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException {
|
|
|
|
|
String destinationWorkbasketId = "2";
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
|
|
|
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
|
|
|
|
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
|
|
|
|
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.TRANSFER);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
|
|
|
|
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void should_setTheReadFlag_when_taskIsRead() throws TaskNotFoundException {
|
|
|
|
|
createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
public void testGetTaskCountForState() {
|
|
|
|
|
List<TaskState> taskStates = Arrays.asList(TaskState.CLAIMED, TaskState.COMPLETED);
|
|
|
|
|
List<TaskStateCounter> expectedResult = new ArrayList<>();
|
|
|
|
|
doReturn(expectedResult).when(taskMapperMock).getTaskCountForState(taskStates);
|
|
|
|
|
|
|
|
|
|
Task readTask = taskServiceImpl.setTaskRead("1", true);
|
|
|
|
|
Assert.assertTrue(readTask.isRead());
|
|
|
|
|
List<TaskStateCounter> actualResult = cut.getTaskCountForState(taskStates);
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).getTaskCountForState(taskStates);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
assertThat(actualResult, equalTo(expectedResult));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void should_InsertObjectReference_when_TaskIsCreated() throws NotAuthorizedException {
|
|
|
|
|
Mockito.when(objectReferenceMapper.findByObjectReference(any())).thenReturn(null);
|
|
|
|
|
public void testGetTaskCountForWorkbasketByDaysInPastAndState() {
|
|
|
|
|
List<TaskState> taskStates = Arrays.asList(TaskState.CLAIMED, TaskState.COMPLETED);
|
|
|
|
|
final long daysInPast = 10L;
|
|
|
|
|
final long expectedResult = 5L;
|
|
|
|
|
String workbasketId = "1";
|
|
|
|
|
doReturn(expectedResult).when(taskMapperMock).getTaskCountForWorkbasketByDaysInPastAndState(any(), any(), any());
|
|
|
|
|
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
ObjectReference primaryObjRef = new ObjectReference();
|
|
|
|
|
primaryObjRef.setSystem("Sol");
|
|
|
|
|
task.setPrimaryObjRef(primaryObjRef);
|
|
|
|
|
Task createdTask = taskServiceImpl.create(task);
|
|
|
|
|
long actualResult = cut.getTaskCountForWorkbasketByDaysInPastAndState(workbasketId, daysInPast, taskStates);
|
|
|
|
|
|
|
|
|
|
Assert.assertNotNull(createdTask.getPrimaryObjRef());
|
|
|
|
|
Assert.assertNotNull(createdTask.getPrimaryObjRef().getId());
|
|
|
|
|
Assert.assertEquals("Sol", createdTask.getPrimaryObjRef().getSystem());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).getTaskCountForWorkbasketByDaysInPastAndState(any(), any(), any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
assertThat(actualResult, equalTo(expectedResult));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void should_LinkObjectReference_when_TaskIsCreated() throws NotAuthorizedException {
|
|
|
|
|
public void testGetTaskCountByWorkbasketAndDaysInPastAndState() {
|
|
|
|
|
final long daysInPast = 10L;
|
|
|
|
|
List<TaskState> taskStates = Arrays.asList(TaskState.CLAIMED, TaskState.COMPLETED);
|
|
|
|
|
List<DueWorkbasketCounter> expectedResult = new ArrayList<>();
|
|
|
|
|
doReturn(expectedResult).when(taskMapperMock).getTaskCountByWorkbasketIdAndDaysInPastAndState(any(Date.class), any());
|
|
|
|
|
|
|
|
|
|
List<DueWorkbasketCounter> actualResult = cut.getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast, taskStates);
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).getTaskCountByWorkbasketIdAndDaysInPastAndState(any(Date.class), any());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
assertThat(actualResult, equalTo(expectedResult));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testSetTaskReadWIthExistingTask() throws TaskNotFoundException {
|
|
|
|
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
ObjectReference primaryObjRef = new ObjectReference();
|
|
|
|
|
primaryObjRef.setSystem("Sol");
|
|
|
|
|
task.setPrimaryObjRef(primaryObjRef);
|
|
|
|
|
task.setModified(null);
|
|
|
|
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
|
|
|
|
doNothing().when(taskMapperMock).update(task);
|
|
|
|
|
|
|
|
|
|
ObjectReference returnPrimaryObjRef = new ObjectReference();
|
|
|
|
|
returnPrimaryObjRef.setId("1");
|
|
|
|
|
returnPrimaryObjRef.setSystem("Sol");
|
|
|
|
|
Task actualTask = cutSpy.setTaskRead("1", true);
|
|
|
|
|
|
|
|
|
|
Mockito.when(objectReferenceMapper.findByObjectReference(any())).thenReturn(returnPrimaryObjRef);
|
|
|
|
|
Task createdTask = taskServiceImpl.create(task);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).update(task);
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
assertThat(actualTask.getModified(), not(equalTo(null)));
|
|
|
|
|
assertThat(actualTask.isRead(), equalTo(true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.assertNotNull(createdTask.getPrimaryObjRef());
|
|
|
|
|
Assert.assertEquals("1", createdTask.getPrimaryObjRef().getId());
|
|
|
|
|
Assert.assertEquals("Sol", createdTask.getPrimaryObjRef().getSystem());
|
|
|
|
|
@Test(expected = TaskNotFoundException.class)
|
|
|
|
|
public void testSetTaskReadTaskNotBeFound() throws TaskNotFoundException {
|
|
|
|
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
|
|
|
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
|
|
|
|
task.setModified(null);
|
|
|
|
|
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
cutSpy.setTaskRead("1", true);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetTaskByIdWithExistingTask() throws TaskNotFoundException {
|
|
|
|
|
Task expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1");
|
|
|
|
|
doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
|
|
|
|
|
|
|
|
|
Task actualTask = cut.getTaskById(expectedTask.getId());
|
|
|
|
|
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
assertThat(actualTask, equalTo(expectedTask));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected = TaskNotFoundException.class)
|
|
|
|
|
public void testGetTaskByIdWhereTaskDoesNotExist() throws Exception {
|
|
|
|
|
Task task = createUnitTestTask("1", "DUMMY-TASK", "1");
|
|
|
|
|
doThrow(TaskNotFoundException.class).when(taskMapperMock).findById(task.getId());
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
cut.getTaskById(task.getId());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
|
|
|
verify(taskMapperMock, times(1)).findById(task.getId());
|
|
|
|
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
|
|
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
|
|
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Task createUnitTestTask(String id, String name, String workbasketId) {
|
|
|
|
@ -214,15 +574,13 @@ public class TaskServiceImplTest {
|
|
|
|
|
Timestamp now = new Timestamp(System.currentTimeMillis());
|
|
|
|
|
task.setCreated(now);
|
|
|
|
|
task.setModified(now);
|
|
|
|
|
Mockito.when(taskMapper.findById(any())).thenReturn(task);
|
|
|
|
|
return task;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Workbasket createWorkbasket2() {
|
|
|
|
|
Workbasket workbasket2 = new Workbasket();
|
|
|
|
|
workbasket2.setId("2");
|
|
|
|
|
workbasket2.setName("Workbasket 2");
|
|
|
|
|
return workbasket2;
|
|
|
|
|
private Workbasket createWorkbasket(String id) {
|
|
|
|
|
Workbasket workbasket = new Workbasket();
|
|
|
|
|
workbasket.setId(id);
|
|
|
|
|
workbasket.setName("Workbasket " + id);
|
|
|
|
|
return workbasket;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|