use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testDefaultValueMethodMulti.
@Test
public void testDefaultValueMethodMulti() throws Exception {
Parameter p = new Parameter();
p.setXpathExpression("*/*");
p.setValue("<doc/>");
p.setDefaultValue("fakeDefaultValue");
p.setPattern("{sessionKeyForPattern}");
p.setDefaultValueMethods("sessionKey,value,pattern");
p.configure();
PipeLineSession session = new PipeLineSession();
session.put("sessionKeyForDefaultValue", "fakeDefaultValueSessionKey");
session.put("sessionKeyForPattern", "fakePatternSessionKey");
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
Message message = new Message("fakeMessage");
String result = (String) p.getValue(alreadyResolvedParameters, message, session, false);
assertEquals("<doc/>", result);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testDefaultValueMethodDefault.
@Test
public void testDefaultValueMethodDefault() throws Exception {
Parameter p = new Parameter();
p.setXpathExpression("*/*");
p.setValue("<doc/>");
p.setDefaultValue("fakeDefaultValue");
p.setSessionKey("sessionKeyForDefaultValue");
p.setPattern("{sessionKeyForPattern}");
p.configure();
PipeLineSession session = new PipeLineSession();
session.put("sessionKeyForDefaultValue", "fakeDefaultValueSessionKey");
session.put("sessionKeyForPattern", "fakePatternSessionKey");
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
Message message = new Message("fakeMessage");
String result = (String) p.getValue(alreadyResolvedParameters, message, session, false);
assertEquals("fakeDefaultValue", result);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testParameterFromBytesToNode.
@Test
public void testParameterFromBytesToNode() throws Exception {
PipeLineSession session = new PipeLineSession();
session.put("originalMessage", "<someValue/>".getBytes());
String expectedResultContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><someValue/>";
Parameter parameter = new Parameter();
parameter.setName("InputMessage");
parameter.setSessionKey("originalMessage");
parameter.setType(ParameterType.NODE);
parameter.configure();
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
Message message = new Message("fakeMessage");
Object result = parameter.getValue(alreadyResolvedParameters, message, session, true);
assertThat(result, instanceOf(Node.class));
assertThat(result, not(instanceOf(Document.class)));
String contents = XmlUtils.transformXml(TransformerFactory.newInstance().newTransformer(), new DOMSource((Node) result));
assertEquals(expectedResultContents, contents);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testParameterFromNodeToDomdoc.
@Test
public void testParameterFromNodeToDomdoc() throws Exception {
Node node = XmlUtils.buildDomDocument("<someValue/>").getFirstChild();
String expectedResultContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><someValue/>";
PipeLineSession session = new PipeLineSession();
session.put("originalMessage", node);
Parameter parameter = new Parameter();
parameter.setName("InputMessage");
parameter.setSessionKey("originalMessage");
parameter.setType(ParameterType.DOMDOC);
parameter.configure();
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
Message message = new Message("fakeMessage");
Object result = parameter.getValue(alreadyResolvedParameters, message, session, true);
assertThat(result, instanceOf(Document.class));
String contents = XmlUtils.transformXml(TransformerFactory.newInstance().newTransformer(), new DOMSource((Document) result));
assertEquals(expectedResultContents, contents);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testParameterXPathEmptySessionKey.
@Test
public void testParameterXPathEmptySessionKey() throws Exception {
Parameter p = new Parameter();
p.setName("number");
p.setSessionKey("emptySessionKey");
p.setXpathExpression("/dummy");
p.setDefaultValue("fakeDefault");
p.configure();
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
Message message = new Message("fakeMessage");
PipeLineSession session = new PipeLineSession();
session.put("emptySessionKey", "");
Object result = p.getValue(alreadyResolvedParameters, message, session, false);
assertEquals("fakeDefault", Message.asMessage(result).asString());
}
Aggregations