Skip to content

Commit c40733b

Browse files
committed
add test
1 parent 456202e commit c40733b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointServletDocumentationTests.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,13 +47,17 @@
4747
import org.springframework.test.web.reactive.server.WebTestClient;
4848
import org.springframework.web.bind.annotation.PostMapping;
4949
import org.springframework.web.bind.annotation.RestController;
50+
import org.springframework.web.servlet.function.RouterFunction;
51+
import org.springframework.web.servlet.function.RouterFunctions;
52+
import org.springframework.web.servlet.function.ServerResponse;
5053

5154
import static org.springframework.restdocs.payload.PayloadDocumentation.beneathPath;
5255
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
5356
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
5457
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
5558
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
5659
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
60+
import static org.springframework.web.servlet.function.RequestPredicates.GET;
5761

5862
/**
5963
* Tests for generating documentation describing {@link MappingsEndpoint}.
@@ -130,6 +134,13 @@ void mappings() {
130134
fieldWithPath("*.[].details.handlerMethod.name").description("Name of the method."),
131135
fieldWithPath("*.[].details.handlerMethod.descriptor")
132136
.description("Descriptor of the method as specified in the Java Language Specification."));
137+
List<FieldDescriptor> handlerFunction = List.of(
138+
fieldWithPath("*.[].details.handlerFunction").optional()
139+
.type(JsonFieldType.OBJECT)
140+
.description("Details of the function, if any, that will handle requests to this mapping."),
141+
fieldWithPath("*.[].details.handlerFunction.className").type(JsonFieldType.STRING)
142+
.description("Fully qualified name of the class of the function."));
143+
dispatcherServletFields.addAll(handlerFunction);
133144
dispatcherServletFields.addAll(handlerMethod);
134145
dispatcherServletFields.addAll(requestMappingConditions);
135146
this.client.get()
@@ -192,6 +203,11 @@ ExampleController exampleController() {
192203
return new ExampleController();
193204
}
194205

206+
@Bean
207+
RouterFunction<ServerResponse> exampleRouter() {
208+
return RouterFunctions.route(GET("/foo"), (request) -> ServerResponse.ok().build());
209+
}
210+
195211
}
196212

197213
@RestController

0 commit comments

Comments
 (0)