ConfigurationInitializer { static <T extends SecurityConfiguration> void initializeConfigurations(@NotNull CompositeConfiguration<T> configuration, @NotNull SecurityProvider securityProvider, @NotNull ConfigurationParameters parameters, @NotNull RootProvider rootProvider, @NotNull TreeProvider treeProvider) { configuration.setSecurityProvider(securityProvider); configuration.setRootProvider(rootProvider); configuration.setTreeProvider(treeProvider); List<T> configs = configuration.getConfigurations(); for (T config : configs) { initializeConfiguration(config, securityProvider, parameters, rootProvider, treeProvider); } } private  ConfigurationInitializer();   }
@Test public void testInitCompositeConfiguration() { TestComposite<SecurityConfiguration.Default> composite = new TestComposite<SecurityConfiguration.Default>(); composite.addConfiguration(new SecurityConfiguration.Default()); composite.addConfiguration(new SecurityConfiguration.Default()); ConfigurationInitializer.initializeConfigurations(composite, sp, params, rootProvider, treeProvider); assertSame(sp, composite.getSecurityProvider()); for (SecurityConfiguration.Default sc : composite.getConfigurations()) { assertFalse(sc.getParameters().containsKey("key")); } }
@Test public void testInitCompositeBaseConfiguration() { TestComposite<TestConfiguration> composite = new TestComposite<TestConfiguration>(); composite.addConfiguration(new TestConfiguration()); composite.addConfiguration(new TestConfiguration()); ConfigurationInitializer.initializeConfigurations(composite, sp, params, rootProvider, treeProvider); assertSame(sp, composite.getSecurityProvider()); for (SecurityConfiguration sc : composite.getConfigurations()) { ConfigurationParameters parameters = sc.getParameters(); assertTrue(parameters.containsKey("key")); assertTrue(parameters.containsKey("key2")); assertEquals("value", parameters.get("key")); assertEquals("initialValue", parameters.get("key2")); } }