Search in sources :

Example 6 with ExtensionType

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();
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ExtensionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

ExtensionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType)6 Test (org.testng.annotations.Test)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)3 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)3 MapXNode (com.evolveum.midpoint.prism.xnode.MapXNode)2 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)2 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)2 CachingMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType)1 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)1 XmlSchemaType (com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType)1 SchemaDefinitionType (com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType)1 Element (org.w3c.dom.Element)1