Browse Source

Refactor.

fix-pageable-processing-when-querymap-present
Olga Maciaszek-Sharma 2 years ago
parent
commit
5bc28fa1dd
  1. 6
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java
  2. 24
      spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java

6
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java

@ -299,11 +299,7 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource @@ -299,11 +299,7 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource
}
}
if (!
isMultipartFormData(data) && isHttpAnnotation && data.indexToExpander().
get(paramIndex) == null) {
if (!isMultipartFormData(data) && isHttpAnnotation && data.indexToExpander().get(paramIndex) == null) {
TypeDescriptor typeDescriptor = createTypeDescriptor(method, paramIndex);
if (conversionService.canConvert(typeDescriptor, STRING_TYPE_DESCRIPTOR)) {
Param.Expander expander = convertingExpanderFactory.getExpander(typeDescriptor);

24
spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java

@ -631,20 +631,20 @@ class SpringMvcContractTests { @@ -631,20 +631,20 @@ class SpringMvcContractTests {
void shouldNotFailWhenBothPageableAndRequestBodyParamsInPostRequest() {
List<MethodMetadata> data = contract.parseAndValidateMetadata(TestTemplate_PageablePost.class);
assertThat(data.get(2).queryMapIndex()).isEqualTo(1);
assertThat(data.get(2).bodyIndex()).isEqualTo(0);
assertThat(data.get(3).queryMapIndex()).isEqualTo(0);
assertThat(data.get(3).bodyIndex()).isEqualTo(1);
assertThat(data.get(0).queryMapIndex()).isEqualTo(0);
assertThat(data.get(0).bodyIndex()).isEqualTo(1);
assertThat(data.get(1).queryMapIndex()).isEqualTo(1);
assertThat(data.get(1).bodyIndex()).isEqualTo(0);
}
@Test
void shouldSetPageableAsBodyWhenQueryMapParamPresent() {
List<MethodMetadata> data = contract.parseAndValidateMetadata(TestTemplate_PageablePost.class);
List<MethodMetadata> data = contract.parseAndValidateMetadata(TestTemplate_PageablePostWithQueryMap.class);
assertThat(data.get(0).queryMapIndex()).isEqualTo(1);
assertThat(data.get(0).bodyIndex()).isEqualTo(0);
assertThat(data.get(1).queryMapIndex()).isEqualTo(0);
assertThat(data.get(1).bodyIndex()).isEqualTo(1);
assertThat(data.get(0).queryMapIndex()).isEqualTo(0);
assertThat(data.get(0).bodyIndex()).isEqualTo(1);
assertThat(data.get(1).queryMapIndex()).isEqualTo(1);
assertThat(data.get(1).bodyIndex()).isEqualTo(0);
}
private ConversionService getConversionService() {
@ -848,7 +848,7 @@ class SpringMvcContractTests { @@ -848,7 +848,7 @@ class SpringMvcContractTests {
}
public interface TestTemplate_PageablePost {
interface TestTemplate_PageablePost {
@PostMapping
Page<String> getPage(Pageable pageable, @RequestBody String body);
@ -856,6 +856,10 @@ class SpringMvcContractTests { @@ -856,6 +856,10 @@ class SpringMvcContractTests {
@PostMapping
Page<String> getPage(@RequestBody String body, Pageable pageable);
}
interface TestTemplate_PageablePostWithQueryMap {
@PostMapping
Page<String> getPage(@SpringQueryMap TestObject pojo, Pageable pageable);

Loading…
Cancel
Save