-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Behavior of AnnotatedMember.equals()
(#3187)
#3195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cowtowncoder
merged 1 commit into
FasterXML:2.13
from
klaasdellschaft:3187-annotated-member-equals
Jul 3, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/test/java/com/fasterxml/jackson/databind/introspect/AnnotatedMemberEqualityTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.fasterxml.jackson.databind.introspect; | ||
|
||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.DeserializationConfig; | ||
import com.fasterxml.jackson.databind.JavaType; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.json.JsonMapper; | ||
|
||
public class AnnotatedMemberEqualityTest extends BaseMapTest { | ||
|
||
private static class SomeBean { | ||
|
||
private String value; | ||
|
||
public SomeBean(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
} | ||
|
||
public void testAnnotatedConstructorEquality() { | ||
ObjectMapper mapper = new JsonMapper(); | ||
DeserializationConfig context = mapper.getDeserializationConfig(); | ||
JavaType beanType = mapper.constructType(SomeBean.class); | ||
|
||
AnnotatedClass instance1 = AnnotatedClassResolver.resolve(context, beanType, context); | ||
AnnotatedClass instance2 = AnnotatedClassResolver.resolve(context, beanType, context); | ||
|
||
AnnotatedConstructor constructor1 = instance1.getConstructors().get(0); | ||
AnnotatedConstructor constructor2 = instance2.getConstructors().get(0); | ||
|
||
assertEquals(instance1, instance2); | ||
assertEquals(constructor1.getAnnotated(), constructor2.getAnnotated()); | ||
assertEquals(constructor1, constructor2); | ||
assertEquals(constructor1.getParameter(0), constructor2.getParameter(0)); | ||
} | ||
|
||
public void testAnnotatedMethodEquality() { | ||
ObjectMapper mapper = new JsonMapper(); | ||
DeserializationConfig context = mapper.getDeserializationConfig(); | ||
JavaType beanType = mapper.constructType(SomeBean.class); | ||
|
||
AnnotatedClass instance1 = AnnotatedClassResolver.resolve(context, beanType, context); | ||
AnnotatedClass instance2 = AnnotatedClassResolver.resolve(context, beanType, context); | ||
|
||
String methodName = "setValue"; | ||
Class<?>[] paramTypes = {String.class}; | ||
AnnotatedMethod method1 = instance1.findMethod(methodName, paramTypes); | ||
AnnotatedMethod method2 = instance2.findMethod(methodName, paramTypes); | ||
|
||
assertEquals(instance1, instance2); | ||
assertEquals(method1.getAnnotated(), method2.getAnnotated()); | ||
assertEquals(method1, method2); | ||
assertEquals(method1.getParameter(0), method2.getParameter(0)); | ||
} | ||
|
||
public void testAnnotatedFieldEquality() { | ||
ObjectMapper mapper = new JsonMapper(); | ||
DeserializationConfig context = mapper.getDeserializationConfig(); | ||
JavaType beanType = mapper.constructType(SomeBean.class); | ||
|
||
AnnotatedClass instance1 = AnnotatedClassResolver.resolve(context, beanType, context); | ||
AnnotatedClass instance2 = AnnotatedClassResolver.resolve(context, beanType, context); | ||
|
||
AnnotatedField field1 = instance1.fields().iterator().next(); | ||
AnnotatedField field2 = instance2.fields().iterator().next(); | ||
|
||
assertEquals(instance1, instance2); | ||
assertEquals(field1.getAnnotated(), field2.getAnnotated()); | ||
assertEquals(field1, field2); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whops. Sorry about that, thank you for fixing!