Skip to content

Commit 17d0161

Browse files
committed
Reformat.
1 parent d6783a6 commit 17d0161

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,13 @@ public void setResourceLoader(ResourceLoader resourceLoader) {
185185

186186
@Override
187187
protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
188-
RequestMapping classAnnotation = findMergedAnnotation(clz,
189-
RequestMapping.class);
190-
if (classAnnotation != null) {
191-
LOG.error("Cannot process class: " + clz.getName()
192-
+ ". @RequestMapping annotation is not allowed on @FeignClient interfaces.");
193-
throw new IllegalArgumentException(
194-
"@RequestMapping annotation not allowed on @FeignClient interfaces");
195-
}
188+
RequestMapping classAnnotation = findMergedAnnotation(clz, RequestMapping.class);
189+
if (classAnnotation != null) {
190+
LOG.error("Cannot process class: " + clz.getName()
191+
+ ". @RequestMapping annotation is not allowed on @FeignClient interfaces.");
192+
throw new IllegalArgumentException(
193+
"@RequestMapping annotation not allowed on @FeignClient interfaces");
194+
}
196195
}
197196

198197
@Override

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,19 @@ public void testProcessAnnotations_SimpleGetMapping() throws Exception {
184184

185185
@Test
186186
public void testProcessAnnotations_Class_Annotations_RequestMapping() {
187-
assertThatIllegalArgumentException()
188-
.isThrownBy(() -> {
189-
Method method = TestTemplate_Class_RequestMapping.class
187+
assertThatIllegalArgumentException().isThrownBy(() -> {
188+
Method method = TestTemplate_Class_RequestMapping.class
190189
.getDeclaredMethod("getSpecificTest", String.class, String.class);
191-
contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
192-
});
190+
contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
191+
});
193192
}
194193

195194
@Test
196195
public void testProcessAnnotations_Class_AnnotationsGetAllTests() throws Exception {
197196
Method method = TestTemplate_Class_Annotations.class
198-
.getDeclaredMethod("getAllTests", String.class);
197+
.getDeclaredMethod("getAllTests", String.class);
199198
MethodMetadata data = contract
200-
.parseAndValidateMetadata(method.getDeclaringClass(), method);
199+
.parseAndValidateMetadata(method.getDeclaringClass(), method);
201200

202201
assertThat(data.template().url()).isEqualTo("/");
203202
assertThat(data.template().method()).isEqualTo("GET");
@@ -264,8 +263,7 @@ public void testProcessAnnotationsOnMethod_Advanced() throws Exception {
264263
MethodMetadata data = contract
265264
.parseAndValidateMetadata(method.getDeclaringClass(), method);
266265

267-
assertThat(data.template().url())
268-
.isEqualTo("/test/{id}?amount=" + "{amount}");
266+
assertThat(data.template().url()).isEqualTo("/test/{id}?amount=" + "{amount}");
269267
assertThat(data.template().method()).isEqualTo("PUT");
270268
assertThat(data.template().headers().get("Accept").iterator().next())
271269
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
@@ -300,8 +298,7 @@ public void testProcessAnnotations_Advanced() throws Exception {
300298
MethodMetadata data = contract
301299
.parseAndValidateMetadata(method.getDeclaringClass(), method);
302300

303-
assertThat(data.template().url())
304-
.isEqualTo("/test/{id}?amount=" + "{amount}");
301+
assertThat(data.template().url()).isEqualTo("/test/{id}?amount=" + "{amount}");
305302
assertThat(data.template().method()).isEqualTo("PUT");
306303
assertThat(data.template().headers().get("Accept").iterator().next())
307304
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
@@ -325,8 +322,7 @@ public void testProcessAnnotations_Aliased() throws Exception {
325322
MethodMetadata data = contract
326323
.parseAndValidateMetadata(method.getDeclaringClass(), method);
327324

328-
assertThat(data.template().url())
329-
.isEqualTo("/test2?amount=" + "{amount}");
325+
assertThat(data.template().url()).isEqualTo("/test2?amount=" + "{amount}");
330326
assertThat(data.template().method()).isEqualTo("PUT");
331327
assertThat(data.template().headers().get("Accept").iterator().next())
332328
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
@@ -386,12 +382,12 @@ public void testProcessAnnotations_NumberFormatParam() throws Exception {
386382
public void testProcessAnnotations_Advanced2() throws Exception {
387383
Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest");
388384
MethodMetadata data = contract
389-
.parseAndValidateMetadata(method.getDeclaringClass(), method);
385+
.parseAndValidateMetadata(method.getDeclaringClass(), method);
390386

391387
assertThat(data.template().url()).isEqualTo("/");
392388
assertThat(data.template().method()).isEqualTo("GET");
393389
assertThat(data.template().headers().get("Accept").iterator().next())
394-
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
390+
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
395391
}
396392

397393
@Test
@@ -498,7 +494,7 @@ public void testProcessAnnotations_Fallback() throws Exception {
498494
.parseAndValidateMetadata(method.getDeclaringClass(), method);
499495

500496
assertThat(data.template().url())
501-
.isEqualTo("/testfallback/{id}?amount=" + "{amount}");
497+
.isEqualTo("/testfallback/{id}?amount=" + "{amount}");
502498
assertThat(data.template().method()).isEqualTo("PUT");
503499
assertThat(data.template().headers().get("Accept").iterator().next())
504500
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
@@ -658,7 +654,7 @@ public interface TestTemplate_Simple {
658654
ResponseEntity<TestObject> getMappingTest(@PathVariable("id") String id);
659655

660656
@RequestMapping(method = RequestMethod.POST,
661-
produces = MediaType.APPLICATION_JSON_VALUE)
657+
produces = MediaType.APPLICATION_JSON_VALUE)
662658
TestObject postTest(@RequestBody TestObject object);
663659

664660
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@@ -671,15 +667,15 @@ public interface TestTemplate_Class_RequestMapping {
671667

672668
@RequestMapping(value = "/test/{testId}", method = RequestMethod.GET)
673669
TestObject getSpecificTest(@PathVariable("classId") String classId,
674-
@PathVariable("testId") String testId);
670+
@PathVariable("testId") String testId);
675671

676672
}
677673

678674
public interface TestTemplate_Class_Annotations {
679675

680676
@RequestMapping(value = "/test/{testId}", method = RequestMethod.GET)
681677
TestObject getSpecificTest(@PathVariable("classId") String classId,
682-
@PathVariable("testId") String testId);
678+
@PathVariable("testId") String testId);
683679

684680
@RequestMapping(method = RequestMethod.GET)
685681
TestObject getAllTests(@PathVariable("classId") String classId);

0 commit comments

Comments
 (0)