use of pro.taskana.TaskService in project taskana by Taskana.
the class TaskServiceImplTest method testClaimWithInvalidOwner.
@Test(expected = InvalidOwnerException.class)
public void testClaimWithInvalidOwner() throws Exception {
TaskService cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("1", "taskName", "wbKey", null);
task.setState(TaskState.CLAIMED);
task.setOwner("Max Mustermann");
doReturn(task).when(cutSpy).getTask(task.getId());
try {
cutSpy.claim("1");
} catch (Exception e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
throw e;
}
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class TaskServiceImplTest method testClaimWithInvalidState.
@Test(expected = InvalidStateException.class)
public void testClaimWithInvalidState() throws Exception {
TaskService cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("1", "taskName", "wbKey", null);
task.setState(TaskState.COMPLETED);
doReturn(task).when(cutSpy).getTask(task.getId());
try {
cutSpy.claim("1", true);
} catch (Exception e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
throw e;
}
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class UpdateWorkbasketAuthorizationsAccTest method testUpdatedAccessItemLeadsToNotAuthorizedException.
@WithAccessId(userName = "user_1_1", groupNames = { "group_2", "businessadmin" })
@Test
public void testUpdatedAccessItemLeadsToNotAuthorizedException() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
TaskService taskService = taskanaEngine.getTaskService();
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
String wbKey = "USER_2_1";
String wbDomain = "DOMAIN_A";
String groupName = "group_2";
Task newTask = taskService.newTask(wbKey, wbDomain);
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Task createdTask = taskService.createTask(newTask);
List<TaskSummary> tasks = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)).list();
Assert.assertEquals(1, tasks.size());
assertThat(createdTask, not(equalTo(null)));
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008");
WorkbasketAccessItem theAccessItem = accessItems.stream().filter(x -> groupName.equals(x.getAccessId())).findFirst().orElse(null);
Assert.assertTrue(theAccessItem != null);
theAccessItem.setPermOpen(false);
workbasketService.updateWorkbasketAccessItem(theAccessItem);
try {
taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)).list();
fail("NotAuthorizedToQueryWorkbasketException was expected ");
} catch (NotAuthorizedToQueryWorkbasketException ignored) {
// nothing to do
}
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class QueryTasksByObjectReferenceAccTest method testQueryTasksByValueLikeOfObjectReference.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testQueryTasksByValueLikeOfObjectReference() throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().primaryObjectReferenceValueLike("%567%").list();
Assert.assertEquals(10L, results.size());
}
use of pro.taskana.TaskService in project taskana by Taskana.
the class QueryTasksByObjectReferenceAccTest method testQueryTasksByExcactValueAndTypeOfObjectReference.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testQueryTasksByExcactValueAndTypeOfObjectReference() throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().primaryObjectReferenceTypeIn("SDNR").primaryObjectReferenceValueIn("11223344").list();
Assert.assertEquals(10L, results.size());
}
Aggregations