use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class WebEndpointDiscovererTests method getEndpointsWhenExtensionAddsOperationShouldHaveBothOperations.
@Test
void getEndpointsWhenExtensionAddsOperationShouldHaveBothOperations() {
load(AdditionalOperationWebEndpointConfiguration.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"), path("test/{id}").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/json")));
});
}
use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class WebEndpointDiscovererTests method getEndpointsWhenHasCustomPathShouldReturnCustomPath.
@Test
void getEndpointsWhenHasCustomPathShouldReturnCustomPath() {
load((id) -> null, (id) -> "custom/" + id, AdditionalOperationWebEndpointConfiguration.class, (discoverer) -> {
Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("test"));
Condition<List<? extends WebOperationRequestPredicate>> expected = requestPredicates(path("custom/test").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/json"), path("custom/test/{id}").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/json"));
assertThat(requestPredicates(endpoint)).has(expected);
});
}
use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class WebEndpointDiscovererTests method getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue.
@Test
void getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue() {
load((id) -> 500L, EndpointId::toString, TestEndpointConfiguration.class, (discoverer) -> {
Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("test"));
assertThat(endpoint.getOperations()).hasSize(1);
WebOperation operation = endpoint.getOperations().iterator().next();
Object invoker = ReflectionTestUtils.getField(operation, "invoker");
assertThat(invoker).isInstanceOf(CachingOperationInvoker.class);
assertThat(((CachingOperationInvoker) invoker).getTimeToLive()).isEqualTo(500);
});
}
use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class JmxEndpointDiscovererTests method getEndpointsShouldDiscoverStandardEndpoints.
@Test
void getEndpointsShouldDiscoverStandardEndpoints() {
load(TestEndpoint.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");
JmxOperation getAll = operationByName.get("getAll");
assertThat(getAll.getDescription()).isEqualTo("Invoke getAll for endpoint test");
assertThat(getAll.getOutputType()).isEqualTo(Object.class);
assertThat(getAll.getParameters()).isEmpty();
JmxOperation getSomething = operationByName.get("getSomething");
assertThat(getSomething.getDescription()).isEqualTo("Invoke getSomething for endpoint test");
assertThat(getSomething.getOutputType()).isEqualTo(String.class);
assertThat(getSomething.getParameters()).hasSize(1);
assertThat(getSomething.getParameters().get(0).getType()).isEqualTo(String.class);
JmxOperation update = operationByName.get("update");
assertThat(update.getDescription()).isEqualTo("Invoke update for endpoint test");
assertThat(update.getOutputType()).isEqualTo(Void.TYPE);
assertThat(update.getParameters()).hasSize(2);
assertThat(update.getParameters().get(0).getType()).isEqualTo(String.class);
assertThat(update.getParameters().get(1).getType()).isEqualTo(String.class);
JmxOperation deleteSomething = operationByName.get("deleteSomething");
assertThat(deleteSomething.getDescription()).isEqualTo("Invoke deleteSomething for endpoint test");
assertThat(deleteSomething.getOutputType()).isEqualTo(Void.TYPE);
assertThat(deleteSomething.getParameters()).hasSize(1);
assertThat(deleteSomething.getParameters().get(0).getType()).isEqualTo(String.class);
});
}
use of org.springframework.boot.actuate.endpoint.EndpointId in project spring-boot by spring-projects.
the class WebEndpointDiscovererTests method getEndpointsWhenOperationReturnsResourceShouldProduceApplicationOctetStream.
@Test
void getEndpointsWhenOperationReturnsResourceShouldProduceApplicationOctetStream() {
load(ResourceEndpointConfiguration.class, (discoverer) -> {
Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
assertThat(endpoints).containsOnlyKeys(EndpointId.of("resource"));
ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("resource"));
assertThat(requestPredicates(endpoint)).has(requestPredicates(path("resource").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/octet-stream")));
});
}
Aggregations