Search in sources :

Example 16 with QName

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

the class TestPrismContext method testCompileTimeClassmap.

@Test
public void testCompileTimeClassmap() throws SchemaException, SAXException, IOException {
    System.out.println("===[ testCompileTimeClassmap ]===");
    // WHEN
    PrismContext prismContext = constructInitializedPrismContext();
    // THEN
    assertNotNull("No prism context", prismContext);
    SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
    assertNotNull("No schema registry in context", schemaRegistry);
    SchemaDescription fooDesc = schemaRegistry.findSchemaDescriptionByNamespace(NS_FOO);
    Map<QName, Class<?>> map = fooDesc.getXsdTypeTocompileTimeClassMap();
    assertNotNull("No XsdTypeTocompileTimeClassMap", map);
    assertFalse("Empty XsdTypeTocompileTimeClassMap", map.isEmpty());
    assertMapping(map, UserType.class, USER_TYPE_QNAME);
    assertMapping(map, AccountType.class, ACCOUNT_TYPE_QNAME);
    assertMapping(map, AssignmentType.class, ASSIGNMENT_TYPE_QNAME);
    assertMapping(map, ActivationType.class, ACTIVATION_TYPE_QNAME);
    // This is not a container, but it should be in the map anyway
    assertMapping(map, AccountConstructionType.class, ACCOUNT_CONSTRUCTION_TYPE_QNAME);
}
Also used : SchemaDescription(com.evolveum.midpoint.prism.schema.SchemaDescription) QName(javax.xml.namespace.QName) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Example 17 with QName

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

the class TestPrismContext method testBasicSchemas.

@Test
public void testBasicSchemas() throws SchemaException, SAXException, IOException {
    System.out.println("===[ testBasicSchemas ]===");
    // WHEN
    PrismContext prismContext = constructInitializedPrismContext();
    // THEN
    assertNotNull("No prism context", prismContext);
    SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
    assertNotNull("No schema registry in context", schemaRegistry);
    System.out.println("Schema registry:");
    System.out.println(schemaRegistry.debugDump());
    PrismSchema fooSchema = schemaRegistry.findSchemaByNamespace(NS_FOO);
    System.out.println("Foo schema:");
    System.out.println(fooSchema.debugDump());
    // Assert USER definition
    PrismObjectDefinition<UserType> userDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO, "user"));
    assertNotNull("No user definition", userDefinition);
    System.out.println("User definition:");
    System.out.println(userDefinition.debugDump());
    PrismObjectDefinition<UserType> userDefinitionByClass = schemaRegistry.findObjectDefinitionByCompileTimeClass(UserType.class);
    assertTrue("Different user def", userDefinition == userDefinitionByClass);
    assertUserDefinition(userDefinition);
    // Assert ACCOUNT definition
    PrismObjectDefinition<AccountType> accountDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO, "account"));
    assertNotNull("No account definition", accountDefinition);
    System.out.println("Account definition:");
    System.out.println(accountDefinition.debugDump());
    PrismObjectDefinition<AccountType> accountDefinitionByClass = schemaRegistry.findObjectDefinitionByCompileTimeClass(AccountType.class);
    assertTrue("Different user def", accountDefinition == accountDefinitionByClass);
    assertAccountDefinition(accountDefinition);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) QName(javax.xml.namespace.QName) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) UserType(com.evolveum.midpoint.prism.foo.UserType) AccountType(com.evolveum.midpoint.prism.foo.AccountType) Test(org.testng.annotations.Test)

Example 18 with QName

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

the class TestPath method testPathNormalize.

@Test
public void testPathNormalize() throws Exception {
    System.out.println("\n\n===[ testPathNormalize ]===\n");
    // GIVEN
    ItemPath path1 = new ItemPath(new QName(NS, "foo"), new QName(NS, "bar"));
    ItemPath path2 = new ItemPath(new NameItemPathSegment(new QName(NS, "foo")), new IdItemPathSegment(123L), new NameItemPathSegment(new QName(NS, "bar")));
    ItemPath path22 = new ItemPath(new NameItemPathSegment(new QName(NS, "foo")), new IdItemPathSegment(123L), new NameItemPathSegment(new QName(NS, "bar")), new IdItemPathSegment(null));
    ItemPath path3 = new ItemPath(new NameItemPathSegment(new QName(NS, "foo")), new IdItemPathSegment(123L), new NameItemPathSegment(new QName(NS, "bar")), new IdItemPathSegment(333L));
    ItemPath path4 = new ItemPath(new QName(NS, "x"));
    ItemPath path5 = new ItemPath(new NameItemPathSegment(new QName(NS, "foo")), new IdItemPathSegment(123L));
    ItemPath pathE = new ItemPath();
    // WHEN
    ItemPath normalized1 = path1.normalize();
    ItemPath normalized2 = path2.normalize();
    ItemPath normalized22 = path22.normalize();
    ItemPath normalized3 = path3.normalize();
    ItemPath normalized4 = path4.normalize();
    ItemPath normalized5 = path5.normalize();
    ItemPath normalizedE = pathE.normalize();
    // THEN
    System.out.println("Normalized path 1:" + normalized1);
    System.out.println("Normalized path 2:" + normalized2);
    System.out.println("Normalized path 22:" + normalized22);
    System.out.println("Normalized path 3:" + normalized3);
    System.out.println("Normalized path 4:" + normalized4);
    System.out.println("Normalized path 5:" + normalized5);
    System.out.println("Normalized path E:" + normalizedE);
    assertNormalizedPath(normalized1, "foo", null, "bar");
    assertNormalizedPath(normalized2, "foo", 123L, "bar");
    assertNormalizedPath(normalized22, "foo", 123L, "bar", null);
    assertNormalizedPath(normalized3, "foo", 123L, "bar", 333L);
    assertNormalizedPath(normalized4, "x");
    assertNormalizedPath(normalized5, "foo", 123L);
    assert normalizedE.isEmpty() : "normalizedE is not empty";
}
Also used : QName(javax.xml.namespace.QName) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 19 with QName

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

the class TestObjectQuery method testMatchEqualMultivalue.

@Test
public void testMatchEqualMultivalue() throws Exception {
    PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
    PrismPropertyDefinitionImpl def = new PrismPropertyDefinitionImpl(new QName("indexedString"), DOMUtil.XSD_STRING, PrismTestUtil.getPrismContext());
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(new ItemPath(UserType.F_EXTENSION, "indexedString"), def).eq("alpha").buildFilter();
    boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
    AssertJUnit.assertTrue("filter does not match object", match);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) UserType(com.evolveum.midpoint.prism.foo.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 20 with QName

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

the class DeltaConvertor method createItemDelta.

public static <IV extends PrismValue, ID extends ItemDefinition> ItemDelta<IV, ID> createItemDelta(ItemDeltaType propMod, PrismContainerDefinition<?> pcDef, boolean allowRawValues) throws SchemaException {
    ItemPathType parentPathType = propMod.getPath();
    ItemPath parentPath = null;
    if (parentPathType != null) {
        parentPath = parentPathType.getItemPath();
    } else {
        throw new IllegalStateException("Path argument in the itemDelta HAVE TO BE specified.");
    }
    if (propMod.getValue() == null) {
        throw new IllegalArgumentException("No value in item delta (path: " + parentPath + ") while creating a property delta");
    }
    ItemDefinition containingPcd = pcDef.findItemDefinition(parentPath);
    PrismContainerDefinition containerDef = null;
    if (containingPcd == null) {
        containerDef = pcDef.findContainerDefinition(parentPath.allUpToLastNamed());
        if (containerDef == null) {
            if (allowRawValues) {
                return null;
            }
            throw new SchemaException("No definition for " + parentPath.allUpToLastNamed().lastNamed().getName() + " (while creating delta for " + pcDef + ")");
        }
    }
    QName elementName = parentPath.lastNamed().getName();
    //propMod.getValue().getParsedValue(containingPcd);
    Item item = RawTypeUtil.getParsedItem(containingPcd, propMod.getValue(), elementName, containerDef);
    ItemDelta<IV, ID> itemDelta = item.createDelta(parentPath);
    if (propMod.getModificationType() == ModificationTypeType.ADD) {
        itemDelta.addValuesToAdd(PrismValue.resetParentCollection(PrismValue.cloneCollection(item.getValues())));
    } else if (propMod.getModificationType() == ModificationTypeType.DELETE) {
        itemDelta.addValuesToDelete(PrismValue.resetParentCollection(PrismValue.cloneCollection(item.getValues())));
    } else if (propMod.getModificationType() == ModificationTypeType.REPLACE) {
        itemDelta.setValuesToReplace(PrismValue.resetParentCollection(PrismValue.cloneCollection(item.getValues())));
    }
    if (!propMod.getEstimatedOldValue().isEmpty()) {
        Item oldItem = RawTypeUtil.getParsedItem(containingPcd, propMod.getEstimatedOldValue(), elementName, containerDef);
        itemDelta.addEstimatedOldValues(PrismValue.resetParentCollection(PrismValue.cloneCollection(oldItem.getValues())));
    }
    return itemDelta;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

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