-
Notifications
You must be signed in to change notification settings - Fork 2k
Introduce RestHandler.Wrapper to help with delegate implementations #1004
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
Conversation
✅ DCO Check Passed 2e686413840026ac523175b51c26365d6f2c93eb |
✅ Gradle Wrapper Validation success 2e686413840026ac523175b51c26365d6f2c93eb |
✅ Gradle Precommit success 2e686413840026ac523175b51c26365d6f2c93eb |
✅ DCO Check Passed 4da9029898bd32766b437e4ac0143305998288a3 |
✅ Gradle Wrapper Validation success 4da9029898bd32766b437e4ac0143305998288a3 |
✅ Gradle Precommit success 4da9029898bd32766b437e4ac0143305998288a3 |
Is there a specific use case you would like to use this wrapper for? |
The current use case is outside of OpenSearch repo in the security plugin that returns not null @nknize @dblock @CEHENKLE please comment on https://github.com/opensearch-project/security/issues/1307#issuecomment-886155806. |
Great:) However, if external plugins are to rely on this code then i think it should be protected by a test. |
Please suggest what test should be implemented? As there is no new functionality there is no test. This is plain delegate pattern. Also, there is no test for |
Good question! I don't think every commit has to have a test accompanying it, however, this is code you say you require for plugins to work - without coverage how can you guarantee that this is not going to break plugins relying on it in the future?
This is really up to you, maybe implement an example plugin test case (if there isn't one already) that uses this code? |
There is no (unit) test for
This is beyond the scope of the current PR, but agree that it will be good to test |
start gradle check |
✅ Gradle Check success 4da9029898bd32766b437e4ac0143305998288a3 |
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.
I think this need a test that shows how this is used, at least. For starters, the wrapper constructor now raises an error when the delegate is null
, could be a test. Methods that call delegate.
could be invoked. Missing tests for BaseRestHandler
should be added, just because they weren't added earlier doesn't mean you shouldn't try - since you're touching this code, make some effort to catch up what's missing please so we can leave things in a better state than they were.
Signed-off-by: Vlad Rozov <[email protected]>
✅ Gradle Wrapper Validation success 0990085 |
✅ DCO Check Passed 0990085 |
✅ Gradle Precommit success 0990085 |
A test case that shows how I can remove changes to |
@VachaShah another instance of Link Checker failure. |
I don't want to argue. My personal take is that when I write any code, I write tests that at least call that code so I can catch my own dumb mistakes like typo-ing |
start gradle check |
@dblock I mostly did not write that code. I used IDE (IntelliJ) to generate it.
unit test does not prevent this issue. Somebody can remove unit test as well, assuming that both code and unit test are not needed. My bigger concern is that somebody will add new method to an interface without adding it to delegate. IMO, it will be better to revisit all wrappers and see which one don't have unit test and introduce a generic helper class that can validate proper delegation pattern. |
…1004) (#1031) Signed-off-by: Vlad Rozov <[email protected]>
Description
Wrapper class that implements delegate pattern for
RestHandler
Issues Resolved
None, this is java utility class that can be utilized by OpenSearch core and OpenSearch plugins
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.