use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestSchemaSanity method testResourceDefinition.
@Test
public void testResourceDefinition() {
System.out.println("===[ testResourceDefinition ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
// WHEN
PrismObjectDefinition<ResourceType> resourceDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON, "resource"));
assertNotNull("No resource definition", resourceDefinition);
System.out.println("Resource definition:");
System.out.println(resourceDefinition.debugDump());
PrismObjectDefinition<ResourceType> resourceDefinitionByClass = schemaRegistry.findObjectDefinitionByCompileTimeClass(ResourceType.class);
assertTrue("Different user def", resourceDefinition == resourceDefinitionByClass);
assertEquals("Wrong compile-time class in resource definition", ResourceType.class, resourceDefinition.getCompileTimeClass());
PrismAsserts.assertPropertyDefinition(resourceDefinition, ResourceType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
PrismAsserts.assertPropertyDefinition(resourceDefinition, ResourceType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
assertFalse("Resource definition is marked as runtime", resourceDefinition.isRuntimeSchema());
PrismContainerDefinition<ConnectorConfigurationType> connectorConfContainerDef = resourceDefinition.findContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION);
PrismAsserts.assertDefinition(connectorConfContainerDef, ResourceType.F_CONNECTOR_CONFIGURATION, ConnectorConfigurationType.COMPLEX_TYPE, 1, 1);
assertTrue("<connectorConfiguration> is NOT dynamic", connectorConfContainerDef.isDynamic());
// assertFalse("<connectorConfiguration> is runtime", connectorConfContainerDef.isRuntimeSchema());
assertEquals("Wrong compile-time class for <connectorConfiguration> in resource definition", ConnectorConfigurationType.class, connectorConfContainerDef.getCompileTimeClass());
PrismContainerDefinition<XmlSchemaType> schemaContainerDef = resourceDefinition.findContainerDefinition(ResourceType.F_SCHEMA);
PrismAsserts.assertDefinition(schemaContainerDef, ResourceType.F_SCHEMA, XmlSchemaType.COMPLEX_TYPE, 0, 1);
assertFalse("Schema is runtime", schemaContainerDef.isRuntimeSchema());
assertEquals("Wrong compile-time class for <schema> in resource definition", XmlSchemaType.class, schemaContainerDef.getCompileTimeClass());
assertEquals("Unexpected number of definitions in <schema>", 3, schemaContainerDef.getDefinitions().size());
PrismAsserts.assertPropertyDefinition(schemaContainerDef, XmlSchemaType.F_CACHING_METADATA, CachingMetadataType.COMPLEX_TYPE, 0, 1);
PrismAsserts.assertPropertyDefinition(schemaContainerDef, XmlSchemaType.F_DEFINITION, SchemaDefinitionType.COMPLEX_TYPE, 0, 1);
PrismPropertyDefinition definitionPropertyDef = schemaContainerDef.findPropertyDefinition(XmlSchemaType.F_DEFINITION);
assertNotNull("Null <definition> definition", definitionPropertyDef);
// assertFalse("schema/definition is NOT runtime", definitionPropertyDef.isRuntimeSchema());
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestSchemaSanity method testFocusDefinition.
@Test
public void testFocusDefinition() {
System.out.println("===[ testFocusDefinition ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
// WHEN
ComplexTypeDefinition focusDefinition = schemaRegistry.findComplexTypeDefinition(FocusType.COMPLEX_TYPE);
// THEN
assertNotNull("No focus definition", focusDefinition);
System.out.println("Focus definition:");
System.out.println(focusDefinition.debugDump());
SchemaTestUtil.assertFocusDefinition(focusDefinition, "focus");
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestSchemaSanity method testUserDefinition.
@Test
public void testUserDefinition() {
System.out.println("===[ testUserDefinition ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
// WHEN
PrismObjectDefinition<UserType> userDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON, "user"));
// THEN
assertNotNull("No user definition", userDefinition);
System.out.println("User definition:");
System.out.println(userDefinition.debugDump());
PrismObjectDefinition<UserType> userDefinitionByClass = schemaRegistry.findObjectDefinitionByCompileTimeClass(UserType.class);
assertTrue("Different user def", userDefinition == userDefinitionByClass);
SchemaTestUtil.assertUserDefinition(userDefinition);
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestParseTaskBulkAction method testParseTaskFile.
@Test
public void testParseTaskFile() throws Exception {
System.out.println("===[ testParseTaskFile ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
PrismObject<TaskType> task = prismContext.parserFor(TASK_FILE).xml().parse();
// THEN
System.out.println("Parsed task:");
System.out.println(task.debugDump());
assertTask(task);
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestParseLookupTable method testParseTableFileRoundTrip.
@Test
public void testParseTableFileRoundTrip() throws Exception {
System.out.println("===[ testParseTableFileRoundTrip ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
PrismObject<LookupTableType> table = prismContext.parserFor(LOOKUP_TABLE_FILE).xml().parse();
// THEN
System.out.println("Parsed table:");
System.out.println(table.debugDump());
assertTable(table);
// WHEN
String xml = prismContext.serializeObjectToString(table, PrismContext.LANG_XML);
// THEN
System.out.println("Serialized object:");
System.out.println(xml);
// WHEN
PrismObject<ObjectTemplateType> reparsedObject = prismContext.parseObject(xml);
// THEN
System.out.println("Re-parsed object:");
System.out.println(reparsedObject.debugDump());
assertTable(table);
PrismAsserts.assertEquals(table.asObjectable(), reparsedObject.asObjectable());
}
Aggregations