Search in sources :

Example 86 with SelectorOptions

use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.

the class AbstractManualResourceTest method test102GetAccountWillFuture.

@Test
public void test102GetAccountWillFuture() throws Exception {
    final String TEST_NAME = "test102GetAccountWillFuture";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE));
    // WHEN
    displayWhen(TEST_NAME);
    PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, options, task, result);
    // THEN
    displayThen(TEST_NAME);
    assertSuccess(result);
    display("Model shadow", shadowModel);
    ShadowType shadowTypeProvisioning = shadowModel.asObjectable();
    assertShadowName(shadowModel, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertAttribute(shadowModel, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowModel, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME);
    assertNoAttribute(shadowModel, ATTR_DESCRIPTION_QNAME);
    assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED);
    assertShadowExists(shadowModel, true);
// TODO 
//		assertShadowPassword(shadowProvisioning);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 87 with SelectorOptions

use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.

the class TestRoleEntitlement method test102GetGroupNoFetch.

@Test
public void test102GetGroupNoFetch() throws Exception {
    final String TEST_NAME = "test102GetGroupNoFetch";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestRoleEntitlement.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE);
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
    // WHEN
    PrismObject<ShadowType> shadow = modelService.getObject(ShadowType.class, groupOid, options, task, result);
    display("Account", shadow);
    display("Account def", shadow.getDefinition());
    PrismContainer<Containerable> accountContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    display("Account attributes def", accountContainer.getDefinition());
    display("Account attributes def complex type def", accountContainer.getDefinition().getComplexTypeDefinition());
    assertDummyGroupShadowRepo(shadow, groupOid, GROUP_PIRATE_DUMMY_NAME);
    result.computeStatus();
    TestUtil.assertSuccess("getObject result", result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Containerable(com.evolveum.midpoint.prism.Containerable) Test(org.testng.annotations.Test)

Example 88 with SelectorOptions

use of com.evolveum.midpoint.schema.SelectorOptions 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 89 with SelectorOptions

use of com.evolveum.midpoint.schema.SelectorOptions 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)

Example 90 with SelectorOptions

use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method assertWfContextAfterRootTaskFinishes.

protected void assertWfContextAfterRootTaskFinishes(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();
    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);
        assertNull("Unexpected fetch result in wf subtask: " + subtask, subtaskType.getFetchResult());
        WfContextType wfc = subtaskType.getWorkflowContext();
        assertNotNull("Missing workflow context in wf subtask: " + subtask, wfc);
        assertNotNull("No process ID in wf subtask: " + subtask, wfc.getProcessInstanceId());
        assertEquals("Wrong process ID name in subtask: " + subtask, processNames[i++], wfc.getProcessInstanceName());
        assertNotNull("Missing process start time in subtask: " + subtask, wfc.getStartTimestamp());
        assertNotNull("Missing process end time in subtask: " + subtask, wfc.getEndTimestamp());
        assertEquals("Wrong outcome", SchemaConstants.MODEL_APPROVAL_OUTCOME_APPROVE, wfc.getOutcome());
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) WfContextType(com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)127 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)106 Task (com.evolveum.midpoint.task.api.Task)82 Test (org.testng.annotations.Test)47 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)34 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)31 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)31 PrismObject (com.evolveum.midpoint.prism.PrismObject)28 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)28 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)28 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)23 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)21 ArrayList (java.util.ArrayList)19 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)17 QName (javax.xml.namespace.QName)17 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)16 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)16 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)14 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)14 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)12