AddFormattedMetadataService extends ServiceImp { private ElementFormatter elementFormatter() { return ObjectUtils.defaultIfNull(getElementFormatter(), DEF_FORMATTER); } AddFormattedMetadataService(); @Override void doService(AdaptrisMessage msg); @Override void prepare(); String getFormatString(); void setFormatString(String formatString); AddFormattedMetadataService withFormatString(String s); List<String> getArgumentMetadataKeys(); void setArgumentMetadataKeys(List<String> l); AddFormattedMetadataService withArgumentMetadataKeys(List<String> s); AddFormattedMetadataService withArgumentMetadataKeys(String... s); String getMetadataKey(); void setMetadataKey(String metadatakey); AddFormattedMetadataService withMetadataKey(String s); ElementFormatter getElementFormatter(); void setElementFormatter(ElementFormatter elementFormatter);  }
@Test public void testElementFormatter() throws Exception { AddFormattedMetadataService service = retrieveObjectForSampleConfig(); service.setFormatString("%s ; %s"); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); msg.addMetadata("MetadataKey1", "Hello"); msg.addMetadata("MetadataKey2", "World"); service.setElementFormatter(new ElementKeyAndValueFormatter()); service.doService(msg); assertEquals("MetadataKey1=Hello ; MetadataKey2=World", msg.getMessageHeaders().get("destinationMetadataKey")); }