Expose getLabel() for GHEventPayload.Issue

It was exposed on pull requests but not issues.
This commit is contained in:
Guillaume Smet
2021-03-19 13:11:38 +01:00
parent 1f7f646bec
commit b0aea0c575
4 changed files with 396 additions and 2 deletions

View File

@@ -381,9 +381,9 @@ public class GHEventPayload extends GitHubInteractiveObject {
}
/**
* Gets label.
* Gets the added or removed label for labeled/unlabeled events.
*
* @return the label
* @return label the added or removed label
*/
public GHLabel getLabel() {
return label;
@@ -520,6 +520,8 @@ public class GHEventPayload extends GitHubInteractiveObject {
public static class Issue extends GHEventPayload {
private GHIssue issue;
private GHLabel label;
/**
* Gets issue.
*
@@ -539,6 +541,15 @@ public class GHEventPayload extends GitHubInteractiveObject {
this.issue = issue;
}
/**
* Gets the added or removed label for labeled/unlabeled events.
*
* @return label the added or removed label
*/
public GHLabel getLabel() {
return label;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);

View File

@@ -141,6 +141,27 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
assertThat(event.getSender().getLogin(), is("baxterthehacker"));
}
@Test
public void issue_labeled() throws Exception {
GHEventPayload.Issue event = GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Issue.class);
assertThat(event.getAction(), is("labeled"));
assertThat(event.getIssue().getNumber(), is(42));
assertThat(event.getIssue().getTitle(), is("Test GHEventPayload.Issue label/unlabel"));
assertThat(event.getIssue().getLabels().size(), is(1));
assertThat(event.getIssue().getLabels().iterator().next().getName(), is("enhancement"));
assertThat(event.getLabel().getName(), is("enhancement"));
}
@Test
public void issue_unlabeled() throws Exception {
GHEventPayload.Issue event = GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Issue.class);
assertThat(event.getAction(), is("unlabeled"));
assertThat(event.getIssue().getNumber(), is(42));
assertThat(event.getIssue().getTitle(), is("Test GHEventPayload.Issue label/unlabel"));
assertThat(event.getIssue().getLabels().size(), is(0));
assertThat(event.getLabel().getName(), is("enhancement"));
}
// TODO implement support classes and write test
// @Test
// public void label() throws Exception {}

View File

@@ -0,0 +1,186 @@
{
"action": "labeled",
"issue": {
"url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/42",
"repository_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground",
"labels_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/42/labels{/name}",
"comments_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/42/comments",
"events_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/42/events",
"html_url": "https://github.com/gsmet/quarkus-bot-java-playground/issues/42",
"id": 835908684,
"node_id": "MDU6SXNzdWU4MzU5MDg2ODQ=",
"number": 42,
"title": "Test GHEventPayload.Issue label/unlabel",
"user": {
"login": "gsmet",
"id": 1279749,
"node_id": "MDQ6VXNlcjEyNzk3NDk=",
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gsmet",
"html_url": "https://github.com/gsmet",
"followers_url": "https://api.github.com/users/gsmet/followers",
"following_url": "https://api.github.com/users/gsmet/following{/other_user}",
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
"organizations_url": "https://api.github.com/users/gsmet/orgs",
"repos_url": "https://api.github.com/users/gsmet/repos",
"events_url": "https://api.github.com/users/gsmet/events{/privacy}",
"received_events_url": "https://api.github.com/users/gsmet/received_events",
"type": "User",
"site_admin": false
},
"labels": [
{
"id": 2510333772,
"node_id": "MDU6TGFiZWwyNTEwMzMzNzcy",
"url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/labels/enhancement",
"name": "enhancement",
"color": "a2eeef",
"default": true,
"description": "New feature or request"
}
],
"state": "open",
"locked": false,
"assignee": null,
"assignees": [],
"milestone": null,
"comments": 0,
"created_at": "2021-03-19T12:02:09Z",
"updated_at": "2021-03-19T12:02:31Z",
"closed_at": null,
"author_association": "OWNER",
"active_lock_reason": null,
"body": "",
"performed_via_github_app": null
},
"label": {
"id": 2510333772,
"node_id": "MDU6TGFiZWwyNTEwMzMzNzcy",
"url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/labels/enhancement",
"name": "enhancement",
"color": "a2eeef",
"default": true,
"description": "New feature or request"
},
"repository": {
"id": 313384129,
"node_id": "MDEwOlJlcG9zaXRvcnkzMTMzODQxMjk=",
"name": "quarkus-bot-java-playground",
"full_name": "gsmet/quarkus-bot-java-playground",
"private": true,
"owner": {
"login": "gsmet",
"id": 1279749,
"node_id": "MDQ6VXNlcjEyNzk3NDk=",
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gsmet",
"html_url": "https://github.com/gsmet",
"followers_url": "https://api.github.com/users/gsmet/followers",
"following_url": "https://api.github.com/users/gsmet/following{/other_user}",
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
"organizations_url": "https://api.github.com/users/gsmet/orgs",
"repos_url": "https://api.github.com/users/gsmet/repos",
"events_url": "https://api.github.com/users/gsmet/events{/privacy}",
"received_events_url": "https://api.github.com/users/gsmet/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/gsmet/quarkus-bot-java-playground",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground",
"forks_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/forks",
"keys_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/teams",
"hooks_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/hooks",
"issue_events_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/events{/number}",
"events_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/events",
"assignees_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/assignees{/user}",
"branches_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/branches{/branch}",
"tags_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/tags",
"blobs_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/statuses/{sha}",
"languages_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/languages",
"stargazers_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/stargazers",
"contributors_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/contributors",
"subscribers_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/subscribers",
"subscription_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/subscription",
"commits_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/contents/{+path}",
"compare_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/merges",
"archive_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/downloads",
"issues_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues{/number}",
"pulls_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/pulls{/number}",
"milestones_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/milestones{/number}",
"notifications_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/labels{/name}",
"releases_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/releases{/id}",
"deployments_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/deployments",
"created_at": "2020-11-16T17:55:53Z",
"updated_at": "2020-12-01T08:39:07Z",
"pushed_at": "2020-12-01T08:39:05Z",
"git_url": "git://github.com/gsmet/quarkus-bot-java-playground.git",
"ssh_url": "git@github.com:gsmet/quarkus-bot-java-playground.git",
"clone_url": "https://github.com/gsmet/quarkus-bot-java-playground.git",
"svn_url": "https://github.com/gsmet/quarkus-bot-java-playground",
"homepage": null,
"size": 13,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 1,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 14,
"license": null,
"forks": 1,
"open_issues": 14,
"watchers": 0,
"default_branch": "main"
},
"sender": {
"login": "gsmet",
"id": 1279749,
"node_id": "MDQ6VXNlcjEyNzk3NDk=",
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gsmet",
"html_url": "https://github.com/gsmet",
"followers_url": "https://api.github.com/users/gsmet/followers",
"following_url": "https://api.github.com/users/gsmet/following{/other_user}",
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
"organizations_url": "https://api.github.com/users/gsmet/orgs",
"repos_url": "https://api.github.com/users/gsmet/repos",
"events_url": "https://api.github.com/users/gsmet/events{/privacy}",
"received_events_url": "https://api.github.com/users/gsmet/received_events",
"type": "User",
"site_admin": false
},
"installation": {
"id": 13005535,
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMTMwMDU1MzU="
}
}

View File

@@ -0,0 +1,176 @@
{
"action": "unlabeled",
"issue": {
"url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/42",
"repository_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground",
"labels_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/42/labels{/name}",
"comments_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/42/comments",
"events_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/42/events",
"html_url": "https://github.com/gsmet/quarkus-bot-java-playground/issues/42",
"id": 835908684,
"node_id": "MDU6SXNzdWU4MzU5MDg2ODQ=",
"number": 42,
"title": "Test GHEventPayload.Issue label/unlabel",
"user": {
"login": "gsmet",
"id": 1279749,
"node_id": "MDQ6VXNlcjEyNzk3NDk=",
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gsmet",
"html_url": "https://github.com/gsmet",
"followers_url": "https://api.github.com/users/gsmet/followers",
"following_url": "https://api.github.com/users/gsmet/following{/other_user}",
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
"organizations_url": "https://api.github.com/users/gsmet/orgs",
"repos_url": "https://api.github.com/users/gsmet/repos",
"events_url": "https://api.github.com/users/gsmet/events{/privacy}",
"received_events_url": "https://api.github.com/users/gsmet/received_events",
"type": "User",
"site_admin": false
},
"labels": [],
"state": "open",
"locked": false,
"assignee": null,
"assignees": [],
"milestone": null,
"comments": 0,
"created_at": "2021-03-19T12:02:09Z",
"updated_at": "2021-03-19T12:02:43Z",
"closed_at": null,
"author_association": "OWNER",
"active_lock_reason": null,
"body": "",
"performed_via_github_app": null
},
"label": {
"id": 2510333772,
"node_id": "MDU6TGFiZWwyNTEwMzMzNzcy",
"url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/labels/enhancement",
"name": "enhancement",
"color": "a2eeef",
"default": true,
"description": "New feature or request"
},
"repository": {
"id": 313384129,
"node_id": "MDEwOlJlcG9zaXRvcnkzMTMzODQxMjk=",
"name": "quarkus-bot-java-playground",
"full_name": "gsmet/quarkus-bot-java-playground",
"private": true,
"owner": {
"login": "gsmet",
"id": 1279749,
"node_id": "MDQ6VXNlcjEyNzk3NDk=",
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gsmet",
"html_url": "https://github.com/gsmet",
"followers_url": "https://api.github.com/users/gsmet/followers",
"following_url": "https://api.github.com/users/gsmet/following{/other_user}",
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
"organizations_url": "https://api.github.com/users/gsmet/orgs",
"repos_url": "https://api.github.com/users/gsmet/repos",
"events_url": "https://api.github.com/users/gsmet/events{/privacy}",
"received_events_url": "https://api.github.com/users/gsmet/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/gsmet/quarkus-bot-java-playground",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground",
"forks_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/forks",
"keys_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/teams",
"hooks_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/hooks",
"issue_events_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/events{/number}",
"events_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/events",
"assignees_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/assignees{/user}",
"branches_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/branches{/branch}",
"tags_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/tags",
"blobs_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/statuses/{sha}",
"languages_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/languages",
"stargazers_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/stargazers",
"contributors_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/contributors",
"subscribers_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/subscribers",
"subscription_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/subscription",
"commits_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/contents/{+path}",
"compare_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/merges",
"archive_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/downloads",
"issues_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/issues{/number}",
"pulls_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/pulls{/number}",
"milestones_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/milestones{/number}",
"notifications_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/labels{/name}",
"releases_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/releases{/id}",
"deployments_url": "https://api.github.com/repos/gsmet/quarkus-bot-java-playground/deployments",
"created_at": "2020-11-16T17:55:53Z",
"updated_at": "2020-12-01T08:39:07Z",
"pushed_at": "2020-12-01T08:39:05Z",
"git_url": "git://github.com/gsmet/quarkus-bot-java-playground.git",
"ssh_url": "git@github.com:gsmet/quarkus-bot-java-playground.git",
"clone_url": "https://github.com/gsmet/quarkus-bot-java-playground.git",
"svn_url": "https://github.com/gsmet/quarkus-bot-java-playground",
"homepage": null,
"size": 13,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 1,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 14,
"license": null,
"forks": 1,
"open_issues": 14,
"watchers": 0,
"default_branch": "main"
},
"sender": {
"login": "gsmet",
"id": 1279749,
"node_id": "MDQ6VXNlcjEyNzk3NDk=",
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gsmet",
"html_url": "https://github.com/gsmet",
"followers_url": "https://api.github.com/users/gsmet/followers",
"following_url": "https://api.github.com/users/gsmet/following{/other_user}",
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
"organizations_url": "https://api.github.com/users/gsmet/orgs",
"repos_url": "https://api.github.com/users/gsmet/repos",
"events_url": "https://api.github.com/users/gsmet/events{/privacy}",
"received_events_url": "https://api.github.com/users/gsmet/received_events",
"type": "User",
"site_admin": false
},
"installation": {
"id": 13005535,
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMTMwMDU1MzU="
}
}