Merge branch '2.7.x'

Closes gh-33729
pull/33736/head
Moritz Halbritter 2 years ago
commit 3b6b795c9f

@ -273,6 +273,24 @@ public final class EndpointRequest {
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (this.includes.isEmpty()) {
sb.append("EndpointRequest [includes='[").append("*").append("]'");
}
else {
sb.append("EndpointRequest [includes='")
.append(this.includes.stream().map(this::getEndpointId).collect(Collectors.toList()))
.append("'");
}
sb.append(", Excludes='")
.append(this.excludes.stream().map(this::getEndpointId).collect(Collectors.toList())).append("'");
sb.append(", IncludeLinks='").append(this.includeLinks).append("'");
sb.append("]");
return sb.toString();
}
} }
/** /**

@ -215,6 +215,34 @@ class EndpointRequestTests {
assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/bar"); assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/bar");
} }
@Test
void toStringIncludedEndpoints() {
RequestMatcher matcher = EndpointRequest.to("foo", "bar");
assertThat(matcher.toString())
.isEqualTo("EndpointRequest [includes='[foo, bar]', Excludes='[]', IncludeLinks='false']");
}
@Test
void toStringEmptyIncludedEndpoints() {
RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
assertThat(matcher.toString())
.isEqualTo("EndpointRequest [includes='[*]', Excludes='[]', IncludeLinks='true']");
}
@Test
void toStringIncludedEndpointsClasses() {
RequestMatcher matcher = EndpointRequest.to(FooEndpoint.class).excluding("bar");
assertThat(matcher.toString())
.isEqualTo("EndpointRequest [includes='[foo]', Excludes='[bar]', IncludeLinks='false']");
}
@Test
void toStringIncludedExcludedEndpoints() {
RequestMatcher matcher = EndpointRequest.toAnyEndpoint().excluding("bar").excludingLinks();
assertThat(matcher.toString())
.isEqualTo("EndpointRequest [includes='[*]', Excludes='[bar]', IncludeLinks='false']");
}
private RequestMatcherAssert assertMatcher(RequestMatcher matcher) { private RequestMatcherAssert assertMatcher(RequestMatcher matcher) {
return assertMatcher(matcher, mockPathMappedEndpoints("/actuator")); return assertMatcher(matcher, mockPathMappedEndpoints("/actuator"));
} }

Loading…
Cancel
Save