Search in sources :

Example 46 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class TestRetirement method test300RetireUserGorc.

@Test
public void test300RetireUserGorc() throws Exception {
    final String TEST_NAME = "test300RetireUserGorc";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
    modifications.add(createAssignmentModification(orgCortuvHradOid, OrgType.COMPLEX_TYPE, null, null, null, false));
    modifications.add(createAssignmentModification(ORG_RETIRED_OID, OrgType.COMPLEX_TYPE, null, null, null, true));
    ObjectDelta<UserType> userDelta = ObjectDelta.createModifyDelta(userGorcOid, modifications, UserType.class, prismContext);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    dumpOrgTree();
    dumpLdap();
    PrismObject<UserType> userAfter = getAndAssertRetiredUser(USER_GORC_USERNAME);
    userGorcOid = userAfter.getOid();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest)

Example 47 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class TestPlentyOfAssignments method test120CheesePreviewChanges.

@Test
public void test120CheesePreviewChanges() throws Exception {
    final String TEST_NAME = "test120CheesePreviewChanges";
    displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> cheeseBefore = prepareCheese();
    display("Cheese before", assignmentSummary(cheeseBefore));
    ObjectDelta<UserType> delta = cheeseBefore.createModifyDelta();
    delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_NUMBER, "123");
    inspector.reset();
    rememberPrismObjectCompareCount();
    rememberRepositoryReadCount();
    long startMillis = System.currentTimeMillis();
    // WHEN
    displayWhen(TEST_NAME);
    ModelContext<ObjectType> modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result);
    // THEN
    displayThen(TEST_NAME);
    long endMillis = System.currentTimeMillis();
    assertSuccess(result);
    display("Preview cheese in " + (endMillis - startMillis) + "ms (" + ((endMillis - startMillis) / NUMBER_OF_CHEESE_ASSIGNMENTS) + "ms per assignment)");
    PrismObject<UserType> cheeseAfter = getUser(USER_CHEESE_OID);
    display("Cheese after", assignmentSummary(cheeseAfter));
    assertCheeseRoleMembershipRef(cheeseAfter);
    display("Repo reads", InternalMonitor.getRepositoryReadCount());
    display("Object compares", InternalMonitor.getPrismObjectCompareCount());
    display("Inspector", inspector);
    inspector.assertRead(RoleType.class, 1);
    //        assertRepositoryReadCount(4); // may be influenced by tasks
    assertPrismObjectCompareCount(0);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 48 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class TestActivation method test150ModifyUserJackAssignYellowAccount.

/**
     * Assign yellow account.
     */
@Test
public void test150ModifyUserJackAssignYellowAccount() throws Exception {
    final String TEST_NAME = "test150ModifyUserJackAssignYellowAccount";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_OID, null, true);
    deltas.add(accountAssignmentUserDelta);
    XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar();
    result.computeStatus();
    TestUtil.assertSuccess("executeChanges result", result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack);
    accountYellowOid = getLinkRefOid(userJack, RESOURCE_DUMMY_YELLOW_OID);
    // Check account in dummy resource
    assertDummyAccount(RESOURCE_DUMMY_YELLOW_NAME, "jack", "Jack Sparrow", true);
    // Check shadow
    PrismObject<ShadowType> accountShadowYellow = getShadowModel(accountYellowOid);
    assertAccountShadowModel(accountShadowYellow, accountYellowOid, ACCOUNT_JACK_DUMMY_USERNAME, getDummyResourceType(RESOURCE_DUMMY_YELLOW_NAME));
    assertAdministrativeStatusEnabled(accountShadowYellow);
    TestUtil.assertCreateTimestamp(accountShadowYellow, start, end);
    assertEnableTimestampShadow(accountShadowYellow, start, end);
    // Check user
    TestUtil.assertModifyTimestamp(userJack, start, end);
    assertAdministrativeStatusEnabled(userJack);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestValidityRecomputeTask(com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractSynchronizationStoryTest(com.evolveum.midpoint.model.intest.sync.AbstractSynchronizationStoryTest)

Example 49 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class TestIteration method test100JackAssignAccountDummyConflicting.

/**
	 * The default dummy instance will not iterate. It has correlation rule which will link the account instead.
	 */
@Test
public void test100JackAssignAccountDummyConflicting() throws Exception {
    final String TEST_NAME = "test100JackAssignAccountDummyConflicting";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestIteration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    // Make sure there is a conflicting account and also a shadow for it
    DummyAccount account = new DummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Sparrow");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Tortuga");
    getDummyResource().addAccount(account);
    repoAddObject(createShadow(getDummyResourceObject(), ACCOUNT_JACK_DUMMY_USERNAME), result);
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_OID, null, true);
    deltas.add(accountAssignmentUserDelta);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack);
    String accountOid = getSingleLinkOid(userJack);
    // Check shadow
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    assertDummyAccountShadowRepo(accountShadow, accountOid, ACCOUNT_JACK_DUMMY_USERNAME);
    // Check account
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
    assertDummyAccountShadowModel(accountModel, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow");
    // Check account in dummy resource
    assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(3);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
    dummyAuditService.assertExecutionSuccess();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 50 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class TestIteration method test360HermanAssignAccountDummyViolet.

@Test
public void test360HermanAssignAccountDummyViolet() throws Exception {
    final String TEST_NAME = "test360HermanAssignAccountDummyViolet";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestIteration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    addObject(USER_HERMAN_FILE);
    dummyAuditService.clear();
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_HERMAN_OID, RESOURCE_DUMMY_VIOLET_OID, null, true);
    deltas.add(accountAssignmentUserDelta);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userHerman = getUser(USER_HERMAN_OID);
    display("User after change execution", userHerman);
    assertUser(userHerman, USER_HERMAN_OID, "herman", "Herman Toothrot", "Herman", "Toothrot");
    assertLinks(userHerman, 1);
    assertAccount(userHerman, RESOURCE_DUMMY_VIOLET_OID);
    String accountVioletOid = getLinkRefOid(userHerman, RESOURCE_DUMMY_VIOLET_OID);
    // Check shadow
    PrismObject<ShadowType> accountVioletShadow = repositoryService.getObject(ShadowType.class, accountVioletOid, null, result);
    assertAccountShadowRepo(accountVioletShadow, accountVioletOid, "herman.1", resourceDummyVioletType);
    assertIteration(accountVioletShadow, 1, ".1");
    // Check account
    PrismObject<ShadowType> accountVioletModel = modelService.getObject(ShadowType.class, accountVioletOid, null, task, result);
    assertAccountShadowModel(accountVioletModel, accountVioletOid, "herman.1", resourceDummyVioletType);
    // There should be no account with the "straight" name
    assertNoDummyAccount(RESOURCE_DUMMY_VIOLET_NAME, "herman");
    // The new account
    assertDummyAccount(RESOURCE_DUMMY_VIOLET_NAME, "herman.1", "Herman Toothrot", true);
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(3);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class);
    dummyAuditService.assertExecutionSuccess();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)371 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)297 Test (org.testng.annotations.Test)264 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)253 Task (com.evolveum.midpoint.task.api.Task)252 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)223 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)155 ArrayList (java.util.ArrayList)123 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)100 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)58 Holder (javax.xml.ws.Holder)49 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)46 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)46 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)38 QName (javax.xml.namespace.QName)38 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)37 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)33 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)33 ShadowDiscriminatorObjectDelta (com.evolveum.midpoint.common.refinery.ShadowDiscriminatorObjectDelta)32