Search in sources :

Example 46 with ResourceSchema

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

Example 47 with ResourceSchema

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

the class TestDummySchemaless method test005ParsedSchemaSchemaless.

/**
	 * This basically checks if the methods do not die on NPE
	 */
@Test
public void test005ParsedSchemaSchemaless() throws Exception {
    final String TEST_NAME = "test005ParsedSchemaSchemaless";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME);
    // THEN
    // The returned type should have the schema pre-parsed
    assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceTypeSchemaless));
    // Also test if the utility method returns the same thing
    ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceTypeSchemaless, prismContext);
    display("Parsed resource schema", returnedSchema);
    assertNull("Unexpected schema after parsing", returnedSchema);
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 48 with ResourceSchema

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

the class TestDummySchemaless method test106GetObjectStaticSchema.

@Test
public void test106GetObjectStaticSchema() throws Exception {
    final String TEST_NAME = "test106GetObjectStaticSchema";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME);
    PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result);
    assertNotNull("Resource is null", resource);
    ResourceType resourceType = resource.asObjectable();
    assertNotNull("No connector ref", resourceType.getConnectorRef());
    assertNotNull("No connector ref OID", resourceType.getConnectorRef().getOid());
    ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    display("Parsed resource schema", returnedSchema);
    assertNotNull("Null resource schema", returnedSchema);
    dummyResourceSchemalessCtl.assertDummyResourceSchemaSanity(returnedSchema, resource.asObjectable(), true);
}
Also used : 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)

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