Search in sources :

Example 86 with PolyString

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 87 with PolyString

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 88 with PolyString

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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 89 with PolyString

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());
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 90 with PolyString

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();
}
Also used : QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Aggregations

PolyString (com.evolveum.midpoint.prism.polystring.PolyString)168 Test (org.testng.annotations.Test)103 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)90 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)67 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)53 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)44 Task (com.evolveum.midpoint.task.api.Task)41 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)27 PrismObject (com.evolveum.midpoint.prism.PrismObject)21 QName (javax.xml.namespace.QName)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)16 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)15 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)12 ArrayList (java.util.ArrayList)12 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)10 File (java.io.File)10 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)8 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)8