use of org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint in project spring-boot by spring-projects.
the class LinksEnhancerTests method useNameAsRelIfAvailable.
@Test
public void useNameAsRelIfAvailable() throws Exception {
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a"));
endpoint.setPath("something-else");
LinksEnhancer enhancer = getLinksEnhancer(Collections.singletonList((MvcEndpoint) endpoint));
ResourceSupport support = new ResourceSupport();
enhancer.addEndpointLinks(support, "");
assertThat(support.getLink("a").getHref()).contains("/something-else");
}
use of org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint in project spring-boot by spring-projects.
the class LinksEnhancerTests method usePathAsRelIfNameNotAvailable.
@Test
public void usePathAsRelIfNameNotAvailable() throws Exception {
MvcEndpoint endpoint = new NoNameTestMvcEndpoint("/a", false);
LinksEnhancer enhancer = getLinksEnhancer(Collections.singletonList(endpoint));
ResourceSupport support = new ResourceSupport();
enhancer.addEndpointLinks(support, "");
assertThat(support.getLink("a").getHref()).contains("/a");
}
use of org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint in project spring-boot by spring-projects.
the class LinksEnhancerTests method multipleHrefsForSameRelWhenPathIsDifferent.
@Test
public void multipleHrefsForSameRelWhenPathIsDifferent() throws Exception {
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a"));
endpoint.setPath("endpoint");
TestMvcEndpoint otherEndpoint = new TestMvcEndpoint(new TestEndpoint("a"));
otherEndpoint.setPath("other-endpoint");
LinksEnhancer enhancer = getLinksEnhancer(Arrays.asList((MvcEndpoint) endpoint, otherEndpoint));
ResourceSupport support = new ResourceSupport();
enhancer.addEndpointLinks(support, "");
assertThat(support.getLinks()).haveExactly(1, getCondition("a", "endpoint"));
assertThat(support.getLinks()).haveExactly(1, getCondition("a", "other-endpoint"));
}
use of org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint in project spring-boot by spring-projects.
the class LinksEnhancerTests method hrefNotAddedToRelTwice.
@Test
public void hrefNotAddedToRelTwice() throws Exception {
MvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a"));
MvcEndpoint otherEndpoint = new TestMvcEndpoint(new TestEndpoint("a"));
LinksEnhancer enhancer = getLinksEnhancer(Arrays.asList(endpoint, otherEndpoint));
ResourceSupport support = new ResourceSupport();
enhancer.addEndpointLinks(support, "");
assertThat(support.getLinks()).haveExactly(1, getCondition("a", "a"));
}
use of org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint in project spring-boot by spring-projects.
the class LinksEnhancerTests method getLinksEnhancer.
private LinksEnhancer getLinksEnhancer(List<MvcEndpoint> endpoints) throws Exception {
StaticWebApplicationContext context = new StaticWebApplicationContext();
for (MvcEndpoint endpoint : endpoints) {
context.getDefaultListableBeanFactory().registerSingleton(endpoint.toString(), endpoint);
}
MvcEndpoints mvcEndpoints = new MvcEndpoints();
mvcEndpoints.setApplicationContext(context);
mvcEndpoints.afterPropertiesSet();
return new LinksEnhancer("", mvcEndpoints);
}
Aggregations