Search in sources :

Example 6 with ConstantDataInputParameter

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

the class AddPayloadTest method getService.

private AddPayloadService getService(String id, String payload, String encoding) {
    AddPayloadService service = new AddPayloadService();
    service.setNewPayloadId(id);
    service.setNewPayload(new ConstantDataInputParameter(payload));
    service.setNewPayloadEncoding(encoding);
    return service;
}
Also used : ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter)

Example 7 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter 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 8 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter 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 9 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter 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 10 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter 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

ConstantDataInputParameter (com.adaptris.core.common.ConstantDataInputParameter)13 Test (org.junit.Test)10 Execution (com.adaptris.core.common.Execution)7 MetadataDataOutputParameter (com.adaptris.core.common.MetadataDataOutputParameter)7 StringPayloadDataInputParameter (com.adaptris.core.common.StringPayloadDataInputParameter)6 ArrayList (java.util.ArrayList)6 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)5 ServiceException (com.adaptris.core.ServiceException)2 CoreException (com.adaptris.core.CoreException)1 ServiceList (com.adaptris.core.ServiceList)1 MetadataDataInputParameter (com.adaptris.core.common.MetadataDataInputParameter)1 PayloadInputStreamWrapper (com.adaptris.core.common.PayloadInputStreamWrapper)1 PayloadOutputStreamWrapper (com.adaptris.core.common.PayloadOutputStreamWrapper)1 LogMessageService (com.adaptris.core.services.LogMessageService)1 KeyValuePair (com.adaptris.util.KeyValuePair)1 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)1 InputStream (java.io.InputStream)1