Search in sources :

Example 1 with MetadataDataInputParameter

use of com.adaptris.core.common.MetadataDataInputParameter in project interlok by adaptris.

the class RegexpServiceTest method testService_CachedPattern_Mismatch.

@Test
public void testService_CachedPattern_Mismatch() throws Exception {
    RegexpService s = new RegexpService();
    List<Execution> executions = s.getExecutions();
    executions.add(new Execution(new MetadataDataInputParameter(SOURCE_METADATA_KEY), new MetadataDataOutputParameter(TARGET_METADATA_KEY)));
    start(s);
    AdaptrisMessage msg1 = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
    msg1.addMetadata(new MetadataElement(SOURCE_METADATA_KEY, POSTCODE_REGEXP));
    s.doService(msg1);
    AdaptrisMessage msg2 = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
    msg2.addMetadata(new MetadataElement(SOURCE_METADATA_KEY, ALTERNATE_REGEX));
    s.doService(msg2);
    stop(s);
    assertEquals("UB3 5AN", msg1.getMetadataValue(TARGET_METADATA_KEY));
    assertFalse(msg2.containsKey(TARGET_METADATA_KEY));
}
Also used : Execution(com.adaptris.core.common.Execution) MetadataDataInputParameter(com.adaptris.core.common.MetadataDataInputParameter) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) MetadataElement(com.adaptris.core.MetadataElement) Test(org.junit.Test)

Example 2 with MetadataDataInputParameter

use of com.adaptris.core.common.MetadataDataInputParameter in project interlok by adaptris.

the class XPathServiceTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    MetadataDataOutputParameter metadataDataDestination1 = new MetadataDataOutputParameter("targetMetadataKey");
    MetadataDataInputParameter metadataDataDestination2 = new MetadataDataInputParameter("sourceXpathMetadataKey");
    ConstantDataInputParameter constantDataDestination = new ConstantDataInputParameter("//my/xpath/expression");
    constantDataDestination.setValue("//my/xpath/expression");
    Execution execution1 = new Execution();
    execution1.setSource(constantDataDestination);
    execution1.setTarget(metadataDataDestination1);
    Execution execution2 = new Execution();
    execution2.setSource(metadataDataDestination2);
    execution2.setTarget(new MetadataDataOutputParameter("targetMetadataKey2"));
    List<Execution> executions = new ArrayList<Execution>();
    executions.add(execution1);
    executions.add(execution2);
    KeyValuePairSet namespaceMappings = new KeyValuePairSet();
    namespaceMappings.addKeyValuePair(new KeyValuePair("some", "http://adaptris.com/xml/some"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n1", "http://adaptris.com/xml/n1"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n2", "http://adaptris.com/xml/n2"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n3", "http://adaptris.com/xml/n3"));
    service.setNamespaceContext(namespaceMappings);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    return service;
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) MetadataDataInputParameter(com.adaptris.core.common.MetadataDataInputParameter) KeyValuePair(com.adaptris.util.KeyValuePair) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) ArrayList(java.util.ArrayList) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 3 with MetadataDataInputParameter

use of com.adaptris.core.common.MetadataDataInputParameter in project interlok by adaptris.

the class XPathServiceTest method testPayloadSimpleValueXPathIntoPayload.

@Test
public void testPayloadSimpleValueXPathIntoPayload() throws Exception {
    message.setContent(sampleXml, message.getContentEncoding());
    message.addMetadata("sourceXpathMetadataKey", "//some/random/xml/node1/text()");
    MetadataDataInputParameter metadataDataDestination1 = new MetadataDataInputParameter("sourceXpathMetadataKey");
    Execution execution = new Execution(metadataDataDestination1, new StringPayloadDataOutputParameter());
    List<Execution> executions = new ArrayList<>();
    executions.add(execution);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    execute(service, message);
    assertEquals("value1", message.getContent());
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) MetadataDataInputParameter(com.adaptris.core.common.MetadataDataInputParameter) ArrayList(java.util.ArrayList) StringPayloadDataOutputParameter(com.adaptris.core.common.StringPayloadDataOutputParameter) Test(org.junit.Test)

Example 4 with MetadataDataInputParameter

use of com.adaptris.core.common.MetadataDataInputParameter in project interlok by adaptris.

the class XPathServiceTest method testPayloadSimpleValueXPathIntoPayloadWithHeaderNamespaces.

@Test
public void testPayloadSimpleValueXPathIntoPayloadWithHeaderNamespaces() throws Exception {
    message.setContent(sampleXmlWithHeaderNamespaces, message.getContentEncoding());
    message.addMetadata("sourceXpathMetadataKey", "//some:some/random/xml/n1:node1/text()");
    MetadataDataInputParameter metadataDataDestination1 = new MetadataDataInputParameter("sourceXpathMetadataKey");
    Execution execution = new Execution(metadataDataDestination1, new StringPayloadDataOutputParameter());
    List<Execution> executions = new ArrayList<>();
    executions.add(execution);
    // Add the namespace mappings
    KeyValuePairSet namespaceMappings = new KeyValuePairSet();
    namespaceMappings.addKeyValuePair(new KeyValuePair("some", "http://adaptris.com/xml/some"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n1", "http://adaptris.com/xml/n1"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n2", "http://adaptris.com/xml/n2"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n3", "http://adaptris.com/xml/n3"));
    service.setNamespaceContext(namespaceMappings);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    execute(service, message);
    assertEquals("value1", message.getContent());
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) MetadataDataInputParameter(com.adaptris.core.common.MetadataDataInputParameter) KeyValuePair(com.adaptris.util.KeyValuePair) ArrayList(java.util.ArrayList) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) StringPayloadDataOutputParameter(com.adaptris.core.common.StringPayloadDataOutputParameter) Test(org.junit.Test)

Example 5 with MetadataDataInputParameter

use of com.adaptris.core.common.MetadataDataInputParameter in project interlok by adaptris.

the class XPathServiceTest method testPayloadSimpleValueXPathIntoPayloadWithNamespace.

@Test
public void testPayloadSimpleValueXPathIntoPayloadWithNamespace() throws Exception {
    message.setContent(sampleXmlWithInternalNamespaces, message.getContentEncoding());
    message.addMetadata("sourceXpathMetadataKey", "//some/random/xml/node1/text()");
    MetadataDataInputParameter metadataDataDestination1 = new MetadataDataInputParameter("sourceXpathMetadataKey");
    Execution execution = new Execution(metadataDataDestination1, new StringPayloadDataOutputParameter());
    List<Execution> executions = new ArrayList<>();
    executions.add(execution);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    execute(service, message);
    assertEquals("value1", message.getContent());
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) MetadataDataInputParameter(com.adaptris.core.common.MetadataDataInputParameter) ArrayList(java.util.ArrayList) StringPayloadDataOutputParameter(com.adaptris.core.common.StringPayloadDataOutputParameter) Test(org.junit.Test)

Aggregations

Execution (com.adaptris.core.common.Execution)5 MetadataDataInputParameter (com.adaptris.core.common.MetadataDataInputParameter)5 StringPayloadDataInputParameter (com.adaptris.core.common.StringPayloadDataInputParameter)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 StringPayloadDataOutputParameter (com.adaptris.core.common.StringPayloadDataOutputParameter)3 MetadataDataOutputParameter (com.adaptris.core.common.MetadataDataOutputParameter)2 KeyValuePair (com.adaptris.util.KeyValuePair)2 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 MetadataElement (com.adaptris.core.MetadataElement)1 ConstantDataInputParameter (com.adaptris.core.common.ConstantDataInputParameter)1