use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestOrgSync method test500ReconcileOpenDJDefault.
@Test
public void test500ReconcileOpenDJDefault() throws Exception {
final String TEST_NAME = "test500ReconcileOpenDJDefault";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestOrgSync.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users before recon", users);
assertUsers(15);
reconciliationTaskResultListener.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
importObjectFromFile(TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE);
// THEN
TestUtil.displayThen(TEST_NAME);
waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false);
waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);
// THEN
TestUtil.displayThen(TEST_NAME);
reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0);
users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after recon", users);
assertUsers(18);
// Task result
PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);
display("Recon task after", reconTaskAfter);
assertTaskClosed(reconTaskAfter);
OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
TestUtil.assertSuccess(reconTaskResult);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestUserChangeApprovalLegacy method checkTask.
private void checkTask(TaskType subtaskType, String subtaskName, String processName) {
assertEquals("Unexpected fetch result in wf subtask: " + subtaskName, null, 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, processName, wfc.getProcessInstanceName());
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());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestDelegation method test120DelegateToUser2.
@Test
public void test120DelegateToUser2() throws Exception {
final String TEST_NAME = "test120DelegateToUser2";
TestUtil.displayTestTile(this, TEST_NAME);
login(userLead1);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
workflowService.delegateWorkItem(workItemId, Collections.singletonList(ort(userLead2Oid)), ADD_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()), userLead1Oid, userLead2Oid);
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:" + userLead1Oid, activitiTask.getAssignee());
List<String> assignees = getAssignees(activitiTask);
assertEquals("Wrong midpoint-assignee values", new HashSet<>(Arrays.asList("UserType:" + userLead1Oid, "UserType:" + userLead2Oid)), new HashSet<>(assignees));
List<WorkItemDelegationEventType> events = WfContextUtil.getWorkItemEvents(wfTask.asObjectable().getWorkflowContext(), workItemId, WorkItemDelegationEventType.class);
assertEquals("Wrong # of delegation events", 1, events.size());
// TODO check content
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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.TaskType in project midpoint by Evolveum.
the class TestSanityLegacy method test400ImportFromResource.
@Test
public void test400ImportFromResource() throws Exception {
final String TEST_NAME = "test400ImportFromResource";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
checkAllShadows();
assertNoRepoCache();
OperationResult result = new OperationResult(TestSanityLegacy.class.getName() + "." + TEST_NAME);
// Make sure Mr. Gibbs has "l" attribute set to the same value as an outbound expression is setting
ChangeRecordEntry entry = openDJController.executeLdifChange(LDIF_GIBBS_MODIFY_FILE);
display("Entry from LDIF", entry);
// Let's add an entry with multiple uids.
Entry addEntry = openDJController.addEntryFromLdifFile(LDIF_HERMAN_FILENAME);
display("Entry from LDIF", addEntry);
// WHEN
TaskType taskType = modelWeb.importFromResource(RESOURCE_OPENDJ_OID, IMPORT_OBJECTCLASS);
// THEN
assertNoRepoCache();
displayJaxb("importFromResource result", taskType.getResult(), SchemaConstants.C_RESULT);
AssertJUnit.assertEquals("importFromResource has failed", OperationResultStatusType.IN_PROGRESS, taskType.getResult().getStatus());
// Convert the returned TaskType to a more usable Task
Task task = taskManager.createTaskInstance(taskType.asPrismObject(), result);
AssertJUnit.assertNotNull(task);
assertNotNull(task.getOid());
AssertJUnit.assertTrue(task.isAsynchronous());
AssertJUnit.assertEquals(TaskExecutionStatus.RUNNABLE, task.getExecutionStatus());
// AssertJUnit.assertEquals(TaskExclusivityStatus.CLAIMED, task.getExclusivityStatus());
display("Import task after launch", task);
PrismObject<TaskType> tObject = repositoryService.getObject(TaskType.class, task.getOid(), null, result);
TaskType taskAfter = tObject.asObjectable();
display("Import task in repo after launch", taskAfter);
result.computeStatus();
TestUtil.assertSuccess("getObject has failed", result);
final String taskOid = task.getOid();
waitFor("Waiting for import to complete", new Checker() {
@Override
public boolean check() throws CommonException {
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
OperationResult opResult = new OperationResult("import check");
assertNoRepoCache();
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
try {
modelWeb.getObject(ObjectTypes.TASK.getTypeQName(), taskOid, options, objectHolder, resultHolder);
} catch (FaultMessage faultMessage) {
throw new SystemException(faultMessage);
}
assertNoRepoCache();
// display("getObject result (wait loop)",resultHolder.value);
TestUtil.assertSuccess("getObject has failed", resultHolder.value);
Task task = taskManager.createTaskInstance((PrismObject<TaskType>) objectHolder.value.asPrismObject(), opResult);
System.out.println(new Date() + ": Import task status: " + task.getExecutionStatus() + ", progress: " + task.getProgress());
if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) {
// Task closed, wait finished
return true;
}
// IntegrationTestTools.display("Task result while waiting: ", task.getResult());
return false;
}
@Override
public void timeout() {
// No reaction, the test will fail right after return from this
}
}, 180000);
// wait a second until the task will be definitely saved
Thread.sleep(1000);
//### Check task state after the task is finished ###
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
assertNoRepoCache();
modelWeb.getObject(ObjectTypes.TASK.getTypeQName(), task.getOid(), options, objectHolder, resultHolder);
assertNoRepoCache();
TestUtil.assertSuccess("getObject has failed", resultHolder.value);
task = taskManager.createTaskInstance((PrismObject<TaskType>) objectHolder.value.asPrismObject(), result);
display("Import task after finish (fetched from model)", task);
AssertJUnit.assertEquals(TaskExecutionStatus.CLOSED, task.getExecutionStatus());
assertNotNull("Null lastRunStartTimestamp in " + task, task.getLastRunStartTimestamp());
assertNotNull("Null lastRunFinishTimestamp in " + task, task.getLastRunFinishTimestamp());
long importDuration = task.getLastRunFinishTimestamp() - task.getLastRunStartTimestamp();
double usersPerSec = (task.getProgress() * 1000) / importDuration;
display("Imported " + task.getProgress() + " users in " + importDuration + " milliseconds (" + usersPerSec + " users/sec)");
OperationResult taskResult = task.getResult();
AssertJUnit.assertNotNull("Task has no result", taskResult);
TestUtil.assertSuccess("Import task result is not success", taskResult);
AssertJUnit.assertTrue("Task failed", taskResult.isSuccess());
AssertJUnit.assertTrue("No progress", task.getProgress() > 0);
//### Check if the import created users and shadows ###
// Listing of shadows is not supported by the provisioning. So we need
// to look directly into repository
List<PrismObject<ShadowType>> sobjects = repositoryService.searchObjects(ShadowType.class, null, null, result);
result.computeStatus();
TestUtil.assertSuccess("listObjects has failed", result);
AssertJUnit.assertFalse("No shadows created", sobjects.isEmpty());
for (PrismObject<ShadowType> aObject : sobjects) {
ShadowType shadow = aObject.asObjectable();
display("Shadow object after import (repo)", shadow);
// This would be really strange ;-)
assertNotEmpty("No OID in shadow", shadow.getOid());
assertNotEmpty("No name in shadow", shadow.getName());
AssertJUnit.assertNotNull("No objectclass in shadow", shadow.getObjectClass());
AssertJUnit.assertNotNull("Null attributes in shadow", shadow.getAttributes());
assertAttributeNotNull("No UID in shadow", shadow, SchemaConstants.ICFS_UID);
}
Holder<ObjectListType> listHolder = new Holder<ObjectListType>();
assertNoRepoCache();
modelWeb.searchObjects(ObjectTypes.USER.getTypeQName(), null, null, listHolder, resultHolder);
assertNoRepoCache();
ObjectListType uobjects = listHolder.value;
TestUtil.assertSuccess("listObjects has failed", resultHolder.value);
AssertJUnit.assertFalse("No users created", uobjects.getObject().isEmpty());
// TODO: use another account, not guybrush
display("Users after import " + uobjects.getObject().size());
for (ObjectType oo : uobjects.getObject()) {
UserType user = (UserType) oo;
if (SystemObjectsType.USER_ADMINISTRATOR.value().equals(user.getOid())) {
//skip administrator check
continue;
}
display("User after import (repo)", user);
// This would be
assertNotEmpty("No OID in user", user.getOid());
// really
// strange ;-)
assertNotEmpty("No name in user", user.getName());
assertNotNull("No fullName in user", user.getFullName());
assertNotEmpty("No fullName in user", user.getFullName().getOrig());
assertNotEmpty("No familyName in user", user.getFamilyName().getOrig());
if (user.getName().getOrig().equals(USER_GUYBRUSH_USERNAME)) {
// skip the rest of checks for guybrush, he does not have LDAP account now
continue;
}
assertTrue("User " + user.getName() + " is disabled (" + user.getActivation().getAdministrativeStatus() + ")", user.getActivation() == null || user.getActivation().getAdministrativeStatus() == ActivationStatusType.ENABLED);
List<ObjectReferenceType> accountRefs = user.getLinkRef();
AssertJUnit.assertEquals("Wrong accountRef for user " + user.getName(), 1, accountRefs.size());
ObjectReferenceType accountRef = accountRefs.get(0);
boolean found = false;
for (PrismObject<ShadowType> aObject : sobjects) {
ShadowType acc = aObject.asObjectable();
if (accountRef.getOid().equals(acc.getOid())) {
found = true;
break;
}
}
if (!found) {
AssertJUnit.fail("accountRef does not point to existing account " + accountRef.getOid());
}
PrismObject<ShadowType> aObject = modelService.getObject(ShadowType.class, accountRef.getOid(), null, task, result);
ShadowType account = aObject.asObjectable();
display("Account after import ", account);
String attributeValueL = ShadowUtil.getMultiStringAttributeValueAsSingle(account, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "l"));
// assertEquals("Unexcpected value of l", "middle of nowhere", attributeValueL);
assertEquals("Unexcpected value of l", getUserLocality(user), attributeValueL);
}
// This also includes "idm" user imported from LDAP. Later we need to ignore that one.
assertEquals("Wrong number of users after import", 10, uobjects.getObject().size());
checkAllShadows();
}
Aggregations