Search in sources :

Example 11 with EndpointId

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

the class WebEndpointDiscovererTests method getEndpointsWhenPredicateForWriteOperationThatReturnsVoidShouldHaveNoProducedMediaTypes.

@Test
void getEndpointsWhenPredicateForWriteOperationThatReturnsVoidShouldHaveNoProducedMediaTypes() {
    load(VoidWriteOperationEndpointConfiguration.class, (discoverer) -> {
        Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
        assertThat(endpoints).containsOnlyKeys(EndpointId.of("voidwrite"));
        ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("voidwrite"));
        assertThat(requestPredicates(endpoint)).has(requestPredicates(path("voidwrite").httpMethod(WebEndpointHttpMethod.POST).produces().consumes("application/json")));
    });
}
Also used : ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) Test(org.junit.jupiter.api.Test)

Example 12 with EndpointId

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

the class WebEndpointDiscovererTests method getEndpointsWhenHasWebExtensionShouldOverrideStandardEndpoint.

@Test
void getEndpointsWhenHasWebExtensionShouldOverrideStandardEndpoint() {
    load(OverriddenOperationWebEndpointExtensionConfiguration.class, (discoverer) -> {
        Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
        assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
        ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("test"));
        assertThat(requestPredicates(endpoint)).has(requestPredicates(path("test").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/json")));
    });
}
Also used : ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) Test(org.junit.jupiter.api.Test)

Example 13 with EndpointId

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

the class OnAvailableEndpointCondition method getMatchOutcome.

private ConditionOutcome getMatchOutcome(Environment environment, MergedAnnotation<ConditionalOnAvailableEndpoint> conditionAnnotation, MergedAnnotation<Endpoint> endpointAnnotation) {
    ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnAvailableEndpoint.class);
    EndpointId endpointId = EndpointId.of(environment, endpointAnnotation.getString("id"));
    ConditionOutcome enablementOutcome = getEnablementOutcome(environment, endpointAnnotation, endpointId, message);
    if (!enablementOutcome.isMatch()) {
        return enablementOutcome;
    }
    Set<EndpointExposure> exposuresToCheck = getExposuresToCheck(conditionAnnotation);
    Set<ExposureFilter> exposureFilters = getExposureFilters(environment);
    for (ExposureFilter exposureFilter : exposureFilters) {
        if (exposuresToCheck.contains(exposureFilter.getExposure()) && exposureFilter.isExposed(endpointId)) {
            return ConditionOutcome.match(message.because("marked as exposed by a 'management.endpoints." + exposureFilter.getExposure().name().toLowerCase() + ".exposure' property"));
        }
    }
    return ConditionOutcome.noMatch(message.because("no 'management.endpoints' property marked it as exposed"));
}
Also used : ConditionMessage(org.springframework.boot.autoconfigure.condition.ConditionMessage) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) EndpointExposure(org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure) ConditionOutcome(org.springframework.boot.autoconfigure.condition.ConditionOutcome)

Aggregations

EndpointId (org.springframework.boot.actuate.endpoint.EndpointId)13 Test (org.junit.jupiter.api.Test)11 ExposableWebEndpoint (org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint)7 ExposableJmxEndpoint (org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint)4 JmxOperation (org.springframework.boot.actuate.endpoint.jmx.JmxOperation)4 CachingOperationInvoker (org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EndpointExposure (org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure)1 WebOperation (org.springframework.boot.actuate.endpoint.web.WebOperation)1 WebOperationRequestPredicate (org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate)1 ConditionMessage (org.springframework.boot.autoconfigure.condition.ConditionMessage)1 ConditionOutcome (org.springframework.boot.autoconfigure.condition.ConditionOutcome)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1