BaseFlag implements Flag<T> { @Override public void accept(T value) { checkValidators(value); this.value = value; notifyListeners(value); } BaseFlag(T defaultValue); @Override T get(); @Override T defaultValue(); @Override void accept(T value); @Override String name(); @Nullable @Override String altName(); @Override String help(); BaseFlag<T> withValidator(Predicate<T> predicate); BaseFlag<T> withListener(Consumer<T> predicate);  }
@Test public void testNoActionOnDefultValues() { String[] args = {}; Flagz.parse(args, EMPTY_PACKAGE_PREFIXES, SET_OF_THIS_TEST); verify(mockConsumer, never()).accept(anyString()); }
@Test public void testListenerFiredOnCommandLine() { String[] args = {"--test_flag_string=moo"}; FlagFieldRegistry registry = Flagz.parse(args, EMPTY_PACKAGE_PREFIXES, SET_OF_THIS_TEST); verify(mockConsumer).accept("moo"); }
@Test public void testListenerFiredOnDynamicChange() { String[] args = {}; FlagFieldRegistry registry = Flagz.parse(args, EMPTY_PACKAGE_PREFIXES, SET_OF_THIS_TEST); registry.setField("test_flag_string", "foo"); verify(mockConsumer).accept("foo"); }