Search in sources :

Example 51 with ObjectClassComplexTypeDefinition

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

the class TestDummy method createAccountShadow.

private PrismObject<ShadowType> createAccountShadow(String username) throws SchemaException {
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    ShadowType shadowType = new ShadowType();
    PrismTestUtil.getPrismContext().adopt(shadowType);
    shadowType.setName(PrismTestUtil.createPolyStringType(username));
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resource.getOid());
    shadowType.setResourceRef(resourceRef);
    shadowType.setObjectClass(defaultAccountDefinition.getTypeName());
    PrismObject<ShadowType> shadow = shadowType.asPrismObject();
    PrismContainer<Containerable> attrsCont = shadow.findOrCreateContainer(ShadowType.F_ATTRIBUTES);
    PrismProperty<String> icfsNameProp = attrsCont.findOrCreateProperty(SchemaConstants.ICFS_NAME);
    icfsNameProp.setRealValue(username);
    return shadow;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Containerable(com.evolveum.midpoint.prism.Containerable)

Example 52 with ObjectClassComplexTypeDefinition

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

the class TestDummyLegacy method assertObjectClass.

private void assertObjectClass(ResourceSchema schema, String objectClassLocalName) {
    ObjectClassComplexTypeDefinition ocDef = schema.findObjectClassDefinition(objectClassLocalName);
    assertNotNull("No objectclass " + objectClassLocalName + " found in schema", ocDef);
}
Also used : ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 53 with ObjectClassComplexTypeDefinition

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

the class AbstractManualResourceTest method test005ParsedSchema.

@Test
public void test005ParsedSchema() throws Exception {
    final String TEST_NAME = "test005ParsedSchema";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME);
    // THEN
    // The returned type should have the schema pre-parsed
    assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType));
    // Also test if the utility method returns the same thing
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
    display("Parsed resource schema", resourceSchema);
    // Check whether it is reusing the existing schema and not parsing it all over again
    // Not equals() but == ... we want to really know if exactly the same
    // object instance is returned
    assertTrue("Broken caching", resourceSchema == RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext));
    ObjectClassComplexTypeDefinition accountDef = resourceSchema.findObjectClassDefinition(RESOURCE_ACCOUNT_OBJECTCLASS);
    assertNotNull("Account definition is missing", accountDef);
    assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers());
    assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty());
    assertNotNull("No naming attribute in account", accountDef.getNamingAttribute());
    assertEquals("Unexpected number of definitions", getNumberOfAccountAttributeDefinitions(), accountDef.getDefinitions().size());
    ResourceAttributeDefinition<String> usernameDef = accountDef.findAttributeDefinition(ATTR_USERNAME);
    assertNotNull("No definition for username", usernameDef);
    assertEquals(1, usernameDef.getMaxOccurs());
    assertEquals(1, usernameDef.getMinOccurs());
    assertTrue("No username create", usernameDef.canAdd());
    assertTrue("No username update", usernameDef.canModify());
    assertTrue("No username read", usernameDef.canRead());
    ResourceAttributeDefinition<String> fullnameDef = accountDef.findAttributeDefinition(ATTR_FULLNAME);
    assertNotNull("No definition for fullname", fullnameDef);
    assertEquals(1, fullnameDef.getMaxOccurs());
    assertEquals(0, fullnameDef.getMinOccurs());
    assertTrue("No fullname create", fullnameDef.canAdd());
    assertTrue("No fullname update", fullnameDef.canModify());
    assertTrue("No fullname read", fullnameDef.canRead());
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Test(org.testng.annotations.Test) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

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