Search in sources :

Example 11 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class TestDelegation method test140DelegateToNoneByReplace.

@Test
public void test140DelegateToNoneByReplace() throws Exception {
    final String TEST_NAME = "test140DelegateToNoneByReplace";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(userLead3);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    workflowService.delegateWorkItem(workItemId, Collections.emptyList(), REPLACE_ASSIGNEES, result);
    result.computeStatus();
    assertSuccess(result);
    WorkItemType workItem = getWorkItem(task, result);
    display("work item", workItem);
    PrismObject<TaskType> wfTask = getObjectViaRepo(TaskType.class, taskOid);
    display("task", wfTask);
    assertEquals("Wrong assigneeRef count", 0, workItem.getAssigneeRef().size());
    assertRefEquals("Wrong originalAssigneeRef", ort(userLead1Oid), workItem.getOriginalAssigneeRef());
    org.activiti.engine.task.Task activitiTask = activitiEngine.getTaskService().createTaskQuery().taskId(workItem.getExternalId()).singleResult();
    System.out.println("Activiti task: " + activitiTask);
    assertEquals("Wrong activiti assignee", null, activitiTask.getAssignee());
    assertEquals("Wrong # of assignees", 0, getAssignees(activitiTask).size());
    List<WorkItemDelegationEventType> events = WfContextUtil.getWorkItemEvents(wfTask.asObjectable().getWorkflowContext(), workItemId, WorkItemDelegationEventType.class);
    assertEquals("Wrong # of delegation events", 3, events.size());
// TODO check content
}
Also used : Task(com.evolveum.midpoint.task.api.Task) WorkItemDelegationEventType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemDelegationEventType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType) Test(org.testng.annotations.Test)

Example 12 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class AbstractWfTestPolicy method getWorkItem.

protected WorkItemType getWorkItem(Task task, OperationResult result) throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException {
    //Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.resolveItemsNamed(WorkItemType.F_TASK_REF);
    SearchResultList<WorkItemType> itemsAll = modelService.searchContainers(WorkItemType.class, null, null, task, result);
    if (itemsAll.size() != 1) {
        System.out.println("Unexpected # of work items: " + itemsAll.size());
        for (WorkItemType workItem : itemsAll) {
            System.out.println(PrismUtil.serializeQuietly(prismContext, workItem));
        }
    }
    assertEquals("Wrong # of total work items", 1, itemsAll.size());
    return itemsAll.get(0);
}
Also used : WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)

Example 13 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class AbstractWfTestPolicy method checkVisibleWorkItem.

protected void checkVisibleWorkItem(ExpectedWorkItem expectedWorkItem, int count, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ConfigurationException, SecurityViolationException {
    S_AtomicFilterExit q = QueryUtils.filterForAssignees(QueryBuilder.queryFor(WorkItemType.class, prismContext), SecurityUtil.getPrincipal(), OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS);
    List<WorkItemType> currentWorkItems = modelService.searchContainers(WorkItemType.class, q.build(), null, task, result);
    long found = currentWorkItems.stream().filter(wi -> expectedWorkItem == null || expectedWorkItem.matches(wi)).count();
    assertEquals("Wrong # of matching work items", count, found);
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) F_DELTAS_TO_PROCESS(com.evolveum.midpoint.xml.ns._public.common.common_3.WfPrimaryChangeProcessorStateType.F_DELTAS_TO_PROCESS) GetOperationOptions.createRetrieve(com.evolveum.midpoint.schema.GetOperationOptions.createRetrieve) T_PARENT(com.evolveum.midpoint.prism.PrismConstants.T_PARENT) Autowired(org.springframework.beans.factory.annotation.Autowired) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) HookOperationMode(com.evolveum.midpoint.model.api.hooks.HookOperationMode) LightweightObjectRef(com.evolveum.midpoint.wf.impl.processes.common.LightweightObjectRef) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) QueryUtils(com.evolveum.midpoint.wf.util.QueryUtils) ModelOperationTaskHandler(com.evolveum.midpoint.model.impl.controller.ModelOperationTaskHandler) CommonProcessVariableNames(com.evolveum.midpoint.wf.impl.processes.common.CommonProcessVariableNames) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) F_WORKFLOW_CONTEXT(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType.F_WORKFLOW_CONTEXT) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType) Task(com.evolveum.midpoint.task.api.Task) WorkflowResult(com.evolveum.midpoint.wf.impl.WorkflowResult) WfTestUtil(com.evolveum.midpoint.wf.impl.WfTestUtil) ActivitiEngine(com.evolveum.midpoint.wf.impl.activiti.ActivitiEngine) GetOperationOptions.resolveItemsNamed(com.evolveum.midpoint.schema.GetOperationOptions.resolveItemsNamed) Checker(com.evolveum.midpoint.test.Checker) QName(javax.xml.namespace.QName) java.util(java.util) AssertJUnit(org.testng.AssertJUnit) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) WfContextType(com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WorkflowManager(com.evolveum.midpoint.wf.api.WorkflowManager) WfTaskUtil(com.evolveum.midpoint.wf.impl.tasks.WfTaskUtil) TaskManager(com.evolveum.midpoint.task.api.TaskManager) MiscDataUtil(com.evolveum.midpoint.wf.impl.util.MiscDataUtil) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ModelContext(com.evolveum.midpoint.model.api.context.ModelContext) WfContextUtil(com.evolveum.midpoint.schema.util.WfContextUtil) GeneralChangeProcessor(com.evolveum.midpoint.wf.impl.processors.general.GeneralChangeProcessor) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) Clockwork(com.evolveum.midpoint.model.impl.lens.Clockwork) IntegrationTestTools(com.evolveum.midpoint.test.IntegrationTestTools) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) ModelState(com.evolveum.midpoint.model.api.context.ModelState) ClassMode(org.springframework.test.annotation.DirtiesContext.ClassMode) PrismUtil(com.evolveum.midpoint.prism.util.PrismUtil) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit) TaskExecutionStatus(com.evolveum.midpoint.task.api.TaskExecutionStatus) AbstractModelImplementationIntegrationTest(com.evolveum.midpoint.model.impl.AbstractModelImplementationIntegrationTest) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) File(java.io.File) IntegrationTestTools.display(com.evolveum.midpoint.test.IntegrationTestTools.display) QueryBuilder(com.evolveum.midpoint.prism.query.builder.QueryBuilder) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) SecurityUtil(com.evolveum.midpoint.security.api.SecurityUtil) PrimaryChangeProcessor(com.evolveum.midpoint.wf.impl.processors.primary.PrimaryChangeProcessor) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)

Example 14 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class AbstractWfTestPolicy method assertWfContextAfterClockworkRun.

protected void assertWfContextAfterClockworkRun(Task rootTask, List<Task> subtasks, List<WorkItemType> workItems, OperationResult result, String objectOid, List<ExpectedTask> expectedTasks, List<ExpectedWorkItem> expectedWorkItems) throws Exception {
    final Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(new ItemPath(F_WORKFLOW_CONTEXT, F_WORK_ITEM), createRetrieve());
    Task opTask = taskManager.createTaskInstance();
    TaskType rootTaskType = modelService.getObject(TaskType.class, rootTask.getOid(), options, opTask, result).asObjectable();
    display("rootTask", rootTaskType);
    assertTrue("unexpected process instance id in root task", rootTaskType.getWorkflowContext() == null || rootTaskType.getWorkflowContext().getProcessInstanceId() == null);
    assertEquals("Wrong # of wf subtasks (" + expectedTasks + ")", expectedTasks.size(), subtasks.size());
    int i = 0;
    for (Task subtask : subtasks) {
        TaskType subtaskType = modelService.getObject(TaskType.class, subtask.getOid(), options, opTask, result).asObjectable();
        display("Subtask #" + (i + 1) + ": ", subtaskType);
        checkTask(subtaskType, subtask.toString(), expectedTasks.get(i));
        WfTestUtil.assertRef("requester ref", subtaskType.getWorkflowContext().getRequesterRef(), USER_ADMINISTRATOR_OID, false, false);
        i++;
    }
    assertEquals("Wrong # of work items", expectedWorkItems.size(), workItems.size());
    i = 0;
    for (WorkItemType workItem : workItems) {
        display("Work item #" + (i + 1) + ": ", workItem);
        display("Task", WfContextUtil.getTask(workItem));
        if (objectOid != null) {
            WfTestUtil.assertRef("object reference", WfContextUtil.getObjectRef(workItem), objectOid, true, true);
        }
        String targetOid = expectedWorkItems.get(i).targetOid;
        if (targetOid != null) {
            WfTestUtil.assertRef("target reference", WfContextUtil.getTargetRef(workItem), targetOid, true, true);
        }
        WfTestUtil.assertRef("assignee reference", workItem.getOriginalAssigneeRef(), expectedWorkItems.get(i).assigneeOid, false, true);
        // name is not known, as it is not stored in activiti (only OID is)
        //WfTestUtil.assertRef("task reference", workItem.getTaskRef(), null, false, true);
        final TaskType subtaskType = WfContextUtil.getTask(workItem);
        checkTask(subtaskType, "task in workItem", expectedWorkItems.get(i).task);
        WfTestUtil.assertRef("requester ref", subtaskType.getWorkflowContext().getRequesterRef(), USER_ADMINISTRATOR_OID, false, true);
        i++;
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)

Example 15 with WorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method assertWfContextAfterClockworkRun.

protected void assertWfContextAfterClockworkRun(Task rootTask, List<Task> subtasks, OperationResult result, String... processNames) throws Exception {
    final Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(new ItemPath(F_WORKFLOW_CONTEXT, F_WORK_ITEM), createRetrieve());
    Task opTask = taskManager.createTaskInstance();
    TaskType rootTaskType = modelService.getObject(TaskType.class, rootTask.getOid(), options, opTask, result).asObjectable();
    display("rootTask", rootTaskType);
    assertTrue("unexpected process instance id in root task", rootTaskType.getWorkflowContext() == null || rootTaskType.getWorkflowContext().getProcessInstanceId() == null);
    assertEquals("Wrong # of wf subtasks w.r.t processNames (" + Arrays.asList(processNames) + ")", processNames.length, subtasks.size());
    int i = 0;
    for (Task subtask : subtasks) {
        TaskType subtaskType = modelService.getObject(TaskType.class, subtask.getOid(), options, opTask, result).asObjectable();
        display("Subtask #" + (i + 1) + ": ", subtaskType);
        checkTask(subtaskType, subtask.toString(), processNames[i++]);
        WfTestUtil.assertRef("requester ref", subtaskType.getWorkflowContext().getRequesterRef(), USER_ADMINISTRATOR_OID, false, false);
    }
    final Collection<SelectorOptions<GetOperationOptions>> options1 = resolveItemsNamed(new ItemPath(T_PARENT, F_OBJECT_REF), new ItemPath(T_PARENT, F_TARGET_REF), F_ASSIGNEE_REF, F_ORIGINAL_ASSIGNEE_REF, new ItemPath(T_PARENT, F_REQUESTER_REF));
    List<WorkItemType> workItems = modelService.searchContainers(WorkItemType.class, null, options1, opTask, result);
    assertEquals("Wrong # of work items", processNames.length, workItems.size());
    i = 0;
    for (WorkItemType workItem : workItems) {
        display("Work item #" + (i + 1) + ": ", workItem);
        display("Task ref", WfContextUtil.getTask(workItem));
        WfTestUtil.assertRef("object reference", WfContextUtil.getObjectRef(workItem), USER_JACK_OID, true, true);
        WfTestUtil.assertRef("target reference", WfContextUtil.getTargetRef(workItem), ROLE_R1_OID, true, true);
        // name is not known, as it is not stored in activiti (only OID is)
        WfTestUtil.assertRef("assignee reference", workItem.getOriginalAssigneeRef(), R1BOSS_OID, false, true);
        //WfTestUtil.assertRef("task reference", workItem.getTaskRef(), null, false, true);
        final TaskType subtaskType = WfContextUtil.getTask(workItem);
        checkTask(subtaskType, "task in workItem", processNames[i++]);
        WfTestUtil.assertRef("requester ref", subtaskType.getWorkflowContext().getRequesterRef(), USER_ADMINISTRATOR_OID, false, true);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)

Aggregations

WorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)13 Task (com.evolveum.midpoint.task.api.Task)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 Test (org.testng.annotations.Test)6 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)5 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)5 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)4 ModelContext (com.evolveum.midpoint.model.api.context.ModelContext)2 HookOperationMode (com.evolveum.midpoint.model.api.hooks.HookOperationMode)2 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 WorkItemDelegationEventType (com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemDelegationEventType)2 ArrayList (java.util.ArrayList)2 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 ModelState (com.evolveum.midpoint.model.api.context.ModelState)1 AbstractModelImplementationIntegrationTest (com.evolveum.midpoint.model.impl.AbstractModelImplementationIntegrationTest)1 ModelOperationTaskHandler (com.evolveum.midpoint.model.impl.controller.ModelOperationTaskHandler)1