use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM in project midpoint by Evolveum.
the class CertificationTest method test260AddWorkItem.
@Test
public void test260AddWorkItem() throws Exception {
OperationResult result = new OperationResult("test260AddWorkItem");
AccessCertificationWorkItemType workItem = new AccessCertificationWorkItemType(prismContext).beginOriginalAssigneeRef().oid("orig1").type(UserType.COMPLEX_TYPE).<AccessCertificationWorkItemType>end().beginAssigneeRef().oid("rev1").type(UserType.COMPLEX_TYPE).<AccessCertificationWorkItemType>end().beginAssigneeRef().oid("rev2").type(UserType.COMPLEX_TYPE).end();
List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, NEW_CASE_ID, F_WORK_ITEM).add(workItem).asItemDeltas();
// WHEN
executeAndCheckModification(modifications, result, 0);
// THEN
checkCasesForCampaign(campaign1Oid, 8, result);
checkCasesTotal(8, result);
checkWorkItemsForCampaign(campaign1Oid, 10, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, NEW_CASE_ID, 2, result);
checkWorkItemsTotal(10, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM in project midpoint by Evolveum.
the class CertificationTest method test280DeleteWorkItem.
@Test
public void test280DeleteWorkItem() throws Exception {
OperationResult result = new OperationResult("test280DeleteWorkItem");
PrismObject<AccessCertificationCampaignType> campaign = getFullCampaign(campaign1Oid, result);
AccessCertificationCaseType case100 = campaign.asObjectable().getCase().stream().filter(c -> c.getId() == NEW_CASE_ID).findFirst().orElseThrow(() -> new AssertionError("No case 100"));
assertEquals("Wrong # of work items in case 100", 2, case100.getWorkItem().size());
AccessCertificationWorkItemType workItem = case100.getWorkItem().stream().filter(wi -> wi.getOriginalAssigneeRef() != null).findFirst().orElse(null);
assertNotNull("No new work item", workItem);
List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, NEW_CASE_ID, F_WORK_ITEM).delete(workItem.clone()).asItemDeltas();
// WHEN
executeAndCheckModification(modifications, result, 0);
// THEN
checkCasesForCampaign(campaign1Oid, 8, result);
checkCasesTotal(8, result);
checkWorkItemsForCampaign(campaign1Oid, 9, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, NEW_CASE_ID, 1, result);
checkWorkItemsTotal(9, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM in project midpoint by Evolveum.
the class QueryInterpreter2Test method test747QueryCertCaseReviewerAndEnabledByRequestedDesc.
@Test
public void test747QueryCertCaseReviewerAndEnabledByRequestedDesc() throws Exception {
Session session = open();
try {
PrismReferenceValue assigneeRef = ObjectTypeUtil.createObjectRef("1234567890", ObjectTypes.USER).asReferenceValue();
ObjectQuery query = QueryBuilder.queryFor(AccessCertificationCaseType.class, prismContext).item(F_WORK_ITEM, F_ASSIGNEE_REF).ref(assigneeRef).and().item(AccessCertificationCaseType.F_STAGE_NUMBER).eq().item(T_PARENT, AccessCertificationCampaignType.F_STAGE_NUMBER).and().item(T_PARENT, F_STATE).eq(IN_REVIEW_STAGE).desc(F_CURRENT_STAGE_CREATE_TIMESTAMP).build();
String real = getInterpretedQuery2(session, AccessCertificationCaseType.class, query, false);
String expected = "select\n" + " a.ownerOid, a.id, a.fullObject\n" + "from\n" + " RAccessCertificationCase a\n" + " left join a.workItems w\n" + " left join w.assigneeRef a2\n" + " left join a.owner o\n" + "where\n" + " (\n" + " (\n" + " a2.targetOid = :targetOid and\n" + " a2.relation in (:relation) and\n" + " a2.type = :type\n" + " ) and\n" + " (\n" + " a.stageNumber = o.stageNumber or\n" + " (\n" + " a.stageNumber is null and\n" + " o.stageNumber is null\n" + " )\n" + " ) and\n" + " o.state = :state\n" + " )\n" + "order by a.reviewRequestedTimestamp desc";
assertEqualsIgnoreWhitespace(expected, real);
} finally {
close(session);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM 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++;
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM 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);
}
}
Aggregations