SystemConfig implements ISystemConfig { @Override public void registerConfiguration( IConfiguration configuration ) throws IOException { String configId = configuration.getId(); if ( configId == null ) { throw new IllegalStateException( "Config id is null" ); } if ( configs.containsKey( configId ) ) { try { configs.get( configId ).update( configuration.getProperties() ); } catch ( UnsupportedOperationException e ) { } } else { configs.put( configId, configuration ); } } SystemConfig();  SystemConfig( List<IConfiguration> startingConfigs ); String getProperty( String placeholder ); @Override IConfiguration getConfiguration( String configId ); @Override void registerConfiguration( IConfiguration configuration ); @Override IConfiguration[] listConfigurations();  }
@Test public void testRegisterConfiguration() throws Exception { systemConfig = new SystemConfig(); systemConfig.registerConfiguration( config1 ); assertEquals( 1, systemConfig.listConfigurations().length ); when( config3.getId() ).thenReturn( "1" ); when( config3.getProperties() ).thenReturn( props2 ); systemConfig.registerConfiguration( config3 ); assertEquals( 1, systemConfig.listConfigurations().length ); verify( config1 ).update( props2 ); }