SecurityProviderImpl implements SecurityProvider, WhiteboardAware { @SuppressWarnings("UnusedDeclaration") protected void bindPrincipalConfiguration(@NotNull PrincipalConfiguration reference) { principalConfiguration.addConfiguration(initConfiguration(reference)); } SecurityProviderImpl();  SecurityProviderImpl(@NotNull ConfigurationParameters configuration); @Override void setWhiteboard(@NotNull Whiteboard whiteboard); @Override Whiteboard getWhiteboard(); @NotNull @Override ConfigurationParameters getParameters(@Nullable String name); @NotNull @Override Iterable<? extends SecurityConfiguration> getConfigurations(); @SuppressWarnings("unchecked") @NotNull @Override T getConfiguration(@NotNull Class<T> configClass);  }
@Test public void testBindPrincipalConfiguration() { PrincipalConfiguration defaultConfig = securityProvider.getConfiguration(PrincipalConfiguration.class); assertTrue(defaultConfig instanceof CompositePrincipalConfiguration); CompositePrincipalConfiguration cpc = (CompositePrincipalConfiguration) defaultConfig; PrincipalConfiguration pc = Mockito.mock(PrincipalConfiguration.class); when(pc.getParameters()).thenReturn(ConfigurationParameters.EMPTY); securityProvider.bindPrincipalConfiguration(pc); assertNotSame(pc, securityProvider.getConfiguration(PrincipalConfiguration.class)); assertSame(defaultConfig, securityProvider.getConfiguration(PrincipalConfiguration.class)); for (SecurityConfiguration sc : securityProvider.getConfigurations()) { if (sc instanceof PrincipalConfiguration) { assertSame(defaultConfig, sc); } } assertTrue(cpc.getConfigurations().contains(pc)); }