use of pro.taskana.Workbasket in project taskana by Taskana.
the class TransferTaskAccTest method testBulkTransferTaskToWorkbasketById.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testBulkTransferTaskToWorkbasketById() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
Instant before = Instant.now();
TaskService taskService = taskanaEngine.getTaskService();
ArrayList<String> taskIdList = new ArrayList<>();
taskIdList.add("TKI:000000000000000000000000000000000004");
taskIdList.add("TKI:000000000000000000000000000000000005");
BulkOperationResults<String, TaskanaException> results = taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIdList);
assertFalse(results.containsErrors());
Workbasket wb = taskanaEngine.getWorkbasketService().getWorkbasket("USER_1_1", "DOMAIN_A");
Task transferredTask = taskService.getTask("TKI:000000000000000000000000000000000004");
assertNotNull(transferredTask);
assertTrue(transferredTask.isTransferred());
assertFalse(transferredTask.isRead());
assertEquals(TaskState.READY, transferredTask.getState());
assertThat(transferredTask.getWorkbasketKey(), equalTo(wb.getKey()));
assertThat(transferredTask.getDomain(), equalTo(wb.getDomain()));
assertFalse(transferredTask.getModified().isBefore(before));
assertThat(transferredTask.getOwner(), equalTo(null));
transferredTask = taskService.getTask("TKI:000000000000000000000000000000000005");
assertNotNull(transferredTask);
assertTrue(transferredTask.isTransferred());
assertFalse(transferredTask.isRead());
assertEquals(TaskState.READY, transferredTask.getState());
assertThat(transferredTask.getWorkbasketKey(), equalTo(wb.getKey()));
assertThat(transferredTask.getDomain(), equalTo(wb.getDomain()));
assertFalse(transferredTask.getModified().isBefore(before));
assertThat(transferredTask.getOwner(), equalTo(null));
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class WorkbasketServiceImplTest method testGetWorkbasketById.
@Test
public void testGetWorkbasketById() throws NotAuthorizedException, WorkbasketNotFoundException {
String wbId = "ID-1";
Workbasket wb = createTestWorkbasket(wbId, "key-1");
WorkbasketPermission authorization = WorkbasketPermission.READ;
doReturn(wb).when(workbasketMapperMock).findById(wbId);
doNothing().when(cutSpy).checkAuthorization(wb.getId(), authorization);
Workbasket actualWb = cutSpy.getWorkbasket(wbId);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(workbasketMapperMock, times(1)).findById(wbId);
verify(cutSpy, times(1)).checkAuthorization(wb.getId(), authorization);
verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).isUserInRole(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, distributionTargetMapperMock, taskanaEngineImplMock, taskanaEngineConfigurationMock);
assertThat(actualWb, equalTo(wb));
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class WorkbasketServiceImplTest method testGetWorkbasketById_NonAuthorizedUser.
@Test(expected = NotAuthorizedException.class)
public void testGetWorkbasketById_NonAuthorizedUser() throws WorkbasketNotFoundException, NotAuthorizedException {
String wbId = "ID-1";
Workbasket wb = createTestWorkbasket(wbId, "Key-1");
WorkbasketPermission authorization = WorkbasketPermission.READ;
doReturn(wb).when(workbasketMapperMock).findById(wbId);
doThrow(NotAuthorizedException.class).when(cutSpy).checkAuthorization(wb.getId(), authorization);
try {
cutSpy.getWorkbasket(wbId);
} catch (NotAuthorizedException ex) {
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(workbasketMapperMock, times(1)).findById(wbId);
verify(cutSpy, times(1)).checkAuthorization(wb.getId(), authorization);
verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).isUserInRole(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, distributionTargetMapperMock, taskanaEngineImplMock, taskanaEngineConfigurationMock);
throw ex;
}
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class WorkbasketServiceImplTest method testCreateWorkbasket_WithDistibutionTargets.
@Test
public void testCreateWorkbasket_WithDistibutionTargets() throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
final int distTargetAmount = 2;
WorkbasketImpl expectedWb = createTestWorkbasket(null, "Key-1");
doNothing().when(workbasketMapperMock).insert(expectedWb);
doReturn(expectedWb).when(cutSpy).getWorkbasket(any());
doReturn(true).when(taskanaEngineImplMock).domainExists(any());
Workbasket actualWb = cutSpy.createWorkbasket(expectedWb);
cutSpy.setDistributionTargets(expectedWb.getId(), createTestDistributionTargets(distTargetAmount));
verify(taskanaEngineImplMock, times(4)).openConnection();
verify(workbasketMapperMock, times(3)).insert(any());
verify(cutSpy, times(distTargetAmount + 1)).getWorkbasket(any());
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(any());
verify(distributionTargetMapperMock, times(distTargetAmount)).insert(any(), any());
verify(workbasketMapperMock, times(3)).findByKeyAndDomain(any(), any());
verify(workbasketMapperMock, times(1)).update(any());
verify(taskanaEngineImplMock, times(4)).returnConnection();
verify(taskanaEngineImplMock, times(4)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(3)).domainExists(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, distributionTargetMapperMock, taskanaEngineImplMock, taskanaEngineConfigurationMock);
assertThat(actualWb.getId(), not(equalTo(null)));
assertThat(actualWb.getId(), startsWith("WBI"));
assertThat(actualWb.getCreated(), not(equalTo(null)));
assertThat(actualWb.getModified(), not(equalTo(null)));
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class WorkbasketServiceImplTest method testDeleteWorkbasket.
@Test
public void testDeleteWorkbasket() throws NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException, WorkbasketNotFoundException {
Workbasket wb = createTestWorkbasket("WBI:0", "wb-key");
doReturn(wb).when(cutSpy).getWorkbasket(wb.getId());
doReturn(sqlSessionMock).when(taskanaEngineImplMock).getSqlSession();
doReturn(taskMapperMock).when(sqlSessionMock).getMapper(TaskMapper.class);
doReturn(new Long(0)).when(taskMapperMock).countTasksInWorkbasket(any());
cutSpy.deleteWorkbasket(wb.getId());
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(cutSpy, times(1)).getWorkbasket(wb.getId());
verify(taskanaEngineImplMock, times(1)).getSqlSession();
verify(sqlSessionMock, times(1)).getMapper(TaskMapper.class);
verify(taskMapperMock, times(1)).countTasksInWorkbasket(any());
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(wb.getId());
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsByTargetId(wb.getId());
verify(workbasketAccessMapperMock, times(1)).deleteAllAccessItemsForWorkbasketId(wb.getId());
verify(workbasketMapperMock, times(1)).delete(wb.getId());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, distributionTargetMapperMock, taskanaEngineImplMock, taskanaEngineConfigurationMock);
}
Aggregations