use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.
the class TestActivitiQuery method test300SearchByAssignee.
@Test
public void test300SearchByAssignee() throws Exception {
final String TEST_NAME = "test210SearchByAssignee";
TestUtil.displayTestTile(this, TEST_NAME);
login(userAdministrator);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
List<PrismReferenceValue> assigneeRefs = new ArrayList<>();
assigneeRefs.add(prv("oid-number-1"));
assigneeRefs.add(prv(userLead1Oid));
assigneeRefs.add(prv("oid-number-3"));
assigneeRefs.add(prv("oid-number-4"));
assigneeRefs.add(prv("oid-number-5"));
assigneeRefs.add(prv("oid-number-6"));
ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(assigneeRefs).build();
SearchResultList<WorkItemType> items = modelService.searchContainers(WorkItemType.class, query, null, task, result);
assertEquals("Wrong # of work items found using multi-assignee/multi-delegate query", 1, items.size());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.
the class TestDelegation method test110DelegateToUser2Unauthorized.
@Test
public void test110DelegateToUser2Unauthorized() throws Exception {
final String TEST_NAME = "test110DelegateToUser2Unauthorized";
TestUtil.displayTestTile(this, TEST_NAME);
login(userLead3);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
try {
workflowService.delegateWorkItem(workItemId, Collections.singletonList(ort(userLead2Oid)), ADD_ASSIGNEES, result);
fail("delegate succeeded even if it shouldn't");
} catch (SecurityViolationException e) {
// ok
}
WorkItemType workItem = getWorkItem(task, result);
PrismAsserts.assertReferenceValues(ref(workItem.getAssigneeRef()), userLead1Oid);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.
the class TestDelegation method test130DelegateToUser3ByReplace.
@Test
public void test130DelegateToUser3ByReplace() throws Exception {
final String TEST_NAME = "test130DelegateToUser3ByReplace";
TestUtil.displayTestTile(this, TEST_NAME);
login(userLead1);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
workflowService.delegateWorkItem(workItemId, Collections.singletonList(ort(userLead3Oid)), 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);
PrismAsserts.assertReferenceValues(ref(workItem.getAssigneeRef()), userLead3Oid);
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", "UserType:" + userLead3Oid, activitiTask.getAssignee());
List<String> assignees = getAssignees(activitiTask);
assertEquals("Wrong midpoint-assignee values", Collections.singleton("UserType:" + userLead3Oid), new HashSet<>(assignees));
List<WorkItemDelegationEventType> events = WfContextUtil.getWorkItemEvents(wfTask.asObjectable().getWorkflowContext(), workItemId, WorkItemDelegationEventType.class);
assertEquals("Wrong # of delegation events", 2, events.size());
// TODO check content
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.
the class AbstractTestAssignmentApproval method assertActiveWorkItems.
protected void assertActiveWorkItems(String approverOid, int expectedCount) throws Exception {
if (approverOid == null && expectedCount == 0) {
return;
}
Task task = createTask("query");
ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(getPotentialAssignees(getUser(approverOid))).build();
List<WorkItemType> items = modelService.searchContainers(WorkItemType.class, query, null, task, task.getResult());
assertEquals("Wrong active work items for " + approverOid, expectedCount, items.size());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType in project midpoint by Evolveum.
the class ActivitiInterface method notifyMidpointAboutTaskEvent.
public void notifyMidpointAboutTaskEvent(DelegateTask delegateTask) {
OperationResult result = new OperationResult(DOT_CLASS + "notifyMidpointAboutTaskEvent");
TaskEvent taskEvent;
if (TaskListener.EVENTNAME_CREATE.equals(delegateTask.getEventName())) {
// TODO distinguish created vs. assigned event
taskEvent = new TaskCreatedEvent();
} else if (TaskListener.EVENTNAME_COMPLETE.equals(delegateTask.getEventName())) {
taskEvent = new TaskCompletedEvent();
} else if (TaskListener.EVENTNAME_DELETE.equals(delegateTask.getEventName())) {
taskEvent = new TaskDeletedEvent();
} else {
// ignoring other events
return;
}
taskEvent.setVariables(delegateTask.getVariables());
taskEvent.setAssigneeOid(delegateTask.getAssignee());
taskEvent.setTaskId(delegateTask.getId());
taskEvent.setTaskName(delegateTask.getName());
taskEvent.setProcessInstanceName((String) delegateTask.getVariable(CommonProcessVariableNames.VARIABLE_PROCESS_INSTANCE_NAME));
taskEvent.setProcessInstanceId(delegateTask.getProcessInstanceId());
taskEvent.setCreateTime(delegateTask.getCreateTime());
taskEvent.setDueDate(delegateTask.getDueDate());
taskEvent.setExecutionId(delegateTask.getExecutionId());
taskEvent.setOwner(delegateTask.getOwner());
for (IdentityLink identityLink : delegateTask.getCandidates()) {
if (identityLink.getUserId() != null) {
taskEvent.getCandidateUsers().add(identityLink.getUserId());
} else if (identityLink.getGroupId() != null) {
taskEvent.getCandidateGroups().add(identityLink.getGroupId());
} else {
throw new IllegalStateException("Neither candidate user nor group id is provided in delegateTask: " + delegateTask);
}
}
try {
WorkItemType workItem = workItemProvider.taskEventToWorkItemNew(taskEvent, null, true, true, true, result);
wfTaskController.onTaskEvent(workItem, taskEvent, result);
} catch (Exception e) {
// todo fix the exception processing e.g. think about situation where an event cannot be audited - should we allow to proceed?
String message = "Couldn't process an event coming from the workflow management system";
LoggingUtils.logUnexpectedException(LOGGER, message, e);
result.recordFatalError(message, e);
}
}
Aggregations