Search in sources :

Example 6 with WebOperation

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

the class ReactiveCloudFoundryActuatorAutoConfigurationTests method endpointPathCustomizationIsNotApplied.

@Test
void endpointPathCustomizationIsNotApplied() {
    this.contextRunner.withBean(TestEndpoint.class, TestEndpoint::new).withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id", "vcap.application.cf_api:https://my-cloud-controller.com").run((context) -> {
        CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context);
        Collection<ExposableWebEndpoint> endpoints = handlerMapping.getEndpoints();
        ExposableWebEndpoint endpoint = endpoints.stream().filter((candidate) -> EndpointId.of("test").equals(candidate.getEndpointId())).findFirst().get();
        assertThat(endpoint.getOperations()).hasSize(1);
        WebOperation operation = endpoint.getOperations().iterator().next();
        assertThat(operation.getRequestPredicate().getPath()).isEqualTo("test");
    });
}
Also used : WebOperation(org.springframework.boot.actuate.endpoint.web.WebOperation) ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) Test(org.junit.jupiter.api.Test)

Example 7 with WebOperation

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

the class CloudFoundryActuatorAutoConfigurationTests method healthEndpointInvokerShouldBeCloudFoundryWebExtension.

@Test
void healthEndpointInvokerShouldBeCloudFoundryWebExtension() {
    this.contextRunner.withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id", "vcap.application.cf_api:https://my-cloud-controller.com").withConfiguration(AutoConfigurations.of(HealthContributorAutoConfiguration.class, HealthEndpointAutoConfiguration.class)).run((context) -> {
        Collection<ExposableWebEndpoint> endpoints = context.getBean("cloudFoundryWebEndpointServletHandlerMapping", CloudFoundryWebEndpointServletHandlerMapping.class).getEndpoints();
        ExposableWebEndpoint endpoint = endpoints.iterator().next();
        assertThat(endpoint.getOperations()).hasSize(2);
        WebOperation webOperation = findOperationWithRequestPath(endpoint, "health");
        assertThat(webOperation).extracting("invoker.target").isInstanceOf(CloudFoundryHealthEndpointWebExtension.class);
    });
}
Also used : WebOperation(org.springframework.boot.actuate.endpoint.web.WebOperation) ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) Test(org.junit.jupiter.api.Test)

Example 8 with WebOperation

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

the class AdditionalHealthEndpointPathsWebFluxHandlerMapping method initHandlerMethods.

@Override
protected void initHandlerMethods() {
    for (WebOperation operation : this.endpoint.getOperations()) {
        WebOperationRequestPredicate predicate = operation.getRequestPredicate();
        String matchAllRemainingPathSegmentsVariable = predicate.getMatchAllRemainingPathSegmentsVariable();
        if (matchAllRemainingPathSegmentsVariable != null) {
            for (HealthEndpointGroup group : this.groups) {
                AdditionalHealthEndpointPath additionalPath = group.getAdditionalPath();
                if (additionalPath != null) {
                    RequestMappingInfo requestMappingInfo = getRequestMappingInfo(operation, additionalPath.getValue());
                    registerReadMapping(requestMappingInfo, this.endpoint, operation);
                }
            }
        }
    }
}
Also used : WebOperation(org.springframework.boot.actuate.endpoint.web.WebOperation) WebOperationRequestPredicate(org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate) AdditionalHealthEndpointPath(org.springframework.boot.actuate.health.AdditionalHealthEndpointPath) RequestMappingInfo(org.springframework.web.reactive.result.method.RequestMappingInfo) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup)

Aggregations

WebOperation (org.springframework.boot.actuate.endpoint.web.WebOperation)8 Test (org.junit.jupiter.api.Test)6 ExposableWebEndpoint (org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint)6 WebOperationRequestPredicate (org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate)2 AdditionalHealthEndpointPath (org.springframework.boot.actuate.health.AdditionalHealthEndpointPath)2 HealthEndpointGroup (org.springframework.boot.actuate.health.HealthEndpointGroup)2 HealthEndpointAutoConfiguration (org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration)1 EndpointId (org.springframework.boot.actuate.endpoint.EndpointId)1 InvocationContext (org.springframework.boot.actuate.endpoint.InvocationContext)1 CachingOperationInvoker (org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker)1 RequestMappingInfo (org.springframework.web.reactive.result.method.RequestMappingInfo)1