use of org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod in project spring-boot by spring-projects.
the class RequestPredicateFactoryTests method getRequestPredicateWhenHasMoreThanOneMatchAllThrowsException.
@Test
void getRequestPredicateWhenHasMoreThanOneMatchAllThrowsException() {
DiscoveredOperationMethod operationMethod = getDiscoveredOperationMethod(MoreThanOneMatchAll.class);
assertThatIllegalStateException().isThrownBy(() -> this.factory.getRequestPredicate(this.rootPath, operationMethod)).withMessage("@Selector annotation with Match.ALL_REMAINING must be unique");
}
use of org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod in project spring-boot by spring-projects.
the class RequestPredicateFactoryTests method getRequestPredicateReturnsPredicateWithPath.
@Test
void getRequestPredicateReturnsPredicateWithPath() {
DiscoveredOperationMethod operationMethod = getDiscoveredOperationMethod(ValidSelectors.class);
WebOperationRequestPredicate requestPredicate = this.factory.getRequestPredicate(this.rootPath, operationMethod);
assertThat(requestPredicate.getPath()).isEqualTo("/root/{one}/{*two}");
}
use of org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod in project spring-boot by spring-projects.
the class RequestPredicateFactoryTests method getRequestPredicateWhenMatchAllIsNotLastParameterThrowsException.
@Test
void getRequestPredicateWhenMatchAllIsNotLastParameterThrowsException() {
DiscoveredOperationMethod operationMethod = getDiscoveredOperationMethod(MatchAllIsNotLastParameter.class);
assertThatIllegalStateException().isThrownBy(() -> this.factory.getRequestPredicate(this.rootPath, operationMethod)).withMessage("@Selector annotation with Match.ALL_REMAINING must be the last parameter");
}
use of org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod in project spring-boot by spring-projects.
the class RequestPredicateFactoryTests method getDiscoveredOperationMethod.
private DiscoveredOperationMethod getDiscoveredOperationMethod(Class<?> source) {
Method method = source.getDeclaredMethods()[0];
AnnotationAttributes attributes = new AnnotationAttributes();
attributes.put("produces", "application/json");
return new DiscoveredOperationMethod(method, OperationType.READ, attributes);
}
use of org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod in project spring-boot by spring-projects.
the class RequestPredicateFactory method getRequestPredicate.
WebOperationRequestPredicate getRequestPredicate(String rootPath, DiscoveredOperationMethod operationMethod) {
Method method = operationMethod.getMethod();
Parameter[] selectorParameters = Arrays.stream(method.getParameters()).filter(this::hasSelector).toArray(Parameter[]::new);
Parameter allRemainingPathSegmentsParameter = getAllRemainingPathSegmentsParameter(selectorParameters);
String path = getPath(rootPath, selectorParameters, allRemainingPathSegmentsParameter != null);
WebEndpointHttpMethod httpMethod = determineHttpMethod(operationMethod.getOperationType());
Collection<String> consumes = getConsumes(httpMethod, method);
Collection<String> produces = getProduces(operationMethod, method);
return new WebOperationRequestPredicate(path, httpMethod, consumes, produces);
}
Aggregations