use of com.evolveum.midpoint.prism.schema.PrismSchema in project midpoint by Evolveum.
the class TestExtraSchema method testTypeOverride.
/**
* Test if a schema directory can be loaded to the schema registry. This contains definition of
* user extension, therefore check if it is applied to the user definition.
*/
@Test
public void testTypeOverride() throws SAXException, IOException, SchemaException {
System.out.println("===[ testTypeOverride ]===");
PrismContext context = constructPrismContext();
SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry();
reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR);
context.initialize();
PrismSchema schema = reg.getSchema(NS_ROOT);
System.out.println("Parsed root schema:");
System.out.println(schema.debugDump());
PrismContainerDefinition rootContDef = schema.findContainerDefinitionByElementName(new QName(NS_ROOT, "root"));
assertNotNull("Not <root> definition", rootContDef);
PrismContainerDefinition extensionContDef = rootContDef.findContainerDefinition(new QName(NS_FOO, "extension"));
assertNotNull("Not <extension> definition", extensionContDef);
assertEquals("Wrong <extension> type", new QName(NS_ROOT, "MyExtensionType"), extensionContDef.getTypeName());
}
use of com.evolveum.midpoint.prism.schema.PrismSchema in project midpoint by Evolveum.
the class TestSchemaRegistry method testCommonSchema.
@Test
public void testCommonSchema() throws SchemaException, SAXException, IOException {
MidPointPrismContextFactory factory = getContextFactory();
PrismContext context = factory.createInitializedPrismContext();
SchemaRegistry schemaRegistry = context.getSchemaRegistry();
PrismSchema commonSchema = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_C);
assertNotNull("No parsed common schema", commonSchema);
System.out.println("Parsed common schema:");
System.out.println(commonSchema.debugDump());
// TODO
}
use of com.evolveum.midpoint.prism.schema.PrismSchema 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.PrismSchema in project midpoint by Evolveum.
the class TestRbac method test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment.
@Test
public void test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment() throws Exception {
final String TEST_NAME = "test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismContainer<?> extension = getAssignmentExtensionInstance();
PrismSchema piracySchema = getPiracySchema();
PrismPropertyDefinition<String> seaPropDef = piracySchema.findPropertyDefinitionByElementName(PIRACY_SEA_QNAME);
PrismProperty<String> seaProp = seaPropDef.instantiate();
seaProp.setRealValue("Caribbean");
extension.add(seaProp);
// WHEN
unassignRole(USER_JACK_OID, ROLE_ADRIATIC_PIRATE_OID, extension, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after", userJack);
assertAssignments(userJack, 0);
assertRoleMembershipRef(userJack);
assertDelegatedRef(userJack);
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}
use of com.evolveum.midpoint.prism.schema.PrismSchema in project midpoint by Evolveum.
the class TestRbac method test130JackAssignRolePirateWithSeaInAssignment.
@Test
public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception {
final String TEST_NAME = "test130JackAssignRolePirateWithSeaInAssignment";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismContainer<?> extension = getAssignmentExtensionInstance();
PrismSchema piracySchema = getPiracySchema();
PrismPropertyDefinition<String> seaPropDef = piracySchema.findPropertyDefinitionByElementName(PIRACY_SEA_QNAME);
PrismProperty<String> seaProp = seaPropDef.instantiate();
seaProp.setRealValue("Caribbean");
extension.add(seaProp);
// WHEN
assignRole(USER_JACK_OID, ROLE_PIRATE_OID, extension, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User jack after", userAfter);
assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result);
assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID);
assertDelegatedRef(userAfter);
assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Bloody Pirate");
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "location", "Tortuga");
// Outbound mapping for weapon is weak, therefore the mapping in role should override it
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "cutlass");
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "Jack Sparrow is the best pirate Tortuga has ever seen");
assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME, "jack sailed Caribbean, immediately Caribbean, role , with this The Seven Seas while focused on Caribbean (in Pirate)");
}
Aggregations