use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestModelServiceContract method test109ModifyUserAddAccountAgain.
@Test
public void test109ModifyUserAddAccountAgain() throws Exception {
TestUtil.displayTestTile(this, "test109ModifyUserAddAccountAgain");
// GIVEN
Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test109ModifyUserAddAccountAgain");
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
PrismObject<ShadowType> account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE);
account.setOid(null);
ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_JACK_OID, prismContext);
PrismReferenceValue accountRefVal = new PrismReferenceValue();
accountRefVal.setObject(account);
ReferenceDelta accountDelta = ReferenceDelta.createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
userDelta.addModification(accountDelta);
Collection<ObjectDelta<? extends ObjectType>> deltas = (Collection) MiscUtil.createCollection(userDelta);
try {
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
assert false : "Expected executeChanges operation to fail but it has obviously succeeded";
} catch (SchemaException e) {
// This is expected
// THEN
String message = e.getMessage();
assertMessageContains(message, "already contains account");
assertMessageContains(message, "default");
}
assertNoProvisioningScripts();
assertShadowFetchOperationCountIncrement(0);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionOutcome(OperationResultStatus.FATAL_ERROR);
assertSteadyResources();
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestModelServiceContract method test149ModifyUserJackDeleteAccount.
/**
* Assignment enforcement is set to POSITIVE for this test as it was for the previous test.
* Now we will explicitly delete the account.
*/
@Test
public void test149ModifyUserJackDeleteAccount() throws Exception {
final String TEST_NAME = "test149ModifyUserJackDeleteAccount";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_JACK_OID, prismContext);
PrismReferenceValue accountRefVal = new PrismReferenceValue();
accountRefVal.setOid(accountJackOid);
ReferenceDelta accountRefDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountJackOid);
userDelta.addModification(accountRefDelta);
ObjectDelta<ShadowType> accountDelta = ObjectDelta.createDeleteDelta(ShadowType.class, accountJackOid, prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta, accountDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
assertShadowFetchOperationCountIncrement(0);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
assertUserJack(userJack, "Jack Sparrow", "Jack", "Sparrow");
// Check accountRef
assertUserNoAccountRefs(userJack);
// Check is shadow is gone
assertNoShadow(accountJackOid);
// Check if dummy resource account is gone
assertNoDummyAccount("jack");
assertDummyScriptsDelete();
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.DELETE, ShadowType.class);
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
// Check notifications
notificationManager.setDisabled(true);
checkDummyTransportMessages("accountPasswordNotifier", 0);
checkDummyTransportMessages("userPasswordNotifier", 0);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 0);
checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 1);
checkDummyTransportMessages("simpleUserNotifier", 0);
checkDummyTransportMessages("simpleUserNotifier-ADD", 0);
assertScriptCompileIncrement(0);
assertSteadyResources();
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestModelServiceContract method test120AddAccount.
@Test
public void test120AddAccount() throws Exception {
TestUtil.displayTestTile(this, "test120AddAccount");
// GIVEN
Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test120AddAccount");
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
PrismObject<ShadowType> account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE);
ObjectDelta<ShadowType> accountDelta = ObjectDelta.createAddDelta(account);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(accountDelta);
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
assertShadowFetchOperationCountIncrement(0);
accountJackOid = accountDelta.getOid();
assertNotNull("No account OID in resulting delta", accountJackOid);
// Check accountRef (should be none)
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
assertUserJack(userJack);
UserType userJackType = userJack.asObjectable();
assertEquals("Unexpected number of accountRefs", 0, userJackType.getLinkRef().size());
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, null, result);
assertDummyAccountShadowRepo(accountShadow, accountJackOid, "jack");
assertEnableTimestampShadow(accountShadow, startTime, endTime);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
assertDummyAccountShadowModel(accountModel, accountJackOid, "jack", "Jack Sparrow");
assertEnableTimestampShadow(accountModel, startTime, endTime);
// Check account in dummy resource
assertDefaultDummyAccount("jack", "Jack Sparrow", true);
// The user is not associated with the account
assertDummyScriptsAdd(null, accountModel, getDummyResourceType());
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(1);
dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class);
// We cannot have OID in the request. The OID is not assigned yet at that stage.
dummyAuditService.assertTarget(accountShadow.getOid(), AuditEventStage.EXECUTION);
dummyAuditService.assertExecutionSuccess();
// Check notifications
notificationManager.setDisabled(true);
// there's no password for that account
checkDummyTransportMessages("accountPasswordNotifier", 0);
checkDummyTransportMessages("userPasswordNotifier", 0);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 1);
// account has no owner
checkDummyTransportMessages("simpleUserNotifier", 0);
checkDummyTransportMessages("simpleUserNotifier-ADD", 0);
assertSteadyResources();
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestUserTemplate method test204AddUserHerman.
/**
* MID-3186
*/
@Test
public void test204AddUserHerman() throws Exception {
final String TEST_NAME = "test204AddUserHerman";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<UserType> user = PrismTestUtil.parseObject(USER_HERMAN_FILE);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> userDelta = ObjectDelta.createAddDelta(user);
deltas.add(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_HERMAN_OID, null, task, result);
assertUser(userAfter, USER_HERMAN_OID, USER_HERMAN_USERNAME, USER_HERMAN_FULL_NAME, "Herman", "Toothrot");
PrismAsserts.assertNoItem(userAfter, UserType.F_DESCRIPTION);
PrismAsserts.assertPropertyValue(userAfter, UserType.F_TIMEZONE, "High Seas/Monkey Island");
assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID);
assertAssignedNoRole(userAfter);
assertAssignments(userAfter, 1);
UserType userAfterType = userAfter.asObjectable();
assertLinks(userAfter, 1);
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals("Wrong costCenter", "G001", userAfterType.getCostCenter());
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class TestUserTemplate method test201AddUserLargo.
@Test
public void test201AddUserLargo() throws Exception {
TestUtil.displayTestTile(this, "test201AddUserLargo");
// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + ".test201AddUserLargo");
// This simulates IMPORT to trigger the channel-limited mapping
task.setChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_IMPORT));
OperationResult result = task.getResult();
PrismObject<UserType> user = PrismTestUtil.parseObject(USER_LARGO_FILE);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> userDelta = ObjectDelta.createAddDelta(user);
deltas.add(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_LARGO_OID, null, task, result);
display("Largo after", userAfter);
assertUser(userAfter, USER_LARGO_OID, "largo", "Largo LaGrande", "Largo", "LaGrande");
// locality is null; the description comes from inbound mapping on dummy resource
// PrismAsserts.assertPropertyValue(userAfter, UserType.F_DESCRIPTION, "Came from null");
// TODO TEMPORARILY allowing value of "Imported user", because the inbound mapping is not applied because of
// the "locality" attribute is null (Skipping inbound for {...}location in Discr(RSD(account (default)
// @10000000-0000-0000-0000-000000000004)): Not a full shadow and account a priori delta exists, but
// doesn't have change for processed property.
//
// Either we fix this or recommend setting volatility=unpredictable for such situations.
PrismAsserts.assertPropertyValue(userAfter, UserType.F_DESCRIPTION, "Imported user");
assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID);
assertAssignedRole(userAfter, ROLE_PIRATE_OID);
assertAssignments(userAfter, 2);
UserType userAfterType = userAfter.asObjectable();
assertEquals("Unexpected number of accountRefs", 2, userAfterType.getLinkRef().size());
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals("Unexpected length of employeeNumber, maybe it was not generated?", GenerateExpressionEvaluator.DEFAULT_LENGTH, userAfterType.getEmployeeNumber().length());
}
Aggregations