Search in sources :

Example 6 with StringPayloadDataInputParameter

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

the class XPathServiceTest method testPayloadAttributeValueXPathIntoMetadata.

@Test
public void testPayloadAttributeValueXPathIntoMetadata() throws Exception {
    message.setContent(sampleXml, message.getContentEncoding());
    MetadataDataOutputParameter metadataDataDestination1 = new MetadataDataOutputParameter("targetMetadataKey");
    ConstantDataInputParameter constantDataDestination = new ConstantDataInputParameter("//some/random/xml/node1/@attr");
    Execution execution = new Execution(constantDataDestination, metadataDataDestination1);
    List<Execution> executions = new ArrayList<>();
    executions.add(execution);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    execute(service, message);
    assertEquals("attribute value", message.getMetadataValue("targetMetadataKey"));
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) ArrayList(java.util.ArrayList) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) Test(org.junit.Test)

Example 7 with StringPayloadDataInputParameter

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

the class XPathServiceTest method testPayloadSimpleValueXPathIntoMultipleMetadataExecutions.

@Test
public void testPayloadSimpleValueXPathIntoMultipleMetadataExecutions() throws Exception {
    message.setContent(sampleXml, message.getContentEncoding());
    MetadataDataOutputParameter metadataDataDestination1 = new MetadataDataOutputParameter("targetMetadataKey1");
    ConstantDataInputParameter constantDataDestination1 = new ConstantDataInputParameter("//some/random/xml/node1/text()");
    MetadataDataOutputParameter metadataDataDestination2 = new MetadataDataOutputParameter("targetMetadataKey2");
    ConstantDataInputParameter constantDataDestination2 = new ConstantDataInputParameter("//some/random/xml/node2/text()");
    MetadataDataOutputParameter metadataDataDestination3 = new MetadataDataOutputParameter("targetMetadataKey3");
    ConstantDataInputParameter constantDataDestination3 = new ConstantDataInputParameter("//some/random/xml/node3/text()");
    Execution execution = new Execution(constantDataDestination1, metadataDataDestination1);
    Execution execution2 = new Execution(constantDataDestination2, metadataDataDestination2);
    Execution execution3 = new Execution(constantDataDestination3, metadataDataDestination3);
    List<Execution> executions = new ArrayList<>();
    executions.add(execution);
    executions.add(execution2);
    executions.add(execution3);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    execute(service, message);
    assertEquals("value1", message.getMetadataValue("targetMetadataKey1"));
    assertEquals("value2", message.getMetadataValue("targetMetadataKey2"));
    assertEquals("value3", message.getMetadataValue("targetMetadataKey3"));
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) ArrayList(java.util.ArrayList) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) Test(org.junit.Test)

Example 8 with StringPayloadDataInputParameter

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

the class XPathServiceTest method testPayloadComplexValueXPathIntoMetadata.

@Test
public void testPayloadComplexValueXPathIntoMetadata() throws Exception {
    message.setContent(sampleXml, message.getContentEncoding());
    MetadataDataOutputParameter metadataDataDestination1 = new MetadataDataOutputParameter("targetMetadataKey");
    ConstantDataInputParameter constantDataDestination = new ConstantDataInputParameter("//some/random/xml/node1");
    Execution execution = new Execution(constantDataDestination, metadataDataDestination1);
    List<Execution> executions = new ArrayList<>();
    executions.add(execution);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    execute(service, message);
    assertEquals("<node1 attr=\"attribute value\">value1</node1>", message.getMetadataValue("targetMetadataKey"));
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) ArrayList(java.util.ArrayList) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) Test(org.junit.Test)

Example 9 with StringPayloadDataInputParameter

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

the class XPathServiceTest method testForCoveragePurposesInvalidXml.

@Test
public void testForCoveragePurposesInvalidXml() throws Exception {
    message.setContent("not valid xml!", message.getContentEncoding());
    MetadataDataOutputParameter metadataDataDestination1 = new MetadataDataOutputParameter("targetMetadataKey");
    ConstantDataInputParameter constantDataDestination = new ConstantDataInputParameter("//some/random/xml/node1/text()");
    Execution execution = new Execution(constantDataDestination, metadataDataDestination1);
    List<Execution> executions = new ArrayList<>();
    executions.add(execution);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    try {
        execute(service, message);
    } catch (ServiceException ex) {
    // expected
    }
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) ServiceException(com.adaptris.core.ServiceException) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) ArrayList(java.util.ArrayList) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) Test(org.junit.Test)

Aggregations

Execution (com.adaptris.core.common.Execution)9 StringPayloadDataInputParameter (com.adaptris.core.common.StringPayloadDataInputParameter)9 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)8 ConstantDataInputParameter (com.adaptris.core.common.ConstantDataInputParameter)6 MetadataDataOutputParameter (com.adaptris.core.common.MetadataDataOutputParameter)6 MetadataDataInputParameter (com.adaptris.core.common.MetadataDataInputParameter)4 StringPayloadDataOutputParameter (com.adaptris.core.common.StringPayloadDataOutputParameter)3 KeyValuePair (com.adaptris.util.KeyValuePair)2 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)2 ServiceException (com.adaptris.core.ServiceException)1