From 769b38c5c16ad0ab7eec057adbc2979c62fae3ab Mon Sep 17 00:00:00 2001 From: Jonathan Schneider Date: Tue, 22 Jun 2021 05:37:25 +0000 Subject: [PATCH] Refactor: replace `@RequestMapping` annotations Co-authored-by: Moderne --- ...lientDisabledClientLevelFeaturesTests.java | 5 +- .../FeignClientDisabledFeaturesTests.java | 5 +- .../FeignClientErrorDecoderTests.java | 5 +- .../openfeign/FeignClientFactoryTests.java | 5 +- .../FeignClientUsingPropertiesTests.java | 7 +-- .../openfeign/FeignClientsRegistrarTests.java | 7 ++- .../openfeign/FeignHttpClientUrlTests.java | 13 +++-- ...ientUrlTestsWithRetryableLoadBalancer.java | 8 ++- .../cloud/openfeign/SpringDecoderTests.java | 14 +++--- .../beans/BeansFeignClientTests.java | 5 +- .../cloud/openfeign/beans/TestClient.java | 5 +- .../openfeign/beans/extra/TestClient.java | 5 +- .../circuitbreaker/CircuitBreakerTests.java | 11 ++-- .../CircuitBreakerWithNoFallbackTests.java | 7 ++- .../encoding/app/client/InvoiceClient.java | 18 +++---- .../app/resource/InvoiceResource.java | 18 +++---- .../invalid/FeignClientValidationTests.java | 11 ++-- .../support/SpringMvcContractTests.java | 50 +++++++++---------- .../openfeign/testclients/TestClient.java | 5 +- .../valid/FeignClientNotPrimaryTests.java | 7 ++- .../valid/FeignClientValidationTests.java | 9 ++-- .../openfeign/valid/FeignHttpClientTests.java | 14 +++--- .../openfeign/valid/FeignOkHttpTests.java | 14 +++--- .../scanning/FeignClientEnvVarTests.java | 5 +- .../scanning/FeignClientScanningTests.java | 9 ++-- 25 files changed, 118 insertions(+), 144 deletions(-) diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledClientLevelFeaturesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledClientLevelFeaturesTests.java index 762f2f11..84dedc29 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledClientLevelFeaturesTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledClientLevelFeaturesTests.java @@ -32,8 +32,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import static org.assertj.core.api.Assertions.assertThat; @@ -83,7 +82,7 @@ class FeignClientDisabledClientLevelFeaturesTests { @FeignClient(name = "bar", url = "https://bar", configuration = BarConfiguration.class) interface BarClient { - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") String get(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledFeaturesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledFeaturesTests.java index bba6ffbc..321c7ad0 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledFeaturesTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledFeaturesTests.java @@ -32,8 +32,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import static org.assertj.core.api.Assertions.assertThat; @@ -82,7 +81,7 @@ class FeignClientDisabledFeaturesTests { @FeignClient(name = "bar", url = "https://bar", configuration = BarConfiguration.class) interface BarClient { - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") String get(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientErrorDecoderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientErrorDecoderTests.java index e8980814..cdfc0e46 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientErrorDecoderTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientErrorDecoderTests.java @@ -37,8 +37,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import static org.assertj.core.api.Assertions.assertThat; @@ -133,7 +132,7 @@ public class FeignClientErrorDecoderTests { @FeignClient(name = "bar", url = "http://bar", configuration = BarConfiguration.class) interface BarClient { - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") String get(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTests.java index da4edd1b..54bfed16 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTests.java @@ -39,10 +39,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.web.bind.annotation.RequestMethod.GET; /** * @author Spencer Gibb @@ -90,7 +89,7 @@ public class FeignClientFactoryTests { interface TestType { - @RequestMapping(value = "/", method = GET) + @GetMapping("/") String hello(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java index a9d3a30a..f14eed1c 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java @@ -66,8 +66,6 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -295,8 +293,7 @@ public class FeignClientUsingPropertiesTests { protected interface FormClient { - @RequestMapping(value = "/form", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) + @PostMapping(value = "/form", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) String form(Map form); } @@ -328,7 +325,7 @@ public class FeignClientUsingPropertiesTests { @Import(NoSecurityConfiguration.class) protected static class Application { - @RequestMapping(method = RequestMethod.GET, value = "/foo") + @GetMapping("/foo") public String foo(HttpServletRequest request) throws IllegalAccessException { if ("Foo".equals(request.getHeader("Foo")) && "Bar".equals(request.getHeader("Bar"))) { return "OK"; diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarTests.java index 11cb4009..16e86bc9 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarTests.java @@ -25,8 +25,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.mock.env.MockEnvironment; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -105,7 +104,7 @@ public class FeignClientsRegistrarTests { @FeignClient(name = "fallbackTestClient", url = "http://localhost:8080/", fallback = FallbackClient.class) protected interface FallbackClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") String fallbackTest(); } @@ -114,7 +113,7 @@ public class FeignClientsRegistrarTests { fallbackFactory = FallbackFactoryClient.class) protected interface FallbackFactoryClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") String fallbackFactoryTest(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTests.java index a064ac3f..0920e03a 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTests.java @@ -37,8 +37,7 @@ import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.util.ReflectionUtils; import org.springframework.util.SocketUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -102,7 +101,7 @@ class FeignHttpClientUrlTests { @FeignClient(name = "localappurl", url = "http://localhost:${server.port}/") protected interface UrlClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); } @@ -110,7 +109,7 @@ class FeignHttpClientUrlTests { @FeignClient(name = "beanappurl", url = "#{SERVER_URL}path") protected interface BeanUrlClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); } @@ -118,7 +117,7 @@ class FeignHttpClientUrlTests { @FeignClient(name = "beanappurlnoprotocol", url = "#{SERVER_URL_NO_PROTOCOL}path") protected interface BeanUrlClientNoProtocol { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); } @@ -130,12 +129,12 @@ class FeignHttpClientUrlTests { @Import(NoSecurityConfiguration.class) protected static class TestConfig { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") public Hello getHello() { return new Hello("hello world 1"); } - @RequestMapping(method = RequestMethod.GET, value = "/path/hello") + @GetMapping("/path/hello") public Hello getHelloWithPath() { return getHello(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTestsWithRetryableLoadBalancer.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTestsWithRetryableLoadBalancer.java index c7f5477d..0bcf8160 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTestsWithRetryableLoadBalancer.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTestsWithRetryableLoadBalancer.java @@ -38,8 +38,6 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.util.ReflectionUtils; import org.springframework.util.SocketUtils; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -104,7 +102,7 @@ class FeignHttpClientUrlTestsWithRetryableLoadBalancer { @FeignClient(name = "localappurl", url = "http://localhost:${server.port}/") protected interface UrlClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); } @@ -112,7 +110,7 @@ class FeignHttpClientUrlTestsWithRetryableLoadBalancer { @FeignClient(name = "beanappurl", url = "#{SERVER_URL}path") protected interface BeanUrlClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); } @@ -120,7 +118,7 @@ class FeignHttpClientUrlTestsWithRetryableLoadBalancer { @FeignClient(name = "beanappurlnoprotocol", url = "#{SERVER_URL_NO_PROTOCOL}path") protected interface BeanUrlClientNoProtocol { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/SpringDecoderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/SpringDecoderTests.java index 3794f86f..c7d5691d 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/SpringDecoderTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/SpringDecoderTests.java @@ -39,8 +39,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -154,22 +152,22 @@ public class SpringDecoderTests extends FeignClientFactoryBean { protected interface TestClient { - @RequestMapping(method = RequestMethod.GET, value = "/helloresponse") + @GetMapping("/helloresponse") ResponseEntity getHelloResponse(); - @RequestMapping(method = RequestMethod.GET, value = "/hellovoid") + @GetMapping("/hellovoid") ResponseEntity getHelloVoid(); - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); - @RequestMapping(method = RequestMethod.GET, value = "/hellos") + @GetMapping("/hellos") List getHellos(); - @RequestMapping(method = RequestMethod.GET, value = "/hellostrings") + @GetMapping("/hellostrings") List getHelloStrings(); - @RequestMapping(method = RequestMethod.GET, value = "/hellonotfound") + @GetMapping("/hellonotfound") ResponseEntity getNotFound(); @GetMapping("/helloWildcard") diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/BeansFeignClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/BeansFeignClientTests.java index 7526bf57..326c6b02 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/BeansFeignClientTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/BeansFeignClientTests.java @@ -39,8 +39,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -122,7 +121,7 @@ public class BeansFeignClientTests { return feignClientBuilder.forType(TestClient.class, "builderapp").build(); } - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") public Hello getHello() { return new Hello("hello world 1"); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/TestClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/TestClient.java index 3ecbd256..a0724bbc 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/TestClient.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/TestClient.java @@ -19,14 +19,13 @@ package org.springframework.cloud.openfeign.beans; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.beans.BeansFeignClientTests.Hello; import org.springframework.context.annotation.Primary; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; @Primary @FeignClient("localapp") public interface TestClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/extra/TestClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/extra/TestClient.java index 7b938aee..8951ecc3 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/extra/TestClient.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/extra/TestClient.java @@ -18,13 +18,12 @@ package org.springframework.cloud.openfeign.beans.extra; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.beans.BeansFeignClientTests.Hello; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; @FeignClient(value = "otherapp", qualifier = "uniquequalifier") public interface TestClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerTests.java index d6b535c8..a300c163 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerTests.java @@ -45,8 +45,7 @@ import org.springframework.stereotype.Component; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.SocketUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -115,10 +114,10 @@ public class CircuitBreakerTests { @FeignClient(name = "test", url = "http://localhost:${server.port}/", fallback = Fallback.class) protected interface TestClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); - @RequestMapping(method = RequestMethod.GET, value = "/hellonotfound") + @GetMapping("/hellonotfound") String getException(); } @@ -142,10 +141,10 @@ public class CircuitBreakerTests { fallbackFactory = TestFallbackFactory.class) protected interface TestClientWithFactory { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); - @RequestMapping(method = RequestMethod.GET, value = "/hellonotfound") + @GetMapping("/hellonotfound") String getException(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerWithNoFallbackTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerWithNoFallbackTests.java index da1d50dc..fa15a37e 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerWithNoFallbackTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerWithNoFallbackTests.java @@ -40,8 +40,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.util.SocketUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -97,10 +96,10 @@ public class CircuitBreakerWithNoFallbackTests { @FeignClient(name = "test", url = "http://localhost:${server.port}/") protected interface CircuitBreakerTestClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); - @RequestMapping(method = RequestMethod.GET, value = "/hellonotfound") + @GetMapping("/hellonotfound") String getException(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/client/InvoiceClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/client/InvoiceClient.java index 57d629e0..c80107d3 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/client/InvoiceClient.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/client/InvoiceClient.java @@ -24,9 +24,9 @@ import org.springframework.cloud.openfeign.encoding.app.domain.Invoice; import org.springframework.data.domain.Page; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; /** * Simple Feign client for retrieving the invoice list. @@ -37,23 +37,23 @@ import org.springframework.web.bind.annotation.RequestMethod; @FeignClient("local") public interface InvoiceClient { - @RequestMapping(value = "invoicesPaged", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "invoicesPaged", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity> getInvoicesPaged(org.springframework.data.domain.Pageable pageable); - @RequestMapping(value = "invoicesPagedWithBody", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "invoicesPagedWithBody", consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity> getInvoicesPagedWithBody( @SpringQueryMap org.springframework.data.domain.Pageable pageable, @RequestBody String titlePrefix); - @RequestMapping(value = "invoicesSortedWithBody", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "invoicesSortedWithBody", consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity> getInvoicesSortedWithBody(@SpringQueryMap org.springframework.data.domain.Sort sort, @RequestBody String titlePrefix); - @RequestMapping(value = "invoices", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "invoices", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity> getInvoices(); - @RequestMapping(value = "invoices", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, + @PostMapping(value = "invoices", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity> saveInvoices(List invoices); diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/resource/InvoiceResource.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/resource/InvoiceResource.java index 5eb6a7ce..6dc9ec00 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/resource/InvoiceResource.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/resource/InvoiceResource.java @@ -28,9 +28,9 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** @@ -42,28 +42,28 @@ import org.springframework.web.bind.annotation.RestController; @RestController public class InvoiceResource { - @RequestMapping(value = "invoices", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "invoices", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getInvoices() { return ResponseEntity.ok(createInvoiceList(null, 100, null)); } - @RequestMapping(value = "invoices", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, + @PostMapping(value = "invoices", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity> saveInvoices(@RequestBody List invoices) { return ResponseEntity.ok(invoices); } - @RequestMapping(value = "invoicesPaged", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "invoicesPaged", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getInvoicesPaged(org.springframework.data.domain.Pageable pageable) { Page page = new PageImpl<>(createInvoiceList(null, pageable.getPageSize(), pageable.getSort()), pageable, 100); return ResponseEntity.ok(page); } - @RequestMapping(value = "invoicesPagedWithBody", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "invoicesPagedWithBody", consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getInvoicesPagedWithBody(org.springframework.data.domain.Pageable pageable, @RequestBody String titlePrefix) { Page page = new PageImpl<>(createInvoiceList(titlePrefix, pageable.getPageSize(), pageable.getSort()), @@ -71,8 +71,8 @@ public class InvoiceResource { return ResponseEntity.ok(page); } - @RequestMapping(value = "invoicesSortedWithBody", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "invoicesSortedWithBody", consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getInvoicesSortedWithBody(org.springframework.data.domain.Sort sort, @RequestBody String titlePrefix) { Page page = new PageImpl<>(createInvoiceList(titlePrefix, 100, sort), PageRequest.of(0, 100, sort), diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/invalid/FeignClientValidationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/invalid/FeignClientValidationTests.java index 12d155b3..6e5960fe 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/invalid/FeignClientValidationTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/invalid/FeignClientValidationTests.java @@ -28,8 +28,7 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import static org.assertj.core.api.Assertions.assertThat; @@ -74,7 +73,7 @@ public class FeignClientValidationTests { @FeignClient(name = "bar") interface Client { - @RequestMapping(method = RequestMethod.GET, value = "/") + @GetMapping("/") String get(); } @@ -90,7 +89,7 @@ public class FeignClientValidationTests { @FeignClient(contextId = "foo", name = "bar") interface FooClient { - @RequestMapping(method = RequestMethod.GET, value = "/") + @GetMapping("/") String get(); } @@ -98,7 +97,7 @@ public class FeignClientValidationTests { @FeignClient(name = "bar") interface BarClient { - @RequestMapping(method = RequestMethod.GET, value = "/") + @GetMapping("/") String get(); } @@ -113,7 +112,7 @@ public class FeignClientValidationTests { @FeignClient("foo_bar") interface Client { - @RequestMapping(method = RequestMethod.GET, value = "/") + @GetMapping("/") String get(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java index 738333f6..7f6d7ad7 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java @@ -50,6 +50,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.MatrixVariable; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; @@ -587,13 +588,13 @@ public class SpringMvcContractTests { @RequestMapping(value = "/test/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity getTest(@PathVariable("id") String id); - @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) TestObject getTest(); @GetMapping(value = "/test/{id}", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity getMappingTest(@PathVariable("id") String id); - @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) TestObject postTest(@RequestBody TestObject object); @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) @@ -604,7 +605,7 @@ public class SpringMvcContractTests { @RequestMapping("/prepend/{classId}") public interface TestTemplate_Class_Annotations { - @RequestMapping(value = "/test/{testId}", method = RequestMethod.GET) + @GetMapping("/test/{testId}") TestObject getSpecificTest(@PathVariable("classId") String classId, @PathVariable("testId") String testId); @RequestMapping(method = RequestMethod.GET) @@ -618,47 +619,46 @@ public class SpringMvcContractTests { public interface TestTemplate_Headers { - @RequestMapping(value = "/test/{id}", method = RequestMethod.GET, headers = "X-Foo=bar") + @GetMapping(value = "/test/{id}", headers = "X-Foo=bar") ResponseEntity getTest(@PathVariable("id") String id); } public interface TestTemplate_HeadersWithoutValues { - @RequestMapping(value = "/test/{id}", method = RequestMethod.GET, - headers = { "X-Foo", "!X-Bar", "X-Baz!=fooBar" }) + @GetMapping(value = "/test/{id}", headers = { "X-Foo", "!X-Bar", "X-Baz!=fooBar" }) ResponseEntity getTest(@PathVariable("id") String id); } public interface TestTemplate_ListParams { - @RequestMapping(value = "/test", method = RequestMethod.GET) + @GetMapping("/test") ResponseEntity getTest(@RequestParam("id") List id); } public interface TestTemplate_ListParamsWithoutName { - @RequestMapping(value = "/test", method = RequestMethod.GET) + @GetMapping("/test") ResponseEntity getTest(@RequestParam List id); } public interface TestTemplate_MapParams { - @RequestMapping(value = "/test", method = RequestMethod.GET) + @GetMapping("/test") ResponseEntity getTest(@RequestParam Map params); } public interface TestTemplate_HeaderMap { - @RequestMapping(path = "/headerMap") + @GetMapping("/headerMap") String headerMap(@RequestHeader MultiValueMap headerMap, @RequestHeader(name = "aHeader") String aHeader); - @RequestMapping(path = "/headerMapMoreThanOnce") + @GetMapping("/headerMapMoreThanOnce") String headerMapMoreThanOnce(@RequestHeader MultiValueMap headerMap1, @RequestHeader MultiValueMap headerMap2); @@ -666,36 +666,35 @@ public class SpringMvcContractTests { public interface TestTemplate_QueryMap { - @RequestMapping(path = "/queryMap") + @GetMapping("/queryMap") String queryMap(@RequestParam MultiValueMap queryMap, @RequestParam(name = "aParam") String aParam); - @RequestMapping(path = "/queryMapMoreThanOnce") + @GetMapping("/queryMapMoreThanOnce") String queryMapMoreThanOnce(@RequestParam MultiValueMap queryMap1, @RequestParam MultiValueMap queryMap2); - @RequestMapping(path = "/queryMapObject") + @GetMapping("/queryMapObject") String queryMapObject(@SpringQueryMap TestObject queryMap, @RequestParam(name = "aParam") String aParam); } public interface TestTemplate_RequestPart { - @RequestMapping(path = "/requestPart", method = RequestMethod.POST, - consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @PostMapping(path = "/requestPart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) void requestWithMultipleParts(@RequestPart("file") MultipartFile file, @RequestPart("id") String identifier); } public interface TestTemplate_MatrixVariable { - @RequestMapping(path = "/matrixVariable/{params}") + @GetMapping("/matrixVariable/{params}") String matrixVariable(@MatrixVariable("params") Map params); - @RequestMapping(path = "/matrixVariableObject/{param}") + @GetMapping("/matrixVariableObject/{param}") String matrixVariableObject(@MatrixVariable("param") Object object); - @RequestMapping(path = "/matrixVariable/{params}") + @GetMapping("/matrixVariable/{params}") String matrixVariableNotNamed(@MatrixVariable Map params); } @@ -709,21 +708,20 @@ public class SpringMvcContractTests { ResponseEntity getWithCollectionFormat(); @ExceptionHandler - @RequestMapping(path = "/test/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) + @PutMapping(path = "/test/{id}", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity getTest(@RequestHeader("Authorization") String auth, @PathVariable("id") String id, @RequestParam("amount") Integer amount); - @RequestMapping(path = "/test2", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) + @PutMapping(path = "/test2", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity getTest2(@RequestHeader(name = "Authorization") String auth, @RequestParam(name = "amount") Integer amount); @ExceptionHandler - @RequestMapping(path = "/testfallback/{id}", method = RequestMethod.PUT, - produces = MediaType.APPLICATION_JSON_VALUE) + @PutMapping(path = "/testfallback/{id}", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity getTestFallback(@RequestHeader String Authorization, @PathVariable String id, @RequestParam Integer amount); - @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) TestObject getTest(); @GetMapping(produces = "application/json") @@ -735,7 +733,7 @@ public class SpringMvcContractTests { String CUSTOM_PATTERN = "dd-MM-yyyy HH:mm"; - @RequestMapping(method = RequestMethod.GET) + @GetMapping String getTest(@RequestParam(name = "localDateTime") @DateTimeFormat( pattern = CUSTOM_PATTERN) LocalDateTime localDateTime); @@ -745,7 +743,7 @@ public class SpringMvcContractTests { String CUSTOM_PATTERN = "$###,###.###"; - @RequestMapping(method = RequestMethod.GET) + @GetMapping String getTest(@RequestParam("amount") @NumberFormat(pattern = CUSTOM_PATTERN) BigDecimal amount); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/testclients/TestClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/testclients/TestClient.java index 025f02ff..02e91705 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/testclients/TestClient.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/testclients/TestClient.java @@ -17,8 +17,7 @@ package org.springframework.cloud.openfeign.testclients; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; /** * @author Ryan Baxter @@ -26,7 +25,7 @@ import org.springframework.web.bind.annotation.RequestMethod; @FeignClient(name = "localapp") public interface TestClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") String getHello(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientNotPrimaryTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientNotPrimaryTests.java index 18ea2834..6bc5f78a 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientNotPrimaryTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientNotPrimaryTests.java @@ -37,8 +37,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -83,7 +82,7 @@ public class FeignClientNotPrimaryTests { @FeignClient(name = "localapp", primary = false) protected interface TestClient { - @RequestMapping(method = RequestMethod.GET, path = "/hello") + @GetMapping("/hello") Hello getHello(); } @@ -101,7 +100,7 @@ public class FeignClientNotPrimaryTests { return new PrimaryTestClient(); } - @RequestMapping(method = RequestMethod.GET, path = "/hello") + @GetMapping("/hello") public Hello getHello() { return new Hello(HELLO_WORLD_1); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientValidationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientValidationTests.java index 119c0212..e94e6bbd 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientValidationTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientValidationTests.java @@ -27,8 +27,7 @@ import org.springframework.cloud.openfeign.loadbalancer.FeignLoadBalancerAutoCon import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import static org.assertj.core.api.Assertions.assertThat; @@ -70,7 +69,7 @@ public class FeignClientValidationTests { @FeignClient(name = "example", url = "https://example.com") interface Client { - @RequestMapping(method = RequestMethod.GET, value = "/") + @GetMapping("/") @Deprecated String get(); @@ -86,7 +85,7 @@ public class FeignClientValidationTests { @FeignClient(name = "example", url = "${feignClient.url:https://example.com}") interface Client { - @RequestMapping(method = RequestMethod.GET, value = "/") + @GetMapping("/") @Deprecated String get(); @@ -102,7 +101,7 @@ public class FeignClientValidationTests { @FeignClient("foo") interface Client { - @RequestMapping(method = RequestMethod.GET, value = "/") + @GetMapping("/") @Deprecated String get(); diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttpClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttpClientTests.java index 82d25aa6..7d3dbf69 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttpClientTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttpClientTests.java @@ -41,11 +41,11 @@ import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -107,17 +107,17 @@ class FeignHttpClientTests { protected interface BaseTestClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) Hello getHello(); - @RequestMapping(method = RequestMethod.PATCH, value = "/hellop", consumes = "application/json") + @PatchMapping(value = "/hellop", consumes = "application/json") ResponseEntity patchHello(Hello hello); } protected interface UserService { - @RequestMapping(method = RequestMethod.GET, value = "/users/{id}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "/users/{id}", produces = MediaType.APPLICATION_JSON_VALUE) User getUser(@PathVariable("id") long id); } @@ -136,12 +136,12 @@ class FeignHttpClientTests { @Import(NoSecurityConfiguration.class) protected static class Application implements UserService { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") public Hello getHello() { return new Hello("hello world 1"); } - @RequestMapping(method = RequestMethod.PATCH, value = "/hellop") + @PatchMapping("/hellop") public ResponseEntity patchHello(@RequestBody Hello hello, @RequestHeader("Content-Length") int contentLength) { if (contentLength <= 0) { diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignOkHttpTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignOkHttpTests.java index 19b459f9..d78b06f5 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignOkHttpTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignOkHttpTests.java @@ -40,11 +40,11 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -107,17 +107,17 @@ class FeignOkHttpTests { protected interface BaseTestClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") Hello getHello(); - @RequestMapping(method = RequestMethod.PATCH, value = "/hellop", consumes = "application/json") + @PatchMapping(value = "/hellop", consumes = "application/json") ResponseEntity patchHello(Hello hello); } protected interface UserService { - @RequestMapping(method = RequestMethod.GET, value = "/users/{id}") + @GetMapping("/users/{id}") User getUser(@PathVariable("id") long id); } @@ -138,12 +138,12 @@ class FeignOkHttpTests { @Import(NoSecurityConfiguration.class) protected static class Application implements UserService { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") public Hello getHello() { return new Hello("hello world 1"); } - @RequestMapping(method = RequestMethod.PATCH, value = "/hellop") + @PatchMapping("/hellop") public ResponseEntity patchHello(@RequestBody Hello hello, @RequestHeader("Content-Length") int contentLength) { if (contentLength <= 0) { diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientEnvVarTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientEnvVarTests.java index 33da7cb6..a6160e76 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientEnvVarTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientEnvVarTests.java @@ -35,8 +35,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -70,7 +69,7 @@ public class FeignClientEnvVarTests { @Import(NoSecurityConfiguration.class) protected static class Application { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") public String getHello() { return "hello world 1"; } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java index 4abc6bf4..1f4b9721 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java @@ -37,8 +37,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -83,7 +82,7 @@ public class FeignClientScanningTests { @FeignClient("localapp123") protected interface TestClient { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") String getHello(); } @@ -91,7 +90,7 @@ public class FeignClientScanningTests { @FeignClient("${feignClient.localappName}") protected interface TestClientByKey { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") String getHello(); } @@ -104,7 +103,7 @@ public class FeignClientScanningTests { @Import(NoSecurityConfiguration.class) protected static class Application { - @RequestMapping(method = RequestMethod.GET, value = "/hello") + @GetMapping("/hello") public String getHello() { return "hello world 1"; }