-
Notifications
You must be signed in to change notification settings - Fork 728
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
Support state reason for issues #1793
Conversation
Hey @stianst , Yeah, you usually need access to the test org when recording testing as it's easier for them to be reproduced by others when something needs a change. You need @bitwiseman for that. As for the error you have when running the tests, the test runs by default with an HTTP Client that is not compatible with Java 17+. Run them with Java 11 and things should work better. |
Ah, actually, good news, I forgot I had the permission to do that. I added you to the test org. You should have received an invite. @bitwiseman Stian is a colleague from Red Hat leading the Keycloak project. |
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 spotted a few minor issues.
@@ -67,6 +69,9 @@ public class GHIssue extends GHObject implements Reactable { | |||
/** The state. */ | |||
protected String state; | |||
|
|||
/** The state. */ |
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.
This needs an update
* @return the state reason | ||
*/ | ||
public GHIssueStateReason getStateReason() { | ||
return Enum.valueOf(GHIssueStateReason.class, state_reason.toUpperCase(Locale.ENGLISH)); |
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 know you were trying to be consistent with the one above but we have a new way of doing this:
- add an
UNKNOWN
value to your enum - use
EnumUtils.getEnumOrDefault()
(there are plenty of examples in the source code). There is also a method supporting null value, you probably need to check if thestate_reason
can be null... which is probably the case. In this case, you would need to usegetNullableEnumOrDefault
.
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.
Nice, that's much better. Updated to use that.
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2011, Eric Maupin |
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.
This is off. But I'm not sure if we are encouraged to put our name here, these days. @bitwiseman would know.
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.
Looked at a couple recent commits and they don't have any license headers so removed this.
|
||
public enum GHIssueStateReason { | ||
|
||
COMPLETED, NOT_PLANNED |
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.
As previously stated, you can add UNKNOWN
here. This avoids errors when GitHub add a new value.
Ah also, do not record things for all the tests, doing:
will be better. Then you should add the new snapshots to your commit. |
a6ed0f6
to
0c41dd7
Compare
Got the test working eventually (well, okay I only spent 30 min, so this wasn't too bad ;)), but used an org I created for the purpose. Will try with the official org and update the data. |
@gsmet @bitwiseman would it be okay to enable fine-grained personal access tokens for the org (https://github.com/organizations/hub4j-test-org/settings/personal-access-tokens-onboarding). They are a bit nicer than the legacy tokens as you can limit to a specific org/repo. |
0c41dd7
to
4e24b7d
Compare
d911b1e
to
5b3e6d0
Compare
Should be ready to go now |
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 added a very small comment for something that we need to check but otherwise it looks very good.
Note that we will have to wait for @bitwiseman to merge it as I'm not a committer here.
* @return the state reason | ||
*/ | ||
public GHIssueStateReason getStateReason() { | ||
return EnumUtils.getEnumOrDefault(GHIssueStateReason.class, state_reason, GHIssueStateReason.UNKNOWN); |
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.
Are you sure this can't be null? My understanding is that when the issue is not closed, it will be null but I might be mistaken.
If so, please use EnumUtils.getNullableEnumOrDefault()
. I pointed you to it in my previous comment but it might have been a bit confusing as I pointed to this one first.
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.
Updated, I was kinda thinking it should be set to UNKNOWN when null, but obviously null makes more sense ;)
Enabled the fine-grained PATs. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1793 +/- ##
============================================
+ Coverage 80.64% 80.69% +0.04%
- Complexity 2322 2328 +6
============================================
Files 219 220 +1
Lines 7027 7043 +16
Branches 371 371
============================================
+ Hits 5667 5683 +16
Misses 1128 1128
Partials 232 232 ☔ View full report in Codecov by Sentry. |
5b3e6d0
to
599b78c
Compare
Fixed the last issue with using |
@bitwiseman hi, sorry to ping you on this as I'm sure you're busy with other stuff. Just wondering a bit on when/if this could be merged and what the plans are for a new release? I'm a bit blocked on this for some automation for the Keycloak project. |
Hi, first of thanks for providing this library. I'm using it quite a lot, but finding a few things that are missing for my needs, and trying to contribute those, with the first one being supporting closing issues as not planned.
Trying to figure out how to work with the testsuite, but having a few issues.
When running
mvn install -Dtest.github.org=false -Dtest=GHIssueTest
I'm getting the following exception:Another thing is the test is hardwired to
hub4j-test-org
which I don't have access to, so guess I need to use my own repository somehow.Closes #1792