Search in sources :

Example 11 with KeyDomain

use of pro.taskana.KeyDomain in project taskana by Taskana.

the class QueryTasksWithSortingAccTest method testSortByPorCompanyAndClaimed.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testSortByPorCompanyAndClaimed() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")).orderByPrimaryObjectReferenceCompany(desc).orderByClaimed(asc).list();
    assertThat(results.size(), equalTo(25));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        // + taskSummary.getClaimed());
        if (previousSummary != null) {
            Assert.assertTrue(taskSummary.getPrimaryObjRef().getCompany().compareToIgnoreCase(previousSummary.getPrimaryObjRef().getCompany()) <= 0);
        }
        previousSummary = taskSummary;
    }
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) KeyDomain(pro.taskana.KeyDomain) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 12 with KeyDomain

use of pro.taskana.KeyDomain in project taskana by Taskana.

the class TaskServiceImplIntExplicitTest method should_ReturnList_when_BuilderIsUsed.

@WithAccessId(userName = "Elena", groupNames = { "DummyGroup", "businessadmin" })
@Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException, WorkbasketAlreadyExistException, DomainNotFoundException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    generateSampleAccessItems();
    WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
    workbasket.setName("workbasket");
    Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
    classificationService.createClassification(classification);
    // set id manually for authorization tests
    workbasket.setId("1");
    workbasket.setType(WorkbasketType.GROUP);
    workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
    Task task = taskServiceImpl.newTask(workbasket.getId());
    task.setName("Unit Test Task");
    task.setClassificationKey(classification.getKey());
    task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
    task = taskServiceImpl.createTask(task);
    List<TaskSummary> results = taskServiceImpl.createTaskQuery().nameIn("bla", "test").descriptionLike("test").priorityIn(1, 2, 2).stateIn(TaskState.CLAIMED).workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A")).ownerIn("test", "test2", "bla").customAttributeLike("13", "test").classificationKeyIn("pId1", "pId2").primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh").primaryObjectReferenceSystemIn("sys").primaryObjectReferenceTypeIn("type1", "type2").primaryObjectReferenceSystemInstanceIn("sysInst1", "sysInst2").primaryObjectReferenceValueIn("val1", "val2", "val3").list();
    Assert.assertEquals(0, results.size());
    connection.commit();
}
Also used : Task(pro.taskana.Task) Classification(pro.taskana.Classification) Connection(java.sql.Connection) TaskSummary(pro.taskana.TaskSummary) WorkbasketImpl(pro.taskana.impl.WorkbasketImpl) KeyDomain(pro.taskana.KeyDomain) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 13 with KeyDomain

use of pro.taskana.KeyDomain 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
    }
}
Also used : Task(pro.taskana.Task) WorkbasketService(pro.taskana.WorkbasketService) TaskService(pro.taskana.TaskService) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) TaskSummary(pro.taskana.TaskSummary) NotAuthorizedToQueryWorkbasketException(pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException) KeyDomain(pro.taskana.KeyDomain) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 14 with KeyDomain

use of pro.taskana.KeyDomain in project taskana by Taskana.

the class QueryTasksWithSortingAccTest method testSortByPorSystemNoteDueAndOwner.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testSortByPorSystemNoteDueAndOwner() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")).orderByPrimaryObjectReferenceSystem(SortDirection.DESCENDING).orderByNote(null).orderByDue(null).orderByOwner(asc).list();
    assertThat(results.size(), equalTo(25));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        if (previousSummary != null) {
            Assert.assertTrue(taskSummary.getPrimaryObjRef().getSystem().compareToIgnoreCase(previousSummary.getPrimaryObjRef().getSystem()) <= 0);
        }
        previousSummary = taskSummary;
    }
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) KeyDomain(pro.taskana.KeyDomain) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 15 with KeyDomain

use of pro.taskana.KeyDomain in project taskana by Taskana.

the class QueryTasksWithSortingAccTest method testSortByPorSystemInstanceParentProcPlannedAndState.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testSortByPorSystemInstanceParentProcPlannedAndState() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")).orderByPrimaryObjectReferenceSystemInstance(desc).orderByParentBusinessProcessId(asc).orderByPlanned(asc).orderByState(asc).list();
    assertThat(results.size(), equalTo(25));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        if (previousSummary != null) {
            Assert.assertTrue(taskSummary.getPrimaryObjRef().getSystemInstance().compareToIgnoreCase(previousSummary.getPrimaryObjRef().getSystemInstance()) <= 0);
        }
        previousSummary = taskSummary;
    }
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) KeyDomain(pro.taskana.KeyDomain) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

Test (org.junit.Test)18 KeyDomain (pro.taskana.KeyDomain)18 WithAccessId (pro.taskana.security.WithAccessId)17 AbstractAccTest (acceptance.AbstractAccTest)16 TaskService (pro.taskana.TaskService)16 TaskSummary (pro.taskana.TaskSummary)14 Ignore (org.junit.Ignore)3 Task (pro.taskana.Task)3 Classification (pro.taskana.Classification)2 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)2 Connection (java.sql.Connection)1 Workbasket (pro.taskana.Workbasket)1 WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)1 WorkbasketService (pro.taskana.WorkbasketService)1 NotAuthorizedToQueryWorkbasketException (pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException)1 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)1 WorkbasketImpl (pro.taskana.impl.WorkbasketImpl)1