### Question:
Slf4jAuditLoggerConfig { Optional<DateTimeFormatter> getTimeFormatter() { return Optional.ofNullable(timeFormatter); } Slf4jAuditLoggerConfig(Map<String, String> parameters);   }### Answer:
@Test public void testGetTimeFormatterWithFormatAndZoneConfigured() { Map<String, String> options = ImmutableMap.of("time_format", "yyyy-MM-dd HH:mm:ss.SSSZ", "time_zone", "Europe/Stockholm"); Slf4jAuditLoggerConfig auditConfig = new Slf4jAuditLoggerConfig(options); Optional<DateTimeFormatter> timeFormatter = auditConfig.getTimeFormatter(); assertThat(timeFormatter).map(f -> f.format(Instant.EPOCH.plusMillis(42))).contains("1970-01-01 01:00:00.042+0100"); assertThat(timeFormatter).map(DateTimeFormatter::getZone).contains(ZoneId.of("Europe/Stockholm")); }
@Test public void testGetTimeFormatterWithoutZoneConfiguredGetSystemDefault() { Map<String, String> options = ImmutableMap.of("time_format", "yyyy"); Slf4jAuditLoggerConfig auditConfig = new Slf4jAuditLoggerConfig(options); Optional<DateTimeFormatter> timeFormatter = auditConfig.getTimeFormatter(); assertThat(timeFormatter).map(DateTimeFormatter::getZone).contains(ZoneId.systemDefault()); }
@Test public void testGetTimeFormatterWithoutFormatConfiguredIsEmpty() { Map<String, String> options = ImmutableMap.of("time_zone", "Europe/Stockholm"); Slf4jAuditLoggerConfig auditConfig = new Slf4jAuditLoggerConfig(options); Optional<DateTimeFormatter> timeFormatter = auditConfig.getTimeFormatter(); assertThat(timeFormatter).isEmpty(); }