MetadataDestination implements MessageDrivenDestination { public String getDestination(AdaptrisMessage msg) throws CoreException { String destinationName = ""; for (String key : keys) { destinationName += StringUtils.defaultIfEmpty(msg.getMetadataValue(key), ""); } destinationName = StringUtils.defaultIfEmpty(destinationName, null); log.debug("dynamic destination [{}]", destinationName); return destinationName; } MetadataDestination(); void addKey(String s); List<String> getKeys(); void setKeys(List<String> l); String getDestination(AdaptrisMessage msg);  }
@Test public void testGetDestination() throws CoreException { MetadataDestination dest = new MetadataDestination(); dest.addKey("key1"); dest.addKey("key2"); Set metadata = new HashSet(); metadata.add(new MetadataElement("key1", "val1")); metadata.add(new MetadataElement("key2", "val2")); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("payload", metadata); assertTrue("val1val2".equals(dest.getDestination(msg))); }