Search in sources :

Example 16 with ResourceSchema

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

the class AddGetObjectTest method addGetFullAccount.

/**
     * Attempt to store full account in the repo and then get it out again. The
     * potential problem is that there are attributes that do not have a fixed
     * (static) definition.
     */
@Test
public void addGetFullAccount() throws Exception {
    LOGGER.info("===[ addGetFullAccount ]===");
    File file = new File(FOLDER_BASIC, "account-full.xml");
    PrismObject<ShadowType> fileAccount = prismContext.parseObject(new File(FOLDER_BASIC, "account-full.xml"));
    // apply appropriate schema
    PrismObject<ResourceType> resource = prismContext.parseObject(new File(FOLDER_BASIC, "resource-opendj.xml"));
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    ShadowUtil.applyResourceSchema(fileAccount, resourceSchema);
    OperationResult result = new OperationResult("ADD");
    String oid = repositoryService.addObject(fileAccount, null, result);
    PrismObject<ShadowType> repoAccount = repositoryService.getObject(ShadowType.class, oid, null, result);
    ObjectDelta<ShadowType> delta = fileAccount.diff(repoAccount);
    AssertJUnit.assertNotNull(delta);
    LOGGER.info("delta\n{}", new Object[] { delta.debugDump(3) });
    AssertJUnit.assertTrue(delta.isEmpty());
    ShadowType repoShadow = repoAccount.asObjectable();
    AssertJUnit.assertNotNull(repoShadow.getSynchronizationSituation());
    AssertJUnit.assertEquals(SynchronizationSituationType.LINKED, repoShadow.getSynchronizationSituation());
    AssertJUnit.assertNotNull(repoShadow.getSynchronizationSituationDescription());
    AssertJUnit.assertEquals(1, repoShadow.getSynchronizationSituationDescription().size());
    AssertJUnit.assertEquals(SynchronizationSituationType.LINKED, repoShadow.getSynchronizationSituationDescription().get(0).getSituation());
    AssertJUnit.assertEquals("syncChannel", repoShadow.getSynchronizationSituationDescription().get(0).getChannel());
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 17 with ResourceSchema

use of com.evolveum.midpoint.schema.processor.ResourceSchema 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 ResourceSchema

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

the class AddGetObjectTest method addGetFullAccountShadow.

@Test
private void addGetFullAccountShadow() throws Exception {
    LOGGER.info("===[ simpleAddAccountShadowTest ]===");
    OperationResult result = new OperationResult("testAddAccountShadow");
    File file = new File(FOLDER_BASIC, "account-accountTypeShadow.xml");
    try {
        PrismObject<ShadowType> account = prismContext.parseObject(file);
        // apply appropriate schema
        PrismObject<ResourceType> resource = prismContext.parseObject(new File(FOLDER_BASIC, "resource-opendj.xml"));
        ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
        ShadowUtil.applyResourceSchema(account, resourceSchema);
        repositoryService.addObject(account, null, result);
        PrismObject<ShadowType> afterAdd = repositoryService.getObject(ShadowType.class, account.getOid(), null, result);
        AssertJUnit.assertNotNull(afterAdd);
    } catch (Exception ex) {
        LOGGER.error("Exception occurred", ex);
        throw ex;
    }
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Test(org.testng.annotations.Test)

Example 19 with ResourceSchema

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

the class IntegrationTestTools method applyResourceSchema.

public static void applyResourceSchema(ShadowType accountType, ResourceType resourceType, PrismContext prismContext) throws SchemaException {
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
    ShadowUtil.applyResourceSchema(accountType.asPrismObject(), resourceSchema);
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema)

Example 20 with ResourceSchema

use of com.evolveum.midpoint.schema.processor.ResourceSchema 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)

Aggregations

ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)48 Test (org.testng.annotations.Test)26 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)23 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)21 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)17 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)16 QName (javax.xml.namespace.QName)14 Task (com.evolveum.midpoint.task.api.Task)13 Element (org.w3c.dom.Element)8 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)7 CachingMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType)7 ArrayList (java.util.ArrayList)7 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)6 XmlSchemaType (com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType)6 Containerable (com.evolveum.midpoint.prism.Containerable)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 AbstractProvisioningIntegrationTest (com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3