Search in sources :

Example 76 with TaskType

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

the class AbstractModelIntegrationTest method getTask.

protected PrismObject<TaskType> getTask(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask");
    OperationResult result = task.getResult();
    PrismObject<TaskType> retTask = modelService.getObject(TaskType.class, taskOid, null, task, result);
    result.computeStatus();
    TestUtil.assertSuccess("getObject(Task) result not success", result);
    return retTask;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 77 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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 78 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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 79 with TaskType

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

the class AbstractWfTestPolicy method checkTask.

private void checkTask(TaskType subtaskType, String subtaskName, ExpectedTask expectedTask) {
    assertNull("Unexpected fetch result in wf subtask: " + subtaskName, subtaskType.getFetchResult());
    WfContextType wfc = subtaskType.getWorkflowContext();
    assertNotNull("Missing workflow context in wf subtask: " + subtaskName, wfc);
    assertNotNull("No process ID in wf subtask: " + subtaskName, wfc.getProcessInstanceId());
    assertEquals("Wrong process ID name in subtask: " + subtaskName, expectedTask.processName, wfc.getProcessInstanceName());
    if (expectedTask.targetOid != null) {
        assertEquals("Wrong target OID in subtask: " + subtaskName, expectedTask.targetOid, wfc.getTargetRef().getOid());
    } else {
        assertNull("TargetRef in subtask: " + subtaskName + " present even if it shouldn't", wfc.getTargetRef());
    }
    assertNotNull("Missing process start time in subtask: " + subtaskName, wfc.getStartTimestamp());
    assertNull("Unexpected process end time in subtask: " + subtaskName, wfc.getEndTimestamp());
    assertEquals("Wrong outcome", null, wfc.getOutcome());
//assertEquals("Wrong state", null, wfc.getState());
}
Also used : WfContextType(com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType)

Example 80 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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

TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)88 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)63 Test (org.testng.annotations.Test)50 Task (com.evolveum.midpoint.task.api.Task)47 PrismObject (com.evolveum.midpoint.prism.PrismObject)30 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)25 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)23 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)19 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)16 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)15 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)15 ArrayList (java.util.ArrayList)14 QName (javax.xml.namespace.QName)13 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)11 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 Checker (com.evolveum.midpoint.test.Checker)8 ObjectChecker (com.evolveum.midpoint.test.ObjectChecker)8