Skip to content

Commit a6ac444

Browse files
committed
Use fixed timestamp so included snippets match accompanying text
Closes gh-45995
1 parent e914539 commit a6ac444

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointDocumentationTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.boot.actuate.autoconfigure.audit;
1818

19-
import java.time.OffsetDateTime;
19+
import java.time.Instant;
2020
import java.time.format.DateTimeFormatter;
2121
import java.util.Collections;
2222
import java.util.List;
@@ -69,10 +69,10 @@ void allAuditEvents() throws Exception {
6969

7070
@Test
7171
void filteredAuditEvents() throws Exception {
72-
OffsetDateTime now = OffsetDateTime.now();
73-
String queryTimestamp = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(now);
74-
given(this.repository.find("alice", now.toInstant(), "logout"))
75-
.willReturn(List.of(new AuditEvent("alice", "logout", Collections.emptyMap())));
72+
String queryTimestamp = "2017-11-07T09:37Z";
73+
Instant instant = Instant.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(queryTimestamp));
74+
given(this.repository.find("alice", instant, "logout"))
75+
.willReturn(List.of(new AuditEvent(instant.plusSeconds(73), "alice", "logout", Collections.emptyMap())));
7676
this.mockMvc
7777
.perform(get("/actuator/auditevents").param("principal", "alice")
7878
.param("after", queryTimestamp)
@@ -86,7 +86,7 @@ void filteredAuditEvents() throws Exception {
8686
.description("Restricts the events to those with the given principal. Optional."),
8787
parameterWithName("type")
8888
.description("Restricts the events to those with the given type. Optional."))));
89-
then(this.repository).should().find("alice", now.toInstant(), "logout");
89+
then(this.repository).should().find("alice", instant, "logout");
9090
}
9191

9292
@Configuration(proxyBeanMethods = false)

0 commit comments

Comments
 (0)