TraceSampleRateWatcher extends ConfigChangeWatcher { @Override public void notify(ConfigChangeEvent value) { if (EventType.DELETE.equals(value.getEventType())) { activeSetting(String.valueOf(getDefaultValue())); } else { activeSetting(value.getNewValue()); } } TraceSampleRateWatcher(ModuleProvider provider); @Override void notify(ConfigChangeEvent value); @Override String value(); int getSampleRate();  }
@Test public void testNotify() { TraceSampleRateWatcher traceSampleRateWatcher = new TraceSampleRateWatcher(provider); ConfigChangeWatcher.ConfigChangeEvent value1 = new ConfigChangeWatcher.ConfigChangeEvent( "8000", ConfigChangeWatcher.EventType.MODIFY); traceSampleRateWatcher.notify(value1); Assert.assertEquals(traceSampleRateWatcher.getSampleRate(), 8000); Assert.assertEquals(traceSampleRateWatcher.value(), "8000"); ConfigChangeWatcher.ConfigChangeEvent value2 = new ConfigChangeWatcher.ConfigChangeEvent( "8000", ConfigChangeWatcher.EventType.DELETE); traceSampleRateWatcher.notify(value2); Assert.assertEquals(traceSampleRateWatcher.getSampleRate(), 10000); Assert.assertEquals(traceSampleRateWatcher.value(), "10000"); ConfigChangeWatcher.ConfigChangeEvent value3 = new ConfigChangeWatcher.ConfigChangeEvent( "500", ConfigChangeWatcher.EventType.ADD); traceSampleRateWatcher.notify(value3); Assert.assertEquals(traceSampleRateWatcher.getSampleRate(), 500); Assert.assertEquals(traceSampleRateWatcher.value(), "500"); ConfigChangeWatcher.ConfigChangeEvent value4 = new ConfigChangeWatcher.ConfigChangeEvent( "abc", ConfigChangeWatcher.EventType.MODIFY); traceSampleRateWatcher.notify(value4); Assert.assertEquals(traceSampleRateWatcher.getSampleRate(), 500); Assert.assertEquals(traceSampleRateWatcher.value(), "500"); }