use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testParameterValueList.
@Test
public void testParameterValueList() throws Exception {
String sessionKey = "mySessionKey";
Parameter p = new Parameter();
p.setName("myParameter");
p.setSessionKey(sessionKey);
p.setType(ParameterType.LIST);
p.setXpathExpression("items/item");
p.configure();
PipeLineSession session = new PipeLineSession();
session.put(sessionKey, Arrays.asList(new String[] { "fiets", "bel", "appel" }));
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
Message message = new Message("fakeMessage");
Object result = p.getValue(alreadyResolvedParameters, message, session, false);
assertTrue(result instanceof String);
String stringResult = Message.asMessage(result).asString();
assertEquals("fiets bel appel", stringResult);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testPatternCombined.
@Test
public void testPatternCombined() throws ConfigurationException, ParameterException {
Parameter p = new Parameter();
p.setName("dummy");
p.setPattern("param [{siblingParameter}] sessionKey [{sessionKey}] username [{username}] password [{password}]");
p.setUsername("fakeUsername");
p.setPassword("fakePassword");
p.configure();
PipeLineSession session = new PipeLineSession();
session.put("sessionKey", "fakeSessionVariable");
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
Parameter siblingParameter = new Parameter();
siblingParameter.setName("siblingParameter");
siblingParameter.setValue("fakeParameterValue");
siblingParameter.configure();
alreadyResolvedParameters.add(new ParameterValue(siblingParameter, siblingParameter.getValue(alreadyResolvedParameters, null, session, false)));
assertEquals("param [fakeParameterValue] sessionKey [fakeSessionVariable] username [fakeUsername] password [fakePassword]", p.getValue(alreadyResolvedParameters, null, session, false));
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testContextKeyWithSessionKeyAndXPath.
@Test
public void testContextKeyWithSessionKeyAndXPath() throws ConfigurationException, ParameterException {
Parameter p = new Parameter();
p.setName("dummy");
p.setSessionKey("fakeSessionKey");
p.setContextKey("fakeContextKey");
p.setXpathExpression("count(root/a)");
p.configure();
Message input = new Message("fakeMessage1", new MessageContext().with("fakeContextKey", "<root><a/><a/></root>"));
Message sessionValue = new Message("fakeMessage2", new MessageContext().with("fakeContextKey", "<root><a/><a/><a/></root>"));
PipeLineSession session = new PipeLineSession();
session.put("fakeSessionKey", sessionValue);
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
assertEquals("3", p.getValue(alreadyResolvedParameters, input, session, false));
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testParameterFromURLToNodeWithXpath.
@Test
public void testParameterFromURLToNodeWithXpath() throws Exception {
URL originalMessage = TestFileUtils.getTestFileURL("/Xslt/MultiNamespace/in.xml");
String expectedResultContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><block><XDOC><REF_ID>0</REF_ID><XX>0</XX></XDOC><XDOC><REF_ID>1</REF_ID></XDOC><XDOC><REF_ID>2</REF_ID></XDOC></block>";
PipeLineSession session = new PipeLineSession();
session.put("originalMessage", Message.asMessage(originalMessage));
Parameter parameter = new Parameter();
parameter.setName("InputMessage");
parameter.setSessionKey("originalMessage");
parameter.setType(ParameterType.NODE);
parameter.setRemoveNamespaces(true);
parameter.setXpathExpression("*");
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 testDefaultValueMethodValue.
@Test
public void testDefaultValueMethodValue() throws Exception {
Parameter p = new Parameter();
p.setXpathExpression("*/*");
p.setValue("<doc/>");
p.setDefaultValue("fakeDefaultValue");
p.setSessionKey("sessionKeyForDefaultValue");
p.setPattern("{sessionKeyForPattern}");
p.setDefaultValueMethods("value");
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);
}
Aggregations