Commit 66164bff authored by Andy Wilkinson's avatar Andy Wilkinson

Polish

parent fbb1ba1b
...@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier; ...@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier;
* @author Phillip Webb * @author Phillip Webb
* @since 2.0.0 * @since 2.0.0
*/ */
@FunctionalInterface
public interface JmxEndpointsSupplier extends EndpointsSupplier<ExposableJmxEndpoint> { public interface JmxEndpointsSupplier extends EndpointsSupplier<ExposableJmxEndpoint> {
} }
...@@ -26,6 +26,7 @@ import org.springframework.boot.actuate.endpoint.ExposableEndpoint; ...@@ -26,6 +26,7 @@ import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
* @since 2.0.0 * @since 2.0.0
* @see PathMapper * @see PathMapper
*/ */
@FunctionalInterface
public interface PathMappedEndpoint { public interface PathMappedEndpoint {
/** /**
......
...@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier; ...@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier;
* @author Phillip Webb * @author Phillip Webb
* @since 2.0.0 * @since 2.0.0
*/ */
@FunctionalInterface
public interface WebEndpointsSupplier extends EndpointsSupplier<ExposableWebEndpoint> { public interface WebEndpointsSupplier extends EndpointsSupplier<ExposableWebEndpoint> {
} }
...@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier; ...@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.EndpointsSupplier;
* @author Phillip Webb * @author Phillip Webb
* @since 2.0.0 * @since 2.0.0
*/ */
@FunctionalInterface
public interface ControllerEndpointsSupplier public interface ControllerEndpointsSupplier
extends EndpointsSupplier<ExposableControllerEndpoint> { extends EndpointsSupplier<ExposableControllerEndpoint> {
......
...@@ -238,8 +238,9 @@ public abstract class AbstractWebFluxEndpointHandlerMapping ...@@ -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 { protected interface ReactiveWebOperation {
Mono<ResponseEntity<Object>> handle(ServerWebExchange exchange, Mono<ResponseEntity<Object>> handle(ServerWebExchange exchange,
......
...@@ -214,8 +214,9 @@ public abstract class AbstractWebMvcEndpointHandlerMapping ...@@ -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 { protected interface ServletWebOperation {
Object handle(HttpServletRequest request, Map<String, String> body); Object handle(HttpServletRequest request, Map<String, String> body);
......
...@@ -68,31 +68,27 @@ public class ControllerEndpointHandlerMappingIntegrationTests { ...@@ -68,31 +68,27 @@ public class ControllerEndpointHandlerMappingIntegrationTests {
@Test @Test
public void get() { public void get() {
this.contextRunner.run(withWebTestClient(webTestClient -> { this.contextRunner.run(withWebTestClient(
webTestClient.get().uri("/actuator/example/one").accept(MediaType.TEXT_PLAIN) (webTestClient) -> webTestClient.get().uri("/actuator/example/one")
.exchange().expectStatus().isOk().expectHeader() .accept(MediaType.TEXT_PLAIN).exchange().expectStatus().isOk()
.contentTypeCompatibleWith(MediaType.TEXT_PLAIN) .expectHeader().contentTypeCompatibleWith(MediaType.TEXT_PLAIN)
.expectBody(String.class).isEqualTo("One"); .expectBody(String.class).isEqualTo("One")));
}));
} }
@Test @Test
public void getWithUnacceptableContentType() { public void getWithUnacceptableContentType() {
this.contextRunner.run(withWebTestClient(webTestClient -> { this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.get()
webTestClient.get().uri("/actuator/example/one") .uri("/actuator/example/one").accept(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus() .exchange().expectStatus().isEqualTo(HttpStatus.NOT_ACCEPTABLE)));
.isEqualTo(HttpStatus.NOT_ACCEPTABLE);
}));
} }
@Test @Test
public void post() { public void post() {
this.contextRunner.run(withWebTestClient(webTestClient -> { this.contextRunner.run(withWebTestClient(
webTestClient.post().uri("/actuator/example/two") (webTestClient) -> webTestClient.post().uri("/actuator/example/two")
.syncBody(Collections.singletonMap("id", "test")).exchange() .syncBody(Collections.singletonMap("id", "test")).exchange()
.expectStatus().isCreated().expectHeader() .expectStatus().isCreated().expectHeader()
.valueEquals(HttpHeaders.LOCATION, "/example/test"); .valueEquals(HttpHeaders.LOCATION, "/example/test")));
}));
} }
private ContextConsumer<AssertableReactiveWebApplicationContext> withWebTestClient( private ContextConsumer<AssertableReactiveWebApplicationContext> withWebTestClient(
......
...@@ -67,31 +67,27 @@ public class ControllerEndpointHandlerMappingIntegrationTests { ...@@ -67,31 +67,27 @@ public class ControllerEndpointHandlerMappingIntegrationTests {
@Test @Test
public void get() { public void get() {
this.contextRunner.run(withWebTestClient(webTestClient -> { this.contextRunner.run(withWebTestClient(
webTestClient.get().uri("/actuator/example/one").accept(MediaType.TEXT_PLAIN) (webTestClient) -> webTestClient.get().uri("/actuator/example/one")
.exchange().expectStatus().isOk().expectHeader() .accept(MediaType.TEXT_PLAIN).exchange().expectStatus().isOk()
.contentTypeCompatibleWith(MediaType.TEXT_PLAIN) .expectHeader().contentTypeCompatibleWith(MediaType.TEXT_PLAIN)
.expectBody(String.class).isEqualTo("One"); .expectBody(String.class).isEqualTo("One")));
}));
} }
@Test @Test
public void getWithUnacceptableContentType() { public void getWithUnacceptableContentType() {
this.contextRunner.run(withWebTestClient(webTestClient -> { this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.get()
webTestClient.get().uri("/actuator/example/one") .uri("/actuator/example/one").accept(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus() .exchange().expectStatus().isEqualTo(HttpStatus.NOT_ACCEPTABLE)));
.isEqualTo(HttpStatus.NOT_ACCEPTABLE);
}));
} }
@Test @Test
public void post() { public void post() {
this.contextRunner.run(withWebTestClient(webTestClient -> { this.contextRunner.run(withWebTestClient(
webTestClient.post().uri("/actuator/example/two") (webTestClient) -> webTestClient.post().uri("/actuator/example/two")
.syncBody(Collections.singletonMap("id", "test")).exchange() .syncBody(Collections.singletonMap("id", "test")).exchange()
.expectStatus().isCreated().expectHeader() .expectStatus().isCreated().expectHeader()
.valueEquals(HttpHeaders.LOCATION, "/example/test"); .valueEquals(HttpHeaders.LOCATION, "/example/test")));
}));
} }
private ContextConsumer<AssertableWebApplicationContext> withWebTestClient( private ContextConsumer<AssertableWebApplicationContext> withWebTestClient(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment