StringMetadataParameter implements XmlTransformParameter { @Override public Map createParameters(AdaptrisMessage msg, Map existingParams) { MetadataCollection metadataToInclude = metadataFilter.filter(msg); if (metadataToInclude.size() == 0) { return existingParams; } Map params = existingParams == null ? new HashMap() : new HashMap(existingParams); for (MetadataElement e : metadataToInclude) { params.put(e.getKey(), e.getValue()); } log.trace("Stylesheet parameters: {}", params); return params; } StringMetadataParameter();  StringMetadataParameter(String[] include, String[] exclude); @Override Map createParameters(AdaptrisMessage msg, Map existingParams); RegexMetadataFilter getMetadataFilter(); void setMetadataFilter(RegexMetadataFilter rmf);  }
@Test public void testCreateParameters() throws Exception { StringMetadataParameter p = new StringMetadataParameter(); AdaptrisMessage msg = createMessage(); Map map = p.createParameters(msg, null); assertNotNull(map); assertTrue(map.containsKey(KEY_STRING_METADATA)); assertEquals(METADATA_VALUE, map.get(KEY_STRING_METADATA)); Map existing = new HashMap(); existing.put("key", "value"); map = p.createParameters(msg, existing); assertNotNull(map); assertTrue(map.containsKey(KEY_STRING_METADATA)); assertEquals(METADATA_VALUE, map.get(KEY_STRING_METADATA)); }
@Test public void testCreateParameters_UnmatchedRegexp() throws Exception { StringMetadataParameter p = new StringMetadataParameter(new String[] { "abc" }, new String[] {}); AdaptrisMessage msg = createMessage(); Map existing = new HashMap(); Map map = p.createParameters(msg, existing); assertNotNull(map); assertTrue(map == existing); assertEquals(0, map.size()); }