Search in sources :

Example 91 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class DummyConnectorLegacyUpdate method addAttributeValues.

/**
 * {@inheritDoc}
 */
@Override
public Uid addAttributeValues(ObjectClass objectClass, Uid uid, Set<Attribute> valuesToAdd, OperationOptions options) {
    validate(objectClass);
    validate(uid);
    try {
        if (ObjectClass.ACCOUNT.is(objectClass.getObjectClassValue())) {
            DummyAccount account;
            if (configuration.isUidBoundToName()) {
                account = resource.getAccountByUsername(uid.getUidValue());
            } else if (configuration.isUidSeparateFromName()) {
                account = resource.getAccountById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (account == null) {
                throw new UnknownUidException("Account with UID " + uid + " does not exist on resource");
            }
            applyModifyMetadata(account, options);
            for (Attribute attr : valuesToAdd) {
                if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                    if (account.getPassword() != null) {
                        throw new InvalidAttributeValueException("Attempt to add value for password while password is already set");
                    }
                    changePassword(account, attr);
                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new InvalidAttributeValueException("Attempt to add value for enable attribute");
                } else if (PredefinedAttributes.AUXILIARY_OBJECT_CLASS_NAME.equalsIgnoreCase(attr.getName())) {
                    account.addAuxiliaryObjectClassNames(attr.getValue());
                } else {
                    String name = attr.getName();
                    try {
                        account.addAttributeValues(name, attr.getValue());
                        LOG.ok("Added attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), account, account.getAttributeValues(name, Object.class));
                    } catch (SchemaViolationException e) {
                        // The framework should deal with it ... somehow
                        throw new InvalidAttributeValueException(e.getMessage(), e);
                    }
                }
            }
        } else if (ObjectClass.GROUP.is(objectClass.getObjectClassValue())) {
            DummyGroup group;
            if (configuration.isUidBoundToName()) {
                group = resource.getGroupByName(uid.getUidValue());
            } else if (configuration.isUidSeparateFromName()) {
                group = resource.getGroupById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (group == null) {
                throw new UnknownUidException("Group with UID " + uid + " does not exist on resource");
            }
            applyModifyMetadata(group, options);
            for (Attribute attr : valuesToAdd) {
                if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                    throw new InvalidAttributeValueException("Attempt to change password on group");
                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new InvalidAttributeValueException("Attempt to add value for enable attribute");
                } else {
                    String name = attr.getName();
                    List<Object> values = attr.getValue();
                    if (attr.is(DummyGroup.ATTR_MEMBERS_NAME) && values != null && configuration.getUpCaseName()) {
                        List<Object> newValues = new ArrayList<>(values.size());
                        for (Object val : values) {
                            newValues.add(StringUtils.upperCase((String) val));
                        }
                        values = newValues;
                    }
                    try {
                        group.addAttributeValues(name, values);
                        LOG.ok("Added attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), group, group.getAttributeValues(name, Object.class));
                    } catch (SchemaViolationException e) {
                        // The framework should deal with it ... somehow
                        throw new InvalidAttributeValueException(e.getMessage(), e);
                    }
                }
            }
        } else if (objectClass.is(OBJECTCLASS_PRIVILEGE_NAME)) {
            DummyPrivilege priv;
            if (configuration.isUidBoundToName()) {
                priv = resource.getPrivilegeByName(uid.getUidValue());
            } else if (configuration.isUidSeparateFromName()) {
                priv = resource.getPrivilegeById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (priv == null) {
                throw new UnknownUidException("Privilege with UID " + uid + " does not exist on resource");
            }
            applyModifyMetadata(priv, options);
            for (Attribute attr : valuesToAdd) {
                if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                    throw new InvalidAttributeValueException("Attempt to change password on privilege");
                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new InvalidAttributeValueException("Attempt to add value for enable attribute");
                } else {
                    String name = attr.getName();
                    try {
                        priv.addAttributeValues(name, attr.getValue());
                        LOG.ok("Added attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), priv, priv.getAttributeValues(name, Object.class));
                    } catch (SchemaViolationException e) {
                        // The framework should deal with it ... somehow
                        throw new InvalidAttributeValueException(e.getMessage(), e);
                    }
                }
            }
        } else if (objectClass.is(OBJECTCLASS_ORG_NAME)) {
            DummyOrg org;
            if (configuration.isUidBoundToName()) {
                org = resource.getOrgByName(uid.getUidValue());
            } else if (configuration.isUidSeparateFromName()) {
                org = resource.getOrgById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (org == null) {
                throw new UnknownUidException("Org with UID " + uid + " does not exist on resource");
            }
            applyModifyMetadata(org, options);
            for (Attribute attr : valuesToAdd) {
                if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                    throw new InvalidAttributeValueException("Attempt to change password on org");
                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new InvalidAttributeValueException("Attempt to add value for enable org");
                } else {
                    String name = attr.getName();
                    try {
                        org.addAttributeValues(name, attr.getValue());
                        LOG.ok("Added attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), org, org.getAttributeValues(name, Object.class));
                    } catch (SchemaViolationException e) {
                        // The framework should deal with it ... somehow
                        throw new InvalidAttributeValueException(e.getMessage(), e);
                    }
                }
            }
        } else {
            throw new ConnectorException("Unknown object class " + objectClass);
        }
    } catch (ConnectException e) {
        LOG.info("addAttributeValues::exception " + e);
        throw new ConnectionFailedException(e.getMessage(), e);
    } catch (FileNotFoundException e) {
        LOG.info("addAttributeValues::exception " + e);
        throw new ConnectorIOException(e.getMessage(), e);
    } catch (SchemaViolationException e) {
        LOG.info("addAttributeValues::exception " + e);
        throw new InvalidAttributeValueException(e.getMessage(), e);
    } catch (ConflictException e) {
        LOG.info("addAttributeValues::exception " + e);
        throw new AlreadyExistsException(e);
    } catch (InterruptedException e) {
        LOG.info("addAttributeValues::exception " + e);
        throw new OperationTimeoutException(e);
    }
    return uid;
}
Also used : ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) AlreadyExistsException(org.identityconnectors.framework.common.exceptions.AlreadyExistsException) ObjectAlreadyExistsException(com.evolveum.icf.dummy.resource.ObjectAlreadyExistsException) ConflictException(com.evolveum.icf.dummy.resource.ConflictException) OperationTimeoutException(org.identityconnectors.framework.common.exceptions.OperationTimeoutException) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) InvalidAttributeValueException(org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) UnknownUidException(org.identityconnectors.framework.common.exceptions.UnknownUidException) SchemaViolationException(com.evolveum.icf.dummy.resource.SchemaViolationException) DummyPrivilege(com.evolveum.icf.dummy.resource.DummyPrivilege) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) DummyOrg(com.evolveum.icf.dummy.resource.DummyOrg) ConnectionFailedException(org.identityconnectors.framework.common.exceptions.ConnectionFailedException) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) ConnectException(java.net.ConnectException)

Example 92 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class DummyConnectorLegacyUpdate method removeAttributeValues.

/**
 * {@inheritDoc}
 */
@Override
public Uid removeAttributeValues(ObjectClass objectClass, Uid uid, Set<Attribute> valuesToRemove, OperationOptions options) {
    validate(objectClass);
    validate(uid);
    try {
        if (ObjectClass.ACCOUNT.is(objectClass.getObjectClassValue())) {
            DummyAccount account;
            if (configuration.isUidBoundToName()) {
                account = resource.getAccountByUsername(uid.getUidValue());
            } else if (configuration.isUidSeparateFromName()) {
                account = resource.getAccountById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (account == null) {
                throw new UnknownUidException("Account with UID " + uid + " does not exist on resource");
            }
            applyModifyMetadata(account, options);
            for (Attribute attr : valuesToRemove) {
                if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                    throw new UnsupportedOperationException("Removing password value is not supported");
                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new InvalidAttributeValueException("Attempt to remove value from enable attribute");
                } else if (PredefinedAttributes.AUXILIARY_OBJECT_CLASS_NAME.equalsIgnoreCase(attr.getName())) {
                    account.deleteAuxiliaryObjectClassNames(attr.getValue());
                } else {
                    String name = attr.getName();
                    try {
                        account.removeAttributeValues(name, attr.getValue());
                        LOG.ok("Removed attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), account, account.getAttributeValues(name, Object.class));
                    } catch (SchemaViolationException e) {
                        // The framework should deal with it ... somehow
                        throw new InvalidAttributeValueException(e.getMessage(), e);
                    }
                }
            }
        } else if (ObjectClass.GROUP.is(objectClass.getObjectClassValue())) {
            DummyGroup group;
            if (configuration.isUidBoundToName()) {
                group = resource.getGroupByName(uid.getUidValue());
            } else if (configuration.isUidSeparateFromName()) {
                group = resource.getGroupById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (group == null) {
                throw new UnknownUidException("Group with UID " + uid + " does not exist on resource");
            }
            applyModifyMetadata(group, options);
            for (Attribute attr : valuesToRemove) {
                if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                    throw new InvalidAttributeValueException("Attempt to change password on group");
                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new InvalidAttributeValueException("Attempt to remove value from enable attribute");
                } else {
                    String name = attr.getName();
                    List<Object> values = attr.getValue();
                    if (attr.is(DummyGroup.ATTR_MEMBERS_NAME) && values != null && configuration.getUpCaseName()) {
                        List<Object> newValues = new ArrayList<>(values.size());
                        for (Object val : values) {
                            newValues.add(StringUtils.upperCase((String) val));
                        }
                        values = newValues;
                    }
                    try {
                        group.removeAttributeValues(name, values);
                        LOG.ok("Removed attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), group, group.getAttributeValues(name, Object.class));
                    } catch (SchemaViolationException e) {
                        // The framework should deal with it ... somehow
                        throw new InvalidAttributeValueException(e.getMessage(), e);
                    }
                }
            }
        } else if (objectClass.is(OBJECTCLASS_PRIVILEGE_NAME)) {
            DummyPrivilege priv;
            if (configuration.isUidBoundToName()) {
                priv = resource.getPrivilegeByName(uid.getUidValue());
            } else if (configuration.isUidSeparateFromName()) {
                priv = resource.getPrivilegeById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (priv == null) {
                throw new UnknownUidException("Privilege with UID " + uid + " does not exist on resource");
            }
            applyModifyMetadata(priv, options);
            for (Attribute attr : valuesToRemove) {
                if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                    throw new InvalidAttributeValueException("Attempt to change password on privilege");
                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new InvalidAttributeValueException("Attempt to remove value from enable attribute");
                } else {
                    String name = attr.getName();
                    try {
                        priv.removeAttributeValues(name, attr.getValue());
                        LOG.ok("Removed attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), priv, priv.getAttributeValues(name, Object.class));
                    } catch (SchemaViolationException e) {
                        // The framework should deal with it ... somehow
                        throw new InvalidAttributeValueException(e.getMessage(), e);
                    }
                }
            }
        } else if (objectClass.is(OBJECTCLASS_ORG_NAME)) {
            DummyOrg org;
            if (configuration.isUidBoundToName()) {
                org = resource.getOrgByName(uid.getUidValue());
            } else if (configuration.isUidSeparateFromName()) {
                org = resource.getOrgById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (org == null) {
                throw new UnknownUidException("Org with UID " + uid + " does not exist on resource");
            }
            applyModifyMetadata(org, options);
            for (Attribute attr : valuesToRemove) {
                if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                    throw new InvalidAttributeValueException("Attempt to change password on org");
                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new InvalidAttributeValueException("Attempt to remove value from enable org");
                } else {
                    String name = attr.getName();
                    try {
                        org.removeAttributeValues(name, attr.getValue());
                        LOG.ok("Removed attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), org, org.getAttributeValues(name, Object.class));
                    } catch (SchemaViolationException e) {
                        // The framework should deal with it ... somehow
                        throw new InvalidAttributeValueException(e.getMessage(), e);
                    }
                }
            }
        } else {
            throw new ConnectorException("Unknown object class " + objectClass);
        }
    } catch (ConnectException e) {
        LOG.info("removeAttributeValues::exception " + e);
        throw new ConnectionFailedException(e.getMessage(), e);
    } catch (FileNotFoundException e) {
        LOG.info("removeAttributeValues::exception " + e);
        throw new ConnectorIOException(e.getMessage(), e);
    } catch (SchemaViolationException e) {
        LOG.info("removeAttributeValues::exception " + e);
        throw new InvalidAttributeValueException(e.getMessage(), e);
    } catch (ConflictException e) {
        LOG.info("removeAttributeValues::exception " + e);
        throw new AlreadyExistsException(e);
    } catch (InterruptedException e) {
        LOG.info("removeAttributeValues::exception " + e);
        throw new OperationTimeoutException(e);
    }
    return uid;
}
Also used : ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) AlreadyExistsException(org.identityconnectors.framework.common.exceptions.AlreadyExistsException) ObjectAlreadyExistsException(com.evolveum.icf.dummy.resource.ObjectAlreadyExistsException) ConflictException(com.evolveum.icf.dummy.resource.ConflictException) OperationTimeoutException(org.identityconnectors.framework.common.exceptions.OperationTimeoutException) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) InvalidAttributeValueException(org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) UnknownUidException(org.identityconnectors.framework.common.exceptions.UnknownUidException) SchemaViolationException(com.evolveum.icf.dummy.resource.SchemaViolationException) DummyPrivilege(com.evolveum.icf.dummy.resource.DummyPrivilege) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) DummyOrg(com.evolveum.icf.dummy.resource.DummyOrg) ConnectionFailedException(org.identityconnectors.framework.common.exceptions.ConnectionFailedException) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) ConnectException(java.net.ConnectException)

Example 93 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class AbstractBasicDummyTest method test106GetModifiedAccountWill.

/**
 * Make a native modification to an account and read it again. Make sure that
 * fresh data are returned - even though caching may be in effect.
 * MID-3481
 */
@Test
public void test106GetModifiedAccountWill() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = createOperationResult();
    rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
    DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
    accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
    accountWill.setEnabled(false);
    XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
    when();
    PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
    then();
    assertSuccess(result);
    assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);
    XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
    display("Retrieved account shadow", shadow);
    assertNotNull("No dummy account", shadow);
    assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
    assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
    assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE");
    assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
    Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow);
    assertEquals("Unexpected number of attributes", 7, attributes.size());
    PrismObject<ShadowType> shadowRepo = getShadowRepo(ACCOUNT_WILL_OID);
    checkRepoAccountShadowWillBasic(shadowRepo, startTs, endTs, null);
    assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
    assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
    assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "sword", "love");
    assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
    assertRepoShadowCacheActivation(shadowRepo, ActivationStatusType.DISABLED);
    assertRepoShadowCredentials(shadowRepo, ACCOUNT_WILL_PASSWORD);
    checkUniqueness(shadow);
    assertCachingMetadata(shadow, false, startTs, endTs);
    assertSteadyResource();
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 94 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestDummyCaching method test107CSkipCachingForIncompleteAttributes.

/**
 * Incomplete attributes should not be cached.
 */
@Test
public void test107CSkipCachingForIncompleteAttributes() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = createOperationResult();
    rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
    DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
    accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, null);
    accountWill.getAttributeDefinition(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME).setReturnedAsIncomplete(true);
    accountWill.setEnabled(true);
    try {
        XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
        // WHEN
        when();
        PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
        // THEN
        then();
        assertSuccess(result);
        assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);
        display("Retrieved account shadow", shadow);
        assertNotNull("No dummy account", shadow);
        assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
        assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME);
        Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow);
        assertEquals("Unexpected number of attributes", 7, attributes.size());
        PrismObject<ShadowType> shadowRepo = getShadowRepo(ACCOUNT_WILL_OID);
        checkRepoAccountShadowWillBasic(shadowRepo, null, startTs, null);
        assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
        assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
        assertRepoShadowCachedAttributeValue(shadowRepo, DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "sword", "love");
        assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
        assertRepoShadowCacheActivation(shadowRepo, ActivationStatusType.ENABLED);
        checkUniqueness(shadow);
        assertCachingMetadata(shadow, false, null, startTs);
        assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);
        assertSteadyResource();
    } finally {
        // cleanup the state to allow other tests to pass
        accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Interceptor");
        accountWill.getAttributeDefinition(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME).setReturnedAsIncomplete(false);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceAttribute(com.evolveum.midpoint.schema.processor.ResourceAttribute) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 95 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestDummyCaching method test910CacheMultivaluedAttribute.

/**
 * Checks whether multivalued attributes are correctly cached, especially when deleting values.
 * See MID-7162.
 */
@Test
public void test910CacheMultivaluedAttribute() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    DummyAccount will = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    updateAndCheckMultivaluedAttribute(will, false, "initial values", Arrays.asList("sword", "love"), task, result);
    updateAndCheckMultivaluedAttribute(will, false, "replacing by w1-w3", Arrays.asList("w1", "w2", "w3"), task, result);
    updateAndCheckMultivaluedAttribute(will, false, "adding w4", Arrays.asList("w1", "w2", "w3", "w4"), task, result);
    updateAndCheckMultivaluedAttribute(will, false, "removing w1", Arrays.asList("w2", "w3", "w4"), task, result);
    updateAndCheckMultivaluedAttribute(will, false, "removing all", Collections.emptyList(), task, result);
    updateAndCheckMultivaluedAttribute(will, true, "adding w1-w3", Arrays.asList("w1", "w2", "w3"), task, result);
    updateAndCheckMultivaluedAttribute(will, true, "adding w4", Arrays.asList("w1", "w2", "w3", "w4"), task, result);
    updateAndCheckMultivaluedAttribute(will, true, "removing w1", Arrays.asList("w2", "w3", "w4"), task, result);
    updateAndCheckMultivaluedAttribute(will, true, "removing all", Collections.emptyList(), task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Aggregations

DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)261 Test (org.testng.annotations.Test)211 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)158 Task (com.evolveum.midpoint.task.api.Task)152 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)40 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)40 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)24 DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 ArrayList (java.util.ArrayList)19 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)18 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)16 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)14 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)12 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)12 SchemaViolationException (com.evolveum.icf.dummy.resource.SchemaViolationException)10 QName (javax.xml.namespace.QName)10 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)9 DummyOrg (com.evolveum.icf.dummy.resource.DummyOrg)9