LoggingStateRepository implements StateRepository { @Override public void setFeatureState(FeatureState featureState) { if (customLogMessage != null) { log.info(createCustomLogMessage(featureState)); } else { log.info(createDefaultLogMessage(featureState)); } delegate.setFeatureState(featureState); } LoggingStateRepository(StateRepository delegate);  LoggingStateRepository(StateRepository delegate, String customLogMessage); protected  LoggingStateRepository(StateRepository delegate, Log log); protected  LoggingStateRepository(StateRepository delegate, String customLogMessage, Log log); @Override FeatureState getFeatureState(Feature feature); @Override void setFeatureState(FeatureState featureState);  }
@Test void shouldDelegateSetFeatureStateAndLog() { LoggingStateRepository loggingStateRepository = new LoggingStateRepository(delegate, log); loggingStateRepository.setFeatureState(new FeatureState(DummyFeature.TEST, false)); verify(log).info("Setting Feature \"TEST\" to \"disabled\""); }
@Test void shouldDelegateSetFeatureStateAndLogCustomLogMessage() { LoggingStateRepository loggingStateRepository = new LoggingStateRepository(delegate, "Feature \"{1}\": \"{2}\"", log); loggingStateRepository.setFeatureState(new FeatureState(DummyFeature.TEST, false)); verify(log).info("Feature \"TEST\": \"disabled\""); }
@Test void shouldDelegateSetFeatureStateAndLogCustomLogMessageWithoutPlaceholders() { LoggingStateRepository loggingStateRepository = new LoggingStateRepository(delegate, "Feature toggled", log); new LoggingStateRepository(delegate, "Feature toggled"); loggingStateRepository.setFeatureState(new FeatureState(DummyFeature.TEST, false)); verify(log).info("Feature toggled"); }