Search in sources :

Example 11 with XpathQuery

use of com.adaptris.core.services.metadata.xpath.XpathQuery in project interlok by adaptris.

the class XpathMetadataServiceTest method testSetXpathQueryList.

@Test
public void testSetXpathQueryList() {
    XpathMetadataService service = new XpathMetadataService();
    assertEquals(0, service.getXpathQueries().size());
    XpathQuery query = new ConfiguredXpathQuery("metadataKey", "//root");
    List<XpathQuery> list = new ArrayList<>();
    list.add(query);
    service.setXpathQueries(list);
    assertEquals(list, service.getXpathQueries());
    try {
        service.setXpathQueries(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertEquals(list, service.getXpathQueries());
}
Also used : XpathQuery(com.adaptris.core.services.metadata.xpath.XpathQuery) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) MetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MetadataXpathQuery) MultiItemMetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemMetadataXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 12 with XpathQuery

use of com.adaptris.core.services.metadata.xpath.XpathQuery in project interlok by adaptris.

the class XpathMetadataServiceTest method testDoService_UsingXpathQuery.

@Test
public void testDoService_UsingXpathQuery() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
    XpathMetadataService service = new XpathMetadataService();
    service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("source", "//source-id"), new ConfiguredXpathQuery("destination", "//destination-id"))));
    execute(service, msg);
    assertEquals("partnera", msg.getMetadataValue("source"));
    assertEquals("partnerb", msg.getMetadataValue("destination"));
}
Also used : XpathQuery(com.adaptris.core.services.metadata.xpath.XpathQuery) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) MetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MetadataXpathQuery) MultiItemMetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemMetadataXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) Test(org.junit.Test)

Aggregations

XpathQuery (com.adaptris.core.services.metadata.xpath.XpathQuery)12 ConfiguredXpathQuery (com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery)10 MetadataXpathQuery (com.adaptris.core.services.metadata.xpath.MetadataXpathQuery)8 MultiItemConfiguredXpathQuery (com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery)8 MultiItemMetadataXpathQuery (com.adaptris.core.services.metadata.xpath.MultiItemMetadataXpathQuery)8 Test (org.junit.Test)8 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)6 ServiceException (com.adaptris.core.ServiceException)4 DocumentBuilderFactoryBuilder (com.adaptris.core.util.DocumentBuilderFactoryBuilder)3 ArrayList (java.util.ArrayList)2 CoreException (com.adaptris.core.CoreException)1 MetadataElement (com.adaptris.core.MetadataElement)1 LogMessageService (com.adaptris.core.services.LogMessageService)1 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)1 XpathMetadataService (com.adaptris.core.services.metadata.XpathMetadataService)1 XpathObjectQuery (com.adaptris.core.services.metadata.xpath.XpathObjectQuery)1 TruncateMetadata (com.adaptris.core.util.TruncateMetadata)1 KeyValuePair (com.adaptris.util.KeyValuePair)1 SimpleNamespaceContext (com.adaptris.util.text.xml.SimpleNamespaceContext)1 XPath (com.adaptris.util.text.xml.XPath)1