Search in sources :

Example 1 with DefaultParameterNameDiscoverer

use of org.springframework.core.DefaultParameterNameDiscoverer in project spring-framework by spring-projects.

the class RequestAttributeMethodArgumentResolverTests method initMethodParameter.

private MethodParameter initMethodParameter(int parameterIndex) {
    MethodParameter param = new SynthesizingMethodParameter(this.handleMethod, parameterIndex);
    param.initParameterNameDiscovery(new DefaultParameterNameDiscoverer());
    GenericTypeResolver.resolveParameterType(param, this.resolver.getClass());
    return param;
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) DefaultParameterNameDiscoverer(org.springframework.core.DefaultParameterNameDiscoverer) MethodParameter(org.springframework.core.MethodParameter) SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter)

Example 2 with DefaultParameterNameDiscoverer

use of org.springframework.core.DefaultParameterNameDiscoverer in project spring-boot by spring-projects.

the class OperationMethodParametersTests method iteratorShouldIterateOperationParameters.

@Test
void iteratorShouldIterateOperationParameters() {
    OperationMethodParameters parameters = new OperationMethodParameters(this.exampleMethod, new DefaultParameterNameDiscoverer());
    Iterator<OperationParameter> iterator = parameters.iterator();
    assertParameters(StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false));
}
Also used : DefaultParameterNameDiscoverer(org.springframework.core.DefaultParameterNameDiscoverer) OperationParameter(org.springframework.boot.actuate.endpoint.invoke.OperationParameter) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultParameterNameDiscoverer

use of org.springframework.core.DefaultParameterNameDiscoverer in project spring-boot by spring-projects.

the class OperationMethodParametersTests method hasParametersWhenHasNoParametersShouldReturnFalse.

@Test
void hasParametersWhenHasNoParametersShouldReturnFalse() {
    OperationMethodParameters parameters = new OperationMethodParameters(this.exampleNoParamsMethod, new DefaultParameterNameDiscoverer());
    assertThat(parameters.hasParameters()).isFalse();
}
Also used : DefaultParameterNameDiscoverer(org.springframework.core.DefaultParameterNameDiscoverer) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultParameterNameDiscoverer

use of org.springframework.core.DefaultParameterNameDiscoverer in project spring-boot by spring-projects.

the class OperationMethodParametersTests method getParameterCountShouldReturnParameterCount.

@Test
void getParameterCountShouldReturnParameterCount() {
    OperationMethodParameters parameters = new OperationMethodParameters(this.exampleMethod, new DefaultParameterNameDiscoverer());
    assertThat(parameters.getParameterCount()).isEqualTo(1);
}
Also used : DefaultParameterNameDiscoverer(org.springframework.core.DefaultParameterNameDiscoverer) Test(org.junit.jupiter.api.Test)

Example 5 with DefaultParameterNameDiscoverer

use of org.springframework.core.DefaultParameterNameDiscoverer in project spring-boot by spring-projects.

the class OperationMethodParametersTests method hasParametersWhenHasParametersShouldReturnTrue.

@Test
void hasParametersWhenHasParametersShouldReturnTrue() {
    OperationMethodParameters parameters = new OperationMethodParameters(this.exampleMethod, new DefaultParameterNameDiscoverer());
    assertThat(parameters.hasParameters()).isTrue();
}
Also used : DefaultParameterNameDiscoverer(org.springframework.core.DefaultParameterNameDiscoverer) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultParameterNameDiscoverer (org.springframework.core.DefaultParameterNameDiscoverer)10 Test (org.junit.jupiter.api.Test)5 MethodParameter (org.springframework.core.MethodParameter)4 SynthesizingMethodParameter (org.springframework.core.annotation.SynthesizingMethodParameter)3 Method (java.lang.reflect.Method)1 Before (org.junit.Before)1 OperationParameter (org.springframework.boot.actuate.endpoint.invoke.OperationParameter)1 DefaultConversionService (org.springframework.core.convert.support.DefaultConversionService)1