use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestStrangeCases method test212ModifyUserJackBrokenSchemaViolationPolyString.
/**
* Cause schema violation on the account during a provisioning operation. This should fail
* the operation, but other operations should proceed and the account should definitelly NOT
* be unlinked.
* MID-2134
*/
@Test
public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Exception {
final String TEST_NAME = "test212ModifyUserJackBrokenSchemaViolationPolyString";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestStrangeCases.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
getDummyResource().setModifyBreakMode(BreakMode.SCHEMA);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, new PolyString("Cpt. Jack Sparrow", null));
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display("Result", result);
TestUtil.assertPartialError(result);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Cpt. Jack Sparrow");
assertLinks(userJack, 2);
String accountJackRedOidAfter = getLinkRefOid(userJack, RESOURCE_DUMMY_RED_OID);
assertNotNull(accountJackRedOidAfter);
// The change was not propagated here because of schema violation error
assertDefaultDummyAccount("jack", "Jack Sparrow", true);
// The change should be propagated here normally
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, "jack", "Cpt. Jack Sparrow", true);
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestStrangeCases method test200ModifyUserJackBrokenAccountRefAndPolyString.
/**
* User with linkRef that points nowhere.
* MID-2134
*/
@Test
public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exception {
final String TEST_NAME = "test200ModifyUserJackBrokenAccountRefAndPolyString";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestStrangeCases.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
dummyAuditService.clear();
addBrokenAccountRef(USER_JACK_OID);
// Make sure that the polystring does not have correct norm value
PolyString fullNamePolyString = new PolyString("Magnificent Captain Jack Sparrow", null);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, fullNamePolyString);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result, 2);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Magnificent Captain Jack Sparrow");
assertAccounts(USER_JACK_OID, 0);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertExecutionOutcome(OperationResultStatus.HANDLED_ERROR);
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestScriptHooks method test110JackAddOrganization.
@Test
public void test110JackAddOrganization() throws Exception {
final String TEST_NAME = "test110JackAddOrganization";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestScriptHooks.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
dummyAuditService.clear();
StaticHookRecorder.reset();
// WHEN
modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATION, task, result, new PolyString("Pirate Brethren"));
// THEN
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);
display("Shadow (repo)", accountShadow);
assertAccountShadowRepo(accountShadow, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, resourceDummyHookType);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
display("Shadow (model)", accountModel);
assertAccountShadowModel(accountModel, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, resourceDummyHookType);
// Check account in dummy resource
assertDummyAccount(RESOURCE_DUMMY_HOOK_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);
PrismObject<OrgType> brethrenOrg = searchObjectByName(OrgType.class, "Pirate Brethren", task, result);
assertNotNull("Brethren org was not created", brethrenOrg);
display("Brethren org", brethrenOrg);
assertAssignedOrg(userJack, brethrenOrg);
display("StaticHookRecorder", StaticHookRecorder.dump());
StaticHookRecorder.assertInvocationCount("org", 1);
StaticHookRecorder.assertInvocationCount("foo", 10);
StaticHookRecorder.assertInvocationCount("bar", 10);
StaticHookRecorder.assertInvocationCount("bar-user", 1);
// TODO
// // Check audit
// display("Audit", dummyAuditService);
// dummyAuditService.assertRecords(4);
// dummyAuditService.assertAnyRequestDeltas();
// dummyAuditService.assertExecutionDeltas(1,1);
// dummyAuditService.asserHasDelta(1,ChangeType.ADD, OrgType.class);
// dummyAuditService.assertExecutionDeltas(3,1);
// dummyAuditService.asserHasDelta(3,ChangeType.MODIFY, UserType.class);
// dummyAuditService.assertExecutionSuccess();
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class SearchIterativeTest method createObjects.
protected void createObjects() throws com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException, com.evolveum.midpoint.util.exception.SchemaException {
OperationResult result = new OperationResult("add objects");
for (int i = BASE; i < BASE + COUNT; i++) {
UserType user = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).instantiate().asObjectable();
user.setOid("user-" + i + "-00");
user.setName(new PolyStringType(new PolyString("user-" + i)));
user.setCostCenter(String.valueOf(i));
repositoryService.addObject(user.asPrismObject(), null, result);
}
result.recomputeStatus();
assertTrue(result.isSuccess());
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class RAnyConverterStaticTest method testUserFullnamePolyString.
@Test
public void testUserFullnamePolyString() throws Exception {
Session session = getFactory().openSession();
ItemDefinition def = getDefinition(UserType.class, UserType.F_FULL_NAME);
AssertJUnit.assertNotNull("Definition not found for " + UserType.F_FULL_NAME, def);
Element value = DOMUtil.createElement(DOMUtil.getDocument(), UserType.F_FULL_NAME);
Element orig = DOMUtil.createElement(value.getOwnerDocument(), new QName(NS_T, "orig"));
orig.setTextContent("john example");
Element norm = DOMUtil.createElement(value.getOwnerDocument(), new QName(NS_T, "norm"));
norm.setTextContent("john example");
value.appendChild(orig);
value.appendChild(norm);
Object realValue = RAnyConverter.getRealRepoValue(def, value);
AssertJUnit.assertEquals(new PolyString("john example", "john example"), realValue);
session.close();
}
Aggregations