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;
}
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"));
}
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"));
}
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"));
}
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
}
}
Aggregations