use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class EndpointDiscoverer method convertToEndpoint.
private E convertToEndpoint(EndpointBean endpointBean) {
MultiValueMap<OperationKey, O> indexed = new LinkedMultiValueMap<>();
EndpointId id = endpointBean.getId();
addOperations(indexed, id, endpointBean.getBean(), false);
if (endpointBean.getExtensions().size() > 1) {
String extensionBeans = endpointBean.getExtensions().stream().map(ExtensionBean::getBeanName).collect(Collectors.joining(", "));
throw new IllegalStateException("Found multiple extensions for the endpoint bean " + endpointBean.getBeanName() + " (" + extensionBeans + ")");
}
for (ExtensionBean extensionBean : endpointBean.getExtensions()) {
addOperations(indexed, id, extensionBean.getBean(), true);
}
assertNoDuplicateOperations(endpointBean, indexed);
List<O> operations = indexed.values().stream().map(this::getLast).filter(Objects::nonNull).collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
return createEndpoint(endpointBean.getBean(), id, endpointBean.isEnabledByDefault(), operations);
}
use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class JmxEndpointDiscovererTests method getEndpointsWhenHasJmxExtensionWithNewOperationAddsExtraOperation.
@Test
void getEndpointsWhenHasJmxExtensionWithNewOperationAddsExtraOperation() {
load(AdditionalOperationJmxEndpointConfiguration.class, (discoverer) -> {
Map<EndpointId, ExposableJmxEndpoint> endpoints = discover(discoverer);
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
Map<String, JmxOperation> operationByName = mapOperations(endpoints.get(EndpointId.of("test")).getOperations());
assertThat(operationByName).containsOnlyKeys("getAll", "getSomething", "update", "deleteSomething", "getAnother");
JmxOperation getAnother = operationByName.get("getAnother");
assertThat(getAnother.getDescription()).isEqualTo("Get another thing");
assertThat(getAnother.getOutputType()).isEqualTo(Object.class);
assertThat(getAnother.getParameters()).isEmpty();
});
}
use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class JmxEndpointDiscovererTests method getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue.
@Test
void getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue() {
load(TestEndpoint.class, (id) -> 500L, (discoverer) -> {
Map<EndpointId, ExposableJmxEndpoint> endpoints = discover(discoverer);
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
Map<String, JmxOperation> operationByName = mapOperations(endpoints.get(EndpointId.of("test")).getOperations());
assertThat(operationByName).containsOnlyKeys("getAll", "getSomething", "update", "deleteSomething");
JmxOperation getAll = operationByName.get("getAll");
assertThat(getInvoker(getAll)).isInstanceOf(CachingOperationInvoker.class);
assertThat(((CachingOperationInvoker) getInvoker(getAll)).getTimeToLive()).isEqualTo(500);
});
}
use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class JmxEndpointDiscovererTests method getEndpointsShouldCacheReadOperations.
@Test
void getEndpointsShouldCacheReadOperations() {
load(AdditionalOperationJmxEndpointConfiguration.class, (id) -> 500L, (discoverer) -> {
Map<EndpointId, ExposableJmxEndpoint> endpoints = discover(discoverer);
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
Map<String, JmxOperation> operationByName = mapOperations(endpoints.get(EndpointId.of("test")).getOperations());
assertThat(operationByName).containsOnlyKeys("getAll", "getSomething", "update", "deleteSomething", "getAnother");
JmxOperation getAll = operationByName.get("getAll");
assertThat(getInvoker(getAll)).isInstanceOf(CachingOperationInvoker.class);
assertThat(((CachingOperationInvoker) getInvoker(getAll)).getTimeToLive()).isEqualTo(500);
JmxOperation getAnother = operationByName.get("getAnother");
assertThat(getInvoker(getAnother)).isInstanceOf(CachingOperationInvoker.class);
assertThat(((CachingOperationInvoker) getInvoker(getAnother)).getTimeToLive()).isEqualTo(500);
});
}
use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class WebEndpointDiscovererTests method getEndpointsWhenHasCustomMediaTypeShouldProduceCustomMediaType.
@Test
void getEndpointsWhenHasCustomMediaTypeShouldProduceCustomMediaType() {
load(CustomMediaTypesEndpointConfiguration.class, (discoverer) -> {
Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
assertThat(endpoints).containsOnlyKeys(EndpointId.of("custommediatypes"));
ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("custommediatypes"));
assertThat(requestPredicates(endpoint)).has(requestPredicates(path("custommediatypes").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("text/plain"), path("custommediatypes").httpMethod(WebEndpointHttpMethod.POST).consumes().produces("a/b", "c/d"), path("custommediatypes").httpMethod(WebEndpointHttpMethod.DELETE).consumes().produces("text/plain")));
});
}
Aggregations