Fix for #2352 - Generic Comparable Stubs/Mocks ==#2353
Conversation
They should come out as unequal like different Stubs/Mocks for a non Comparable class would. Extends the work for spockframework#1322 to handle Generics. Does this by considering any method named compareTo with a single argument that is a Comprable to be a Comparable.compareTo method.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughEnhanced mock argument matching to recognize ChangesGeneric Comparable Argument Matching
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
AndreasTu
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
I have some small changes.
| return () -> Integer.compare(System.identityHashCode(invocation.getMockObject().getInstance()), System.identityHashCode(invocation.getArguments().get(0))); | ||
| } | ||
|
|
||
| private Set<Class<?>> getInterfacesFromClass(Class<?> clazz) { |
There was a problem hiding this comment.
This helper method should probably be moved into org.spockframework.util.ReflectionUtil and please add one of two tests for the util method to ReflectionUtilSpec
| @@ -1,5 +1,7 @@ | |||
| package org.spockframework.mock; | |||
|
|
|||
| import java.util.HashSet; | |||
There was a problem hiding this comment.
Please add a line to the release notes in docs/release_notes.adoc for version 2.5 section Misc.
| @@ -0,0 +1,16 @@ | |||
| package org.spockframework.smoke.mock; | |||
|
|
|||
| import org.jetbrains.annotations.NotNull; | |||
There was a problem hiding this comment.
We do not use the jetbrains nullable annotations.
We only use the internal org.spockframework.util.Nullable everything else in NonNull per conventions.
So please remove.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2353 +/- ##
============================================
+ Coverage 82.16% 82.17% +0.01%
- Complexity 4825 4832 +7
============================================
Files 472 472
Lines 15040 15049 +9
Branches 1908 1912 +4
============================================
+ Hits 12357 12366 +9
Misses 1991 1991
Partials 692 692
🚀 New features to boost your workflow:
|
They should come out as unequal like different Stubs/Mocks for a non Comparable class would. Extends the work for #1322 to handle Generics. Does this by considering any method named compareTo with a single argument that is a Comprable to be a Comparable.compareTo method.
Summary by CodeRabbit
Bug Fixes
Comparableimplementations alongside standardComparabletypes, improving compatibility with parameterized comparable classes.Tests