@Test public void testTimestampFieldFunctionWithTimeFormatConfigured() { Slf4jAuditLoggerConfig configMock = mock(Slf4jAuditLoggerConfig.class); when(configMock.getTimeFormatter()).thenReturn(Optional.of(DateTimeFormatter.ISO_INSTANT)); Function<AuditEntry, Object> timestampFunction = Slf4jAuditLogger.getTimeFunction(configMock); assertThat(timestampFunction.apply(logEntryWithAll)).isEqualTo("1970-01-01T00:00:00.042Z"); }
static Function<AuditEntry, Object> getTimeFunction(Slf4jAuditLoggerConfig auditConfig) { return auditConfig.getTimeFormatter() .map(Slf4jAuditLogger::getFormattedTimestamp) .orElse(AuditEntry::getTimestamp); }
Slf4jAuditLogger implements AuditLogger { static Function<AuditEntry, Object> getTimeFunction(Slf4jAuditLoggerConfig auditConfig) { return auditConfig.getTimeFormatter() .map(Slf4jAuditLogger::getFormattedTimestamp) .orElse(AuditEntry::getTimestamp); } }
Slf4jAuditLogger implements AuditLogger { static Function<AuditEntry, Object> getTimeFunction(Slf4jAuditLoggerConfig auditConfig) { return auditConfig.getTimeFormatter() .map(Slf4jAuditLogger::getFormattedTimestamp) .orElse(AuditEntry::getTimestamp); } Slf4jAuditLogger(Map<String, String> parameters); @VisibleForTesting  Slf4jAuditLogger(Map<String, String> parameters, String loggerName); @VisibleForTesting  Slf4jAuditLogger(Slf4jAuditLoggerConfig auditConfig, Logger logger); }
Slf4jAuditLogger implements AuditLogger { static Function<AuditEntry, Object> getTimeFunction(Slf4jAuditLoggerConfig auditConfig) { return auditConfig.getTimeFormatter() .map(Slf4jAuditLogger::getFormattedTimestamp) .orElse(AuditEntry::getTimestamp); } Slf4jAuditLogger(Map<String, String> parameters); @VisibleForTesting  Slf4jAuditLogger(Map<String, String> parameters, String loggerName); @VisibleForTesting  Slf4jAuditLogger(Slf4jAuditLoggerConfig auditConfig, Logger logger); @Override void log(AuditEntry logEntry); }
Slf4jAuditLogger implements AuditLogger { static Function<AuditEntry, Object> getTimeFunction(Slf4jAuditLoggerConfig auditConfig) { return auditConfig.getTimeFormatter() .map(Slf4jAuditLogger::getFormattedTimestamp) .orElse(AuditEntry::getTimestamp); } Slf4jAuditLogger(Map<String, String> parameters); @VisibleForTesting  Slf4jAuditLogger(Map<String, String> parameters, String loggerName); @VisibleForTesting  Slf4jAuditLogger(Slf4jAuditLoggerConfig auditConfig, Logger logger); @Override void log(AuditEntry logEntry); static final String AUDIT_LOGGER_NAME; }