Search in sources :

Example 86 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestRecomputeTask method test130RecomputeLight.

/**
	 * Light recompute. Very efficient, no resource operations, just fix the focus.
	 * MID-3384
	 */
@Test
public void test130RecomputeLight() throws Exception {
    final String TEST_NAME = "test130RecomputeLight";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    // Preconditions
    assertUsers(6);
    PrismObject<UserType> usetJackBefore = getUser(USER_JACK_OID);
    display("User jack before", usetJackBefore);
    assertAssignedRole(usetJackBefore, ROLE_JUDGE_OID);
    assertRoleMembershipRef(usetJackBefore, ROLE_JUDGE_OID);
    assignOrg(USER_GUYBRUSH_OID, ORG_MINISTRY_OF_OFFENSE_OID, null);
    PrismObject<UserType> usetGuybrushBefore = getUser(USER_GUYBRUSH_OID);
    display("User guybrush before", usetGuybrushBefore);
    assertAssignedRole(usetGuybrushBefore, ROLE_PIRATE_OID);
    assertRoleMembershipRef(usetGuybrushBefore, ROLE_PIRATE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
    assertAssignedOrgs(usetGuybrushBefore, ORG_MINISTRY_OF_OFFENSE_OID);
    assertHasOrgs(usetGuybrushBefore, ORG_MINISTRY_OF_OFFENSE_OID);
    clearUserOrgAndRoleRefs(USER_JACK_OID);
    clearUserOrgAndRoleRefs(USER_GUYBRUSH_OID);
    rememberShadowFetchOperationCount();
    rememberConnectorOperationCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    addObject(TASK_USER_RECOMPUTE_LIGHT_FILE);
    dummyAuditService.clear();
    waitForTaskStart(TASK_USER_RECOMPUTE_LIGHT_OID, false);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    waitForTaskFinish(TASK_USER_RECOMPUTE_LIGHT_OID, true, 40000);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
    display("Users after recompute", users);
    assertShadowFetchOperationCountIncrement(0);
    assertConnectorOperationIncrement(0);
    assertDummyAccount(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "cutlass", "dagger");
    assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    // Red resource does not delete accounts on deprovision, it disables them
    assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false);
    // Herman should be recomputed now
    assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_HERMAN_USERNAME, "Herman Toothrot", false);
    TaskType recomputeTask = getTask(TASK_USER_RECOMPUTE_LIGHT_OID).asObjectable();
    assertEquals("Wrong success count", 6, recomputeTask.getOperationStats().getIterativeTaskInformation().getTotalSuccessCount());
    assertEquals("Wrong failure count", 0, recomputeTask.getOperationStats().getIterativeTaskInformation().getTotalFailureCount());
    PrismObject<UserType> usetJackAfter = getUser(USER_JACK_OID);
    display("User jack after", usetJackAfter);
    assertAssignedRole(usetJackAfter, ROLE_JUDGE_OID);
    assertRoleMembershipRef(usetJackAfter, ROLE_JUDGE_OID);
    PrismObject<UserType> usetGuybrushAfter = getUser(USER_GUYBRUSH_OID);
    display("User guybrush after", usetGuybrushAfter);
    assertAssignedRole(usetGuybrushAfter, ROLE_PIRATE_OID);
    assertRoleMembershipRef(usetGuybrushAfter, ROLE_PIRATE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
    assertAssignedOrgs(usetGuybrushAfter, ORG_MINISTRY_OF_OFFENSE_OID);
    assertHasOrgs(usetGuybrushAfter, ORG_MINISTRY_OF_OFFENSE_OID);
    assertUsers(6);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 87 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestRecomputeTask method test120RecomputeByExpression.

/**
	 * Here we recompute herman as well.
	 */
@Test
public void test120RecomputeByExpression() throws Exception {
    final String TEST_NAME = "test120RecomputeByExpression";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    // Preconditions
    assertUsers(6);
    assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false);
    assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_HERMAN_USERNAME, "Herman Toothrot", true);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    addObject(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_FILE);
    dummyAuditService.clear();
    waitForTaskStart(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID, false);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    waitForTaskFinish(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID, true, 40000);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
    display("Users after recompute", users);
    assertDummyAccount(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "cutlass", "dagger");
    assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    // Red resource does not delete accounts on deprovision, it disables them
    assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false);
    // Herman should be recomputed now
    assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_HERMAN_USERNAME, "Herman Toothrot", false);
    TaskType recomputeTask = getTask(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID).asObjectable();
    assertEquals("Wrong success count", 1, recomputeTask.getOperationStats().getIterativeTaskInformation().getTotalSuccessCount());
    assertEquals("Wrong failure count", 0, recomputeTask.getOperationStats().getIterativeTaskInformation().getTotalFailureCount());
    assertUsers(6);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 88 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestUuid method test210ReconcileDummyUuidAddAugustus.

@Test
public void test210ReconcileDummyUuidAddAugustus() throws Exception {
    final String TEST_NAME = "test210ReconcileDummyUuidAddAugustus";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
    DummyAccount account = new DummyAccount(ACCOUNT_AUGUSTUS_NAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTUS_FULLNAME);
    dummyResourceUuid.addAccount(account);
    getDummyResource().purgeScriptHistory();
    dummyAuditService.clear();
    rememberShadowFetchOperationCount();
    reconciliationTaskResultListener.clear();
    Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    restartTask(TASK_RECONCILE_DUMMY_UUID_OID);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    waitForTaskNextRunAssertSuccess(taskBefore, true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 0);
    List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
    display("Users after import", users);
    assertImportedUserByOid(USER_ADMINISTRATOR_OID);
    assertImportedUserByOid(USER_JACK_OID);
    assertImportedUserByOid(USER_BARBOSSA_OID);
    assertImportedUserByUsername(ACCOUNT_AUGUSTUS_NAME, RESOURCE_DUMMY_UUID_OID);
    assertDummyAccountAttribute(RESOURCE_DUMMY_UUID_NAME, ACCOUNT_AUGUSTUS_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTUS_FULLNAME);
    assertEquals("Unexpected number of users", 6, users.size());
    display("Dummy resource", getDummyResource().debugDump());
    assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_UUID_OID);
    // Task result
    PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_UUID_OID);
    OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
    display("Recon task result", reconTaskResult);
    TestUtil.assertSuccess(reconTaskResult);
    PrismObject<UserType> user = findUserByUsername(USER_AUGUSTUS_NAME);
    display("Augustus after recon", user);
    augustusShadowOid = getSingleLinkOid(user);
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, augustusShadowOid, null, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 89 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestUuid method test220ReconcileDummyUuidDeleteAddAugustus.

/**
	 * Augustus is deleted and re-added with the same username. New shadow needs to be created.
	 */
@Test
public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception {
    final String TEST_NAME = "test220ReconcileDummyUuidDeleteAddAugustus";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
    DummyAccount oldAccount = dummyResourceUuid.getAccountByUsername(ACCOUNT_AUGUSTUS_NAME);
    dummyResourceUuid.deleteAccountByName(ACCOUNT_AUGUSTUS_NAME);
    assertNoDummyAccount(ACCOUNT_AUGUSTUS_NAME, ACCOUNT_AUGUSTUS_NAME);
    DummyAccount account = new DummyAccount(ACCOUNT_AUGUSTUS_NAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTUS_FULLNAME);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, USER_AUGUSTUS_NAME);
    dummyResourceUuid.addAccount(account);
    account = dummyResourceUuid.getAccountByUsername(ACCOUNT_AUGUSTUS_NAME);
    assertFalse("Account IDs not changed", oldAccount.getId().equals(account.getId()));
    display("Old shadow OID", augustusShadowOid);
    display("Account ID " + oldAccount.getId() + " -> " + account.getId());
    Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result);
    getDummyResource().purgeScriptHistory();
    dummyAuditService.clear();
    rememberShadowFetchOperationCount();
    reconciliationTaskResultListener.clear();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    restartTask(TASK_RECONCILE_DUMMY_UUID_OID);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    waitForTaskNextRunAssertSuccess(taskBefore, true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 0);
    List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
    display("Users after import", users);
    assertImportedUserByOid(USER_ADMINISTRATOR_OID);
    assertImportedUserByOid(USER_JACK_OID);
    assertImportedUserByOid(USER_BARBOSSA_OID);
    assertImportedUserByUsername(ACCOUNT_AUGUSTUS_NAME, RESOURCE_DUMMY_UUID_OID);
    assertDummyAccountAttribute(RESOURCE_DUMMY_UUID_NAME, ACCOUNT_AUGUSTUS_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTUS_FULLNAME);
    assertEquals("Unexpected number of users", 6, users.size());
    display("Dummy resource", getDummyResource().debugDump());
    assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_UUID_OID);
    // Task result
    PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_UUID_OID);
    OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
    display("Recon task result", reconTaskResult);
    TestUtil.assertSuccess(reconTaskResult);
    PrismObject<UserType> user = findUserByUsername(USER_AUGUSTUS_NAME);
    display("Augustus after recon", user);
    String newAugustusShadowOid = getSingleLinkOid(user);
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, newAugustusShadowOid, null, result);
    assertFalse("Shadow OID is not changed", augustusShadowOid.equals(newAugustusShadowOid));
    augustusShadowOid = newAugustusShadowOid;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 90 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestImportRecon method test900DeleteDummyShadows.

@Test
public void test900DeleteDummyShadows() throws Exception {
    final String TEST_NAME = "test900DeleteDummyShadows";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestImportRecon.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Preconditions
    assertUsers(18);
    dummyAuditService.clear();
    rememberShadowFetchOperationCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    importObjectFromFile(TASK_DELETE_DUMMY_SHADOWS_FILE);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    waitForTaskFinish(TASK_DELETE_DUMMY_SHADOWS_OID, true, 20000);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    assertShadowFetchOperationCountIncrement(0);
    PrismObject<TaskType> deleteTask = getTask(TASK_DELETE_DUMMY_SHADOWS_OID);
    OperationResultType deleteTaskResultType = deleteTask.asObjectable().getResult();
    display("Final delete task result", deleteTaskResultType);
    TestUtil.assertSuccess(deleteTaskResultType);
    OperationResult deleteTaskResult = OperationResult.createOperationResult(deleteTaskResultType);
    TestUtil.assertSuccess(deleteTaskResult);
    List<OperationResult> opExecResults = deleteTaskResult.findSubresults(ModelService.EXECUTE_CHANGES);
    assertEquals(1, opExecResults.size());
    OperationResult opExecResult = opExecResults.get(0);
    TestUtil.assertSuccess(opExecResult);
    assertEquals("Wrong exec operation count", 17, opExecResult.getCount());
    assertTrue("Too many subresults: " + deleteTaskResult.getSubresults().size(), deleteTaskResult.getSubresults().size() < 10);
    assertUsers(18);
    assertDummyAccountShadows(0, true, task, result);
    assertDummyAccountShadows(17, false, task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)88 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)63 Test (org.testng.annotations.Test)50 Task (com.evolveum.midpoint.task.api.Task)47 PrismObject (com.evolveum.midpoint.prism.PrismObject)30 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)25 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)23 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)19 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)16 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)15 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)15 ArrayList (java.util.ArrayList)14 QName (javax.xml.namespace.QName)13 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)11 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 Checker (com.evolveum.midpoint.test.Checker)8 ObjectChecker (com.evolveum.midpoint.test.ObjectChecker)8