Search in sources :

Example 16 with ObjectClassComplexTypeDefinition

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

the class TestDummy method testSeachIterativeAlternativeAttrFilter.

protected <T> void testSeachIterativeAlternativeAttrFilter(final String TEST_NAME, QName attr1QName, T attr1Val, QName attr2QName, T attr2Val, GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountNames) throws Exception {
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    ObjectClassComplexTypeDefinition objectClassDef = resourceSchema.findObjectClassDefinition(SchemaTestConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME);
    ResourceAttributeDefinition<T> attr1Def = objectClassDef.findAttributeDefinition(attr1QName);
    ResourceAttributeDefinition<T> attr2Def = objectClassDef.findAttributeDefinition(attr2QName);
    ObjectFilter filter = QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(attr1Def, ShadowType.F_ATTRIBUTES, attr1Def.getName()).eq(attr1Val).or().itemWithDef(attr2Def, ShadowType.F_ATTRIBUTES, attr2Def.getName()).eq(attr2Val).buildFilter();
    testSeachIterative(TEST_NAME, filter, rootOptions, fullShadow, false, true, expectedAccountNames);
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter)

Example 17 with ObjectClassComplexTypeDefinition

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

the class AdUtils method assertAdSchema.

public static ObjectClassComplexTypeDefinition assertAdSchema(PrismObject<ResourceType> resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException {
    ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext);
    display("Resource schema", resourceSchema);
    RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource);
    display("Refined schema", refinedSchema);
    ObjectClassComplexTypeDefinition accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(accountObjectClass);
    assertNotNull("No definition for object class " + accountObjectClass, accountObjectClassDefinition);
    display("Account object class def", accountObjectClassDefinition);
    ResourceAttributeDefinition<String> cnDef = accountObjectClassDefinition.findAttributeDefinition("cn");
    PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 1, 1);
    assertTrue("cn read", cnDef.canRead());
    assertTrue("cn modify", cnDef.canModify());
    assertTrue("cn add", cnDef.canAdd());
    ResourceAttributeDefinition<String> samAccountNameDef = accountObjectClassDefinition.findAttributeDefinition(ATTRIBUTE_SAM_ACCOUNT_NAME_NAME);
    PrismAsserts.assertDefinition(samAccountNameDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_SAM_ACCOUNT_NAME_NAME), DOMUtil.XSD_STRING, 0, 1);
    assertTrue("samAccountNameDef read", samAccountNameDef.canRead());
    assertTrue("samAccountNameDef modify", samAccountNameDef.canModify());
    assertTrue("samAccountNameDef add", samAccountNameDef.canAdd());
    ResourceAttributeDefinition<String> oDef = accountObjectClassDefinition.findAttributeDefinition("o");
    PrismAsserts.assertDefinition(oDef, new QName(MidPointConstants.NS_RI, "o"), DOMUtil.XSD_STRING, 0, -1);
    assertTrue("o read", oDef.canRead());
    assertTrue("o modify", oDef.canModify());
    assertTrue("o add", oDef.canAdd());
    ResourceAttributeDefinition<Long> createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimeStamp");
    PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimeStamp"), DOMUtil.XSD_LONG, 0, 1);
    assertTrue("createTimeStampDef read", createTimestampDef.canRead());
    assertFalse("createTimeStampDef modify", createTimestampDef.canModify());
    assertFalse("createTimeStampDef add", createTimestampDef.canAdd());
    ResourceAttributeDefinition<Long> isCriticalSystemObjectDef = accountObjectClassDefinition.findAttributeDefinition("isCriticalSystemObject");
    PrismAsserts.assertDefinition(isCriticalSystemObjectDef, new QName(MidPointConstants.NS_RI, "isCriticalSystemObject"), DOMUtil.XSD_BOOLEAN, 0, 1);
    assertTrue("isCriticalSystemObject read", isCriticalSystemObjectDef.canRead());
    assertTrue("isCriticalSystemObject modify", isCriticalSystemObjectDef.canModify());
    assertTrue("isCriticalSystemObject add", isCriticalSystemObjectDef.canAdd());
    ResourceAttributeDefinition<Long> nTSecurityDescriptorDef = accountObjectClassDefinition.findAttributeDefinition("nTSecurityDescriptor");
    PrismAsserts.assertDefinition(nTSecurityDescriptorDef, new QName(MidPointConstants.NS_RI, "nTSecurityDescriptor"), DOMUtil.XSD_BASE64BINARY, 0, 1);
    assertTrue("nTSecurityDescriptor read", nTSecurityDescriptorDef.canRead());
    assertTrue("nTSecurityDescriptor modify", nTSecurityDescriptorDef.canModify());
    assertTrue("nTSecurityDescriptor add", nTSecurityDescriptorDef.canAdd());
    ResourceAttributeDefinition<Long> lastLogonDef = accountObjectClassDefinition.findAttributeDefinition("lastLogon");
    PrismAsserts.assertDefinition(lastLogonDef, new QName(MidPointConstants.NS_RI, "lastLogon"), DOMUtil.XSD_LONG, 0, 1);
    assertTrue("lastLogonDef read", lastLogonDef.canRead());
    assertTrue("lastLogonDef modify", lastLogonDef.canModify());
    assertTrue("lastLogonDef add", lastLogonDef.canAdd());
    return accountObjectClassDefinition;
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 18 with ObjectClassComplexTypeDefinition

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

the class DummyResourceContoller method assertDummyResourceSchemaSanity.

public void assertDummyResourceSchemaSanity(ResourceSchema resourceSchema, ResourceType resourceType, boolean checkDisplayOrder) {
    IntegrationTestTools.assertIcfResourceSchemaSanity(resourceSchema, resourceType);
    // ACCOUNT
    ObjectClassComplexTypeDefinition accountDef = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    assertNotNull("No ACCOUNT kind definition", accountDef);
    ResourceAttributeDefinition fullnameDef = accountDef.findAttributeDefinition("fullname");
    assertNotNull("No definition for fullname", fullnameDef);
    assertEquals(1, fullnameDef.getMaxOccurs());
    assertEquals(1, fullnameDef.getMinOccurs());
    assertTrue("No fullname create", fullnameDef.canAdd());
    assertTrue("No fullname update", fullnameDef.canModify());
    assertTrue("No fullname read", fullnameDef.canRead());
    if (checkDisplayOrder) {
        // TODO: fix, see MID-2642
        assertTrue("Wrong displayOrder for attribute fullName: " + fullnameDef.getDisplayOrder(), fullnameDef.getDisplayOrder() == 200 || fullnameDef.getDisplayOrder() == 250);
    }
    // GROUP
    ObjectClassComplexTypeDefinition groupObjectClass = resourceSchema.findObjectClassDefinition(SchemaTestConstants.GROUP_OBJECT_CLASS_LOCAL_NAME);
    assertNotNull("No group objectClass", groupObjectClass);
    ResourceAttributeDefinition membersDef = groupObjectClass.findAttributeDefinition(DUMMY_GROUP_MEMBERS_ATTRIBUTE_NAME);
    assertNotNull("No definition for members", membersDef);
    assertEquals("Wrong maxOccurs", -1, membersDef.getMaxOccurs());
    assertEquals("Wrong minOccurs", 0, membersDef.getMinOccurs());
    assertTrue("No members create", membersDef.canAdd());
    assertTrue("No members update", membersDef.canModify());
    assertTrue("No members read", membersDef.canRead());
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 19 with ObjectClassComplexTypeDefinition

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

the class DummyResourceContoller method assertDummyResourceSchemaSanityExtended.

public void assertDummyResourceSchemaSanityExtended(ResourceSchema resourceSchema, ResourceType resourceType, boolean checkDisplayOrder, int numberOfAccountDefinitions) {
    assertDummyResourceSchemaSanity(resourceSchema, resourceType, checkDisplayOrder);
    ObjectClassComplexTypeDefinition accountDef = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    assertNotNull("No default account definition", accountDef);
    ObjectClassComplexTypeDefinition accountObjectClassDef = resourceSchema.findObjectClassDefinition(SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME);
    assertNotNull("No AccountObjectClass definition", accountObjectClassDef);
    assertTrue("Default account definition is not same as AccountObjectClass", accountDef == accountObjectClassDef);
    assertEquals("Unexpected number of defnitions", numberOfAccountDefinitions, accountDef.getDefinitions().size());
    ResourceAttributeDefinition treasureDef = accountDef.findAttributeDefinition(DUMMY_ACCOUNT_ATTRIBUTE_TREASURE_NAME);
    assertFalse("Treasure IS returned by default and should not be", treasureDef.isReturnedByDefault());
    assertEquals("Unexpected kind in account definition", ShadowKindType.ACCOUNT, accountDef.getKind());
    assertTrue("Account definition in not default", accountDef.isDefaultInAKind());
    assertNull("Non-null intent in account definition", accountDef.getIntent());
    assertFalse("Account definition is deprecated", accountDef.isDeprecated());
    assertFalse("Account definition is auxiliary", accountDef.isAuxiliary());
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 20 with ObjectClassComplexTypeDefinition

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

the class IntegrationTestTools method assertProvisioningShadow.

public static void assertProvisioningShadow(PrismObject<ShadowType> account, ResourceType resourceType, Class<?> expetcedAttributeDefinitionClass, QName objectClass) {
    // Check attribute definition
    PrismContainer attributesContainer = account.findContainer(ShadowType.F_ATTRIBUTES);
    assertEquals("Wrong attributes container class", ResourceAttributeContainer.class, attributesContainer.getClass());
    ResourceAttributeContainer rAttributesContainer = (ResourceAttributeContainer) attributesContainer;
    PrismContainerDefinition attrsDef = attributesContainer.getDefinition();
    assertNotNull("No attributes container definition", attrsDef);
    assertTrue("Wrong attributes definition class " + attrsDef.getClass().getName(), attrsDef instanceof ResourceAttributeContainerDefinition);
    ResourceAttributeContainerDefinition rAttrsDef = (ResourceAttributeContainerDefinition) attrsDef;
    ObjectClassComplexTypeDefinition objectClassDef = rAttrsDef.getComplexTypeDefinition();
    assertNotNull("No object class definition in attributes definition", objectClassDef);
    assertEquals("Wrong object class in attributes definition", objectClass, objectClassDef.getTypeName());
    ResourceAttributeDefinition primaryIdDef = objectClassDef.getPrimaryIdentifiers().iterator().next();
    ResourceAttribute<?> primaryIdAttr = rAttributesContainer.findAttribute(primaryIdDef.getName());
    assertNotNull("No primary ID " + primaryIdDef.getName() + " in " + account, primaryIdAttr);
    assertAttributeDefinition(primaryIdAttr, DOMUtil.XSD_STRING, 0, 1, true, false, false, expetcedAttributeDefinitionClass);
    ResourceAttributeDefinition secondaryIdDef = objectClassDef.getSecondaryIdentifiers().iterator().next();
    ResourceAttribute<Object> secondaryIdAttr = rAttributesContainer.findAttribute(secondaryIdDef.getName());
    assertNotNull("No secondary ID " + secondaryIdDef.getName() + " in " + account, secondaryIdAttr);
    assertAttributeDefinition(secondaryIdAttr, DOMUtil.XSD_STRING, 1, 1, true, true, true, expetcedAttributeDefinitionClass);
}
Also used : ResourceAttributeContainerDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

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