Polish
This commit is contained in:
@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier;
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface JmxEndpointsSupplier extends EndpointsSupplier<ExposableJmxEndpoint> {
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
|
||||
* @since 2.0.0
|
||||
* @see PathMapper
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface PathMappedEndpoint {
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier;
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface WebEndpointsSupplier extends EndpointsSupplier<ExposableWebEndpoint> {
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier;
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ControllerEndpointsSupplier
|
||||
extends EndpointsSupplier<ExposableControllerEndpoint> {
|
||||
|
||||
|
||||
@@ -238,8 +238,9 @@ public abstract class AbstractWebFluxEndpointHandlerMapping
|
||||
}
|
||||
|
||||
/**
|
||||
* An reactive web operation that can be handled by WebFlux.
|
||||
* A reactive web operation that can be handled by WebFlux.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
protected interface ReactiveWebOperation {
|
||||
|
||||
Mono<ResponseEntity<Object>> handle(ServerWebExchange exchange,
|
||||
|
||||
@@ -214,8 +214,9 @@ public abstract class AbstractWebMvcEndpointHandlerMapping
|
||||
}
|
||||
|
||||
/**
|
||||
* An reactive web operation that can be handled by WebFlux.
|
||||
* A servlet web operation that can be handled by Spring MVC.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
protected interface ServletWebOperation {
|
||||
|
||||
Object handle(HttpServletRequest request, Map<String, String> body);
|
||||
|
||||
@@ -68,31 +68,27 @@ public class ControllerEndpointHandlerMappingIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void get() {
|
||||
this.contextRunner.run(withWebTestClient(webTestClient -> {
|
||||
webTestClient.get().uri("/actuator/example/one").accept(MediaType.TEXT_PLAIN)
|
||||
.exchange().expectStatus().isOk().expectHeader()
|
||||
.contentTypeCompatibleWith(MediaType.TEXT_PLAIN)
|
||||
.expectBody(String.class).isEqualTo("One");
|
||||
}));
|
||||
this.contextRunner.run(withWebTestClient(
|
||||
(webTestClient) -> webTestClient.get().uri("/actuator/example/one")
|
||||
.accept(MediaType.TEXT_PLAIN).exchange().expectStatus().isOk()
|
||||
.expectHeader().contentTypeCompatibleWith(MediaType.TEXT_PLAIN)
|
||||
.expectBody(String.class).isEqualTo("One")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithUnacceptableContentType() {
|
||||
this.contextRunner.run(withWebTestClient(webTestClient -> {
|
||||
webTestClient.get().uri("/actuator/example/one")
|
||||
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus()
|
||||
.isEqualTo(HttpStatus.NOT_ACCEPTABLE);
|
||||
}));
|
||||
this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.get()
|
||||
.uri("/actuator/example/one").accept(MediaType.APPLICATION_JSON)
|
||||
.exchange().expectStatus().isEqualTo(HttpStatus.NOT_ACCEPTABLE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void post() {
|
||||
this.contextRunner.run(withWebTestClient(webTestClient -> {
|
||||
webTestClient.post().uri("/actuator/example/two")
|
||||
.syncBody(Collections.singletonMap("id", "test")).exchange()
|
||||
.expectStatus().isCreated().expectHeader()
|
||||
.valueEquals(HttpHeaders.LOCATION, "/example/test");
|
||||
}));
|
||||
this.contextRunner.run(withWebTestClient(
|
||||
(webTestClient) -> webTestClient.post().uri("/actuator/example/two")
|
||||
.syncBody(Collections.singletonMap("id", "test")).exchange()
|
||||
.expectStatus().isCreated().expectHeader()
|
||||
.valueEquals(HttpHeaders.LOCATION, "/example/test")));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableReactiveWebApplicationContext> withWebTestClient(
|
||||
|
||||
@@ -67,31 +67,27 @@ public class ControllerEndpointHandlerMappingIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void get() {
|
||||
this.contextRunner.run(withWebTestClient(webTestClient -> {
|
||||
webTestClient.get().uri("/actuator/example/one").accept(MediaType.TEXT_PLAIN)
|
||||
.exchange().expectStatus().isOk().expectHeader()
|
||||
.contentTypeCompatibleWith(MediaType.TEXT_PLAIN)
|
||||
.expectBody(String.class).isEqualTo("One");
|
||||
}));
|
||||
this.contextRunner.run(withWebTestClient(
|
||||
(webTestClient) -> webTestClient.get().uri("/actuator/example/one")
|
||||
.accept(MediaType.TEXT_PLAIN).exchange().expectStatus().isOk()
|
||||
.expectHeader().contentTypeCompatibleWith(MediaType.TEXT_PLAIN)
|
||||
.expectBody(String.class).isEqualTo("One")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithUnacceptableContentType() {
|
||||
this.contextRunner.run(withWebTestClient(webTestClient -> {
|
||||
webTestClient.get().uri("/actuator/example/one")
|
||||
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus()
|
||||
.isEqualTo(HttpStatus.NOT_ACCEPTABLE);
|
||||
}));
|
||||
this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.get()
|
||||
.uri("/actuator/example/one").accept(MediaType.APPLICATION_JSON)
|
||||
.exchange().expectStatus().isEqualTo(HttpStatus.NOT_ACCEPTABLE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void post() {
|
||||
this.contextRunner.run(withWebTestClient(webTestClient -> {
|
||||
webTestClient.post().uri("/actuator/example/two")
|
||||
.syncBody(Collections.singletonMap("id", "test")).exchange()
|
||||
.expectStatus().isCreated().expectHeader()
|
||||
.valueEquals(HttpHeaders.LOCATION, "/example/test");
|
||||
}));
|
||||
this.contextRunner.run(withWebTestClient(
|
||||
(webTestClient) -> webTestClient.post().uri("/actuator/example/two")
|
||||
.syncBody(Collections.singletonMap("id", "test")).exchange()
|
||||
.expectStatus().isCreated().expectHeader()
|
||||
.valueEquals(HttpHeaders.LOCATION, "/example/test")));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableWebApplicationContext> withWebTestClient(
|
||||
|
||||
Reference in New Issue
Block a user