### Question:
CsvAuditEventHandlerFactory implements AuditEventHandlerFactory { @Override public AuditEventHandler create(AuditEventHandlerConfiguration configuration) throws AuditException { Map<String, Set<String>> attributes = configuration.getAttributes(); CsvAuditEventHandlerConfiguration csvHandlerConfiguration = new CsvAuditEventHandlerConfiguration(); String location = getMapAttr(attributes, "location"); csvHandlerConfiguration.setLogDirectory(location.replaceAll("%BASE_DIR%", SystemProperties.get(CONFIG_PATH)). replaceAll("%SERVER_URI%", SystemProperties.get(AM_SERVICES_DEPLOYMENT_DESCRIPTOR))); csvHandlerConfiguration.setTopics(attributes.get("topics")); csvHandlerConfiguration.setName(configuration.getHandlerName()); csvHandlerConfiguration.setEnabled(getBooleanMapAttr(attributes, "enabled", true)); setFileRotationPolicies(csvHandlerConfiguration, attributes); setFileRetentionPolicies(csvHandlerConfiguration, attributes); csvHandlerConfiguration.setBufferingConfiguration(getBufferingConfiguration(attributes)); csvHandlerConfiguration.setSecurity(getCsvSecurity(attributes)); return new CsvAuditEventHandler(csvHandlerConfiguration, configuration.getEventTopicsMetaData(), new DefaultKeyStoreHandlerProvider()); }  @Override AuditEventHandler create(AuditEventHandlerConfiguration configuration);  }### Answer:
@Test private void shouldCreateCsvEventHandler() throws AuditException { Map<String, Set<String>> configAttributes = new HashMap<>(); configAttributes.put("enabled", singleton("true")); configAttributes.put("topics", singleton("access")); configAttributes.put("location", singleton(logDirName)); configAttributes.put("bufferingEnabled", singleton("true")); configAttributes.put("bufferingAutoFlush", singleton("false")); AuditEventHandlerConfiguration configuration = AuditEventHandlerConfiguration.builder() .withName("CSV Handler") .withAttributes(configAttributes) .withEventTopicsMetaData(eventTopicsMetaData).build(); AuditEventHandler handler = factory.create(configuration); assertThat(handler).isInstanceOf(CsvAuditEventHandler.class); assertThat(handler.getName()).isEqualTo("CSV Handler"); assertThat(handler.getHandledTopics()).containsExactly("access"); assertThat(handler.isEnabled()).isTrue(); }
@Test private void shouldCreateCsvEventHandlerWhenDisabled() throws AuditException { Map<String, Set<String>> configAttributes = new HashMap<>(); configAttributes.put("enabled", singleton("false")); configAttributes.put("topics", singleton("access")); configAttributes.put("location", singleton(logDirName)); configAttributes.put("bufferingEnabled", singleton("true")); configAttributes.put("bufferingAutoFlush", singleton("false")); AuditEventHandlerConfiguration configuration = AuditEventHandlerConfiguration.builder() .withName("CSV Handler") .withAttributes(configAttributes) .withEventTopicsMetaData(eventTopicsMetaData).build(); AuditEventHandler handler = factory.create(configuration); assertThat(handler).isInstanceOf(CsvAuditEventHandler.class); assertThat(handler.getName()).isEqualTo("CSV Handler"); assertThat(handler.getHandledTopics()).containsExactly("access"); assertThat(handler.isEnabled()).isFalse(); }