Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/main/java/org/kohsuke/github/GHIssueEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class GHIssueEvent extends GitHubInteractiveObject {
private GHLabel label;
private GHUser assignee;
private GHIssueRename rename;
private GHUser reviewRequester;
private GHUser requestedReviewer;

private GHIssue issue;

Expand Down Expand Up @@ -155,6 +157,38 @@ public GHIssueRename getRename() {
return this.rename;
}

/**
*
* Get the {@link GHUser} person who requested a review. Only present for events "review_requested",
* "review_request_removed", <code>null</code> otherwise.
*
* @return the GHUser
*
* @see <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/events/issue-event-types#review_requested">review_requested</a>
* and <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/events/issue-event-types#review_request_removed">review_request_removed</a>
*/
public GHUser getReviewRequester() {
return this.reviewRequester;
}

/**
*
* Get the {@link GHUser} person requested to review the pull request. Only present for events "review_requested",
* "review_request_removed", <code>null</code> otherwise.
*
* @return the GHUser
*
* @see <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/events/issue-event-types#review_requested">review_requested</a>
* and <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/events/issue-event-types#review_request_removed">review_request_removed</a>
*/
public GHUser getRequestedReviewer() {
return this.requestedReviewer;
}

GHIssueEvent wrapUp(GitHub root) {
this.root = root;
return this;
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/org/kohsuke/github/GHIssueEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static org.hamcrest.Matchers.*;
Expand Down Expand Up @@ -39,6 +40,31 @@ public void testEventsForSingleIssue() throws Exception {
issue.close();
}

@Test
public void testIssueReviewRequestedEvent() throws Exception {
// Create the PR.
final GHPullRequest pullRequest = getRepository()
.createPullRequest("ReviewRequestedEventTest", "test/stable", "main", "## test");

final ArrayList<GHUser> reviewers = new ArrayList<>();
reviewers.add(gitHub.getUser("bitwiseman"));
// Generate review_requested event.
pullRequest.requestReviewers(reviewers);

// Test that the event is present.
final List<GHIssueEvent> list = pullRequest.listEvents().toList();
assertThat(list.size(), equalTo(1));
final GHIssueEvent event = list.get(0);
assertThat(event.getEvent(), equalTo("review_requested"));
assertThat(event.getReviewRequester(), notNullValue());
assertThat(event.getReviewRequester().getLogin(), equalTo("t0m4uk1991"));
assertThat(event.getRequestedReviewer(), notNullValue());
assertThat(event.getRequestedReviewer().getLogin(), equalTo("bitwiseman"));

// Close the PR.
pullRequest.close();
}

@Test
public void testEventsForIssueRename() throws Exception {
// Create the issue.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"url": "https://api.github.com/orgs/hub4j-test-org",
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
"description": "Hub4j Test Org Description (this could be null or blank too)",
"name": "Hub4j Test Org Name (this could be null or blank too)",
"company": null,
"blog": "https://hub4j.url.io/could/be/null",
"location": "Hub4j Test Org Location (this could be null or blank too)",
"email": "hub4jtestorgemail@could.be.null.com",
"twitter_username": null,
"is_verified": false,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 19,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/hub4j-test-org",
"created_at": "2014-05-10T19:39:11Z",
"updated_at": "2020-06-04T05:56:10Z",
"type": "Organization",
"total_private_repos": 2,
"owned_private_repos": 2,
"private_gists": 0,
"disk_usage": 11979,
"collaborators": 0,
"billing_email": "kk@kohsuke.org",
"default_repository_permission": "none",
"members_can_create_repositories": false,
"two_factor_requirement_enabled": false,
"members_can_create_pages": true,
"members_can_create_public_pages": true,
"members_can_create_private_pages": true,
"plan": {
"name": "free",
"space": 976562499,
"private_repos": 10000,
"filled_seats": 26,
"seats": 3
}
}
Loading