use of com.evolveum.midpoint.prism.schema.SchemaRegistry 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.schema.SchemaRegistry 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.schema.SchemaRegistry in project midpoint by Evolveum.
the class TestSchemaSanity method testRoleDefinition.
@Test
public void testRoleDefinition() {
System.out.println("===[ testRoleDefinition ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
// WHEN
PrismObjectDefinition<RoleType> roleDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON, "role"));
// THEN
assertNotNull("No role definition", roleDefinition);
System.out.println("Role definition:");
System.out.println(roleDefinition.debugDump());
PrismObjectDefinition<RoleType> roleDefinitionByClass = schemaRegistry.findObjectDefinitionByCompileTimeClass(RoleType.class);
assertTrue("Different role def", roleDefinition == roleDefinitionByClass);
assertEquals("Wrong compile-time class in role definition", RoleType.class, roleDefinition.getCompileTimeClass());
PrismAsserts.assertPropertyDefinition(roleDefinition, ObjectType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
PrismAsserts.assertItemDefinitionDisplayName(roleDefinition, ObjectType.F_NAME, "ObjectType.name");
PrismAsserts.assertItemDefinitionDisplayOrder(roleDefinition, ObjectType.F_NAME, 0);
PrismAsserts.assertPropertyDefinition(roleDefinition, ObjectType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
PrismAsserts.assertItemDefinitionDisplayName(roleDefinition, ObjectType.F_DESCRIPTION, "ObjectType.description");
PrismAsserts.assertItemDefinitionDisplayOrder(roleDefinition, ObjectType.F_DESCRIPTION, 10);
PrismAsserts.assertPropertyDefinition(roleDefinition, RoleType.F_REQUESTABLE, DOMUtil.XSD_BOOLEAN, 0, 1);
}
use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.
the class TestSchemaSanity method testExtensionSchema.
/**
* Extension schema should be loaded from src/test/resources/schema during test initialization.
*/
@Test
public void testExtensionSchema() {
System.out.println("===[ testExtensionSchema ]===");
// WHEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
assertNotNull("No prism context", prismContext);
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
assertNotNull("No schema registry in context", schemaRegistry);
PrismSchema extensionSchema = schemaRegistry.findSchemaByNamespace(SchemaTestConstants.NS_EXTENSION);
assertNotNull("No extension schema", extensionSchema);
System.out.println("Extension schema:");
System.out.println(extensionSchema.debugDump());
PrismPropertyDefinition locationsProperty = extensionSchema.findPropertyDefinitionByElementName(EXTENSION_LOCATIONS_ELEMENT);
PrismAsserts.assertDefinition(locationsProperty, EXTENSION_LOCATIONS_ELEMENT, EXTENSION_LOCATIONS_TYPE, 0, -1);
}
use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.
the class SchemaDocMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("SchemaDoc plugin started");
PrismContext prismContext = createInitializedPrismContext();
File outDir = initializeOutDir();
PathGenerator pathGenerator = new PathGenerator(outDir);
VelocityEngine velocityEngine = createVelocityEngine();
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
try {
renderSchemaIndex(schemaRegistry, prismContext, velocityEngine, pathGenerator);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
for (PrismSchema schema : schemaRegistry.getSchemas()) {
try {
renderSchema(schema, prismContext, velocityEngine, pathGenerator);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
try {
copyResources(outDir);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
File archiveFile = null;
try {
archiveFile = generateArchive(outDir, finalName + "-schemadoc.zip");
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (ArchiverException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
projectHelper.attachArtifact(project, "zip", "schemadoc", archiveFile);
getLog().info("SchemaDoc plugin finished");
}
Aggregations