Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
b619ee00
Unverified
Commit
b619ee00
authored
Jan 03, 2017
by
Ondřej Božek
Committed by
Spencer Gibb
Jan 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds composed @RequestMapping annotations support
Fixed short circuit condition to correctly detect @RequestMapping shortcuts (@GetMapping, @PostMaping etc.) Fixes gh-1201
parent
899d8bc2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
SpringMvcContract.java
...mework/cloud/netflix/feign/support/SpringMvcContract.java
+2
-1
SpringMvcContractTests.java
...k/cloud/netflix/feign/support/SpringMvcContractTests.java
+37
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/SpringMvcContract.java
View file @
b619ee00
...
@@ -156,7 +156,8 @@ public class SpringMvcContract extends Contract.BaseContract
...
@@ -156,7 +156,8 @@ public class SpringMvcContract extends Contract.BaseContract
@Override
@Override
protected
void
processAnnotationOnMethod
(
MethodMetadata
data
,
protected
void
processAnnotationOnMethod
(
MethodMetadata
data
,
Annotation
methodAnnotation
,
Method
method
)
{
Annotation
methodAnnotation
,
Method
method
)
{
if
(!(
methodAnnotation
instanceof
RequestMapping
))
{
if
(!
RequestMapping
.
class
.
isInstance
(
methodAnnotation
)
&&
!
methodAnnotation
.
annotationType
().
isAnnotationPresent
(
RequestMapping
.
class
))
{
return
;
return
;
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/support/SpringMvcContractTests.java
View file @
b619ee00
...
@@ -48,6 +48,8 @@ import feign.MethodMetadata;
...
@@ -48,6 +48,8 @@ import feign.MethodMetadata;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
lombok.ToString
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
/**
/**
* @author chadjaros
* @author chadjaros
...
@@ -102,6 +104,21 @@ public class SpringMvcContractTests {
...
@@ -102,6 +104,21 @@ public class SpringMvcContractTests {
}
}
@Test
@Test
public
void
testProcessAnnotations_SimpleGetMapping
()
throws
Exception
{
Method
method
=
TestTemplate_Simple
.
class
.
getDeclaredMethod
(
"getMappingTest"
,
String
.
class
);
MethodMetadata
data
=
this
.
contract
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
assertEquals
(
"/test/{id}"
,
data
.
template
().
url
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
assertEquals
(
"id"
,
data
.
indexToName
().
get
(
0
).
iterator
().
next
());
}
@Test
public
void
testProcessAnnotations_Class_AnnotationsGetSpecificTest
()
public
void
testProcessAnnotations_Class_AnnotationsGetSpecificTest
()
throws
Exception
{
throws
Exception
{
Method
method
=
TestTemplate_Class_Annotations
.
class
Method
method
=
TestTemplate_Class_Annotations
.
class
...
@@ -163,6 +180,20 @@ public class SpringMvcContractTests {
...
@@ -163,6 +180,20 @@ public class SpringMvcContractTests {
}
}
@Test
@Test
public
void
testProcessAnnotations_SimplePostMapping
()
throws
Exception
{
Method
method
=
TestTemplate_Simple
.
class
.
getDeclaredMethod
(
"postMappingTest"
,
TestObject
.
class
);
MethodMetadata
data
=
this
.
contract
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
assertEquals
(
""
,
data
.
template
().
url
());
assertEquals
(
"POST"
,
data
.
template
().
method
());
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
}
@Test
public
void
testProcessAnnotationsOnMethod_Advanced
()
throws
Exception
{
public
void
testProcessAnnotationsOnMethod_Advanced
()
throws
Exception
{
Method
method
=
TestTemplate_Advanced
.
class
.
getDeclaredMethod
(
"getTest"
,
Method
method
=
TestTemplate_Advanced
.
class
.
getDeclaredMethod
(
"getTest"
,
String
.
class
,
String
.
class
,
Integer
.
class
);
String
.
class
,
String
.
class
,
Integer
.
class
);
...
@@ -392,8 +423,14 @@ public class SpringMvcContractTests {
...
@@ -392,8 +423,14 @@ public class SpringMvcContractTests {
@RequestMapping
(
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
TestObject
getTest
();
TestObject
getTest
();
@GetMapping
(
value
=
"/test/{id}"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
ResponseEntity
<
TestObject
>
getMappingTest
(
@PathVariable
(
"id"
)
String
id
);
@RequestMapping
(
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
TestObject
postTest
(
@RequestBody
TestObject
object
);
TestObject
postTest
(
@RequestBody
TestObject
object
);
@PostMapping
(
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
TestObject
postMappingTest
(
@RequestBody
TestObject
object
);
}
}
@RequestMapping
(
"/prepend/{classId}"
)
@RequestMapping
(
"/prepend/{classId}"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment