Skip to content

Commit

Permalink
Add Wiremock snapshot files for checkNonExistentReviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
sahansera committed Nov 23, 2021
1 parent e54d410 commit ada9b49
Show file tree
Hide file tree
Showing 12 changed files with 786 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/kohsuke/github/GHPullRequestReview.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public String getBody() {
* the io exception
*/
public GHUser getUser() throws IOException {
return owner.root().getUser(user.getLogin());
if (user != null) {
return owner.root().getUser(user.getLogin());
}
return null;
}

/**
Expand Down
13 changes: 9 additions & 4 deletions src/test/java/org/kohsuke/github/GHPullRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import static org.hamcrest.Matchers.*;

Expand Down Expand Up @@ -544,15 +545,19 @@ public void getUserTest() throws IOException {
}

@Test
public void checkNonExistentReviewerTest() throws IOException {
final GHRepository repository = getRepository();
final GHPullRequest pullRequest = repository.getPullRequest(1);
public void checkNonExistentReviewer() throws IOException, NullPointerException {
// PR id is based on https://github.com/sahansera/TestRepo/pull/1
final GHPullRequest pullRequest = getRepository().getPullRequest(1);
final Optional<GHPullRequestReview> review = pullRequest.listReviews().toList().stream().findFirst();
final GHUser reviewer = review.get().getUser();

assertThat(pullRequest.getRequestedReviewers(), is(empty()));
assertThat(review, notNullValue());
assertThat(reviewer, is(nullValue()));
}

@Test
public void checkNonExistentUserTest() throws IOException {
public void checkNonExistentUser() throws IOException {
final GHRepository repository = getRepository();
final GHPullRequest pullRequest = repository.getPullRequest(2);

Expand Down
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"default_repository_permission": "none",
"members_can_create_repositories": false,
"two_factor_requirement_enabled": false,
"plan": {
"name": "free",
"space": 976562499,
"private_repos": 0,
"filled_seats": 3,
"seats": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"id": 423321524,
"node_id": "R_kgDOGTtftA",
"name": "github-api",
"full_name": "hub4j-test-org/github-api",
"private": false,
"owner": {
"login": "hub4j-test-org",
"id": 2032296,
"node_id": "MDQ6VXNlcjIwMzIyOTY=",
"avatar_url": "https://avatars.githubusercontent.com/u/2032296?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": true
},
"html_url": "https://github.com/hub4j-test-org/github-api",
"description": "Recreating an issue",
"fork": false,
"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": "2021-11-01T03:08:27Z",
"updated_at": "2021-11-01T03:09:57Z",
"pushed_at": "2021-11-08T13:29:40Z",
"git_url": "git://github.com/hub4j-test-org/github-api.git",
"ssh_url": "[email protected]: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": null,
"size": 2,
"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": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": null,
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main",
"permissions": {
"admin": true,
"maintain": true,
"push": true,
"triage": true,
"pull": true
},
"temp_clone_token": "",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_auto_merge": false,
"delete_branch_on_merge": false,
"allow_update_branch": false,
"network_count": 0,
"subscribers_count": 1
}
Loading

0 comments on commit ada9b49

Please sign in to comment.