Search in sources :

Example 21 with ObjectClassComplexTypeDefinition

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

the class AbstractIntegrationTest method assertShadowCommon.

protected void assertShadowCommon(PrismObject<ShadowType> shadow, String oid, String username, ResourceType resourceType, QName objectClass, final MatchingRule<String> nameMatchingRule, boolean requireNormalizedIdentfiers, boolean useMatchingRuleForShadowName) throws SchemaException {
    assertShadow(shadow);
    if (oid != null) {
        assertEquals("Shadow OID mismatch (prism)", oid, shadow.getOid());
    }
    ShadowType resourceObjectShadowType = shadow.asObjectable();
    if (oid != null) {
        assertEquals("Shadow OID mismatch (jaxb)", oid, resourceObjectShadowType.getOid());
    }
    assertEquals("Shadow objectclass", objectClass, resourceObjectShadowType.getObjectClass());
    assertEquals("Shadow resourceRef OID", resourceType.getOid(), shadow.asObjectable().getResourceRef().getOid());
    PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    assertNotNull("Null attributes in shadow for " + username, attributesContainer);
    assertFalse("Empty attributes in shadow for " + username, attributesContainer.isEmpty());
    if (useMatchingRuleForShadowName) {
        MatchingRule<PolyString> polyMatchingRule = new MatchingRule<PolyString>() {

            @Override
            public QName getName() {
                return nameMatchingRule.getName();
            }

            @Override
            public boolean isSupported(QName xsdType) {
                return nameMatchingRule.isSupported(xsdType);
            }

            @Override
            public boolean match(PolyString a, PolyString b) throws SchemaException {
                return nameMatchingRule.match(a.getOrig(), b.getOrig());
            }

            @Override
            public boolean matchRegex(PolyString a, String regex) throws SchemaException {
                return nameMatchingRule.matchRegex(a.getOrig(), regex);
            }

            @Override
            public PolyString normalize(PolyString original) throws SchemaException {
                return new PolyString(nameMatchingRule.normalize(original.getOrig()));
            }
        };
        PrismAsserts.assertPropertyValueMatch(shadow, ShadowType.F_NAME, polyMatchingRule, PrismTestUtil.createPolyString(username));
    } else {
        PrismAsserts.assertPropertyValue(shadow, ShadowType.F_NAME, PrismTestUtil.createPolyString(username));
    }
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(objectClass);
    if (ocDef.getSecondaryIdentifiers().isEmpty()) {
        ResourceAttributeDefinition idDef = ocDef.getPrimaryIdentifiers().iterator().next();
        PrismProperty<String> idProp = attributesContainer.findProperty(idDef.getName());
        assertNotNull("No primary identifier (" + idDef.getName() + ") attribute in shadow for " + username, idProp);
        if (nameMatchingRule == null) {
            assertEquals("Unexpected primary identifier in shadow for " + username, username, idProp.getRealValue());
        } else {
            if (requireNormalizedIdentfiers) {
                assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule.normalize(username), idProp.getRealValue());
            } else {
                PrismAsserts.assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule, username, idProp.getRealValue());
            }
        }
    } else {
        ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next();
        PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName());
        assertNotNull("No secondary identifier (" + idSecDef.getName() + ") attribute in shadow for " + username, idProp);
        if (nameMatchingRule == null) {
            assertEquals("Unexpected secondary identifier in shadow for " + username, username, idProp.getRealValue());
        } else {
            if (requireNormalizedIdentfiers) {
                assertEquals("Unexpected secondary identifier in shadow for " + username, nameMatchingRule.normalize(username), idProp.getRealValue());
            } else {
                PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + username, nameMatchingRule, username, idProp.getRealValue());
            }
        }
    }
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) QName(javax.xml.namespace.QName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Containerable(com.evolveum.midpoint.prism.Containerable) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule)

Example 22 with ObjectClassComplexTypeDefinition

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

the class IntegrationTestTools method assertIcfResourceSchemaSanity.

public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, ResourceType resourceType) {
    assertNotNull("No resource schema in " + resourceType, resourceSchema);
    QName objectClassQname = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass");
    ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(objectClassQname);
    assertNotNull("No object class definition for " + objectClassQname + " in resource schema", accountDefinition);
    ObjectClassComplexTypeDefinition accountDef = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    assertTrue("Mismatched account definition: " + accountDefinition + " <-> " + accountDef, accountDefinition == accountDef);
    assertNotNull("No object class definition " + objectClassQname, accountDefinition);
    assertEquals("Object class " + objectClassQname + " is not account", ShadowKindType.ACCOUNT, accountDefinition.getKind());
    assertTrue("Object class " + objectClassQname + " is not default account", accountDefinition.isDefaultInAKind());
    assertFalse("Object class " + objectClassQname + " is empty", accountDefinition.isEmpty());
    assertFalse("Object class " + objectClassQname + " is empty", accountDefinition.isIgnored());
    Collection<? extends ResourceAttributeDefinition> identifiers = accountDefinition.getPrimaryIdentifiers();
    assertNotNull("Null identifiers for " + objectClassQname, identifiers);
    assertFalse("Empty identifiers for " + objectClassQname, identifiers.isEmpty());
    ResourceAttributeDefinition uidAttributeDefinition = accountDefinition.findAttributeDefinition(SchemaTestConstants.ICFS_UID);
    assertNotNull("No definition for attribute " + SchemaTestConstants.ICFS_UID, uidAttributeDefinition);
    assertTrue("Attribute " + SchemaTestConstants.ICFS_UID + " in not an identifier", uidAttributeDefinition.isIdentifier(accountDefinition));
    assertTrue("Attribute " + SchemaTestConstants.ICFS_UID + " in not in identifiers list", identifiers.contains(uidAttributeDefinition));
    assertEquals("Wrong displayName for attribute " + SchemaTestConstants.ICFS_UID, "ConnId UID", uidAttributeDefinition.getDisplayName());
    assertEquals("Wrong displayOrder for attribute " + SchemaTestConstants.ICFS_UID, (Integer) 100, uidAttributeDefinition.getDisplayOrder());
    Collection<? extends ResourceAttributeDefinition> secondaryIdentifiers = accountDefinition.getSecondaryIdentifiers();
    assertNotNull("Null secondary identifiers for " + objectClassQname, secondaryIdentifiers);
    assertFalse("Empty secondary identifiers for " + objectClassQname, secondaryIdentifiers.isEmpty());
    ResourceAttributeDefinition nameAttributeDefinition = accountDefinition.findAttributeDefinition(SchemaTestConstants.ICFS_NAME);
    assertNotNull("No definition for attribute " + SchemaTestConstants.ICFS_NAME, nameAttributeDefinition);
    assertTrue("Attribute " + SchemaTestConstants.ICFS_NAME + " in not an identifier", nameAttributeDefinition.isSecondaryIdentifier(accountDefinition));
    assertTrue("Attribute " + SchemaTestConstants.ICFS_NAME + " in not in identifiers list", secondaryIdentifiers.contains(nameAttributeDefinition));
    assertEquals("Wrong displayName for attribute " + SchemaTestConstants.ICFS_NAME, "ConnId Name", nameAttributeDefinition.getDisplayName());
    assertEquals("Wrong displayOrder for attribute " + SchemaTestConstants.ICFS_NAME, (Integer) 110, nameAttributeDefinition.getDisplayOrder());
    assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers());
    assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty());
    assertNotNull("Null secondary identifiers in account", accountDef.getSecondaryIdentifiers());
    assertFalse("Empty secondary identifiers in account", accountDef.getSecondaryIdentifiers().isEmpty());
    assertNotNull("No naming attribute in account", accountDef.getNamingAttribute());
    assertFalse("No nativeObjectClass in account", StringUtils.isEmpty(accountDef.getNativeObjectClass()));
    ResourceAttributeDefinition uidDef = accountDef.findAttributeDefinition(SchemaTestConstants.ICFS_UID);
    assertEquals(1, uidDef.getMaxOccurs());
    assertEquals(0, uidDef.getMinOccurs());
    assertFalse("No UID display name", StringUtils.isBlank(uidDef.getDisplayName()));
    assertFalse("UID has create", uidDef.canAdd());
    assertFalse("UID has update", uidDef.canModify());
    assertTrue("No UID read", uidDef.canRead());
    assertTrue("UID definition not in identifiers", accountDef.getPrimaryIdentifiers().contains(uidDef));
    assertEquals("Wrong refined displayName for attribute " + SchemaTestConstants.ICFS_UID, "ConnId UID", uidDef.getDisplayName());
    assertEquals("Wrong refined displayOrder for attribute " + SchemaTestConstants.ICFS_UID, (Integer) 100, uidDef.getDisplayOrder());
    ResourceAttributeDefinition nameDef = accountDef.findAttributeDefinition(SchemaTestConstants.ICFS_NAME);
    assertEquals(1, nameDef.getMaxOccurs());
    assertEquals(1, nameDef.getMinOccurs());
    assertFalse("No NAME displayName", StringUtils.isBlank(nameDef.getDisplayName()));
    assertTrue("No NAME create", nameDef.canAdd());
    assertTrue("No NAME update", nameDef.canModify());
    assertTrue("No NAME read", nameDef.canRead());
    assertTrue("NAME definition not in identifiers", accountDef.getSecondaryIdentifiers().contains(nameDef));
    assertEquals("Wrong refined displayName for attribute " + SchemaTestConstants.ICFS_NAME, "ConnId Name", nameDef.getDisplayName());
    assertEquals("Wrong refined displayOrder for attribute " + SchemaTestConstants.ICFS_NAME, (Integer) 110, nameDef.getDisplayOrder());
    assertNull("The _PASSSWORD_ attribute sneaked into schema", accountDef.findAttributeDefinition(new QName(SchemaTestConstants.NS_ICFS, "password")));
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) QName(javax.xml.namespace.QName) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 23 with ObjectClassComplexTypeDefinition

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

the class TestImportRecon method test001SanityAzure.

@Test
public void test001SanityAzure() throws Exception {
    final String TEST_NAME = "test001SanityAzure";
    TestUtil.displayTestTile(this, TEST_NAME);
    display("Dummy resource azure", dummyResourceAzure);
    // WHEN
    ResourceSchema resourceSchemaAzure = RefinedResourceSchemaImpl.getResourceSchema(resourceDummyAzureType, prismContext);
    display("Dummy azure resource schema", resourceSchemaAzure);
    // THEN
    dummyResourceCtlAzure.assertDummyResourceSchemaSanityExtended(resourceSchemaAzure);
    ObjectClassComplexTypeDefinition orgOcDef = resourceSchemaAzure.findObjectClassDefinition(dummyResourceCtlAzure.getOrgObjectClassQName());
    assertNotNull("No org object class def in azure resource schema", orgOcDef);
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 24 with ObjectClassComplexTypeDefinition

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

the class TestImportRecon method test002SanityAzureRefined.

@Test
public void test002SanityAzureRefined() throws Exception {
    final String TEST_NAME = "test002SanityAzureRefined";
    TestUtil.displayTestTile(this, TEST_NAME);
    // WHEN
    RefinedResourceSchema refinedSchemaAzure = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummyAzureType, prismContext);
    display("Dummy azure refined schema", refinedSchemaAzure);
    // THEN
    dummyResourceCtlAzure.assertRefinedSchemaSanity(refinedSchemaAzure);
    ObjectClassComplexTypeDefinition orgOcDef = refinedSchemaAzure.findObjectClassDefinition(dummyResourceCtlAzure.getOrgObjectClassQName());
    assertNotNull("No org object class def in azure refined schema", orgOcDef);
}
Also used : ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 25 with ObjectClassComplexTypeDefinition

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

the class ResourceEventListenerImpl method notifyEvent.

@Override
public void notifyEvent(ResourceEventDescription eventDescription, Task task, OperationResult parentResult) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ObjectNotFoundException, GenericConnectorException, ObjectAlreadyExistsException, ExpressionEvaluationException {
    Validate.notNull(eventDescription, "Event description must not be null.");
    Validate.notNull(task, "Task must not be null.");
    Validate.notNull(parentResult, "Operation result must not be null");
    LOGGER.trace("Received event notification with the description: {}", eventDescription.debugDump());
    if (eventDescription.getCurrentShadow() == null && eventDescription.getDelta() == null) {
        throw new IllegalStateException("Neither current shadow, nor delta specified. It is required to have at least one of them specified.");
    }
    applyDefinitions(eventDescription, parentResult);
    PrismObject<ShadowType> shadow = null;
    shadow = eventDescription.getShadow();
    ShadowCache shadowCache = getShadowCache(Mode.STANDARD);
    ProvisioningContext ctx = provisioningContextFactory.create(shadow, task, parentResult);
    ctx.assertDefinition();
    Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow);
    Change change = new Change(identifiers, eventDescription.getCurrentShadow(), eventDescription.getOldShadow(), eventDescription.getDelta());
    ObjectClassComplexTypeDefinition objectClassDefinition = ShadowUtil.getObjectClassDefinition(shadow);
    change.setObjectClassDefinition(objectClassDefinition);
    ShadowType shadowType = shadow.asObjectable();
    LOGGER.trace("Start to precess change: {}", change.toString());
    shadowCache.processChange(ctx, change, null, parentResult);
    LOGGER.trace("Change after processing {} . Start synchronizing.", change.toString());
    shadowCache.processSynchronization(ctx, change, parentResult);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Change(com.evolveum.midpoint.provisioning.ucf.api.Change) ResourceAttribute(com.evolveum.midpoint.schema.processor.ResourceAttribute)

Aggregations

ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)53 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)18 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)17 Test (org.testng.annotations.Test)17 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)16 QName (javax.xml.namespace.QName)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ArrayList (java.util.ArrayList)11 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)8 Task (com.evolveum.midpoint.task.api.Task)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)5 Containerable (com.evolveum.midpoint.prism.Containerable)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)4 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)3 ResultHandler (com.evolveum.midpoint.provisioning.ucf.api.ResultHandler)3 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)3