Search in sources :

Example 36 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class TestSchemaSanity method testPrefixMappings.

@Test
public void testPrefixMappings() {
    System.out.println("===[ testPrefixMappings ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    assertNotNull("No prism context", prismContext);
    SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
    assertNotNull("No schema registry in context", schemaRegistry);
    DynamicNamespacePrefixMapper prefixMapper = schemaRegistry.getNamespacePrefixMapper();
    assertNotNull("No prefix mapper in context", prefixMapper);
    System.out.println("Prefix mapper:");
    System.out.println(prefixMapper.debugDump());
    // WHEN, THEN
    assertMapping(prefixMapper, PrismConstants.NS_ANNOTATION, PrismConstants.PREFIX_NS_ANNOTATION);
    assertMapping(prefixMapper, SchemaConstantsGenerated.NS_COMMON, "");
    assertMapping(prefixMapper, MidPointConstants.NS_RA, MidPointConstants.PREFIX_NS_RA);
    assertMapping(prefixMapper, SchemaTestConstants.NS_ICFC, "icfc");
    assertMapping(prefixMapper, SchemaTestConstants.NS_ICFS, "icfs");
    QName cBarQName = new QName(SchemaConstantsGenerated.NS_COMMON, "bar");
    QName cBarQNameWithPrefix = prefixMapper.setQNamePrefix(cBarQName);
    assertQName("common namespace implicit", SchemaConstantsGenerated.NS_COMMON, "bar", "", cBarQNameWithPrefix);
    QName cBarQNameWithPrefixExplixit = prefixMapper.setQNamePrefixExplicit(cBarQName);
    assertQName("common namespace implicit", SchemaConstantsGenerated.NS_COMMON, "bar", "c", cBarQNameWithPrefixExplixit);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) QName(javax.xml.namespace.QName) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) DynamicNamespacePrefixMapper(com.evolveum.midpoint.prism.xml.DynamicNamespacePrefixMapper) Test(org.testng.annotations.Test)

Example 37 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class TestSchemaSanity method testAccountDefinition.

@Test
public void testAccountDefinition() {
    System.out.println("===[ testAccountDefinition ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
    // WHEN
    PrismObjectDefinition<ShadowType> accountDefinition = schemaRegistry.findObjectDefinitionByElementName(SchemaConstants.C_SHADOW);
    assertNotNull("No account definition", accountDefinition);
    System.out.println("Account definition:");
    System.out.println(accountDefinition.debugDump());
    PrismObjectDefinition<ShadowType> accountDefinitionByClass = schemaRegistry.findObjectDefinitionByCompileTimeClass(ShadowType.class);
    assertTrue("Different account def", accountDefinition == accountDefinitionByClass);
    assertEquals("Wrong compile-time class in account definition", ShadowType.class, accountDefinition.getCompileTimeClass());
    PrismAsserts.assertPropertyDefinition(accountDefinition, ShadowType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
    PrismAsserts.assertPropertyDefinition(accountDefinition, ShadowType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
    assertFalse("Account definition is marked as runtime", accountDefinition.isRuntimeSchema());
    PrismContainerDefinition attributesContainer = accountDefinition.findContainerDefinition(ShadowType.F_ATTRIBUTES);
    PrismAsserts.assertDefinition(attributesContainer, ShadowType.F_ATTRIBUTES, ShadowAttributesType.COMPLEX_TYPE, 0, 1);
    assertTrue("Attributes is NOT runtime", attributesContainer.isRuntimeSchema());
    assertEquals("Wrong attributes compile-time class", ShadowAttributesType.class, attributesContainer.getCompileTimeClass());
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Example 38 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class TestSchemaSanity method testIcfSchema.

@Test
public void testIcfSchema() {
    System.out.println("===[ testIcfSchema ]===");
    // WHEN
    // The context should have parsed common schema and also other midPoint schemas
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    assertNotNull("No prism context", prismContext);
    SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
    assertNotNull("No schema registry in context", schemaRegistry);
    System.out.println("Schema registry:");
    System.out.println(schemaRegistry.debugDump());
    PrismSchema icfSchema = schemaRegistry.findSchemaByNamespace(NS_ICFC);
    assertNotNull("No ICF schema", icfSchema);
    System.out.println("ICF schema:");
    System.out.println(icfSchema.debugDump());
    PrismContainerDefinition configurationPropertiesContainerDef = icfSchema.findContainerDefinitionByElementName(ICFC_CONFIGURATION_PROPERTIES);
    PrismAsserts.assertDefinition(configurationPropertiesContainerDef, ICFC_CONFIGURATION_PROPERTIES, ICFC_CONFIGURATION_PROPERTIES_TYPE, 0, 1);
    assertTrue("configurationPropertiesContainer definition is NOT marked as runtime", configurationPropertiesContainerDef.isRuntimeSchema());
    assertTrue("configurationPropertiesContainer definition is NOT marked as dynamic", configurationPropertiesContainerDef.isDynamic());
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) PrismContext(com.evolveum.midpoint.prism.PrismContext) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Example 39 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class TestSchemaSanity method testResourceConfigurationDefinition.

@Test
public void testResourceConfigurationDefinition() {
    System.out.println("===[ testResourceConfigurationDefinition ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
    // WHEN
    PrismContainerDefinition<?> configurationPropertiesDefinition = schemaRegistry.findContainerDefinitionByElementName(SchemaConstantsGenerated.ICF_C_CONFIGURATION_PROPERTIES);
    assertNotNull("No configurationProperties definition", configurationPropertiesDefinition);
    System.out.println("configurationProperties definition:");
    System.out.println(configurationPropertiesDefinition.debugDump());
    assertTrue("configurationProperties definition is NOT marked as runtime", configurationPropertiesDefinition.isRuntimeSchema());
//		assertNull("Unexpected compile-time class in configurationProperties definition", configurationPropertiesDefinition.getCompileTimeClass());
//		assertTrue("configurationProperties definition is NOT marked as wildcard", configurationPropertiesDefinition.isWildcard());
// TODO
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Aggregations

SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)39 Test (org.testng.annotations.Test)26 PrismContext (com.evolveum.midpoint.prism.PrismContext)10 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 Task (com.evolveum.midpoint.task.api.Task)6 QName (javax.xml.namespace.QName)6 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)5 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)4 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)3 PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)3 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ConnectorConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType)3 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2