BaseSetter implements Setter { @Override public final void setTransientColour(@ColorInt int colour) { if (transientChanges) { setColour(colour); } } protected  BaseSetter(Filter filter); protected  BaseSetter(Filter filter, boolean transientChanges); @Override final void setColour(@ColorInt int colour); @Override final void setTransientColour(@ColorInt int colour); abstract void onSetColour(@ColorInt int colour);  }
@Test public void givenATransientColourSetterTransientEventsAreHandled() { TransientSetter colourSetter = new TransientSetter(identityFilter); colourSetter.setTransientColour(ColourUtils.TEST_COLOUR); assertThat(colourSetter.onSetColourCalled).isTrue(); }
@Test public void givenANonTransientColourSetterTransientEventsAreNotHandled() { NonTransientSetter colourSetter = new NonTransientSetter(identityFilter); colourSetter.setTransientColour(ColourUtils.TEST_COLOUR); assertThat(colourSetter.onSetColourCalled).isFalse(); }