### Question:
AuditServiceProviderImpl implements AuditServiceProvider { @Override public AMAuditService getDefaultAuditService() { return defaultAuditService; } @Inject  AuditServiceProviderImpl(AuditServiceConfigurationProvider configProvider, ShutdownManager shutdownManager); @Override AMAuditService getAuditService(String realm); @Override AMAuditService getDefaultAuditService();  }### Answer:
@Test public void shouldCreateDefaultAuditService() throws Exception { assertThat(provider.getDefaultAuditService()).isNotNull(); }
@Test public void shouldInstantiateHandlerFactoryAndCreateMockHandler() throws Exception { configListener.globalConfigurationChanged(); assertThat(provider.getDefaultAuditService().getRegisteredHandler("Mock Handler")).isNotNull(); }
@Test public void shouldSilentlyFailToInstantiateHandlerFactory() throws Exception { configListener.globalConfigurationChanged(); assertThat(provider.getDefaultAuditService().getRegisteredHandler("No such handler")).isNull(); }
@Test public void shouldNotRegisterHandlersWhenDefaultAuditServiceDisabled() throws Exception { auditServiceConfig = new AMAuditServiceConfiguration(false); configListener.globalConfigurationChanged(); assertThat(provider.getDefaultAuditService().getRegisteredHandler("Mock Handler")).isNull(); }
@Test public void shouldNotRegisterHandlersWhenFactoryReturnsNull() throws Exception { for (AuditEventHandlerConfiguration config : handlerConfigs) { config.getAttributes().put("enabled", singleton("false")); } configListener.globalConfigurationChanged(); assertThat(provider.getDefaultAuditService().getRegisteredHandler("Mock Handler")).isNull(); assertThat(provider.getDefaultAuditService().getRegisteredHandler("No such handler")).isNull(); }