Skip to content

Commit

Permalink
Merge pull request #1464 from gsmet/star-payload
Browse files Browse the repository at this point in the history
Add support for star event payload
  • Loading branch information
bitwiseman committed Jun 1, 2022
2 parents 0257ebb + 7218664 commit 4e103a6
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/org/kohsuke/github/GHEventPayload.java
Expand Up @@ -1572,4 +1572,25 @@ public GHLabel getLabel() {
return label;
}
}

/**
* A star was created or deleted on a repository.
*
* @see <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#star">star
* event</a>
*/
public static class Star extends GHEventPayload {

private String starredAt;

/**
* Gets the date when the star is added. Is null when the star is deleted.
*
* @return the date when the star is added
*/
public Date getStarredAt() {
return GitHubClient.parseDate(starredAt);
}
}
}
11 changes: 11 additions & 0 deletions src/test/java/org/kohsuke/github/GHEventPayloadTest.java
Expand Up @@ -1097,4 +1097,15 @@ public void discussion_labeled() throws Exception {
assertThat(label.isDefault(), is(false));
assertThat(label.getDescription(), is(nullValue()));
}

@Test
public void starred() throws Exception {
final GHEventPayload.Star starPayload = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.Star.class);

assertThat(starPayload.getAction(), is("created"));
assertThat(starPayload.getRepository().getFullName(), is("gsmet/quarkus-bot-java-playground"));
assertThat(starPayload.getSender().getLogin(), is("gsmet"));
assertThat(starPayload.getStarredAt().getTime(), is(1654017876000L));
}
}
126 changes: 126 additions & 0 deletions src/test/resources/org/kohsuke/github/GHEventPayloadTest/starred.json
@@ -0,0 +1,126 @@
{
"action": "created",
"starred_at": "2022-05-31T17:24:36Z",
"repository": {
"id": 313384129,
"node_id": "MDEwOlJlcG9zaXRvcnkzMTMzODQxMjk=",
"name": "quarkus-bot-java-playground",
"full_name": "gsmet/quarkus-bot-java-playground",
"private": false,
"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": "2022-05-31T17:24:36Z",
"pushed_at": "2022-05-30T10:55:11Z",
"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": 89,
"stargazers_count": 1,
"watchers_count": 1,
"language": "Java",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 2,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 36,
"license": null,
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 2,
"open_issues": 36,
"watchers": 1,
"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="
}
}

0 comments on commit 4e103a6

Please sign in to comment.