Polishing
See gh-28386
This commit is contained in:
@@ -26,6 +26,7 @@ import org.springframework.core.annotation.AliasFor;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Shortcut for {@link HttpRequest} for HTTP GET requests.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.lang.annotation.Target;
|
|||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Shortcut for {@link HttpRequest} for HTTP POST requests.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.lang.annotation.Target;
|
|||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Shortcut for {@link HttpRequest} for HTTP PUT requests.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import org.reactivestreams.Publisher;
|
|||||||
|
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.core.ResolvableType;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpRequest;
|
import org.springframework.http.HttpRequest;
|
||||||
@@ -56,7 +55,7 @@ public class HttpRequestDefinition {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private URI uri;
|
private URI uri;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private String uriTemplate;
|
private String uriTemplate;
|
||||||
|
|
||||||
@@ -80,7 +79,7 @@ public class HttpRequestDefinition {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Publisher<?> bodyPublisher;
|
private Publisher<?> bodyPublisher;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ParameterizedTypeReference<?> bodyPublisherElementType;
|
private ParameterizedTypeReference<?> bodyPublisherElementType;
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import org.springframework.aop.framework.ProxyFactory;
|
import org.springframework.aop.framework.ProxyFactory;
|
||||||
import org.springframework.core.MethodIntrospector;
|
import org.springframework.core.MethodIntrospector;
|
||||||
@@ -91,7 +89,7 @@ public class HttpServiceProxyFactory {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* {@link MethodInterceptor} that invokes an {@link HttpServiceMethod}.
|
||||||
*/
|
*/
|
||||||
private static final class HttpServiceMethodInterceptor implements MethodInterceptor {
|
private static final class HttpServiceMethodInterceptor implements MethodInterceptor {
|
||||||
|
|
||||||
@@ -101,9 +99,8 @@ public class HttpServiceProxyFactory {
|
|||||||
methods.forEach(serviceMethod -> this.serviceMethodMap.put(serviceMethod.getMethod(), serviceMethod));
|
methods.forEach(serviceMethod -> this.serviceMethodMap.put(serviceMethod.getMethod(), serviceMethod));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(@NotNull MethodInvocation invocation) throws Throwable {
|
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||||
Method method = invocation.getMethod();
|
Method method = invocation.getMethod();
|
||||||
HttpServiceMethod httpServiceMethod = this.serviceMethodMap.get(method);
|
HttpServiceMethod httpServiceMethod = this.serviceMethodMap.get(method);
|
||||||
return httpServiceMethod.invoke(invocation.getArguments());
|
return httpServiceMethod.invoke(invocation.getArguments());
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
*
|
* Support to create a client proxy for an HTTP service annotated with
|
||||||
|
* {@link org.springframework.web.service.annotation.HttpRequest} methods.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NonNullApi
|
||||||
@NonNullFields
|
@NonNullFields
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ public class HttpMethodArgumentResolverTests {
|
|||||||
|
|
||||||
private final Service service = this.clientAdapter.createService(Service.class, new HttpMethodArgumentResolver());
|
private final Service service = this.clientAdapter.createService(Service.class, new HttpMethodArgumentResolver());
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldResolveRequestMethodFromArgument() {
|
void shouldResolveRequestMethodFromArgument() {
|
||||||
this.service.execute(HttpMethod.GET);
|
this.service.execute(HttpMethod.GET);
|
||||||
assertThat(getActualMethod()).isEqualTo(HttpMethod.GET);
|
assertThat(getActualMethod()).isEqualTo(HttpMethod.GET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldIgnoreArgumentsNotMatchingType() {
|
void shouldIgnoreArgumentsNotMatchingType() {
|
||||||
this.service.execute("test");
|
this.service.execute("test");
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.springframework.web.service.invoker;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.core.convert.support.DefaultConversionService;
|
import org.springframework.core.convert.support.DefaultConversionService;
|
||||||
@@ -143,7 +142,6 @@ class PathVariableArgumentResolverTests {
|
|||||||
assertThat(getActualUriVariables().get(name)).isEqualTo(expectedValue);
|
assertThat(getActualUriVariables().get(name)).isEqualTo(expectedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private Map<String, String> getActualUriVariables() {
|
private Map<String, String> getActualUriVariables() {
|
||||||
return this.clientAdapter.getRequestDefinition().getUriVariables();
|
return this.clientAdapter.getRequestDefinition().getUriVariables();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user