Search in sources :

Example 36 with PrismSchema

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());
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) QName(javax.xml.namespace.QName) SchemaRegistryImpl(com.evolveum.midpoint.prism.schema.SchemaRegistryImpl) Test(org.testng.annotations.Test)

Example 37 with PrismSchema

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
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Example 38 with PrismSchema

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

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);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 40 with PrismSchema

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)");
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)44 Test (org.testng.annotations.Test)20 QName (javax.xml.namespace.QName)10 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)8 Element (org.w3c.dom.Element)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)6 Task (com.evolveum.midpoint.task.api.Task)6 ConnectorConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType)6 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 Document (org.w3c.dom.Document)4 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 PrismSchemaImpl (com.evolveum.midpoint.prism.schema.PrismSchemaImpl)3 SchemaRegistryImpl (com.evolveum.midpoint.prism.schema.SchemaRegistryImpl)3