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);
}
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;
}
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());
}
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());
}
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);
}
Aggregations