### Question:
RoleMappingServiceImpl implements RoleMappingService, PostConstruct { @Override public void initialize(SecurityConfiguration securityServiceConfiguration) { if (InitializationState.NOT_INITIALIZED != initialized) { return; } try { config = (org.glassfish.security.services.config.RoleMappingService) securityServiceConfiguration; if (config != null) { List<SecurityProvider> providersConfig = config.getSecurityProviders(); SecurityProvider roleProviderConfig = null; if (providersConfig != null) roleProviderConfig = providersConfig.get(0); if (roleProviderConfig != null) { String providerName = roleProviderConfig.getName(); if (isDebug()) { logger.log(DEBUG_LEVEL, "Attempting to get Role Mapping Provider \"{0}\".", providerName ); } provider = AccessController.doPrivileged( new PrivilegedLookup<RoleMappingProvider>(serviceLocator, RoleMappingProvider.class, providerName) ); if (provider == null) { throw new IllegalStateException(localStrings.getLocalString("service.role.not_provider", "Role Mapping Provider {0} not found.", providerName)); } provider.initialize(roleProviderConfig); initialized = InitializationState.SUCCESS_INIT; reasonInitFailed = null; logger.log(Level.INFO, ROLEMAPSVC_INITIALIZED); } } } catch (Exception e) { String eMsg = e.getMessage(); String eClass = e.getClass().getName(); reasonInitFailed = localStrings.getLocalString("service.role.init_failed", "Role Mapping Service initialization failed, exception {0}, message {1}", eClass, eMsg); logger.log(Level.WARNING, ROLEMAPSVC_INIT_FAILED, new Object[] {eClass, eMsg}); throw new RuntimeException(reasonInitFailed, e); } finally { if (InitializationState.SUCCESS_INIT != initialized) { initialized = InitializationState.FAILED_INIT; } } }  @Override void initialize(SecurityConfiguration securityServiceConfiguration); @Override boolean isUserInRole(String appContext, Subject subject, URI resource, String role); @Override boolean isUserInRole(String appContext, AzSubject subject, AzResource resource, String role); @Override RoleMappingService.RoleDeploymentContext findOrCreateDeploymentContext(String appContext); @Override void postConstruct();  }### Answer:
@Test public void testInitialize() throws Exception { assertSame( "NOT_INITIALIZED", NOT_INITIALIZED, impl.getInitializationState() ); try { impl.initialize(null); } catch ( RuntimeException e ) { fail( "Expected service to allow no specified configuration" ); } try { impl.isUserInRole("test", authorizationService.makeAzSubject(new Subject()), authorizationService.makeAzResource(URI.create("test: "aRole"); fail( "Expected fail illegal state exception." ); } catch ( IllegalStateException e ) { assertNotNull("Service fails at run-time", e); } assertSame( "FAILED_INIT", FAILED_INIT, impl.getInitializationState() ); assertNotNull( "getReasonInitializationFailed", impl.getReasonInitializationFailed() ); }