MetadataReplacementSource extends AbstractReplacementSource { public String obtainValue(AdaptrisMessage msg) { return msg.getMetadataValue(this.getValue()); } MetadataReplacementSource();  MetadataReplacementSource(String value); String obtainValue(AdaptrisMessage msg);  }
@Test public void testNullMessage() throws Exception { MetadataReplacementSource source = new MetadataReplacementSource(); try { source.obtainValue(null); fail("null did not throw Exception handled correctly"); } catch (NullPointerException e) { } }
@Test public void testMissingKey() throws Exception { MetadataReplacementSource source = new MetadataReplacementSource(); source.setValue("not-there"); String replaceWith = source.obtainValue(createMessage()); assertTrue(null == replaceWith); }
@Test public void testValidKey() throws Exception { MetadataReplacementSource source = new MetadataReplacementSource(); source.setValue("key"); String replaceWith = source.obtainValue(createMessage()); assertTrue("val".equals(replaceWith)); }