From a6ac444abaa8878e1e334dd032afc5dee7200375 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 17 Jun 2025 19:02:18 +0100 Subject: [PATCH] Use fixed timestamp so included snippets match accompanying text Closes gh-45995 --- .../audit/AuditEventsEndpointDocumentationTests.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointDocumentationTests.java index 50c2e5a211a..28f02105209 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointDocumentationTests.java @@ -16,7 +16,7 @@ package org.springframework.boot.actuate.autoconfigure.audit; -import java.time.OffsetDateTime; +import java.time.Instant; import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; @@ -69,10 +69,10 @@ class AuditEventsEndpointDocumentationTests extends MockMvcEndpointDocumentation @Test void filteredAuditEvents() throws Exception { - OffsetDateTime now = OffsetDateTime.now(); - String queryTimestamp = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(now); - given(this.repository.find("alice", now.toInstant(), "logout")) - .willReturn(List.of(new AuditEvent("alice", "logout", Collections.emptyMap()))); + String queryTimestamp = "2017-11-07T09:37Z"; + Instant instant = Instant.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(queryTimestamp)); + given(this.repository.find("alice", instant, "logout")) + .willReturn(List.of(new AuditEvent(instant.plusSeconds(73), "alice", "logout", Collections.emptyMap()))); this.mockMvc .perform(get("/actuator/auditevents").param("principal", "alice") .param("after", queryTimestamp) @@ -86,7 +86,7 @@ class AuditEventsEndpointDocumentationTests extends MockMvcEndpointDocumentation .description("Restricts the events to those with the given principal. Optional."), parameterWithName("type") .description("Restricts the events to those with the given type. Optional.")))); - then(this.repository).should().find("alice", now.toInstant(), "logout"); + then(this.repository).should().find("alice", instant, "logout"); } @Configuration(proxyBeanMethods = false)