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();
}
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);
}
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);
}
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();
}
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();
}
Aggregations