MetadataAppenderService extends MetadataServiceImpl { public void addAppendKey(String string) { appendKeys.add(Args.notBlank(string, "key")); } MetadataAppenderService(); @Override void doService(AdaptrisMessage msg); List<String> getAppendKeys(); void setAppendKeys(List<String> l); void addAppendKey(String string); String getResultKey(); void setResultKey(String string);  }
@Test public void testTwoKeys() throws CoreException { service.addAppendKey("key1"); service.addAppendKey("key3"); execute(service, msg); assertTrue("val1val3".equals(msg.getMetadataValue(resultKey))); }
@Test public void testTwoReferencedKeys() throws CoreException { msg.addMessageHeader("RefKey1", "key1"); msg.addMessageHeader("RefKey3", "key3"); service.addAppendKey("$$RefKey1"); service.addAppendKey("$$RefKey3"); execute(service, msg); assertTrue("val1val3".equals(msg.getMetadataValue(resultKey))); }
@Test public void testTwoKeysOneNotSet() throws CoreException { service.addAppendKey("key1"); service.addAppendKey("key4"); execute(service, msg); assertTrue("val1".equals(msg.getMetadataValue(resultKey))); }
@Test public void testNullKey() throws CoreException { try { service.addAppendKey(null); fail(); } catch (IllegalArgumentException e) { } }
@Test public void testEmptyKey() throws CoreException { try { service.addAppendKey(""); fail(); } catch (IllegalArgumentException e) { } }