use of com.adaptris.core.common.Execution in project interlok by adaptris.
the class RegexpServiceTest method createService.
private RegexpService createService() {
RegexpService s = new RegexpService();
s.getExecutions().add(new Execution(new ConstantDataInputParameter(POSTCODE_REGEXP), new MetadataDataOutputParameter(TARGET_METADATA_KEY)));
return s;
}
use of com.adaptris.core.common.Execution 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));
}
use of com.adaptris.core.common.Execution in project interlok by adaptris.
the class RegexpServiceTest method testService_Exception.
@Test
public void testService_Exception() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ALTERNATE_PAYLOAD);
RegexpService s = new RegexpService();
s.getExecutions().add(new Execution(new DodgyInputParameter(), new MetadataDataOutputParameter(TARGET_METADATA_KEY)));
try {
execute(s, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.common.Execution 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;
}
use of com.adaptris.core.common.Execution in project interlok by adaptris.
the class XPathServiceTest method testPayloadSimpleValueXPathIntoMetadata.
@Test
public void testPayloadSimpleValueXPathIntoMetadata() throws Exception {
message.setContent(sampleXml, 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);
execute(service, message);
assertEquals("value1", message.getMetadataValue("targetMetadataKey"));
}
Aggregations