AddTimestampMetadataService extends ServiceImp { public void setAlwaysReplace(Boolean b) { alwaysReplace = b; } AddTimestampMetadataService();  AddTimestampMetadataService(String format, String metadataKey);  AddTimestampMetadataService(String format, String metadataKey, Boolean alwaysReplace);  AddTimestampMetadataService(String format, String metadataKey, Boolean alwaysReplace, String offset);  AddTimestampMetadataService(String format, String metadataKey, Boolean alwaysReplace, TimestampGenerator s); @Override void doService(AdaptrisMessage msg); String getMetadataKey(); void setMetadataKey(String metadataKey); Boolean getAlwaysReplace(); void setAlwaysReplace(Boolean b); @Override void prepare(); TimestampGenerator getTimestampGenerator(); void setTimestampGenerator(TimestampGenerator s); DateFormatBuilder getDateFormatBuilder(); void setDateFormatBuilder(DateFormatBuilder builder);  }
@Test public void testSetAlwaysReplace() throws Exception { AddTimestampMetadataService service = new AddTimestampMetadataService(); assertNull(service.getAlwaysReplace()); assertFalse(service.alwaysReplace()); service.setAlwaysReplace(Boolean.TRUE); assertEquals(Boolean.TRUE, service.getAlwaysReplace()); assertEquals(true, service.alwaysReplace()); service.setAlwaysReplace(null); assertNull(service.getAlwaysReplace()); assertFalse(service.alwaysReplace()); }
@Test public void testNotAlwaysReplace() throws Exception { AdaptrisMessage m = AdaptrisMessageFactory.getDefaultInstance().newMessage(); m.addMetadata(DEFAULT_METADATA_KEY, "123456"); AddTimestampMetadataService service = new AddTimestampMetadataService(); service.setAlwaysReplace(false); execute(service, m); assertTrue(m.headersContainsKey(DEFAULT_METADATA_KEY)); assertEquals("123456", m.getMetadataValue(DEFAULT_METADATA_KEY)); }