ServerConfigurationProvider implements ConfigurationProvider { static synchronized void setConfiguration(Configuration configuration) { if (CONFIGURATION == null) { CONFIGURATION = configuration; } else { throw new IllegalStateException("Configuration was already loaded."); } }  @Override Configuration getConfiguration();  }
@Test @DisplayName("Disallows setting configuration multiple times") void testDisallowMultipleConfigurations(@Mock Configuration configuration) { ServerConfigurationProvider.setConfiguration(configuration); assertThatThrownBy(() -> ServerConfigurationProvider.setConfiguration(configuration)) .isInstanceOf(IllegalStateException.class); }