Search in sources :

Example 11 with UserType

use of com.evolveum.midpoint.prism.foo.UserType in project midpoint by Evolveum.

the class TestExtraSchema method testUserExtensionSchemaSchemaRegistry.

@Test
public void testUserExtensionSchemaSchemaRegistry() throws SAXException, IOException, SchemaException {
    System.out.println("===[ testUserExtensionSchemaAsObjectSchema ]===");
    PrismContext context = constructPrismContext();
    SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry();
    reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR);
    context.initialize();
    PrismObjectDefinition<UserType> userDef = reg.findObjectDefinitionByType(USER_TYPE_QNAME);
    System.out.println("User definition:");
    System.out.println(userDef.debugDump());
    assertUserDefinition(userDef);
    PrismObjectDefinition<UserType> usedDefByClass = reg.findObjectDefinitionByCompileTimeClass(UserType.class);
    assertUserDefinition(usedDefByClass);
    PrismObjectDefinition<UserType> userDefByElement = reg.findObjectDefinitionByElementName(USER_QNAME);
    assertUserDefinition(userDefByElement);
}
Also used : SchemaRegistryImpl(com.evolveum.midpoint.prism.schema.SchemaRegistryImpl) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Example 12 with UserType

use of com.evolveum.midpoint.prism.foo.UserType in project midpoint by Evolveum.

the class TestFind method testFindString.

@Test
public void testFindString() throws SchemaException, SAXException, IOException {
    final String TEST_NAME = "testFindString";
    System.out.println("===[ " + TEST_NAME + " ]===");
    // GIVEN
    PrismObject<UserType> user = createUser();
    ItemPath path = new ItemPath(UserType.F_DESCRIPTION);
    // WHEN
    PrismProperty<String> nameProperty = findProperty(user, path);
    // THEN
    assertEquals("Wrong property value (path=" + path + ")", USER_JACK_DESCRIPTION, nameProperty.getRealValue());
    assertTrue("QName found something other", nameProperty == (PrismProperty) user.findProperty(UserType.F_DESCRIPTION));
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.prism.foo.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 13 with UserType

use of com.evolveum.midpoint.prism.foo.UserType in project midpoint by Evolveum.

the class TestFind method testFindPolyString.

@Test
public void testFindPolyString() throws SchemaException, SAXException, IOException {
    final String TEST_NAME = "testFindPolyString";
    System.out.println("===[ " + TEST_NAME + " ]===");
    // GIVEN
    PrismObject<UserType> user = createUser();
    ItemPath path = new ItemPath(UserType.F_POLY_NAME);
    // WHEN
    PrismProperty<PolyString> nameProperty = findProperty(user, path);
    // THEN
    assertEquals("Wrong property value (path=" + path + ")", PrismTestUtil.createPolyString(USER_JACK_POLYNAME_ORIG), nameProperty.getRealValue());
    assertTrue("QName found something other", nameProperty == (PrismProperty) user.findProperty(UserType.F_POLY_NAME));
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.prism.foo.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 14 with UserType

use of com.evolveum.midpoint.prism.foo.UserType in project midpoint by Evolveum.

the class TestPrismObjectConstruction method testClone.

@Test
public void testClone() throws Exception {
    final String TEST_NAME = "testClone";
    PrismInternalTestUtil.displayTestTitle(TEST_NAME);
    // GIVEN
    PrismContext ctx = constructInitializedPrismContext();
    PrismObjectDefinition<UserType> userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user"));
    PrismObject<UserType> user = userDefinition.instantiate();
    fillInUserDrake(user, true);
    // precondition
    assertUserDrake(user, true, ctx);
    // WHEN
    PrismObject<UserType> clone = user.clone();
    // THEN
    System.out.println("Cloned user:");
    System.out.println(clone.debugDump());
    // Check if the values are correct, also checking definitions
    assertUserDrake(clone, true, ctx);
}
Also used : QName(javax.xml.namespace.QName) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Example 15 with UserType

use of com.evolveum.midpoint.prism.foo.UserType in project midpoint by Evolveum.

the class TestPrismObjectConstruction method testDefinitionlessConstructionAndSchemaApplication.

/**
	 * Construct object without schema. Starts by creating object "out of the blue" and
	 * the working downwards. Then apply the schema. Check definitions.
	 */
//	@Test
public void testDefinitionlessConstructionAndSchemaApplication() throws Exception {
    final String TEST_NAME = "testDefinitionlessConstructionAndSchemaApplication";
    PrismInternalTestUtil.displayTestTitle(TEST_NAME);
    // GIVEN
    // No context needed (yet)
    PrismObject<UserType> user = new PrismObject<UserType>(USER_QNAME, UserType.class);
    // Fill-in object values, no schema checking
    fillInUserDrake(user, false);
    // Make sure the object is OK
    PrismContext ctx = constructInitializedPrismContext();
    assertUserDrake(user, false, ctx);
    PrismObjectDefinition<UserType> userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user"));
    // WHEN
    user.applyDefinition(userDefinition);
    // THEN
    System.out.println("User:");
    System.out.println(user.debugDump());
    // Check schema now 
    assertUserDrake(user, true, ctx);
}
Also used : QName(javax.xml.namespace.QName) UserType(com.evolveum.midpoint.prism.foo.UserType)

Aggregations

UserType (com.evolveum.midpoint.prism.foo.UserType)30 Test (org.testng.annotations.Test)27 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)14 QName (javax.xml.namespace.QName)10 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)8 AssignmentType (com.evolveum.midpoint.prism.foo.AssignmentType)7 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)7 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)6 ActivationType (com.evolveum.midpoint.prism.foo.ActivationType)4 PrismInternalTestUtil.constructInitializedPrismContext (com.evolveum.midpoint.prism.PrismInternalTestUtil.constructInitializedPrismContext)3 Document (org.w3c.dom.Document)3 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)2 SchemaRegistryImpl (com.evolveum.midpoint.prism.schema.SchemaRegistryImpl)2 RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 Element (org.w3c.dom.Element)2 AccountConstructionType (com.evolveum.midpoint.prism.foo.AccountConstructionType)1 AccountType (com.evolveum.midpoint.prism.foo.AccountType)1 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)1 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)1