GenerateUniqueMetadataValueService extends MetadataServiceImpl { @Override public void doService(AdaptrisMessage msg) throws ServiceException { String metadataKey = metadataKey(msg); String metadataValue = getGenerator().create(msg); MetadataElement e = new MetadataElement(metadataKey, metadataValue); msg.addMetadata(e); logMetadata("Added {}", e); } GenerateUniqueMetadataValueService();  GenerateUniqueMetadataValueService(String metadataKey);  GenerateUniqueMetadataValueService(String metadataKey, IdGenerator generator); @Override void doService(AdaptrisMessage msg); String getMetadataKey(); void setMetadataKey(String s); IdGenerator getGenerator(); void setGenerator(IdGenerator idg);  }
@Test public void testDoService() throws Exception { GenerateUniqueMetadataValueService service = new GenerateUniqueMetadataValueService("key"); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); execute(service, msg); assertTrue(msg.containsKey("key")); assertNotNull(msg.getMetadataValue("key")); }