Search in sources :

Example 1 with WebEndpointDiscoverer

use of org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer in project spring-boot by spring-projects.

the class WebEndpointAutoConfigurationTests method webApplicationSupportCustomPathMatcher.

@Test
void webApplicationSupportCustomPathMatcher() {
    this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include=*", "management.endpoints.web.path-mapping.testanotherone=foo").withUserConfiguration(TestPathMatcher.class, TestOneEndpoint.class, TestAnotherOneEndpoint.class, TestTwoEndpoint.class).run((context) -> {
        WebEndpointDiscoverer discoverer = context.getBean(WebEndpointDiscoverer.class);
        Collection<ExposableWebEndpoint> endpoints = discoverer.getEndpoints();
        ExposableWebEndpoint[] webEndpoints = endpoints.toArray(new ExposableWebEndpoint[0]);
        List<String> paths = Arrays.stream(webEndpoints).map(PathMappedEndpoint::getRootPath).collect(Collectors.toList());
        assertThat(paths).containsOnly("1/testone", "foo", "testtwo");
    });
}
Also used : ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) WebEndpointDiscoverer(org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 ExposableWebEndpoint (org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint)1 WebEndpointDiscoverer (org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer)1