From 834c84c9ea636fd12e1249f371cb2f4723fcccf4 Mon Sep 17 00:00:00 2001 From: Alex Taylor Date: Wed, 13 Nov 2019 15:07:06 -0500 Subject: [PATCH 1/5] Added the test for Issue #607 Added a test so that we can prove when this issue is fixed --- .../org/kohsuke/github/GHRepositoryTest.java | 19 +- ...-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json | 25 ++ ...-228f0322-215d-487e-9132-17bc4c3bf020.json | 327 ++++++++++++++++++ ...-87afc711-0c63-4cc6-96b5-26eb391105de.json | 45 +++ .../orgs_github-api-test-org-2-cadf65.json | 40 +++ ...thub-api-test-org_github-api-3-228f03.json | 40 +++ ...pi_branches_test_nonexistent-4-b14df6.json | 36 ++ .../mappings/user-1-87afc7.json | 40 +++ 8 files changed, 570 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/user-87afc711-0c63-4cc6-96b5-26eb391105de.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/orgs_github-api-test-org-2-cadf65.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api-3-228f03.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api_branches_test_nonexistent-4-b14df6.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/user-1-87afc7.json diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 3b53ff2807..bfcad7a3bf 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -1,6 +1,7 @@ package org.kohsuke.github; import org.apache.commons.io.IOUtils; +import org.junit.Ignore; import org.junit.Test; import java.io.FileNotFoundException; @@ -48,6 +49,22 @@ public void getBranch_URLEncoded() throws Exception { assertThat(branch.getName(), is("test/#UrlEncode")); } + //Issue #607 + @Test + public void getBranchNonExistentBut200Status() throws Exception { + //Manually changed the returned status to 200 so dont take a new snapshot + this.snapshotNotAllowed(); + + GHRepository repo = getRepository(); + try{ + GHBranch branch = repo.getBranch("test/NonExistent"); + fail(); + } + catch(GHFileNotFoundException e){ + assertEquals("{\"message\":\"Branch not found\",\"documentation_url\":\"https://developer.github.com/v3/repos/branches/#get-branch\"}", e.getMessage()); + } + } + @Test public void subscription() throws Exception { GHRepository r = getRepository(); @@ -268,6 +285,4 @@ public void setMergeOptions() throws IOException { assertTrue(r.isAllowRebaseMerge()); assertFalse(r.isAllowSquashMerge()); } - - } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json new file mode 100644 index 0000000000..e57a3a127b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json @@ -0,0 +1,25 @@ +{ + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "url": "https://api.github.com/orgs/github-api-test-org", + "repos_url": "https://api.github.com/orgs/github-api-test-org/repos", + "events_url": "https://api.github.com/orgs/github-api-test-org/events", + "hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks", + "issues_url": "https://api.github.com/orgs/github-api-test-org/issues", + "members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}", + "public_members_url": "https://api.github.com/orgs/github-api-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": 10, + "public_gists": 0, + "followers": 0, + "following": 0, + "html_url": "https://github.com/github-api-test-org", + "created_at": "2014-05-10T19:39:11Z", + "updated_at": "2015-04-20T00:42:30Z", + "type": "Organization" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json new file mode 100644 index 0000000000..784d00e066 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json @@ -0,0 +1,327 @@ +{ + "id": 206888201, + "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=", + "name": "github-api", + "full_name": "github-api-test-org/github-api", + "private": false, + "owner": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/github-api", + "description": "Resetting", + "fork": true, + "url": "https://api.github.com/repos/github-api-test-org/github-api", + "forks_url": "https://api.github.com/repos/github-api-test-org/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-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/github-api-test-org/github-api.git", + "ssh_url": "git@github.com:github-api-test-org/github-api.git", + "clone_url": "https://github.com/github-api-test-org/github-api.git", + "svn_url": "https://github.com/github-api-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": "master", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "organization": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "github-api/github-api", + "private": false, + "owner": { + "login": "github-api", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api", + "html_url": "https://github.com/github-api", + "followers_url": "https://api.github.com/users/github-api/followers", + "following_url": "https://api.github.com/users/github-api/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api/subscriptions", + "organizations_url": "https://api.github.com/users/github-api/orgs", + "repos_url": "https://api.github.com/users/github-api/repos", + "events_url": "https://api.github.com/users/github-api/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/github-api/github-api", + "forks_url": "https://api.github.com/repos/github-api/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-11-13T17:48:29Z", + "pushed_at": "2019-11-13T17:48:26Z", + "git_url": "git://github.com/github-api/github-api.git", + "ssh_url": "git@github.com:github-api/github-api.git", + "clone_url": "https://github.com/github-api/github-api.git", + "svn_url": "https://github.com/github-api/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 15308, + "stargazers_count": 579, + "watchers_count": 579, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 441, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 55, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 441, + "open_issues": 55, + "watchers": 579, + "default_branch": "master" + }, + "source": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "github-api/github-api", + "private": false, + "owner": { + "login": "github-api", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api", + "html_url": "https://github.com/github-api", + "followers_url": "https://api.github.com/users/github-api/followers", + "following_url": "https://api.github.com/users/github-api/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api/subscriptions", + "organizations_url": "https://api.github.com/users/github-api/orgs", + "repos_url": "https://api.github.com/users/github-api/repos", + "events_url": "https://api.github.com/users/github-api/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/github-api/github-api", + "forks_url": "https://api.github.com/repos/github-api/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-11-13T17:48:29Z", + "pushed_at": "2019-11-13T17:48:26Z", + "git_url": "git://github.com/github-api/github-api.git", + "ssh_url": "git@github.com:github-api/github-api.git", + "clone_url": "https://github.com/github-api/github-api.git", + "svn_url": "https://github.com/github-api/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 15308, + "stargazers_count": 579, + "watchers_count": 579, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 441, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 55, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 441, + "open_issues": 55, + "watchers": 579, + "default_branch": "master" + }, + "network_count": 441, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/user-87afc711-0c63-4cc6-96b5-26eb391105de.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/user-87afc711-0c63-4cc6-96b5-26eb391105de.json new file mode 100644 index 0000000000..d41ddd34b1 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/user-87afc711-0c63-4cc6-96b5-26eb391105de.json @@ -0,0 +1,45 @@ +{ + "login": "alexanderrtaylor", + "id": 852179, + "node_id": "MDQ6VXNlcjg1MjE3OQ==", + "avatar_url": "https://avatars0.githubusercontent.com/u/852179?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/alexanderrtaylor", + "html_url": "https://github.com/alexanderrtaylor", + "followers_url": "https://api.github.com/users/alexanderrtaylor/followers", + "following_url": "https://api.github.com/users/alexanderrtaylor/following{/other_user}", + "gists_url": "https://api.github.com/users/alexanderrtaylor/gists{/gist_id}", + "starred_url": "https://api.github.com/users/alexanderrtaylor/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/alexanderrtaylor/subscriptions", + "organizations_url": "https://api.github.com/users/alexanderrtaylor/orgs", + "repos_url": "https://api.github.com/users/alexanderrtaylor/repos", + "events_url": "https://api.github.com/users/alexanderrtaylor/events{/privacy}", + "received_events_url": "https://api.github.com/users/alexanderrtaylor/received_events", + "type": "User", + "site_admin": false, + "name": "Alex Taylor", + "company": "Cloudbees", + "blog": "", + "location": null, + "email": null, + "hireable": null, + "bio": null, + "public_repos": 39, + "public_gists": 1, + "followers": 5, + "following": 0, + "created_at": "2011-06-15T16:35:58Z", + "updated_at": "2019-07-23T14:01:42Z", + "private_gists": 1, + "total_private_repos": 13, + "owned_private_repos": 0, + "disk_usage": 265, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/orgs_github-api-test-org-2-cadf65.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/orgs_github-api-test-org-2-cadf65.json new file mode 100644 index 0000000000..7c7fc05d34 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/orgs_github-api-test-org-2-cadf65.json @@ -0,0 +1,40 @@ +{ + "id": "cadf65cc-4434-4d3a-b4cf-4b1b79272f46", + "name": "orgs_github-api-test-org", + "request": { + "url": "/orgs/github-api-test-org", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 13 Nov 2019 19:55:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4976", + "X-RateLimit-Reset": "1573678486", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag": "W/\"46db056d052e79900ccf2bffefb0e863\"", + "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT", + "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "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": "F3E5:680D:1B5AF:4044E:5DCC5FBB" + } + }, + "uuid": "cadf65cc-4434-4d3a-b4cf-4b1b79272f46", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api-3-228f03.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api-3-228f03.json new file mode 100644 index 0000000000..3d3853a5b4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api-3-228f03.json @@ -0,0 +1,40 @@ +{ + "id": "228f0322-215d-487e-9132-17bc4c3bf020", + "name": "repos_github-api-test-org_github-api", + "request": { + "url": "/repos/github-api-test-org/github-api", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 13 Nov 2019 19:55:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4975", + "X-RateLimit-Reset": "1573678486", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag": "W/\"30a14752ec6a3eede9a30843cc286a50\"", + "Last-Modified": "Thu, 07 Nov 2019 22:27:11 GMT", + "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "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": "F3E5:680D:1B5B8:4048B:5DCC5FBC" + } + }, + "uuid": "228f0322-215d-487e-9132-17bc4c3bf020", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api_branches_test_nonexistent-4-b14df6.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api_branches_test_nonexistent-4-b14df6.json new file mode 100644 index 0000000000..1b0d5a595e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api_branches_test_nonexistent-4-b14df6.json @@ -0,0 +1,36 @@ +{ + "id": "b14df6ec-ff32-4838-8b38-934766abd880", + "name": "repos_github-api-test-org_github-api_branches_test_nonexistent", + "request": { + "url": "/repos/github-api-test-org/github-api/branches/test%2FNonExistent", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"message\":\"Branch not found\",\"documentation_url\":\"https://developer.github.com/v3/repos/branches/#get-branch\"}", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 13 Nov 2019 19:55:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "404 Not Found", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4974", + "X-RateLimit-Reset": "1573678486", + "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "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": "F3E5:680D:1B5C1:4049C:5DCC5FBC" + } + }, + "uuid": "b14df6ec-ff32-4838-8b38-934766abd880", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/user-1-87afc7.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/user-1-87afc7.json new file mode 100644 index 0000000000..3a4488a2c6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/user-1-87afc7.json @@ -0,0 +1,40 @@ +{ + "id": "87afc711-0c63-4cc6-96b5-26eb391105de", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-87afc711-0c63-4cc6-96b5-26eb391105de.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 13 Nov 2019 19:55:39 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4978", + "X-RateLimit-Reset": "1573678486", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag": "W/\"38c5719328738c2ec6c612f367ae1b59\"", + "Last-Modified": "Tue, 23 Jul 2019 14:01:42 GMT", + "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "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": "F3E5:680D:1B592:40447:5DCC5FBB" + } + }, + "uuid": "87afc711-0c63-4cc6-96b5-26eb391105de", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file From 8d50b338f4662076b62e1db4d57e90a631ec30a2 Mon Sep 17 00:00:00 2001 From: Alex Taylor Date: Fri, 15 Nov 2019 10:54:32 -0500 Subject: [PATCH 2/5] Added GHBranch creator Added GHBranch creator and added a test to make sure it works --- src/main/java/org/kohsuke/github/GHBranch.java | 12 ++++++++++-- .../java/org/kohsuke/github/GHRepositoryTest.java | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index e457fc243d..e594b8fbea 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -1,8 +1,8 @@ package org.kohsuke.github; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - import java.io.IOException; import java.net.URL; import java.util.Collection; @@ -26,7 +26,15 @@ public class GHBranch { private boolean protection; private String protection_url; - + @JsonCreator + GHBranch(@JsonProperty("name") String name) throws Exception{ + if (name != null) { + this.name = name; + } + else{ + throw new GHFileNotFoundException("Branch Not Found"); + } + } public static class Commit { String sha; diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index bfcad7a3bf..c245b5cd4b 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -60,8 +60,9 @@ public void getBranchNonExistentBut200Status() throws Exception { GHBranch branch = repo.getBranch("test/NonExistent"); fail(); } - catch(GHFileNotFoundException e){ - assertEquals("{\"message\":\"Branch not found\",\"documentation_url\":\"https://developer.github.com/v3/repos/branches/#get-branch\"}", e.getMessage()); + catch(Exception e){ + //I dont really love this but I wanted to get to the root wrapped cause + assertEquals("Branch Not Found", e.getCause().getCause().getCause().getMessage()); } } From 6af796fc3bfd05c48fda2638d0d55219dd26f56c Mon Sep 17 00:00:00 2001 From: Alex Taylor Date: Fri, 15 Nov 2019 14:35:32 -0500 Subject: [PATCH 3/5] Adjusted format Adjusted format according to standard from repo --- src/main/java/org/kohsuke/github/GHBranch.java | 6 +++--- .../java/org/kohsuke/github/GHRepositoryTest.java | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index b2f8018929..0cc9cdbdb3 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -27,14 +27,14 @@ public class GHBranch { private String protection_url; @JsonCreator - GHBranch(@JsonProperty("name") String name) throws Exception{ + GHBranch(@JsonProperty("name") String name) throws Exception { if (name != null) { this.name = name; - } - else{ + } else { throw new GHFileNotFoundException("Branch Not Found"); } } + /** * The type Commit. */ diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 40e85230ca..f72e99c976 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -50,19 +50,18 @@ public void getBranch_URLEncoded() throws Exception { assertThat(branch.getName(), is("test/#UrlEncode")); } - //Issue #607 + // Issue #607 @Test public void getBranchNonExistentBut200Status() throws Exception { - //Manually changed the returned status to 200 so dont take a new snapshot + // Manually changed the returned status to 200 so dont take a new snapshot this.snapshotNotAllowed(); GHRepository repo = getRepository(); - try{ + try { GHBranch branch = repo.getBranch("test/NonExistent"); fail(); - } - catch(Exception e){ - //I dont really love this but I wanted to get to the root wrapped cause + } catch (Exception e) { + // I dont really love this but I wanted to get to the root wrapped cause assertEquals("Branch Not Found", e.getCause().getCause().getCause().getMessage()); } } From 78ab5ad156cdcdca0afaeef5fdbc661da87f2bd2 Mon Sep 17 00:00:00 2001 From: Alex Taylor Date: Fri, 15 Nov 2019 14:55:50 -0500 Subject: [PATCH 4/5] Changed Exception Type Changed Exception type and added a comment --- src/main/java/org/kohsuke/github/GHBranch.java | 11 +++++------ .../java/org/kohsuke/github/GHRepositoryTest.java | 11 ++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index 0cc9cdbdb3..c6b0cc1fd6 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -2,10 +2,12 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonMappingException; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.net.URL; import java.util.Collection; +import java.util.Objects; import static org.kohsuke.github.Previews.*; @@ -27,12 +29,9 @@ public class GHBranch { private String protection_url; @JsonCreator - GHBranch(@JsonProperty("name") String name) throws Exception { - if (name != null) { - this.name = name; - } else { - throw new GHFileNotFoundException("Branch Not Found"); - } + GHBranch(@JsonProperty(value = "name", required = true) String name) throws Exception { + Objects.requireNonNull(name); + this.name = name; } /** diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index f72e99c976..306d4e0183 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -9,8 +9,8 @@ import java.util.ArrayList; import java.util.List; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.*; import static org.junit.Assume.assumeFalse; @@ -56,13 +56,18 @@ public void getBranchNonExistentBut200Status() throws Exception { // Manually changed the returned status to 200 so dont take a new snapshot this.snapshotNotAllowed(); + //This should *never* happen but with mocking it was discovered GHRepository repo = getRepository(); try { GHBranch branch = repo.getBranch("test/NonExistent"); fail(); } catch (Exception e) { // I dont really love this but I wanted to get to the root wrapped cause - assertEquals("Branch Not Found", e.getCause().getCause().getCause().getMessage()); + assertThat(e, instanceOf(IOException.class)); + assertThat(e.getMessage(), + equalTo("Server returned HTTP response code: 200, message: 'OK' for URL: " + + mockGitHub.apiServer().baseUrl() + + "/repos/github-api-test-org/github-api/branches/test%2FNonExistent")); } } From cbd06eef96d97865159dd80630ba3098c6cfd517 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Fri, 15 Nov 2019 15:36:49 -0800 Subject: [PATCH 5/5] Code formatting --- .../java/org/kohsuke/github/DeleteToken.java | 3 +- .../github/GHAppCreateTokenBuilder.java | 4 +- src/main/java/org/kohsuke/github/GHEvent.java | 50 ++++++++++++++++--- src/main/java/org/kohsuke/github/GHIssue.java | 44 ++++++++++------ .../org/kohsuke/github/GHPullRequest.java | 44 ++++++++++------ .../java/org/kohsuke/github/Requester.java | 13 +++-- .../example/dataobject/ReadOnlyObjects.java | 6 ++- src/test/java/org/kohsuke/HookApp.java | 4 +- .../java/org/kohsuke/github/GHAppTest.java | 6 ++- .../github/GHBranchProtectionTest.java | 11 ++-- .../github/GHContentIntegrationTest.java | 3 +- .../kohsuke/github/GHEventPayloadTest.java | 44 ++++++++-------- .../org/kohsuke/github/GHGistUpdaterTest.java | 11 ++-- .../java/org/kohsuke/github/GHHookTest.java | 4 +- .../kohsuke/github/GHOrganizationTest.java | 10 ++-- .../org/kohsuke/github/GHPullRequestTest.java | 43 +++++++++++----- .../org/kohsuke/github/GHRepositoryTest.java | 18 ++++--- .../org/kohsuke/github/LifecycleTest.java | 29 ++++++++--- .../java/org/kohsuke/github/PayloadRule.java | 3 +- .../kohsuke/github/RepositoryMockTest.java | 2 +- .../kohsuke/github/RepositoryTrafficTest.java | 6 ++- .../github/WireMockStatusReporterTest.java | 13 ++--- .../extras/okhttp3/OkHttpConnectorTest.java | 15 ++++-- .../github/junit/GitHubWireMockRule.java | 20 +++++--- .../github/junit/WireMockMultiServerRule.java | 3 +- 25 files changed, 278 insertions(+), 131 deletions(-) diff --git a/src/main/java/org/kohsuke/github/DeleteToken.java b/src/main/java/org/kohsuke/github/DeleteToken.java index ebef1967f8..30079d0a21 100644 --- a/src/main/java/org/kohsuke/github/DeleteToken.java +++ b/src/main/java/org/kohsuke/github/DeleteToken.java @@ -28,7 +28,8 @@ /** * @author Kohsuke Kawaguchi */ -@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "Being constructed by JSON deserialization") +@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", + justification = "Being constructed by JSON deserialization") class DeleteToken { public String delete_token; } diff --git a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java index 43291820b7..29830425ba 100644 --- a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java +++ b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java @@ -55,7 +55,9 @@ public GHAppCreateTokenBuilder repositoryIds(List repositoryIds) { @Preview @Deprecated public GHAppInstallationToken create() throws IOException { - return builder.method("POST").withPreview(MACHINE_MAN).to(apiUrlTail, GHAppInstallationToken.class) + return builder.method("POST") + .withPreview(MACHINE_MAN) + .to(apiUrlTail, GHAppInstallationToken.class) .wrapUp(root); } diff --git a/src/main/java/org/kohsuke/github/GHEvent.java b/src/main/java/org/kohsuke/github/GHEvent.java index 7d92543449..c82584096a 100644 --- a/src/main/java/org/kohsuke/github/GHEvent.java +++ b/src/main/java/org/kohsuke/github/GHEvent.java @@ -10,12 +10,50 @@ * @see Event type reference */ public enum GHEvent { - COMMIT_COMMENT, CREATE, DELETE, DEPLOYMENT, DEPLOYMENT_STATUS, DOWNLOAD, FOLLOW, FORK, FORK_APPLY, GIST, GOLLUM, INSTALLATION, INSTALLATION_REPOSITORIES, INTEGRATION_INSTALLATION_REPOSITORIES, CHECK_SUITE, ISSUE_COMMENT, ISSUES, LABEL, MARKETPLACE_PURCHASE, MEMBER, MEMBERSHIP, MILESTONE, ORGANIZATION, ORG_BLOCK, PAGE_BUILD, PROJECT_CARD, PROJECT_COLUMN, PROJECT, PUBLIC, PULL_REQUEST, PULL_REQUEST_REVIEW, PULL_REQUEST_REVIEW_COMMENT, PUSH, RELEASE, REPOSITORY, // only - // valid - // for - // org - // hooks - STATUS, TEAM, TEAM_ADD, WATCH, PING, + COMMIT_COMMENT, + CREATE, + DELETE, + DEPLOYMENT, + DEPLOYMENT_STATUS, + DOWNLOAD, + FOLLOW, + FORK, + FORK_APPLY, + GIST, + GOLLUM, + INSTALLATION, + INSTALLATION_REPOSITORIES, + INTEGRATION_INSTALLATION_REPOSITORIES, + CHECK_SUITE, + ISSUE_COMMENT, + ISSUES, + LABEL, + MARKETPLACE_PURCHASE, + MEMBER, + MEMBERSHIP, + MILESTONE, + ORGANIZATION, + ORG_BLOCK, + PAGE_BUILD, + PROJECT_CARD, + PROJECT_COLUMN, + PROJECT, + PUBLIC, + PULL_REQUEST, + PULL_REQUEST_REVIEW, + PULL_REQUEST_REVIEW_COMMENT, + PUSH, + RELEASE, + REPOSITORY, // only + // valid + // for + // org + // hooks + STATUS, + TEAM, + TEAM_ADD, + WATCH, + PING, /** * Special event type that means "every possible event" */ diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java index 71a95639e1..acee6d5c03 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -179,7 +179,7 @@ public Collection getLabels() throws IOException { if (labels == null) { return Collections.emptyList(); } - return Collections. unmodifiableList(labels); + return Collections.unmodifiableList(labels); } /** @@ -231,8 +231,8 @@ public void unlock() throws IOException { */ @WithBridgeMethods(void.class) public GHIssueComment comment(String message) throws IOException { - GHIssueComment r = new Requester(root).with("body", message).to(getIssuesApiRoute() + "/comments", - GHIssueComment.class); + GHIssueComment r = new Requester(root).with("body", message) + .to(getIssuesApiRoute() + "/comments", GHIssueComment.class); return r.wrapUp(this); } @@ -443,22 +443,27 @@ public List getComments() throws IOException { * the io exception */ public PagedIterable listComments() throws IOException { - return root.retrieve().asPagedIterable(getIssuesApiRoute() + "/comments", GHIssueComment[].class, - item -> item.wrapUp(GHIssue.this)); + return root.retrieve() + .asPagedIterable(getIssuesApiRoute() + "/comments", + GHIssueComment[].class, + item -> item.wrapUp(GHIssue.this)); } @Preview @Deprecated public GHReaction createReaction(ReactionContent content) throws IOException { - return new Requester(owner.root).withPreview(SQUIRREL_GIRL).with("content", content.getContent()) - .to(getApiRoute() + "/reactions", GHReaction.class).wrap(root); + return new Requester(owner.root).withPreview(SQUIRREL_GIRL) + .with("content", content.getContent()) + .to(getApiRoute() + "/reactions", GHReaction.class) + .wrap(root); } @Preview @Deprecated public PagedIterable listReactions() { - return owner.root.retrieve().withPreview(SQUIRREL_GIRL).asPagedIterable(getApiRoute() + "/reactions", - GHReaction[].class, item -> item.wrap(owner.root)); + return owner.root.retrieve() + .withPreview(SQUIRREL_GIRL) + .asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root)); } /** @@ -482,8 +487,10 @@ public void addAssignees(GHUser... assignees) throws IOException { * the io exception */ public void addAssignees(Collection assignees) throws IOException { - root.retrieve().method("POST").with(ASSIGNEES, getLogins(assignees)).to(getIssuesApiRoute() + "/assignees", - this); + root.retrieve() + .method("POST") + .with(ASSIGNEES, getLogins(assignees)) + .to(getIssuesApiRoute() + "/assignees", this); } /** @@ -531,7 +538,10 @@ public void removeAssignees(GHUser... assignees) throws IOException { * the io exception */ public void removeAssignees(Collection assignees) throws IOException { - root.retrieve().method("DELETE").with(ASSIGNEES, getLogins(assignees)).inBody() + root.retrieve() + .method("DELETE") + .with(ASSIGNEES, getLogins(assignees)) + .inBody() .to(getIssuesApiRoute() + "/assignees", this); } @@ -645,8 +655,8 @@ public GHMilestone getMilestone() { /** * The type PullRequest. */ - @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", - "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" }, + justification = "JSON API") public static class PullRequest { private String diff_url, patch_url, html_url; @@ -694,7 +704,9 @@ protected static List getLogins(Collection users) { * the io exception */ public PagedIterable listEvents() throws IOException { - return root.retrieve().asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)), - GHIssueEvent[].class, item -> item.wrapUp(GHIssue.this)); + return root.retrieve() + .asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)), + GHIssueEvent[].class, + item -> item.wrapUp(GHIssue.this)); } } diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 831309b883..e4256854d3 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -392,8 +392,8 @@ public void refresh() throws IOException { * @return the paged iterable */ public PagedIterable listFiles() { - return root.retrieve().asPagedIterable(String.format("%s/files", getApiRoute()), - GHPullRequestFileDetail[].class, null); + return root.retrieve() + .asPagedIterable(String.format("%s/files", getApiRoute()), GHPullRequestFileDetail[].class, null); } /** @@ -402,8 +402,10 @@ public PagedIterable listFiles() { * @return the paged iterable */ public PagedIterable listReviews() { - return root.retrieve().asPagedIterable(String.format("%s/reviews", getApiRoute()), GHPullRequestReview[].class, - item -> item.wrapUp(GHPullRequest.this)); + return root.retrieve() + .asPagedIterable(String.format("%s/reviews", getApiRoute()), + GHPullRequestReview[].class, + item -> item.wrapUp(GHPullRequest.this)); } /** @@ -414,8 +416,10 @@ public PagedIterable listReviews() { * the io exception */ public PagedIterable listReviewComments() throws IOException { - return root.retrieve().asPagedIterable(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment[].class, - item -> item.wrapUp(GHPullRequest.this)); + return root.retrieve() + .asPagedIterable(getApiRoute() + COMMENTS_ACTION, + GHPullRequestReviewComment[].class, + item -> item.wrapUp(GHPullRequest.this)); } /** @@ -424,8 +428,10 @@ public PagedIterable listReviewComments() throws IOE * @return the paged iterable */ public PagedIterable listCommits() { - return root.retrieve().asPagedIterable(String.format("%s/commits", getApiRoute()), - GHPullRequestCommitDetail[].class, item -> item.wrapUp(GHPullRequest.this)); + return root.retrieve() + .asPagedIterable(String.format("%s/commits", getApiRoute()), + GHPullRequestCommitDetail[].class, + item -> item.wrapUp(GHPullRequest.this)); } /** @@ -442,7 +448,8 @@ public PagedIterable listCommits() { * the io exception * @deprecated Use {@link #createReview()} */ - public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, + public GHPullRequestReview createReview(String body, + @CheckForNull GHPullRequestReviewState event, GHPullRequestReviewComment... comments) throws IOException { return createReview(body, event, Arrays.asList(comments)); } @@ -461,7 +468,8 @@ public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequest * the io exception * @deprecated Use {@link #createReview()} */ - public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, + public GHPullRequestReview createReview(String body, + @CheckForNull GHPullRequestReviewState event, List comments) throws IOException { GHPullRequestReviewBuilder b = createReview().body(body); for (GHPullRequestReviewComment c : comments) { @@ -496,8 +504,12 @@ public GHPullRequestReviewBuilder createReview() { */ public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position) throws IOException { - return new Requester(root).method("POST").with("body", body).with("commit_id", sha).with("path", path) - .with("position", position).to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class) + return new Requester(root).method("POST") + .with("body", body) + .with("commit_id", sha) + .with("path", path) + .with("position", position) + .to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class) .wrapUp(this); } @@ -510,7 +522,8 @@ public GHPullRequestReviewComment createReviewComment(String body, String sha, S * the io exception */ public void requestReviewers(List reviewers) throws IOException { - new Requester(root).method("POST").with("reviewers", getLogins(reviewers)) + new Requester(root).method("POST") + .with("reviewers", getLogins(reviewers)) .to(getApiRoute() + REQUEST_REVIEWERS); } @@ -575,7 +588,10 @@ public void merge(String msg, String sha) throws IOException { * the io exception */ public void merge(String msg, String sha, MergeMethod method) throws IOException { - new Requester(root).method("PUT").with("commit_message", msg).with("sha", sha).with("merge_method", method) + new Requester(root).method("PUT") + .with("commit_message", msg) + .with("sha", sha) + .with("merge_method", method) .to(getApiRoute() + "/merge"); } diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index 1a86bf407c..65e60533ed 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -723,8 +723,9 @@ private void findNextURL() throws MalformedURLException { private void setupConnection(URL url) throws IOException { if (LOGGER.isLoggable(FINE)) { - LOGGER.log(FINE, "GitHub API request [" + (root.login == null ? "anonymous" : root.login) + "]: " + method - + " " + url.toString()); + LOGGER.log(FINE, + "GitHub API request [" + (root.login == null ? "anonymous" : root.login) + "]: " + method + " " + + url.toString()); } uc = root.getConnector().connect(url); @@ -811,7 +812,7 @@ private T parse(Class type, T instance, int timeouts) throws IOException throw (IOException) new IOException("Failed to deserialize " + data).initCause(e); } if (instance != null) { - return setResponseHeaders(MAPPER.readerForUpdating(instance). readValue(data)); + return setResponseHeaders(MAPPER.readerForUpdating(instance).readValue(data)); } return null; } catch (FileNotFoundException e) { @@ -872,8 +873,10 @@ void handleApiError(IOException e) throws IOException { // likely to be a network exception (e.g. SSLHandshakeException), // uc.getResponseCode() and any other getter on the response will cause an exception if (LOGGER.isLoggable(FINE)) - LOGGER.log(FINE, "Silently ignore exception retrieving response code for '" + uc.getURL() + "'" - + " handling exception " + e, e); + LOGGER.log(FINE, + "Silently ignore exception retrieving response code for '" + uc.getURL() + "'" + + " handling exception " + e, + e); throw e; } InputStream es = wrapStream(uc.getErrorStream()); diff --git a/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java b/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java index ea39c8e006..aaec14d1b5 100644 --- a/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java +++ b/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java @@ -504,8 +504,10 @@ public static class GHMetaGettersFinalCreator implements GHMetaExample { @JsonCreator private GHMetaGettersFinalCreator(@Nonnull @JsonProperty("hooks") List hooks, - @Nonnull @JsonProperty("git") List git, @Nonnull @JsonProperty("web") List web, - @Nonnull @JsonProperty("api") List api, @Nonnull @JsonProperty("pages") List pages, + @Nonnull @JsonProperty("git") List git, + @Nonnull @JsonProperty("web") List web, + @Nonnull @JsonProperty("api") List api, + @Nonnull @JsonProperty("pages") List pages, @Nonnull @JsonProperty("importer") List importer, @JsonProperty("verifiable_password_authentication") boolean verifiablePasswordAuthentication) { this.verifiablePasswordAuthentication = verifiablePasswordAuthentication; diff --git a/src/test/java/org/kohsuke/HookApp.java b/src/test/java/org/kohsuke/HookApp.java index 32f2e0157b..9ee51407a0 100644 --- a/src/test/java/org/kohsuke/HookApp.java +++ b/src/test/java/org/kohsuke/HookApp.java @@ -26,8 +26,8 @@ public static void main(String[] args) throws Exception { public void doIndex(StaplerRequest req) throws IOException { String str = req.getParameter("payload"); // System.out.println(str); - GHEventPayload.PullRequest o = GitHub.connect().parseEventPayload(new StringReader(str), - GHEventPayload.PullRequest.class); + GHEventPayload.PullRequest o = GitHub.connect() + .parseEventPayload(new StringReader(str), GHEventPayload.PullRequest.class); // System.out.println(o); } } diff --git a/src/test/java/org/kohsuke/github/GHAppTest.java b/src/test/java/org/kohsuke/github/GHAppTest.java index eb9f96be75..980f3c8f6f 100644 --- a/src/test/java/org/kohsuke/github/GHAppTest.java +++ b/src/test/java/org/kohsuke/github/GHAppTest.java @@ -20,7 +20,8 @@ public class GHAppTest extends AbstractGitHubWireMockTest { protected GitHubBuilder getGitHubBuilder() { return super.getGitHubBuilder() // ensure that only JWT will be used against the tests below - .withPassword(null, null).withJwtToken("bogus"); + .withPassword(null, null) + .withJwtToken("bogus"); } @Test @@ -101,7 +102,8 @@ public void createToken() throws IOException { permissions.put("metadata", GHPermissionType.READ); GHAppInstallationToken installationToken = installation.createToken(permissions) - .repositoryIds(Arrays.asList((long) 111111111)).create(); + .repositoryIds(Arrays.asList((long) 111111111)) + .create(); assertThat(installationToken.getToken(), is("bogus")); assertThat(installation.getPermissions(), is(permissions)); diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index 8717d6775c..ee6c62695e 100644 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -48,9 +48,14 @@ public void setUp() throws Exception { @Test public void testEnableBranchProtections() throws Exception { // team/user restrictions require an organization repo to test against - GHBranchProtection protection = branch.enableProtection().addRequiredChecks("test-status-check") - .requireBranchIsUpToDate().requireCodeOwnReviews().dismissStaleReviews().requiredReviewers(2) - .includeAdmins().enable(); + GHBranchProtection protection = branch.enableProtection() + .addRequiredChecks("test-status-check") + .requireBranchIsUpToDate() + .requireCodeOwnReviews() + .dismissStaleReviews() + .requiredReviewers(2) + .includeAdmins() + .enable(); RequiredStatusChecks statusChecks = protection.getRequiredStatusChecks(); assertNotNull(statusChecks); diff --git a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java index 32e0f0090d..9b3d9334f6 100644 --- a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java +++ b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java @@ -73,7 +73,8 @@ public void testGetDirectoryContentTrailingSlash() throws Exception { @Test public void testCRUDContent() throws Exception { GHContentUpdateResponse created = repo.createContent("this is an awesome file I created\n", - "Creating a file for integration tests.", createdFilename); + "Creating a file for integration tests.", + createdFilename); GHContent createdContent = created.getContent(); assertNotNull(created.getCommit()); diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 4f3b92a075..481396a48c 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -14,8 +14,8 @@ public class GHEventPayloadTest { @Test public void commit_comment() throws Exception { - GHEventPayload.CommitComment event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.CommitComment.class); + GHEventPayload.CommitComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.CommitComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getComment().getSHA1(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); assertThat(event.getComment().getUser().getLogin(), is("baxterthehacker")); @@ -26,8 +26,8 @@ public void commit_comment() throws Exception { @Test public void create() throws Exception { - GHEventPayload.Create event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Create.class); + GHEventPayload.Create event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Create.class); assertThat(event.getRef(), is("0.0.1")); assertThat(event.getRefType(), is("tag")); assertThat(event.getMasterBranch(), is("master")); @@ -39,8 +39,8 @@ public void create() throws Exception { @Test public void delete() throws Exception { - GHEventPayload.Delete event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Delete.class); + GHEventPayload.Delete event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Delete.class); assertThat(event.getRef(), is("simple-tag")); assertThat(event.getRefType(), is("tag")); assertThat(event.getRepository().getName(), is("public-repo")); @@ -50,8 +50,8 @@ public void delete() throws Exception { @Test public void deployment() throws Exception { - GHEventPayload.Deployment event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Deployment.class); + GHEventPayload.Deployment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Deployment.class); assertThat(event.getDeployment().getSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); assertThat(event.getDeployment().getEnvironment(), is("production")); assertThat(event.getDeployment().getCreator().getLogin(), is("baxterthehacker")); @@ -62,8 +62,8 @@ public void deployment() throws Exception { @Test public void deployment_status() throws Exception { - GHEventPayload.DeploymentStatus event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.DeploymentStatus.class); + GHEventPayload.DeploymentStatus event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.DeploymentStatus.class); assertThat(event.getDeploymentStatus().getState(), is(GHDeploymentState.SUCCESS)); assertThat(event.getDeploymentStatus().getTargetUrl(), nullValue()); assertThat(event.getDeployment().getSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); @@ -104,8 +104,8 @@ public void fork() throws Exception { @Test public void issue_comment() throws Exception { - GHEventPayload.IssueComment event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.IssueComment.class); + GHEventPayload.IssueComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.IssueComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getIssue().getNumber(), is(2)); assertThat(event.getIssue().getTitle(), is("Spelling error in the README file")); @@ -156,8 +156,8 @@ public void issues() throws Exception { @Test @Payload("public") public void public_() throws Exception { - GHEventPayload.Public event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Public.class); + GHEventPayload.Public event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Public.class); assertThat(event.getRepository().getName(), is("public-repo")); assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker")); assertThat(event.getSender().getLogin(), is("baxterthehacker")); @@ -165,8 +165,8 @@ public void public_() throws Exception { @Test public void pull_request() throws Exception { - GHEventPayload.PullRequest event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.PullRequest.class); + GHEventPayload.PullRequest event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class); assertThat(event.getAction(), is("opened")); assertThat(event.getNumber(), is(1)); assertThat(event.getPullRequest().getNumber(), is(1)); @@ -198,8 +198,8 @@ public void pull_request() throws Exception { @Test public void pull_request_review() throws Exception { - GHEventPayload.PullRequestReview event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.PullRequestReview.class); + GHEventPayload.PullRequestReview event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReview.class); assertThat(event.getAction(), is("submitted")); assertThat(event.getReview().getId(), is(2626884L)); @@ -227,8 +227,8 @@ public void pull_request_review() throws Exception { @Test public void pull_request_review_comment() throws Exception { - GHEventPayload.PullRequestReviewComment event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.PullRequestReviewComment.class); + GHEventPayload.PullRequestReviewComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReviewComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getComment().getBody(), is("Maybe you should use more emojji on this line.")); @@ -285,8 +285,8 @@ public void push() throws Exception { @Test public void repository() throws Exception { - GHEventPayload.Repository event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Repository.class); + GHEventPayload.Repository event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Repository.class); assertThat(event.getAction(), is("created")); assertThat(event.getRepository().getName(), is("new-repository")); assertThat(event.getRepository().getOwner().getLogin(), is("baxterandthehackers")); diff --git a/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java b/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java index 89d5b0f3e6..83156723f4 100644 --- a/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java +++ b/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java @@ -21,9 +21,13 @@ public class GHGistUpdaterTest extends AbstractGitHubWireMockTest { @Before public void setUp() throws IOException { GHGistBuilder builder = new GHGistBuilder(gitHub); - gist = builder.description("Test for the API").file("unmodified.txt", "Should be unmodified") + gist = builder.description("Test for the API") + .file("unmodified.txt", "Should be unmodified") // .file("delete-me.txt", "To be deleted") - .file("rename-me.py", "print 'hello'").file("update-me.txt", "To be updated").public_(true).create(); + .file("rename-me.py", "print 'hello'") + .file("update-me.txt", "To be updated") + .public_(true) + .create(); } @After @@ -42,7 +46,8 @@ public void testGitUpdater() throws Exception { GHGist updatedGist = updater.description("Description updated by API") .addFile("new-file.txt", "Added by updater") // .deleteFile("delete-me.txt") - .renameFile("rename-me.py", "renamed.py").updateFile("update-me.txt", "Content updated by API") + .renameFile("rename-me.py", "renamed.py") + .updateFile("update-me.txt", "Content updated by API") .update(); assertEquals("Description updated by API", updatedGist.getDescription()); diff --git a/src/test/java/org/kohsuke/github/GHHookTest.java b/src/test/java/org/kohsuke/github/GHHookTest.java index 6fee386ca1..087560ef8b 100644 --- a/src/test/java/org/kohsuke/github/GHHookTest.java +++ b/src/test/java/org/kohsuke/github/GHHookTest.java @@ -58,8 +58,8 @@ public void exposeResponceHeaders() throws Exception { try { // fails because application isn't approved in organisation and you can find it only after doing real call - final GHHook hook = repository.createHook("my-hook", singletonMap("url", "http://localhost"), - singletonList(GHEvent.PUSH), true); + final GHHook hook = repository + .createHook("my-hook", singletonMap("url", "http://localhost"), singletonList(GHEvent.PUSH), true); } catch (IOException ex) { assertThat(ex, instanceOf(GHFileNotFoundException.class)); final GHFileNotFoundException ghFileNotFoundException = (GHFileNotFoundException) ex; diff --git a/src/test/java/org/kohsuke/github/GHOrganizationTest.java b/src/test/java/org/kohsuke/github/GHOrganizationTest.java index d9f693edee..808d3b91be 100644 --- a/src/test/java/org/kohsuke/github/GHOrganizationTest.java +++ b/src/test/java/org/kohsuke/github/GHOrganizationTest.java @@ -33,8 +33,10 @@ public void testCreateRepository() throws IOException { GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); GHRepository repository = org.createRepository(GITHUB_API_TEST, - "a test repository used to test kohsuke's github-api", "http://github-api.kohsuke.org/", - "Core Developers", true); + "a test repository used to test kohsuke's github-api", + "http://github-api.kohsuke.org/", + "Core Developers", + true); Assert.assertNotNull(repository); } @@ -45,7 +47,9 @@ public void testCreateRepositoryWithAutoInitialization() throws IOException { GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); GHRepository repository = org.createRepository(GITHUB_API_TEST) .description("a test repository used to test kohsuke's github-api") - .homepage("http://github-api.kohsuke.org/").team(org.getTeamByName("Core Developers")).autoInit(true) + .homepage("http://github-api.kohsuke.org/") + .team(org.getTeamByName("Core Developers")) + .autoInit(true) .create(); Assert.assertNotNull(repository); Assert.assertNotNull(repository.getReadme()); diff --git a/src/test/java/org/kohsuke/github/GHPullRequestTest.java b/src/test/java/org/kohsuke/github/GHPullRequestTest.java index 71ae5db660..4ee1750908 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestTest.java @@ -85,8 +85,10 @@ public void closePullRequest() throws Exception { public void pullRequestReviews() throws Exception { String name = "testPullRequestReviews"; GHPullRequest p = getRepository().createPullRequest(name, "test/stable", "master", "## test"); - GHPullRequestReview draftReview = p.createReview().body("Some draft review") - .comment("Some niggle", "README.md", 1).create(); + GHPullRequestReview draftReview = p.createReview() + .body("Some draft review") + .comment("Some niggle", "README.md", 1) + .create(); assertThat(draftReview.getState(), is(GHPullRequestReviewState.PENDING)); assertThat(draftReview.getBody(), is("Some draft review")); assertThat(draftReview.getCommitId(), notNullValue()); @@ -156,13 +158,17 @@ public void testPullRequestTeamReviewRequests() throws Exception { int baseRequestCount = mockGitHub.getRequestCount(); p.refresh(); assertThat("We should not eagerly load organizations for teams", - mockGitHub.getRequestCount() - baseRequestCount, equalTo(1)); + mockGitHub.getRequestCount() - baseRequestCount, + equalTo(1)); assertThat(p.getRequestedTeams().size(), equalTo(1)); assertThat("We should not eagerly load organizations for teams", - mockGitHub.getRequestCount() - baseRequestCount, equalTo(1)); + mockGitHub.getRequestCount() - baseRequestCount, + equalTo(1)); assertThat("Org should be queried for automatically if asked for", - p.getRequestedTeams().get(0).getOrganization(), notNullValue()); - assertThat("Request count should show lazy load occurred", mockGitHub.getRequestCount() - baseRequestCount, + p.getRequestedTeams().get(0).getOrganization(), + notNullValue()); + assertThat("Request count should show lazy load occurred", + mockGitHub.getRequestCount() - baseRequestCount, equalTo(2)); } @@ -224,8 +230,13 @@ public void updateContentSquashMerge() throws Exception { GHContentUpdateResponse response = getRepository().createContent(name, name, name, branchName); Thread.sleep(1000); - getRepository().createContent().content(name + name).path(name).branch(branchName).message(name) - .sha(response.getContent().getSha()).commit(); + getRepository().createContent() + .content(name + name) + .path(name) + .branch(branchName) + .message(name) + .sha(response.getContent().getSha()) + .commit(); GHPullRequest p = getRepository().createPullRequest(name, branchName, "master", "## test squash"); Thread.sleep(1000); p.merge("squash merge", null, GHPullRequest.MergeMethod.SQUASH); @@ -239,8 +250,12 @@ public void queryPullRequestsQualifiedHead() throws Exception { repo.createPullRequest("queryPullRequestsQualifiedHead_rc", "test/rc", "master", null); // Query by one of the heads and make sure we only get that branch's PR back. - List prs = repo.queryPullRequests().state(GHIssueState.OPEN) - .head("github-api-test-org:test/stable").base("master").list().asList(); + List prs = repo.queryPullRequests() + .state(GHIssueState.OPEN) + .head("github-api-test-org:test/stable") + .base("master") + .list() + .asList(); assertNotNull(prs); assertEquals(1, prs.size()); assertEquals("test/stable", prs.get(0).getHead().getRef()); @@ -254,8 +269,12 @@ public void queryPullRequestsUnqualifiedHead() throws Exception { repo.createPullRequest("queryPullRequestsUnqualifiedHead_rc", "test/rc", "master", null); // Query by one of the heads and make sure we only get that branch's PR back. - List prs = repo.queryPullRequests().state(GHIssueState.OPEN).head("test/stable").base("master") - .list().asList(); + List prs = repo.queryPullRequests() + .state(GHIssueState.OPEN) + .head("test/stable") + .base("master") + .list() + .asList(); assertNotNull(prs); assertEquals(1, prs.size()); assertEquals("test/stable", prs.get(0).getHead().getRef()); diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 306d4e0183..9eb62c8d8e 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -56,7 +56,7 @@ public void getBranchNonExistentBut200Status() throws Exception { // Manually changed the returned status to 200 so dont take a new snapshot this.snapshotNotAllowed(); - //This should *never* happen but with mocking it was discovered + // This should *never* happen but with mocking it was discovered GHRepository repo = getRepository(); try { GHBranch branch = repo.getBranch("test/NonExistent"); @@ -219,8 +219,11 @@ public void listEmptyContributors() throws IOException { @Test public void searchRepositories() throws Exception { - PagedSearchIterable r = gitHub.searchRepositories().q("tetris").language("assembly") - .sort(GHRepositorySearchBuilder.Sort.STARS).list(); + PagedSearchIterable r = gitHub.searchRepositories() + .q("tetris") + .language("assembly") + .sort(GHRepositorySearchBuilder.Sort.STARS) + .list(); GHRepository u = r.iterator().next(); // System.out.println(u.getName()); assertNotNull(u.getId()); @@ -301,7 +304,8 @@ public void testSetTopics() throws Exception { topics.add("java"); topics.add("api-test-dummy"); repo.setTopics(topics); - assertThat("Topics retain input order (are not sort when stored)", repo.listTopics(), + assertThat("Topics retain input order (are not sort when stored)", + repo.listTopics(), contains("java", "api-test-dummy")); topics = new ArrayList<>(); @@ -309,14 +313,16 @@ public void testSetTopics() throws Exception { topics.add("api-test-dummy"); topics.add("java"); repo.setTopics(topics); - assertThat("Topics behave as a set and retain order from previous calls", repo.listTopics(), + assertThat("Topics behave as a set and retain order from previous calls", + repo.listTopics(), contains("java", "api-test-dummy", "ordered-state")); topics = new ArrayList<>(); topics.add("ordered-state"); topics.add("api-test-dummy"); repo.setTopics(topics); - assertThat("Topics retain order even when some are removed", repo.listTopics(), + assertThat("Topics retain order even when some are removed", + repo.listTopics(), contains("api-test-dummy", "ordered-state")); topics = new ArrayList<>(); diff --git a/src/test/java/org/kohsuke/github/LifecycleTest.java b/src/test/java/org/kohsuke/github/LifecycleTest.java index ad892a1de5..fc8ed64244 100644 --- a/src/test/java/org/kohsuke/github/LifecycleTest.java +++ b/src/test/java/org/kohsuke/github/LifecycleTest.java @@ -25,19 +25,30 @@ public void testCreateRepository() throws IOException, GitAPIException, Interrup repository.delete(); Thread.sleep(1000); } - repository = org.createRepository("github-api-test", "a test repository used to test kohsuke's github-api", - "http://github-api.kohsuke.org/", "Core Developers", true); + repository = org.createRepository("github-api-test", + "a test repository used to test kohsuke's github-api", + "http://github-api.kohsuke.org/", + "Core Developers", + true); Thread.sleep(1000); // wait for the repository to become ready assertTrue(repository.getReleases().isEmpty()); try { GHMilestone milestone = repository.createMilestone("Initial Release", "first one"); - GHIssue issue = repository.createIssue("Test Issue").body("issue body just for grins").milestone(milestone) - .assignee(myself).label("bug").create(); + GHIssue issue = repository.createIssue("Test Issue") + .body("issue body just for grins") + .milestone(milestone) + .assignee(myself) + .label("bug") + .create(); File repoDir = new File(System.getProperty("java.io.tmpdir"), "github-api-test"); delete(repoDir); - Git origin = Git.cloneRepository().setBare(false).setURI(repository.getSshUrl()).setDirectory(repoDir) - .setCredentialsProvider(getCredentialsProvider(myself)).call(); + Git origin = Git.cloneRepository() + .setBare(false) + .setURI(repository.getSshUrl()) + .setDirectory(repoDir) + .setCredentialsProvider(getCredentialsProvider(myself)) + .call(); commitTestFile(myself, repoDir, origin); @@ -74,8 +85,10 @@ private GHAsset uploadAsset(GHRelease release) throws IOException { } private GHRelease createRelease(GHRepository repository) throws IOException { - GHRelease builder = repository.createRelease("release_tag").name("Test Release") - .body("How exciting! To be able to programmatically create releases is a dream come true!").create(); + GHRelease builder = repository.createRelease("release_tag") + .name("Test Release") + .body("How exciting! To be able to programmatically create releases is a dream come true!") + .create(); List releases = repository.getReleases(); assertEquals(1, releases.size()); GHRelease release = releases.get(0); diff --git a/src/test/java/org/kohsuke/github/PayloadRule.java b/src/test/java/org/kohsuke/github/PayloadRule.java index 6a24a8e5c2..665186a361 100644 --- a/src/test/java/org/kohsuke/github/PayloadRule.java +++ b/src/test/java/org/kohsuke/github/PayloadRule.java @@ -44,7 +44,8 @@ public void evaluate() throws Throwable { } public InputStream asInputStream() throws FileNotFoundException { - String name = resourceName.startsWith("/") ? resourceName + type + String name = resourceName.startsWith("/") + ? resourceName + type : testClass.getSimpleName() + "/" + resourceName + type; InputStream stream = testClass.getResourceAsStream(name); if (stream == null) { diff --git a/src/test/java/org/kohsuke/github/RepositoryMockTest.java b/src/test/java/org/kohsuke/github/RepositoryMockTest.java index 5805ba66ec..6e8969adae 100644 --- a/src/test/java/org/kohsuke/github/RepositoryMockTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryMockTest.java @@ -39,7 +39,7 @@ public void listCollaborators() throws Exception { user2.login = "login2"; when(iterator.hasNext()).thenReturn(true, false, true); - when(iterator.next()).thenReturn(new GHUser[] { user1 }, new GHUser[] { user2 }); + when(iterator.next()).thenReturn(new GHUser[]{ user1 }, new GHUser[]{ user2 }); Requester requester = Mockito.mock(Requester.class); when(mockGitHub.retrieve()).thenReturn(requester); diff --git a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java index b921d5ea4d..4ba98b0a7c 100644 --- a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java @@ -91,7 +91,8 @@ private void testTraffic(T expectedResult) throw @Test public void testGetViews() throws IOException { - GHRepositoryViewTraffic expectedResult = new GHRepositoryViewTraffic(21523359, 65534, + GHRepositoryViewTraffic expectedResult = new GHRepositoryViewTraffic(21523359, + 65534, Arrays.asList(new GHRepositoryViewTraffic.DailyInfo("2016-10-10T00:00:00Z", 3, 2), new GHRepositoryViewTraffic.DailyInfo("2016-10-11T00:00:00Z", 9, 4), new GHRepositoryViewTraffic.DailyInfo("2016-10-12T00:00:00Z", 27, 8), @@ -112,7 +113,8 @@ public void testGetViews() throws IOException { @Test public void testGetClones() throws IOException { - GHRepositoryCloneTraffic expectedResult = new GHRepositoryCloneTraffic(1500, 455, + GHRepositoryCloneTraffic expectedResult = new GHRepositoryCloneTraffic(1500, + 455, Arrays.asList(new GHRepositoryCloneTraffic.DailyInfo("2016-10-10T00:00:00Z", 10, 3), new GHRepositoryCloneTraffic.DailyInfo("2016-10-11T00:00:00Z", 20, 6), new GHRepositoryCloneTraffic.DailyInfo("2016-10-12T00:00:00Z", 30, 5), diff --git a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java index 975881ac71..ca69393c24 100644 --- a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java +++ b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java @@ -25,7 +25,8 @@ public void user_whenProxying_AuthCorrectlyConfigured() throws Exception { assertThat( "GitHub connection believes it is anonymous. Make sure you set GITHUB_OAUTH or both GITHUB_USER and GITHUB_PASSWORD environment variables", - gitHub.isAnonymous(), is(false)); + gitHub.isAnonymous(), + is(false)); assertThat(gitHub.login, not(equalTo(STUBBED_USER_LOGIN))); @@ -80,7 +81,7 @@ public void BasicBehaviors_whenNotProxying() throws Exception { e = ex; } - assertThat(e, Matchers. instanceOf(GHFileNotFoundException.class)); + assertThat(e, Matchers.instanceOf(GHFileNotFoundException.class)); assertThat(e.getMessage(), containsString("Request was not matched")); // Invalid repository, without stub - fails 404 when not proxying @@ -92,7 +93,7 @@ public void BasicBehaviors_whenNotProxying() throws Exception { e = ex; } - assertThat(e, Matchers. instanceOf(GHFileNotFoundException.class)); + assertThat(e, Matchers.instanceOf(GHFileNotFoundException.class)); assertThat(e.getMessage(), containsString("Request was not matched")); } @@ -120,9 +121,9 @@ public void BasicBehaviors_whenProxying() throws Exception { e = ex; } - assertThat(e, Matchers. instanceOf(GHFileNotFoundException.class)); - assertThat(e.getMessage(), equalTo( - "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}")); + assertThat(e, Matchers.instanceOf(GHFileNotFoundException.class)); + assertThat(e.getMessage(), + equalTo("{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}")); } @Test diff --git a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java index 5992bf84c8..a60221f8d4 100644 --- a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java +++ b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java @@ -108,7 +108,8 @@ public void OkHttpConnector_NoCache() throws Exception { OkHttpClient client = createClient(false); OkHttpConnector connector = new OkHttpConnector(client); - this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).withConnector(connector) + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) .build(); doTestActions(); @@ -133,7 +134,8 @@ public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client, -1); - this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).withConnector(connector) + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) .build(); doTestActions(); @@ -163,7 +165,8 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client, 3); - this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).withConnector(connector) + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) .build(); doTestActions(); @@ -187,7 +190,8 @@ public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client); - this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).withConnector(connector) + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) .build(); doTestActions(); @@ -207,7 +211,8 @@ private void checkRequestAndLimit(int networkRequestCount, int rateLimitUsed) th assertThat("Request Count", getRequestCount(), is(networkRequestCount + userRequestCount)); // Rate limit must be under this value, but if it wiggles we don't care - assertThat("Rate Limit Change", rateLimitBefore.remaining - rateLimitAfter.remaining, + assertThat("Rate Limit Change", + rateLimitBefore.remaining - rateLimitAfter.remaining, is(lessThanOrEqualTo(rateLimitUsed + userRequestCount))); } diff --git a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java index 47600bf0aa..66f1c04e7b 100644 --- a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java @@ -94,11 +94,15 @@ protected void before() { protected void after() { super.after(); if (isTakeSnapshot()) { - this.apiServer().snapshotRecord(recordSpec().forTarget("https://api.github.com") - .captureHeader("If-None-Match").extractTextBodiesOver(255)); + this.apiServer() + .snapshotRecord(recordSpec().forTarget("https://api.github.com") + .captureHeader("If-None-Match") + .extractTextBodiesOver(255)); - this.rawServer().snapshotRecord(recordSpec().forTarget("https://raw.githubusercontent.com") - .captureHeader("If-None-Match").extractTextBodiesOver(255)); + this.rawServer() + .snapshotRecord(recordSpec().forTarget("https://raw.githubusercontent.com") + .captureHeader("If-None-Match") + .extractTextBodiesOver(255)); // After taking the snapshot, format the output formatJsonFiles(new File(this.apiServer().getOptions().filesRoot().getPath()).toPath()); @@ -118,7 +122,10 @@ public static int getRequestCount(WireMockServer server) { private void formatJsonFiles(Path path) { // The more consistent we can make the json output the more meaningful it will be. - Gson g = new Gson().newBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting() + Gson g = new Gson().newBuilder() + .serializeNulls() + .disableHtmlEscaping() + .setPrettyPrinting() .registerTypeAdapter(Double.class, new JsonSerializer() { @Override public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) { @@ -128,7 +135,8 @@ public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContex return new JsonPrimitive(src.longValue()); return new JsonPrimitive(src); } - }).create(); + }) + .create(); try { Files.walk(path).forEach(filePath -> { diff --git a/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java b/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java index f11b4ca025..81e1a958d8 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java @@ -88,7 +88,8 @@ protected final void initializeServer(String serverId, Extension... extensions) directoryName += "_" + serverId; } - final Options localOptions = new WireMockRuleConfiguration(WireMockMultiServerRule.this.options, directoryName, + final Options localOptions = new WireMockRuleConfiguration(WireMockMultiServerRule.this.options, + directoryName, extensions); new File(localOptions.filesRoot().getPath(), "mappings").mkdirs();