Search in sources :

Example 26 with ResourceSchema

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

the class TestVillage method test022ResourceOpenDjRefinedSchema.

/**
	 * MID-3424
	 */
@Test
public void test022ResourceOpenDjRefinedSchema() throws Exception {
    final String TEST_NAME = "test022ResourceOpenDjRefinedSchema";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<ResourceType> resourceBefore = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result);
    ResourceSchema resourceSchemaBefore = RefinedResourceSchema.getResourceSchema(resourceBefore, prismContext);
    RefinedResourceSchema refinedSchemaBefore = RefinedResourceSchema.getRefinedSchema(resourceBefore);
    rememberResourceSchemaFetchCount();
    rememberResourceSchemaParseCount();
    rememberConnectorCapabilitiesFetchCount();
    rememberConnectorInitializationCount();
    rememberConnectorSchemaParseCount();
    rememberPrismObjectCloneCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    long t0 = System.currentTimeMillis();
    PrismObject<ResourceType> resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result);
    long t1 = System.currentTimeMillis();
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    long t2 = System.currentTimeMillis();
    ResourceSchema resourceSchemaAfter = RefinedResourceSchema.getResourceSchema(resourceAfter, prismContext);
    long t3 = System.currentTimeMillis();
    RefinedResourceSchema refinedSchemaAfter = RefinedResourceSchema.getRefinedSchema(resourceAfter);
    long t4 = System.currentTimeMillis();
    display("Times", "getObject(RESOURCE_OPENDJ_OID): " + (t1 - t0) + "ms\ngetResourceSchema: " + (t3 - t2) + "ms\ngetRefinedSchema: " + (t4 - t3) + "ms");
    // variable number of clones: 1 or 2 because of trigger scanner task
    assertPrismObjectCloneIncrement(1, 2);
    assertResourceSchemaFetchIncrement(0);
    assertResourceSchemaParseCountIncrement(0);
    assertConnectorCapabilitiesFetchIncrement(0);
    assertConnectorInitializationCountIncrement(0);
    assertConnectorSchemaParseIncrement(0);
    assertTrue("Resource schema has changed", resourceSchemaBefore == resourceSchemaAfter);
    assertTrue("Refined schema has changed", refinedSchemaBefore == refinedSchemaAfter);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) Test(org.testng.annotations.Test)

Example 27 with ResourceSchema

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

the class TestUnix method test010Schema.

@Test
public void test010Schema() throws Exception {
    final String TEST_NAME = "test010Schema";
    TestUtil.displayTestTile(this, TEST_NAME);
    resourceOpenDj = getObject(ResourceType.class, RESOURCE_OPENDJ_OID);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    IntegrationTestTools.displayXml("Initialized resource", resourceOpenDj);
    ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resourceOpenDj, prismContext);
    display("OpenDJ schema (resource)", resourceSchema);
    ObjectClassComplexTypeDefinition ocDefPosixAccount = resourceSchema.findObjectClassDefinition(OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", ocDefPosixAccount);
    assertTrue("Objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", ocDefPosixAccount.isAuxiliary());
    ObjectClassComplexTypeDefinition ocDefPosixGroup = resourceSchema.findObjectClassDefinition(OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", ocDefPosixGroup);
    assertTrue("Objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", ocDefPosixGroup.isAuxiliary());
    RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resourceOpenDj);
    display("OpenDJ schema (refined)", refinedSchema);
    RefinedObjectClassDefinition rOcDefPosixAccount = refinedSchema.getRefinedDefinition(OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No refined objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", rOcDefPosixAccount);
    assertTrue("Refined objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", rOcDefPosixAccount.isAuxiliary());
    RefinedObjectClassDefinition rOcDefPosixGroup = refinedSchema.getRefinedDefinition(OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No refined objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", rOcDefPosixGroup);
    assertTrue("Refined objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", rOcDefPosixGroup.isAuxiliary());
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) Test(org.testng.annotations.Test)

Example 28 with ResourceSchema

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

the class TestDummyLegacy method test105NativeParsedSchema.

@Test
public void test105NativeParsedSchema() throws Exception {
    final String TEST_NAME = "test105NativeParsedSchema";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    resourceNative = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_NATIVE_OID, null, task, result);
    // THEN
    result.computeStatus();
    assertSuccess(result);
    resourceTypeNative = resourceNative.asObjectable();
    ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceTypeNative, prismContext);
    display("Parsed resource schema", returnedSchema);
    assertNotNull("No parsed schema", returnedSchema);
    assertObjectClass(returnedSchema, OBJECTCLASS_NATIVE_ACCOUNT);
    assertObjectClass(returnedSchema, OBJECTCLASS_NATIVE_GROUP);
    assertObjectClass(returnedSchema, OBJECTCLASS_NATIVE_PRIVILEGE);
    assertNoObjectClass(returnedSchema, OBJECTCLASS_LEGACY_ACCOUNT);
    assertNoObjectClass(returnedSchema, OBJECTCLASS_LEGACY_GROUP);
    assertNoObjectClass(returnedSchema, OBJECTCLASS_LEGACY_PRIVILEGE);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 29 with ResourceSchema

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

the class TestDummyLegacy method test205LegacyParsedSchema.

@Test
public void test205LegacyParsedSchema() throws Exception {
    final String TEST_NAME = "test205LegacyParsedSchema";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    resourceLegacy = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_LEGACY_OID, null, task, result);
    // THEN
    result.computeStatus();
    assertSuccess(result);
    resourceTypeLegacy = resourceLegacy.asObjectable();
    ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceTypeLegacy, prismContext);
    display("Parsed resource schema", returnedSchema);
    assertNotNull("No parsed schema", returnedSchema);
    assertObjectClass(returnedSchema, OBJECTCLASS_LEGACY_ACCOUNT);
    assertObjectClass(returnedSchema, OBJECTCLASS_LEGACY_GROUP);
    assertObjectClass(returnedSchema, OBJECTCLASS_LEGACY_PRIVILEGE);
    assertNoObjectClass(returnedSchema, OBJECTCLASS_NATIVE_ACCOUNT);
    assertNoObjectClass(returnedSchema, OBJECTCLASS_NATIVE_GROUP);
    assertNoObjectClass(returnedSchema, OBJECTCLASS_NATIVE_PRIVILEGE);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 30 with ResourceSchema

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

the class AbstractAdTest method test020Schema.

@Test
public void test020Schema() throws Exception {
    final String TEST_NAME = "test020Schema";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN        
    ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext);
    display("Resource schema", resourceSchema);
    RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource);
    display("Refined schema", refinedSchema);
    accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(getAccountObjectClass());
    assertNotNull("No definition for object class " + getAccountObjectClass(), 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, 0, 1);
    assertTrue("cn read", cnDef.canRead());
    assertFalse("cn modify", cnDef.canModify());
    assertFalse("cn add", cnDef.canAdd());
    ResourceAttributeDefinition<String> userPrincipalNameDef = accountObjectClassDefinition.findAttributeDefinition("userPrincipalName");
    PrismAsserts.assertDefinition(userPrincipalNameDef, new QName(MidPointConstants.NS_RI, "userPrincipalName"), DOMUtil.XSD_STRING, 0, 1);
    assertTrue("o read", userPrincipalNameDef.canRead());
    assertTrue("o modify", userPrincipalNameDef.canModify());
    assertTrue("o add", userPrincipalNameDef.canAdd());
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) Test(org.testng.annotations.Test)

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