Search in sources :

Example 31 with ResourceAttributeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.

the class AbstractEDirTest method test240ModifyAccountBarbossaPasswordAllowChangeFalse.

/**
 * passwordAllowChange is a boolean attribute
 */
@Test
public void test240ModifyAccountBarbossaPasswordAllowChangeFalse() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(ShadowType.class, accountBarbossaOid);
    QName attrQName = new QName(MidPointConstants.NS_RI, "passwordAllowChange");
    // noinspection unchecked
    ResourceAttributeDefinition<Boolean> attrDef = (ResourceAttributeDefinition<Boolean>) accountDefinition.findAttributeDefinition(attrQName);
    PropertyDelta<Boolean> attrDelta = prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, Boolean.FALSE);
    delta.addModification(attrDelta);
    // WHEN
    when();
    modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result);
    // THEN
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
    assertAttribute(entry, "passwordAllowChange", "FALSE");
    PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
    String shadowOid = getSingleLinkOid(user);
    assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);
    PrismObject<ShadowType> shadow = getObject(ShadowType.class, shadowOid);
    display("Shadow after", shadow);
    assertPasswordAllowChange(shadow, false);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Entry(org.apache.directory.api.ldap.model.entry.Entry) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) Test(org.testng.annotations.Test)

Example 32 with ResourceAttributeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.

the class AbstractLdapConnTest method test213ModifyAccountBarbossaAddTitleDuplicateCapitalized.

/**
 * Make another duplicate modification. Add a title value that is already there,
 * but with a different capitalization.
 */
@Test
public void test213ModifyAccountBarbossaAddTitleDuplicateCapitalized() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(ShadowType.class, accountBarbossaOid);
    QName attrQName = new QName(MidPointConstants.NS_RI, "title");
    // noinspection unchecked
    ResourceAttributeDefinition<String> attrDef = (ResourceAttributeDefinition<String>) accountDefinition.findAttributeDefinition(attrQName);
    PropertyDelta<String> attrDelta = prismContext.deltaFactory().property().createModificationAddProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, "CAPTAIN");
    delta.addModification(attrDelta);
    // WHEN
    when();
    modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result);
    // THEN
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
    assertAttribute(entry, "title", "Captain");
    PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
    String shadowOid = getSingleLinkOid(user);
    assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);
    assertLdapConnectorReasonableInstances();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.apache.directory.api.ldap.model.entry.Entry) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Aggregations

ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)32 QName (javax.xml.namespace.QName)19 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)8 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)7 ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 Task (com.evolveum.midpoint.task.api.Task)7 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)6 ArrayList (java.util.ArrayList)6 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)5 Entry (org.apache.directory.api.ldap.model.entry.Entry)5 Test (org.testng.annotations.Test)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)3 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)3 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)2 Containerable (com.evolveum.midpoint.prism.Containerable)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2