Search in sources :

Example 21 with QName

use of javax.xml.namespace.QName 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 22 with QName

use of javax.xml.namespace.QName 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)

Example 23 with QName

use of javax.xml.namespace.QName in project midpoint by Evolveum.

the class TestPrismObjectConstruction method testCloneEquals.

@Test
public void testCloneEquals() throws Exception {
    final String TEST_NAME = "testCloneEquals";
    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);
    PrismObject<UserType> clone = user.clone();
    // WHEN, THEN
    assertTrue("Clone not equal", clone.equals(user));
    assertTrue("Clone not equivalent", clone.equivalent(user));
}
Also used : QName(javax.xml.namespace.QName) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Example 24 with QName

use of javax.xml.namespace.QName in project midpoint by Evolveum.

the class TestPrismObjectConstruction method testConstructionWithSchema.

/**
     * Construct object with schema. Starts by instantiating a definition and working downwards.
     * All the items in the object should have proper definition.
     */
@Test
public void testConstructionWithSchema() throws Exception {
    final String TEST_NAME = "testConstructionWithSchema";
    PrismInternalTestUtil.displayTestTitle(TEST_NAME);
    // GIVEN
    PrismContext ctx = constructInitializedPrismContext();
    PrismObjectDefinition<UserType> userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user"));
    // WHEN
    PrismObject<UserType> user = userDefinition.instantiate();
    // Fill-in object values, checking presence of definition while doing so
    fillInUserDrake(user, true);
    // THEN
    System.out.println("User:");
    System.out.println(user.debugDump());
    // Check if the values are correct, also checking definitions
    assertUserDrake(user, true, ctx);
}
Also used : QName(javax.xml.namespace.QName) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Example 25 with QName

use of javax.xml.namespace.QName in project midpoint by Evolveum.

the class TestPrismParsing method test300MeleeContext.

@Test
public void test300MeleeContext() throws Exception {
    final String TEST_NAME = "test300MeleeContext";
    PrismInternalTestUtil.displayTestTitle(TEST_NAME);
    // GIVEN
    PrismContext prismContext = constructInitializedPrismContext();
    PrismObject<UserType> userJack = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME));
    PrismContainer<Containerable> meleeContextContainer = userJack.findOrCreateContainer(new ItemPath(UserType.F_EXTENSION, EXTENSION_MELEE_CONTEXT_ELEMENT));
    PrismReference opponentRef = meleeContextContainer.findOrCreateReference(EXTENSION_MELEE_CONTEXT_OPPONENT_REF_ELEMENT);
    PrismObject<UserType> userBarbossa = prismContext.parseObject(getFile(USER_BARBOSSA_FILE_BASENAME));
    // Cosmetics to make sure the equivalence assert below works
    userBarbossa.setElementName(EXTENSION_MELEE_CONTEXT_OPPONENT_ELEMENT);
    PrismReferenceValue opponentRefValue = new PrismReferenceValue();
    opponentRefValue.setObject(userBarbossa);
    opponentRef.add(opponentRefValue);
    System.out.println("User jack:");
    System.out.println(userJack.debugDump());
    // WHEN
    String elementJack = prismContext.serializeObjectToString(userJack, getOutputFormat());
    // THEN
    System.out.println("Serialized user jack:");
    System.out.println(elementJack);
    // TODO: see that there is really the serialized barbossa
    // WHEN
    PrismObject<UserType> reparsedUserJack = prismContext.parseObject(elementJack);
    // THEN
    System.out.println("Re-parsed user jack:");
    System.out.println(reparsedUserJack.debugDump());
    PrismReference reparsedOpponentRef = reparsedUserJack.findReference(new ItemPath(UserType.F_EXTENSION, EXTENSION_MELEE_CONTEXT_ELEMENT, EXTENSION_MELEE_CONTEXT_OPPONENT_REF_ELEMENT));
    assertNotNull("No opponent ref (reparsed)", reparsedOpponentRef);
    PrismReferenceValue reparsedOpponentRefValue = reparsedOpponentRef.getValue();
    assertNotNull("No opponent ref value (reparsed)", reparsedOpponentRefValue);
    PrismObject<UserType> reparsedUserBarbossa = reparsedOpponentRefValue.getObject();
    assertNotNull("No object in opponent ref value (reparsed)", reparsedUserBarbossa);
    PrismAsserts.assertEquivalent("User barbossa", userBarbossa, reparsedUserBarbossa);
    // Make the original user jack suitable for comparison.
    // Some of the accountRef information is (intentionally) lost in re-parsing therefore erase it before comparing
    PrismReference jackAccountRef = userJack.findReference(UserType.F_ACCOUNT_REF);
    for (PrismReferenceValue accRefVal : jackAccountRef.getValues()) {
        String oid = accRefVal.getOid();
        QName targetType = accRefVal.getTargetType();
        accRefVal.setObject(null);
        accRefVal.setOid(oid);
        accRefVal.setTargetType(targetType);
    }
    PrismAsserts.assertEquivalent("User jack", userJack, reparsedUserJack);
}
Also used : QName(javax.xml.namespace.QName) UserType(com.evolveum.midpoint.prism.foo.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

QName (javax.xml.namespace.QName)6720 Test (org.junit.Test)1407 URL (java.net.URL)1197 Service (javax.xml.ws.Service)1052 ArrayList (java.util.ArrayList)858 Bus (org.apache.cxf.Bus)486 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)462 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)395 Test (org.testng.annotations.Test)357 HashMap (java.util.HashMap)351 OMElement (org.apache.axiom.om.OMElement)344 Element (org.w3c.dom.Element)312 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)292 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)289 JBossWSTest (org.jboss.wsf.test.JBossWSTest)272 Document (org.w3c.dom.Document)263 List (java.util.List)240 IOException (java.io.IOException)218 InputStream (java.io.InputStream)218 JAXBElement (javax.xml.bind.JAXBElement)218