use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class TaskServiceImplTest method testGetTaskByIdWithExistingTask.
@Test
public void testGetTaskByIdWithExistingTask() throws TaskNotFoundException, ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException {
Classification dummyClassification = createDummyClassification();
Task expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1", dummyClassification);
doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(expectedTask.getId());
doReturn(classificationQueryImplMock).when(classificationServiceImplMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).idIn(any());
doReturn(workbasketQueryImplMock).when(workbasketServiceMock).createWorkbasketQuery();
doReturn(workbasketQueryImplMock).when(workbasketQueryImplMock).idIn(any());
List<WorkbasketSummary> wbList = new ArrayList<>();
WorkbasketSummaryImpl wb = new WorkbasketSummaryImpl();
wb.setDomain("dummy-domain");
wbList.add(wb);
doReturn(wbList).when(workbasketQueryImplMock).list();
List<ClassificationSummaryImpl> classificationList = Arrays.asList((ClassificationSummaryImpl) dummyClassification.asSummary());
doReturn(classificationList).when(classificationQueryImplMock).list();
Task actualTask = cut.getTask(expectedTask.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId());
verify(classificationServiceImplMock, times(1)).createClassificationQuery();
verify(classificationQueryImplMock, times(1)).idIn(any());
verify(classificationQueryImplMock, times(1)).list();
verify(workbasketServiceMock, times(1)).createWorkbasketQuery();
verify(workbasketQueryImplMock, times(1)).idIn(any());
verify(workbasketQueryImplMock, times(1)).list();
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
assertThat(actualTask, equalTo(expectedTask));
}
use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class TaskServiceImplTest method testCompleteTaskDefault.
@Test
public void testCompleteTaskDefault() throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, InterruptedException, 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);
task.setState(TaskState.CLAIMED);
task.setClaimed(Instant.now());
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(classificationQueryImplMock).when(classificationServiceImplMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).idIn(any());
doReturn(new ArrayList<>()).when(classificationQueryImplMock).list();
List<ClassificationSummaryImpl> classificationList = Arrays.asList((ClassificationSummaryImpl) dummyClassification.asSummary());
doReturn(classificationList).when(classificationQueryImplMock).list();
doReturn(workbasketQueryImplMock).when(workbasketServiceMock).createWorkbasketQuery();
doReturn(workbasketQueryImplMock).when(workbasketQueryImplMock).idIn(any());
List<WorkbasketSummary> wbList = new ArrayList<>();
WorkbasketSummaryImpl wb = new WorkbasketSummaryImpl();
wb.setDomain("dummy-domain");
wbList.add(wb);
doReturn(wbList).when(workbasketQueryImplMock).list();
Task actualTask = cut.completeTask(task.getId());
verify(taskanaEngineMock, times(2)).openConnection();
verify(taskMapperMock, times(1)).findById(task.getId());
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(task.getId());
verify(classificationServiceImplMock, times(1)).createClassificationQuery();
verify(classificationQueryImplMock, times(1)).idIn(any());
verify(classificationQueryImplMock, times(1)).list();
verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineMock, times(2)).returnConnection();
verify(workbasketServiceMock, times(1)).createWorkbasketQuery();
verify(workbasketQueryImplMock, times(1)).idIn(any());
verify(workbasketQueryImplMock, times(1)).list();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
assertThat(actualTask.getCreated(), not(equalTo(task.getModified())));
assertThat(actualTask.getCompleted(), not(equalTo(null)));
}
use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class WorkbasketServiceImplIntAutocommitTest method testUpdateWorkbasket.
@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void testUpdateWorkbasket() throws Exception {
String id0 = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket0 = createTestWorkbasket(id0, "key0", "DOMAIN_A", "Superbasket", WorkbasketType.GROUP);
workbasket0 = workBasketService.createWorkbasket(workbasket0);
createWorkbasketWithSecurity(workbasket0, "Elena", true, true, false, false);
String id1 = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket1 = createTestWorkbasket(id1, "key1", "DOMAIN_A", "Megabasket", WorkbasketType.GROUP);
workbasket1 = workBasketService.createWorkbasket(workbasket1);
createWorkbasketWithSecurity(workbasket1, "Elena", true, true, false, false);
String id2 = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "DOMAIN_A", "Hyperbasket", WorkbasketType.GROUP);
workbasket2 = workBasketService.createWorkbasket(workbasket2);
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
List<String> distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
String id3 = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket3 = createTestWorkbasket(id3, "key3", "DOMAIN_A", "hm ... irgend ein basket", WorkbasketType.GROUP);
workbasket3 = workBasketService.createWorkbasket(workbasket3);
createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId()));
Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets);
Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId());
List<WorkbasketSummary> distributionTargets = workBasketService.getDistributionTargets(foundBasket.getId());
Assert.assertEquals(1, distributionTargets.size());
Assert.assertEquals(id3, distributionTargets.get(0).getId());
Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(), workBasketService.getWorkbasket(id2).getModified());
Assert.assertEquals(workBasketService.getWorkbasket(id1).getCreated(), workBasketService.getWorkbasket(id1).getModified());
Assert.assertEquals(workBasketService.getWorkbasket(id3).getCreated(), workBasketService.getWorkbasket(id3).getModified());
}
use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class QueryWorkbasketByPermissionAccTest method testQueryAllAvailableWorkbasketForOpeningForUserAndGroupFromSubject.
@WithAccessId(userName = "user_1_1")
@Test
public void testQueryAllAvailableWorkbasketForOpeningForUserAndGroupFromSubject() throws SQLException, NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery().callerHasPermission(WorkbasketPermission.READ).list();
Assert.assertEquals(1, results.size());
}
use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class QueryWorkbasketByPermissionAccTest method testQueryAllTransferTargetsForUserAndGroupSortedByNameDescending.
@WithAccessId(userName = "dummy", groupNames = { "businessadmin" })
@Test
public void testQueryAllTransferTargetsForUserAndGroupSortedByNameDescending() throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery().accessIdsHavePermission(WorkbasketPermission.APPEND, "user_1_1", "group_1").orderByName(desc).orderByKey(asc).list();
Assert.assertEquals(6, results.size());
Assert.assertEquals("USER_2_2", results.get(0).getKey());
}
Aggregations