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);
}
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));
}
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));
}
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);
}
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);
}
Aggregations