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);
}
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());
}
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());
}
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
}
Aggregations