use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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());
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestParseTaskBulkAction method testParseTaskRoundtrip.
@Test
public void testParseTaskRoundtrip() throws Exception {
System.out.println("===[ testParseTaskRoundtrip ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
PrismObject<TaskType> task = prismContext.parseObject(TASK_FILE);
System.out.println("Parsed task:");
System.out.println(task.debugDump());
assertTask(task);
// SERIALIZE
String serializedTask = prismContext.serializeObjectToString(task, PrismContext.LANG_XML);
System.out.println("serialized task:");
System.out.println(serializedTask);
// RE-PARSE
RootXNode reparsedToXNode = prismContext.parserFor(serializedTask).xml().parseToXNode();
System.out.println("Re-parsed task (to XNode):");
System.out.println(reparsedToXNode.debugDump());
// real reparse
PrismObject<TaskType> reparsedTask = prismContext.parseObject(serializedTask);
System.out.println("Re-parsed task:");
System.out.println(reparsedTask.debugDump());
// Cannot assert here. It will cause parsing of some of the raw values and diff will fail
assertTask(reparsedTask);
ObjectDelta<TaskType> objectDelta = task.diff(reparsedTask);
System.out.println("Delta:");
System.out.println(objectDelta.debugDump());
assertTrue("Delta is not empty", objectDelta.isEmpty());
PrismAsserts.assertEquivalent("Task re-parsed equivalence", task, reparsedTask);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestReconScript method test005TestDryRunDelete.
@Test
public void test005TestDryRunDelete() throws Exception {
final String TEST_NAME = "test005TestDryRunDelete";
TestUtil.displayTestTile(this, TEST_NAME);
PrismObject<TaskType> task = getTask(TASK_RECON_DUMMY_OID);
OperationResult parentResult = new OperationResult(TEST_NAME);
PropertyDelta dryRunDelta = PropertyDelta.createModificationReplaceProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_DRY_RUN), task.getDefinition(), true);
Collection<PropertyDelta> modifications = new ArrayList<>();
modifications.add(dryRunDelta);
repositoryService.modifyObject(TaskType.class, TASK_RECON_DUMMY_OID, modifications, parentResult);
getDummyResource().deleteAccountByName("beforeScript");
waitForTaskStart(TASK_RECON_DUMMY_OID, false);
waitForTaskNextRunAssertSuccess(TASK_RECON_DUMMY_OID, false);
waitForTaskFinish(TASK_RECON_DUMMY_OID, false);
PrismObject<ShadowType> shadow = repositoryService.getObject(ShadowType.class, ACCOUNT_BEFORE_SCRIPT_OID, null, parentResult);
AssertJUnit.assertNotNull(shadow);
PrismObject<FocusType> user = repositoryService.searchShadowOwner(ACCOUNT_BEFORE_SCRIPT_OID, null, parentResult);
AssertJUnit.assertNotNull("Owner for account " + shadow + " not found. Some probelm in dry run occured.", user);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestStrangeCases method test410DeleteJack.
/**
* Delete user jack. See that Jack's tasks are still there (although they may be broken)
*/
@Test
public void test410DeleteJack() throws Exception {
final String TEST_NAME = "test410DeleteJack";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestStrangeCases.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
dummyAuditService.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
deleteObject(UserType.class, USER_JACK_OID, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
assertSuccess(result);
// Make sure the user is gone
assertNoObject(UserType.class, USER_JACK_OID, task, result);
List<PrismObject<TaskType>> objects = modelService.searchObjects(TaskType.class, null, null, task, result);
display("Tasks", objects);
assertEquals("Unexpected number of tastsk", 1, objects.size());
PrismObject<TaskType> jackTask = null;
for (PrismObject<TaskType> object : objects) {
if (object.getOid().equals(TASK_MOCK_JACK_OID)) {
jackTask = object;
}
}
assertNotNull("Mock task not found (model)", jackTask);
display("Jack's task (model)", jackTask);
// ClusterStatusInformation clusterStatusInformation = taskManager.getRunningTasksClusterwide(result);
// display("Cluster status", clusterStatusInformation);
// TaskInfo jackTaskInfo = null;
// Set<TaskInfo> taskInfos = clusterStatusInformation.getTasks();
// for (TaskInfo taskInfo: taskInfos) {
// if (taskInfo.getOid().equals(TASK_MOCK_JACK_OID)) {
// jackTaskInfo = taskInfo;
// }
// }
// assertNotNull("Mock task not found (taskManager)", jackTaskInfo);
// display("Jack's task (taskManager)", jackTaskInfo);
// TODO: check task status
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestStrangeCases method test401ListTasks.
@Test
public void test401ListTasks() throws Exception {
final String TEST_NAME = "test401ListTasks";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestStrangeCases.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
dummyAuditService.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
List<PrismObject<TaskType>> objects = modelService.searchObjects(TaskType.class, null, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
assertSuccess(result);
display("Tasks", objects);
assertEquals("Unexpected number of tasks", 1, objects.size());
boolean found = false;
for (PrismObject<TaskType> object : objects) {
if (object.getOid().equals(TASK_MOCK_JACK_OID)) {
found = true;
}
}
assertTrue("Mock task not found (model)", found);
// ClusterStatusInformation clusterStatusInformation = taskManager.getRunningTasksClusterwide(result);
// display("Cluster status", clusterStatusInformation);
// TaskInfo jackTaskInfo = null;
// Set<TaskInfo> taskInfos = clusterStatusInformation.getTasks();
// for (TaskInfo taskInfo: taskInfos) {
// if (taskInfo.getOid().equals(TASK_MOCK_JACK_OID)) {
// jackTaskInfo = taskInfo;
// }
// }
// assertNotNull("Mock task not found (taskManager)", jackTaskInfo);
// Make sure that the tasks still runs
waitForTaskFinish(TASK_MOCK_JACK_OID, false);
}
Aggregations