Configuration implements LogConfigListener { public synchronized void initialize(final LogConfigSupplier logConfigSupplier) { if (logConfigSupplier == null) { throw new IllegalArgumentException("LogConfigSupplier must not be null"); } this.logConfigSupplier = logConfigSupplier; logConfigSupplier.addLogConfigListener(this); configChanged(); } private  Configuration(final LogLevelUpdateOccurs logLevelUpdateOccurs,
      final LogLevelUpdateScope logLevelUpdateScope, final LoggingProvider loggingProvider); static Configuration create(); @VisibleForTesting static Configuration create(final LoggingProvider loggingProvider); @VisibleForTesting static Configuration create(final LogLevelUpdateOccurs logLevelUpdateOccurs,
      final LogLevelUpdateScope logLevelUpdateScope); @VisibleForTesting static Configuration create(final LogLevelUpdateOccurs logLevelUpdateOccurs,
      final LogLevelUpdateScope logLevelUpdateScope, final LoggingProvider loggingProvider); synchronized void initialize(final LogConfigSupplier logConfigSupplier); @Override synchronized void configChanged(); synchronized void shutdown(); @VisibleForTesting
  static final int DEFAULT_LOGWRITER_LEVEL; static final String STARTUP_CONFIGURATION; static final String CLI_CONFIG; static final String LOG_LEVEL_UPDATE_OCCURS_PROPERTY; }
@Test public void initializeAddsSelfAsListenerToLogConfigSupplier() { configuration.initialize(logConfigSupplier); verify(logConfigSupplier).addLogConfigListener(eq(configuration)); }
@Test public void initializeAddsSelfAsListenerOnlyOnceToEachLogConfigSupplier() { LogConfigSupplier logConfigSupplier1 = mockLogConfigSupplier(); LogConfigSupplier logConfigSupplier2 = mockLogConfigSupplier(); LogConfigSupplier logConfigSupplier3 = mockLogConfigSupplier(); configuration.initialize(logConfigSupplier1); configuration.initialize(logConfigSupplier2); configuration.initialize(logConfigSupplier3); verify(logConfigSupplier1).addLogConfigListener(eq(configuration)); verify(logConfigSupplier2).addLogConfigListener(eq(configuration)); verify(logConfigSupplier3).addLogConfigListener(eq(configuration)); }
@Test public void initializeWithNullThrowsIllegalArgumentException() { assertThatThrownBy(() -> configuration.initialize(null)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void initializeConfiguresProviderAgent() { configuration.initialize(logConfigSupplier); verify(loggingProvider).configure(eq(logConfig), isA(LogLevelUpdateOccurs.class), isA( LogLevelUpdateScope.class)); }