use of com.adaptris.core.common.MetadataDataOutputParameter 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.MetadataDataOutputParameter 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.MetadataDataOutputParameter 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.MetadataDataOutputParameter 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
}
}
use of com.adaptris.core.common.MetadataDataOutputParameter in project interlok by adaptris.
the class ExceptionAsStringReportTest method testDoService_Metadata.
@Test
public void testDoService_Metadata() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addObjectHeader(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception("This is the exception"));
ExceptionReportService service = new ExceptionReportService(new ExceptionAsString().withTarget(new MetadataDataOutputParameter("exceptionKey")).withIncludeStackTrace(false));
execute(service, msg);
assertTrue(msg.getMetadataValue("exceptionKey").contains("This is the exception"));
}
Aggregations