use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TestModelServiceContract method test210AddUserMorganWithAssignment.
@Test
public void test210AddUserMorganWithAssignment() throws Exception {
final String TEST_NAME = "test210AddUserMorganWithAssignment";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.FULL);
PrismObject<UserType> user = PrismTestUtil.parseObject(new File(TEST_DIR, "user-morgan-assignment-dummy.xml"));
ObjectDelta<UserType> userDelta = ObjectDelta.createAddDelta(user);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
assertShadowFetchOperationCountIncrement(0);
PrismObject<UserType> userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result);
display("User morgan after", userMorgan);
UserType userMorganType = userMorgan.asObjectable();
AssignmentType assignmentType = assertAssignedAccount(userMorgan, RESOURCE_DUMMY_OID);
assertLinks(userMorgan, 1);
ObjectReferenceType accountRefType = userMorganType.getLinkRef().get(0);
String accountOid = accountRefType.getOid();
assertFalse("No accountRef oid", StringUtils.isBlank(accountOid));
assertCreateMetadata(userMorgan, startTime, endTime);
assertCreateMetadata(assignmentType, startTime, endTime);
assertEncryptedUserPassword(userMorgan, "rum");
assertPasswordMetadata(userMorgan, true, startTime, endTime);
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
assertDummyAccountShadowRepo(accountShadow, accountOid, "morgan");
assertEnableTimestampShadow(accountShadow, startTime, endTime);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
assertDummyAccountShadowModel(accountModel, accountOid, "morgan", "Sir Henry Morgan");
assertEnableTimestampShadow(accountModel, startTime, endTime);
// Check account in dummy resource
assertDefaultDummyAccount("morgan", "Sir Henry Morgan", true);
assertDummyScriptsAdd(userMorgan, accountModel, getDummyResourceType());
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(3);
dummyAuditService.assertHasDelta(ChangeType.ADD, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class);
dummyAuditService.assertTarget(USER_MORGAN_OID);
dummyAuditService.assertExecutionSuccess();
// Check notifications
notificationManager.setDisabled(true);
checkDummyTransportMessages("accountPasswordNotifier", 1);
checkDummyTransportMessages("userPasswordNotifier", 1);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 0);
checkDummyTransportMessages("simpleUserNotifier", 1);
checkDummyTransportMessages("simpleUserNotifier-ADD", 1);
checkDummyTransportMessages("simpleUserNotifier-DELETE", 0);
assertSteadyResources();
}
use of javax.xml.datatype.XMLGregorianCalendar 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 javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TestUserTemplate method test800Kaboom.
/**
* Move the time to the future. See if the time-based mapping in user template is properly recomputed.
*/
@Test
public void test800Kaboom() throws Exception {
final String TEST_NAME = "test800Kaboom";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
importObjectFromFile(TASK_TRIGGER_SCANNER_FILE);
waitForTaskStart(TASK_TRIGGER_SCANNER_OID, false);
XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
now.add(XmlTypeConverter.createDuration("P1M1D"));
clock.override(now);
// WHEN
waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true);
// THEN
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
PrismAsserts.assertPropertyValue(userJack, UserType.F_ADDITIONAL_NAME, PrismTestUtil.createPolyString("Kaboom!"));
assertNoTrigger(userJack);
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TestUserTemplate method test100ModifyUserGivenName.
@Test
public void test100ModifyUserGivenName() throws Exception {
final String TEST_NAME = "test100ModifyUserGivenName";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, prismContext, new PolyString("Jackie"));
deltas.add(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
assertUserJack(userJack, "Jackie Sparrow", "Jackie", "Sparrow");
PrismAsserts.assertPropertyValue(userJack, UserType.F_DESCRIPTION, "Where's the rum?");
assertAssignedAccount(userJack, RESOURCE_DUMMY_BLUE_OID);
assertAssignedNoRole(userJack);
assertAssignments(userJack, 1);
result.computeStatus();
TestUtil.assertSuccess(result);
UserType userJackType = userJack.asObjectable();
assertEquals("Unexpected number of accountRefs", 1, userJackType.getLinkRef().size());
PrismAsserts.assertPropertyValue(userJack, UserType.F_ADDITIONAL_NAME, PrismTestUtil.createPolyString("Jackie"));
XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
XMLGregorianCalendar monthLater = XmlTypeConverter.addDuration(now, XmlTypeConverter.createDuration("P1M"));
assertTrigger(userJack, RecomputeTriggerHandler.HANDLER_URI, monthLater, 100000L);
// original value of 0 should be gone now, because the corresponding item in user template is marked as non-tolerant
PrismAsserts.assertPropertyValue(userJack.findContainer(UserType.F_EXTENSION), PIRACY_BAD_LUCK, 123L, 456L);
// timezone mapping is normal-strength. The source (locality) has not changed.
// The mapping should not be activated (MID-3040)
PrismAsserts.assertNoItem(userJack, UserType.F_TIMEZONE);
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TestRoleEntitlement method test161ModifyRole.
/**
* Modify role property. The modification should be reflected to group.
*/
@Test
public void test161ModifyRole() throws Exception {
final String TEST_NAME = "test161ModifyRole";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestRoleEntitlement.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
dummyAuditService.clear();
prepareNotifications();
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationReplaceProperty(RoleType.class, ROLE_PIRATE_OID, RoleType.F_DESCRIPTION, prismContext, ROLE_PIRATE_DESCRIPTION);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(roleDelta);
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
PrismObject<RoleType> role = getRole(ROLE_PIRATE_OID);
display("Role after change execution", role);
assertLinks(role, 1);
groupOid = getSingleLinkOid(role);
// Check shadow
PrismObject<ShadowType> shadow = repositoryService.getObject(ShadowType.class, groupOid, null, result);
assertDummyGroupShadowRepo(shadow, groupOid, GROUP_PIRATE_DUMMY_NAME);
// assertEnableTimestampShadow(shadow, startTime, endTime);
// Check group
PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, groupOid, null, task, result);
display("Entitlement shadow after", shadowModel);
assertDummyGroupShadowModel(shadowModel, groupOid, GROUP_PIRATE_DUMMY_NAME);
// assertEnableTimestampShadow(shadowModel, startTime, endTime);
// Check group in dummy resource
assertDummyGroup(GROUP_PIRATE_DUMMY_NAME, ROLE_PIRATE_DESCRIPTION);
// Just to be on a safe side, this is uppercase
assertNoDummyGroup(ROLE_PIRATE_NAME);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, RoleType.class);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertTarget(ROLE_PIRATE_OID);
dummyAuditService.assertExecutionSuccess();
}
Aggregations