Search in sources :

Example 86 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext 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());
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Example 87 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext 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 88 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestParsePasswordPolicy method testParsePasswordPolicyFile.

@Test
public void testParsePasswordPolicyFile() throws Exception {
    System.out.println("===[ testParsePasswordPolicyFile ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    PrismObject<ValuePolicyType> policy = prismContext.parserFor(FILE).xml().parse();
    // THEN
    System.out.println("Parsed policy:");
    System.out.println(policy.debugDump());
    assertPolicy(policy);
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) PrismContext(com.evolveum.midpoint.prism.PrismContext) Test(org.testng.annotations.Test)

Example 89 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestParseModelContext method testParseModelContextPrism.

@Test
public void testParseModelContextPrism() throws Exception {
    System.out.println("===[ testParseModelContextPrism ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    LensContextType lensContextType = prismContext.parserFor(MODEL_CONTEXT_FILE).xml().parseRealValue(LensContextType.class);
    // THEN
    System.out.println("Parsed LensContextType: " + lensContextType);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) LensContextType(com.evolveum.midpoint.xml.ns._public.common.common_3.LensContextType) Test(org.testng.annotations.Test)

Example 90 with PrismContext

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

Aggregations

PrismContext (com.evolveum.midpoint.prism.PrismContext)104 Test (org.testng.annotations.Test)59 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 QName (javax.xml.namespace.QName)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)13 Task (com.evolveum.midpoint.task.api.Task)11 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)10 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 SystemException (com.evolveum.midpoint.util.exception.SystemException)9 File (java.io.File)8 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)7 ArrayList (java.util.ArrayList)7 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)6 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 Protector (com.evolveum.midpoint.prism.crypto.Protector)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)5