From 713afae013f16617ae5a342883f3b019b3c6b3e4 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 18 Sep 2024 11:53:11 +0100 Subject: [PATCH] Accommodate next execution time being unknown A task's next execution time is unknown if, for example, it's currently running. When it's unknown the nextExecution.time will be missing from the json describing the task. This commit updates the documentation test to accommodate this possibility. Closes gh-42351 --- .../ScheduledTasksEndpointDocumentationTests.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/endpoint/web/documentation/ScheduledTasksEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ScheduledTasksEndpointDocumentationTests.java index 59f31a2112..5e8e7c833d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ScheduledTasksEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ScheduledTasksEndpointDocumentationTests.java @@ -63,8 +63,7 @@ class ScheduledTasksEndpointDocumentationTests extends MockMvcEndpointDocumentat fieldWithPath("cron.[].expression").description("Cron expression."), fieldWithPath("fixedDelay").description("Fixed delay tasks, if any."), targetFieldWithPrefix("fixedDelay.[]."), initialDelayWithPrefix("fixedDelay.[]."), - nextExecutionWithPrefix("fixedDelay.[].") - .description("Time of the next scheduled execution."), + nextExecutionWithPrefix("fixedDelay.[]."), fieldWithPath("fixedDelay.[].interval") .description("Interval, in milliseconds, between the end of the last" + " execution and the start of the next."), @@ -72,9 +71,7 @@ class ScheduledTasksEndpointDocumentationTests extends MockMvcEndpointDocumentat targetFieldWithPrefix("fixedRate.[]."), fieldWithPath("fixedRate.[].interval") .description("Interval, in milliseconds, between the start of each execution."), - initialDelayWithPrefix("fixedRate.[]."), - nextExecutionWithPrefix("fixedRate.[].") - .description("Time of the next scheduled execution."), + initialDelayWithPrefix("fixedRate.[]."), nextExecutionWithPrefix("fixedRate.[]."), fieldWithPath("custom").description("Tasks with custom triggers, if any."), targetFieldWithPrefix("custom.[]."), fieldWithPath("custom.[].trigger").description("Trigger for the task.")) @@ -93,7 +90,10 @@ class ScheduledTasksEndpointDocumentationTests extends MockMvcEndpointDocumentat } private FieldDescriptor nextExecutionWithPrefix(String prefix) { - return fieldWithPath(prefix + "nextExecution.time").description("Time of the next scheduled execution."); + return fieldWithPath(prefix + "nextExecution.time") + .description("Time of the next scheduled execution, if known.") + .type(JsonFieldType.STRING) + .optional(); } private FieldDescriptor[] lastExecution() {