Repository: hub4j/github-api
Pull request #1372 (2022-02-08 08:41:12)

Adding Star/Unstar Methods
# Description

This PR adds star/unstar a repository for an authenticated user.

Fixes : #1354 

# Before submitting a PR:

- [x] Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, [CONTRIBUTING.md](CONTRIBUTING.md) for details.
- [x] Add JavaDocs and other comments as appropriate. Consider including links in comments to relevant documentation on https://docs.github.com/en/rest .  
- [x] Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
- [x] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
- [x] Push your changes to a branch other than `main`. You will create your PR from that branch.

# When creating a PR: 

- [x] Fill in the "Description" above with clear summary of the changes. This includes:
  - [x] If this PR fixes one or more issues, include "Fixes #<issue number>" lines for each issue. 
  - [x] Provide links to relevant documentation on https://docs.github.com/en/rest where possible.
- [x] All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."
- [x] Enable "Allow edits from maintainers".



Patch:
diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java
index 4e41822eb..da6658fee 100644
--- a/src/main/java/org/kohsuke/github/GHRepository.java
+++ b/src/main/java/org/kohsuke/github/GHRepository.java
@@ -3514,6 +3514,26 @@ public class GHRepository extends GHObject {
         }
     }
 
+    /**
+     * Star a repository.
+     *
+     * @throws IOException
+     *             the io exception
+     */
+    public void star() throws IOException {
+        root().createRequest().method("PUT").withUrlPath(String.format("/user/starred/%s", full_name)).send();
+    }
+
+    /**
+     * Unstar a repository.
+     *
+     * @throws IOException
+     *             the io exception
+     */
+    public void unstar() throws IOException {
+        root().createRequest().method("DELETE").withUrlPath(String.format("/user/starred/%s", full_name)).send();
+    }
+
     /**
      * A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request.
      *


Test patch:
diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java
index 4d923e354..14c0919dc 100644
--- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java
+++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java
@@ -1563,4 +1563,22 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
         GHRepository repo = getTempRepository();
         repo.createSecret("secret", "encrypted", "public");
     }
+
+    /**
+     * Test to check star method by verifying stargarzer count.
+     *
+     * @throws Exception
+     *             the exception
+     */
+    @Test
+    public void starTest() throws Exception {
+        String owner = "hub4j-test-org";
+        GHRepository repository = getRepository();
+        assertThat(repository.getOwner().getLogin(), equalTo(owner));
+        assertThat(repository.getStargazersCount(), is(0));
+        repository.star();
+        assertThat(repository.listStargazers2().toList().size(), is(1));
+        repository.unstar();
+        assertThat(repository.listStargazers().toList().size(), is(0));
+    }
 }
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/orgs_hub4j-test-org.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/orgs_hub4j-test-org.json
new file mode 100644
index 000000000..54173e5a1
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/orgs_hub4j-test-org.json
@@ -0,0 +1,41 @@
+{
+  "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://avatars3.githubusercontent.com/u/7544739?v=4",
+  "description": null,
+  "is_verified": false,
+  "has_organization_projects": true,
+  "has_repository_projects": true,
+  "public_repos": 9,
+  "public_gists": 0,
+  "followers": 0,
+  "following": 0,
+  "html_url": "https://github.com/hub4j-test-org",
+  "created_at": "2014-05-10T19:39:11Z",
+  "updated_at": "2015-04-20T00:42:30Z",
+  "type": "Organization",
+  "total_private_repos": 0,
+  "owned_private_repos": 0,
+  "private_gists": 0,
+  "disk_usage": 132,
+  "collaborators": 0,
+  "billing_email": "kk@kohsuke.org",
+  "default_repository_permission": "none",
+  "members_can_create_repositories": false,
+  "two_factor_requirement_enabled": false,
+  "plan": {
+    "name": "free",
+    "space": 976562499,
+    "private_repos": 0,
+    "filled_seats": 10,
+    "seats": 0
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/repos_hub4j-test-org_github-api-starred-users.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/repos_hub4j-test-org_github-api-starred-users.json
new file mode 100644
index 000000000..1155b5f6c
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/repos_hub4j-test-org_github-api-starred-users.json
@@ -0,0 +1,25 @@
+[
+  {
+    "starred_at": "2010-04-19T04:13:03Z",
+    "user": {
+      "login": "hub4j-test-org",
+      "id": 9799,
+      "node_id": "MDQ6VXNlcjk3OTk=",
+      "avatar_url": "https://avatars.githubusercontent.com/u/9799?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j-test-org",
+      "html_url": "https://github.com/hub4j-test-org",
+      "followers_url": "https://api.github.com/users/hub4j-test-org/followers",
+      "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
+      "repos_url": "https://api.github.com/users/hub4j-test-org/repos",
+      "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
+      "type": "User",
+      "site_admin": false
+    }
+  }
+]
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/repos_hub4j-test-org_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/repos_hub4j-test-org_github-api.json
new file mode 100644
index 000000000..312a26362
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/repos_hub4j-test-org_github-api.json
@@ -0,0 +1,330 @@
+{
+  "id": 206888201,
+  "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=",
+  "name": "github-api",
+  "full_name": "hub4j-test-org/github-api",
+  "private": false,
+  "owner": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/hub4j-test-org",
+    "html_url": "https://github.com/hub4j-test-org",
+    "followers_url": "https://api.github.com/users/hub4j-test-org/followers",
+    "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
+    "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
+    "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
+    "repos_url": "https://api.github.com/users/hub4j-test-org/repos",
+    "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
+    "type": "Organization",
+    "site_admin": false
+  },
+  "html_url": "https://github.com/hub4j-test-org/github-api",
+  "description": "Resetting",
+  "fork": true,
+  "url": "https://api.github.com/repos/hub4j-test-org/github-api",
+  "forks_url": "https://api.github.com/repos/hub4j-test-org/github-api/forks",
+  "keys_url": "https://api.github.com/repos/hub4j-test-org/github-api/keys{/key_id}",
+  "collaborators_url": "https://api.github.com/repos/hub4j-test-org/github-api/collaborators{/collaborator}",
+  "teams_url": "https://api.github.com/repos/hub4j-test-org/github-api/teams",
+  "hooks_url": "https://api.github.com/repos/hub4j-test-org/github-api/hooks",
+  "issue_events_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/events{/number}",
+  "events_url": "https://api.github.com/repos/hub4j-test-org/github-api/events",
+  "assignees_url": "https://api.github.com/repos/hub4j-test-org/github-api/assignees{/user}",
+  "branches_url": "https://api.github.com/repos/hub4j-test-org/github-api/branches{/branch}",
+  "tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/tags",
+  "blobs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/blobs{/sha}",
+  "git_tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/tags{/sha}",
+  "git_refs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/refs{/sha}",
+  "trees_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/trees{/sha}",
+  "statuses_url": "https://api.github.com/repos/hub4j-test-org/github-api/statuses/{sha}",
+  "languages_url": "https://api.github.com/repos/hub4j-test-org/github-api/languages",
+  "stargazers_url": "https://api.github.com/repos/hub4j-test-org/github-api/stargazers",
+  "contributors_url": "https://api.github.com/repos/hub4j-test-org/github-api/contributors",
+  "subscribers_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscribers",
+  "subscription_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscription",
+  "commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/commits{/sha}",
+  "git_commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/commits{/sha}",
+  "comments_url": "https://api.github.com/repos/hub4j-test-org/github-api/comments{/number}",
+  "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/comments{/number}",
+  "contents_url": "https://api.github.com/repos/hub4j-test-org/github-api/contents/{+path}",
+  "compare_url": "https://api.github.com/repos/hub4j-test-org/github-api/compare/{base}...{head}",
+  "merges_url": "https://api.github.com/repos/hub4j-test-org/github-api/merges",
+  "archive_url": "https://api.github.com/repos/hub4j-test-org/github-api/{archive_format}{/ref}",
+  "downloads_url": "https://api.github.com/repos/hub4j-test-org/github-api/downloads",
+  "issues_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues{/number}",
+  "pulls_url": "https://api.github.com/repos/hub4j-test-org/github-api/pulls{/number}",
+  "milestones_url": "https://api.github.com/repos/hub4j-test-org/github-api/milestones{/number}",
+  "notifications_url": "https://api.github.com/repos/hub4j-test-org/github-api/notifications{?since,all,participating}",
+  "labels_url": "https://api.github.com/repos/hub4j-test-org/github-api/labels{/name}",
+  "releases_url": "https://api.github.com/repos/hub4j-test-org/github-api/releases{/id}",
+  "deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api/deployments",
+  "created_at": "2019-09-06T23:26:04Z",
+  "updated_at": "2019-11-07T22:27:11Z",
+  "pushed_at": "2019-10-21T22:34:49Z",
+  "git_url": "git://github.com/hub4j-test-org/github-api.git",
+  "ssh_url": "git@github.com:hub4j-test-org/github-api.git",
+  "clone_url": "https://github.com/hub4j-test-org/github-api.git",
+  "svn_url": "https://github.com/hub4j-test-org/github-api",
+  "homepage": "http://github-api.kohsuke.org/",
+  "size": 11391,
+  "stargazers_count": 0,
+  "watchers_count": 0,
+  "language": "Java",
+  "has_issues": true,
+  "has_projects": true,
+  "has_downloads": true,
+  "has_wiki": true,
+  "has_pages": false,
+  "forks_count": 0,
+  "mirror_url": null,
+  "archived": false,
+  "disabled": false,
+  "open_issues_count": 0,
+  "license": {
+    "key": "mit",
+    "name": "MIT License",
+    "spdx_id": "MIT",
+    "url": "https://api.github.com/licenses/mit",
+    "node_id": "MDc6TGljZW5zZTEz"
+  },
+  "forks": 0,
+  "open_issues": 0,
+  "watchers": 0,
+  "default_branch": "main",
+  "permissions": {
+    "admin": true,
+    "push": true,
+    "pull": true
+  },
+  "allow_squash_merge": true,
+  "allow_merge_commit": true,
+  "allow_rebase_merge": true,
+  "organization": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/hub4j-test-org",
+    "html_url": "https://github.com/hub4j-test-org",
+    "followers_url": "https://api.github.com/users/hub4j-test-org/followers",
+    "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
+    "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
+    "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
+    "repos_url": "https://api.github.com/users/hub4j-test-org/repos",
+    "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
+    "type": "Organization",
+    "site_admin": false
+  },
+  "parent": {
+    "id": 617210,
+    "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
+    "name": "github-api",
+    "full_name": "hub4j/github-api",
+    "private": false,
+    "owner": {
+      "login": "hub4j",
+      "id": 54909825,
+      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j",
+      "html_url": "https://github.com/hub4j",
+      "followers_url": "https://api.github.com/users/hub4j/followers",
+      "following_url": "https://api.github.com/users/hub4j/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j/orgs",
+      "repos_url": "https://api.github.com/users/hub4j/repos",
+      "events_url": "https://api.github.com/users/hub4j/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j/received_events",
+      "type": "Organization",
+      "site_admin": false
+    },
+    "html_url": "https://github.com/hub4j/github-api",
+    "description": "Java API for GitHub",
+    "fork": false,
+    "url": "https://api.github.com/repos/hub4j/github-api",
+    "forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
+    "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
+    "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
+    "teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
+    "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
+    "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
+    "events_url": "https://api.github.com/repos/hub4j/github-api/events",
+    "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
+    "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
+    "tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
+    "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
+    "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
+    "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
+    "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
+    "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
+    "languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
+    "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
+    "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
+    "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
+    "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
+    "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
+    "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
+    "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
+    "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
+    "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
+    "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
+    "merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
+    "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
+    "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
+    "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
+    "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
+    "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
+    "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
+    "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
+    "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
+    "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
+    "created_at": "2010-04-19T04:13:03Z",
+    "updated_at": "2019-12-04T10:56:12Z",
+    "pushed_at": "2019-12-04T14:15:10Z",
+    "git_url": "git://github.com/hub4j/github-api.git",
+    "ssh_url": "git@github.com:hub4j/github-api.git",
+    "clone_url": "https://github.com/hub4j/github-api.git",
+    "svn_url": "https://github.com/hub4j/github-api",
+    "homepage": "http://github-api.kohsuke.org/",
+    "size": 17060,
+    "stargazers_count": 0,
+    "watchers_count": 0,
+    "language": "Java",
+    "has_issues": true,
+    "has_projects": true,
+    "has_downloads": true,
+    "has_wiki": true,
+    "has_pages": true,
+    "forks_count": 443,
+    "mirror_url": null,
+    "archived": false,
+    "disabled": false,
+    "open_issues_count": 56,
+    "license": {
+      "key": "mit",
+      "name": "MIT License",
+      "spdx_id": "MIT",
+      "url": "https://api.github.com/licenses/mit",
+      "node_id": "MDc6TGljZW5zZTEz"
+    },
+    "forks": 443,
+    "open_issues": 56,
+    "watchers": 585,
+    "default_branch": "main"
+  },
+  "source": {
+    "id": 617210,
+    "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
+    "name": "github-api",
+    "full_name": "hub4j/github-api",
+    "private": false,
+    "owner": {
+      "login": "hub4j",
+      "id": 54909825,
+      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j",
+      "html_url": "https://github.com/hub4j",
+      "followers_url": "https://api.github.com/users/hub4j/followers",
+      "following_url": "https://api.github.com/users/hub4j/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j/orgs",
+      "repos_url": "https://api.github.com/users/hub4j/repos",
+      "events_url": "https://api.github.com/users/hub4j/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j/received_events",
+      "type": "Organization",
+      "site_admin": false
+    },
+    "html_url": "https://github.com/hub4j/github-api",
+    "description": "Java API for GitHub",
+    "fork": false,
+    "url": "https://api.github.com/repos/hub4j/github-api",
+    "forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
+    "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
+    "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
+    "teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
+    "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
+    "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
+    "events_url": "https://api.github.com/repos/hub4j/github-api/events",
+    "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
+    "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
+    "tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
+    "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
+    "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
+    "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
+    "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
+    "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
+    "languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
+    "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
+    "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
+    "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
+    "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
+    "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
+    "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
+    "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
+    "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
+    "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
+    "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
+    "merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
+    "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
+    "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
+    "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
+    "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
+    "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
+    "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
+    "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
+    "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
+    "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
+    "created_at": "2010-04-19T04:13:03Z",
+    "updated_at": "2019-12-04T10:56:12Z",
+    "pushed_at": "2019-12-04T14:15:10Z",
+    "git_url": "git://github.com/hub4j/github-api.git",
+    "ssh_url": "git@github.com:hub4j/github-api.git",
+    "clone_url": "https://github.com/hub4j/github-api.git",
+    "svn_url": "https://github.com/hub4j/github-api",
+    "homepage": "http://github-api.kohsuke.org/",
+    "size": 17060,
+    "stargazers_count": 585,
+    "watchers_count": 585,
+    "language": "Java",
+    "has_issues": true,
+    "has_projects": true,
+    "has_downloads": true,
+    "has_wiki": true,
+    "has_pages": true,
+    "forks_count": 443,
+    "mirror_url": null,
+    "archived": false,
+    "disabled": false,
+    "open_issues_count": 56,
+    "license": {
+      "key": "mit",
+      "name": "MIT License",
+      "spdx_id": "MIT",
+      "url": "https://api.github.com/licenses/mit",
+      "node_id": "MDc6TGljZW5zZTEz"
+    },
+    "forks": 443,
+    "open_issues": 56,
+    "watchers": 585,
+    "default_branch": "main"
+  },
+  "network_count": 443,
+  "subscribers_count": 0
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/user.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/user.json
new file mode 100644
index 000000000..68c8dbe65
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/__files/user.json
@@ -0,0 +1,33 @@
+{
+  "login": "hub4j-test-org",
+  "id": 1958953,
+  "node_id": "MDQ6VXNlcjE5NTg5NTM=",
+  "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
+  "gravatar_id": "",
+  "url": "https://api.github.com/users/hub4j-test-org",
+  "html_url": "https://github.com/hub4j-test-org",
+  "followers_url": "https://api.github.com/users/hub4j-test-org/followers",
+  "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
+  "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
+  "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
+  "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
+  "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
+  "repos_url": "https://api.github.com/users/hub4j-test-org/repos",
+  "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
+  "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
+  "type": "User",
+  "site_admin": false,
+  "name": "Liam Newman",
+  "company": "Cloudbees, Inc.",
+  "blog": "",
+  "location": "Seattle, WA, USA",
+  "email": "hub4j-test-org@gmail.com",
+  "hireable": null,
+  "bio": "https://twitter.com/hub4j-test-org",
+  "public_repos": 166,
+  "public_gists": 4,
+  "followers": 135,
+  "following": 9,
+  "created_at": "2012-07-11T20:38:33Z",
+  "updated_at": "2019-09-24T19:32:29Z"
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/orgs_hub4j-test-org.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/orgs_hub4j-test-org.json
new file mode 100644
index 000000000..0c9eb0f7f
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/orgs_hub4j-test-org.json
@@ -0,0 +1,48 @@
+{
+  "id": "d319a11c-9dce-4642-a18a-175f6cdbde6d",
+  "name": "orgs_hub4j-test-org",
+  "request": {
+    "url": "/orgs/hub4j-test-org",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "orgs_hub4j-test-org.json",
+    "headers": {
+      "Date": "Wed, 04 Dec 2019 17:07:18 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4956",
+      "X-RateLimit-Reset": "1575482837",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"1de516fab0228945881043c1bc527c88\"",
+      "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "A585:3D530:D2A1AF3:FAB1EAD:5DE7E7C5"
+    }
+  },
+  "uuid": "d319a11c-9dce-4642-a18a-175f6cdbde6d",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api-starred.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api-starred.json
new file mode 100644
index 000000000..e869cd0c6
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api-starred.json
@@ -0,0 +1,16 @@
+{
+  "id": "4c1e8c73-a989-4625-8582-5fa6a2f88f4d",
+  "name": "repos_hub4j-test-org_github-api-starred",
+  "request": {
+    "url": "/user/starred/hub4j-test-org/github-api",
+    "method": "PUT",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 204
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api-unstarred.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api-unstarred.json
new file mode 100644
index 000000000..86308c991
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api-unstarred.json
@@ -0,0 +1,16 @@
+{
+  "id": "4c1e8c73-a989-4625-8582-5fa6a2f88f4d",
+  "name": "repos_hub4j-test-org_github-api-starred",
+  "request": {
+    "url": "/user/starred/hub4j-test-org/github-api",
+    "method": "DELETE",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 204
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api.json
new file mode 100644
index 000000000..eebaac8b7
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api.json
@@ -0,0 +1,48 @@
+{
+  "id": "4c1e8c73-a989-4625-8582-5fa6a2f88f4d",
+  "name": "repos_hub4j-test-org_github-api",
+  "request": {
+    "url": "/repos/hub4j-test-org/github-api",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "repos_hub4j-test-org_github-api.json",
+    "headers": {
+      "Date": "Wed, 04 Dec 2019 17:07:19 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4955",
+      "X-RateLimit-Reset": "1575482837",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"bd13c31938217e87f61c9a08bd0fe01d\"",
+      "Last-Modified": "Thu, 07 Nov 2019 22:27:11 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "repo",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "A585:3D530:D2A1B48:FAB201E:5DE7E7C6"
+    }
+  },
+  "uuid": "4c1e8c73-a989-4625-8582-5fa6a2f88f4d",
+  "persistent": true,
+  "insertionIndex": 3
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api_starred-users.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api_starred-users.json
new file mode 100644
index 000000000..3b6cf79f8
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api_starred-users.json
@@ -0,0 +1,47 @@
+{
+  "id": "a8dd4fb9-0ec7-4a93-b642-193312795e64",
+  "name": "repos_hub4j-test-org_github-api_stargazers",
+  "request": {
+    "url": "/repos/hub4j-test-org/github-api/stargazers",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3.star+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "repos_hub4j-test-org_github-api-starred-users.json",
+    "headers": {
+      "Date": "Mon, 25 Jan 2021 01:00:35 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding, Accept, X-Requested-With",
+        "Accept-Encoding"
+      ],
+      "ETag": "\"c0ae8d4e2de626e3c17a734d124e620264c64895ab868c0914ace984cce8cef8\"",
+      "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
+      "X-Accepted-OAuth-Scopes": "",
+      "X-GitHub-Media-Type": "github.v3; param=star; format=json",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4943",
+      "X-RateLimit-Reset": "1611538431",
+      "x-ratelimit-used": "57",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "FEDB:9997:871A4E:9D45ED:600E1833"
+    }
+  },
+  "uuid": "a8dd4fb9-0ec7-4a93-b642-193312795e64",
+  "persistent": true,
+  "insertionIndex": 4
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api_unstarred-users.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api_unstarred-users.json
new file mode 100644
index 000000000..67eef7a24
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/repos_hub4j-test-org_github-api_unstarred-users.json
@@ -0,0 +1,47 @@
+{
+  "id": "a8dd4fb9-0ec7-4a93-b642-193312795e64",
+  "name": "repos_hub4j-test-org_github-api_stargazers",
+  "request": {
+    "url": "/repos/hub4j-test-org/github-api/stargazers",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "body": "[]",
+    "headers": {
+      "Date": "Mon, 25 Jan 2021 01:00:35 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding, Accept, X-Requested-With",
+        "Accept-Encoding"
+      ],
+      "ETag": "\"c0ae8d4e2de626e3c17a734d124e620264c64895ab868c0914ace984cce8cef8\"",
+      "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
+      "X-Accepted-OAuth-Scopes": "",
+      "X-GitHub-Media-Type": "github.v3; param=star; format=json",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4943",
+      "X-RateLimit-Reset": "1611538431",
+      "x-ratelimit-used": "57",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "FEDB:9997:871A4E:9D45ED:600E1833"
+    }
+  },
+  "uuid": "a8dd4fb9-0ec7-4a93-b642-193312795e64",
+  "persistent": true,
+  "insertionIndex": 4
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/user.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/user.json
new file mode 100644
index 000000000..1a514ad25
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/starTest/mappings/user.json
@@ -0,0 +1,48 @@
+{
+  "id": "7f6e9a01-5bfa-4f72-9947-07df902f56c3",
+  "name": "user",
+  "request": {
+    "url": "/users/hub4j-test-org",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "user.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:33 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4992",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"14ffd29009ddc2209c450bb29a5a8330\"",
+      "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F845:5D1D:FFA88A:12FE539:5D8BF9C5"
+    }
+  },
+  "uuid": "7f6e9a01-5bfa-4f72-9947-07df902f56c3",
+  "persistent": true,
+  "insertionIndex": 1
+}
\ No newline at end of file