AddMetadataService extends MetadataServiceImpl { @Override public void doService(AdaptrisMessage msg) throws ServiceException { Set<MetadataElement> addedMetadata = new HashSet<MetadataElement>(); for (MetadataElement e : metadataElements) { MetadataElement addMe = build(e, msg); if (overwrite(msg, addMe.getKey())) { msg.addMetadata(addMe); addedMetadata.add(addMe); } } logMetadata("metadata added : {}", addedMetadata); } AddMetadataService();  AddMetadataService(Collection<MetadataElement> elements);  AddMetadataService(MetadataElement... elements); @Override void doService(AdaptrisMessage msg); Set<MetadataElement> getMetadataElements(); void setMetadataElements(Set<MetadataElement> s); void addMetadataElement(MetadataElement element); void addMetadataElement(String key, String value); Boolean getOverwrite(); void setOverwrite(Boolean b);  }
@Test public void testDoService() throws CoreException { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance() .newMessage(); msg.addMetadata("key1", "originalValue"); execute(service, msg); assertFalse(msg.getMetadataValue("key1").contentEquals("originalValue")); assertTrue(msg.getMetadataValue("key1").equals("val1")); assertTrue(msg.getMetadataValue("key2").equals("val2")); assertTrue(msg.getMetadataValue("key3") == null); }