XpathMappingDataDictionary extends AbstractXmlDataDictionary implements InitializingBean { @Override public <T> T translate(Node node, T value, TestContext context) { for (Map.Entry<String, String> expressionEntry : mappings.entrySet()) { String expression = expressionEntry.getKey(); NodeList findings = (NodeList) XPathUtils.evaluateExpression(node.getOwnerDocument(), expression, buildNamespaceContext(node), XPathConstants.NODESET); if (findings != null && containsNode(findings, node)) { if (log.isDebugEnabled()) { log.debug(String.format("Data dictionary setting element '%s' value: %s", XMLUtils.getNodesPathName(node), expressionEntry.getValue())); } return convertIfNecessary(expressionEntry.getValue(), value, context); } } return value; }  @Override T translate(Node node, T value, TestContext context); @Override void afterPropertiesSet(); NamespaceContextBuilder getNamespaceContextBuilder(); void setNamespaceContextBuilder(NamespaceContextBuilder namespaceContextBuilder);  }
@Test public void testTranslate() throws Exception { Message message = new DefaultMessage(payload); Map<String, String> mappings = new HashMap<String, String>(); mappings.put(" mappings.put(" mappings.put(" XpathMappingDataDictionary dictionary = new XpathMappingDataDictionary(); dictionary.setMappings(mappings); dictionary.processMessage(message, context); Assert.assertEquals(message.getPayload(String.class).trim(), "<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestMessage>" + System.getProperty("line.separator") + " <Text>Hello!</Text>" + System.getProperty("line.separator") + " <OtherText name=\"bar\">No changes</OtherText>" + System.getProperty("line.separator") + "</TestMessage>"); }