use of com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType in project midpoint by Evolveum.
the class TestJaxbConstruction method testUserConstructionBeforeAdopt.
@Test
public void testUserConstructionBeforeAdopt() throws Exception {
System.out.println("\n\n ===[ testUserConstructionBeforeAdopt ]===\n");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
UserType userType = new UserType();
userType.setFullName(new PolyStringType("Čučoriedka"));
userType.setDescription("blah blah");
ExtensionType extension = new ExtensionType();
userType.setExtension(extension);
AssignmentType assignmentType = new AssignmentType();
userType.getAssignment().add(assignmentType);
// Assignment
ExtensionType assignmentExtension = new ExtensionType();
assignmentType.setExtension(assignmentExtension);
// accountRef/account
ObjectReferenceType accountRefType = new ObjectReferenceType();
accountRefType.setOid(USER_ACCOUNT_REF_1_OID);
MapXNode filterElement = createFilter();
SearchFilterType filter = new SearchFilterType();
filter.setFilterClauseXNode(filterElement);
accountRefType.setFilter(filter);
userType.getLinkRef().add(accountRefType);
ShadowType accountShadowType = new ShadowType();
accountShadowType.setOid(USER_ACCOUNT_REF_1_OID);
userType.getLink().add(accountShadowType);
accountShadowType = new ShadowType();
accountShadowType.setOid(USER_ACCOUNT_REF_2_OID);
userType.getLink().add(accountShadowType);
// WHEN
prismContext.adopt(userType);
// THEN
PrismObject<UserType> user = userType.asPrismObject();
assertNotNull("No object definition after adopt", user.getDefinition());
SchemaTestUtil.assertUserDefinition(user.getDefinition());
// fullName: PolyString
PrismProperty<PolyString> fullNameProperty = user.findProperty(UserType.F_FULL_NAME);
user.checkConsistence();
user.assertDefinitions();
PolyString fullName = fullNameProperty.getRealValue();
assertEquals("Wrong fullName orig", "Čučoriedka", fullName.getOrig());
assertEquals("Wrong fullName norm", "cucoriedka", fullName.getNorm());
PrismProperty<String> descriptionProperty = user.findProperty(UserType.F_DESCRIPTION);
assertEquals("Wrong description value", "blah blah", descriptionProperty.getRealValue());
PrismContainer<Containerable> extensionContainer = user.findContainer(GenericObjectType.F_EXTENSION);
checkExtension(extensionContainer, "user extension");
checkExtension(extension, "user extension");
PrismReference accountRef = user.findReference(UserType.F_LINK_REF);
assertEquals("Wrong accountRef values", 2, accountRef.getValues().size());
PrismAsserts.assertReferenceValues(accountRef, USER_ACCOUNT_REF_1_OID, USER_ACCOUNT_REF_2_OID);
PrismReferenceValue accountRefVal0 = accountRef.getValue(0);
SearchFilterType prismFilter = accountRefVal0.getFilter();
assertNotNull("Filter have not passed", prismFilter);
// assertTrue("Wrong filter in reference " , prismFilter instanceof EqualsFilter);
// assertEquals("Difference filter", filterElement, prismFilter);
assertAccountRefs(userType, USER_ACCOUNT_REF_1_OID, USER_ACCOUNT_REF_2_OID);
user.assertDefinitions();
user.checkConsistence();
}
Aggregations