From cbd06eef96d97865159dd80630ba3098c6cfd517 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Fri, 15 Nov 2019 15:36:49 -0800 Subject: [PATCH] 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 ebef1967f..30079d0a2 100644 --- a/src/main/java/org/kohsuke/github/DeleteToken.java +++ b/src/main/java/org/kohsuke/github/DeleteToken.java @@ -28,7 +28,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** * @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 43291820b..29830425b 100644 --- a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java +++ b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java @@ -55,7 +55,9 @@ public class GHAppCreateTokenBuilder { @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 7d9254344..c82584096 100644 --- a/src/main/java/org/kohsuke/github/GHEvent.java +++ b/src/main/java/org/kohsuke/github/GHEvent.java @@ -10,12 +10,50 @@ import java.util.Locale; * @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 71a95639e..acee6d5c0 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -179,7 +179,7 @@ public class GHIssue extends GHObject implements Reactable { if (labels == null) { return Collections.emptyList(); } - return Collections. unmodifiableList(labels); + return Collections.unmodifiableList(labels); } /** @@ -231,8 +231,8 @@ public class GHIssue extends GHObject implements Reactable { */ @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 class GHIssue extends GHObject implements Reactable { * 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 class GHIssue extends GHObject implements Reactable { * 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 class GHIssue extends GHObject implements Reactable { * 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 class GHIssue extends GHObject implements Reactable { /** * 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 @@ public class GHIssue extends GHObject implements Reactable { * 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 831309b88..e4256854d 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -392,8 +392,8 @@ public class GHPullRequest extends GHIssue implements Refreshable { * @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 class GHPullRequest extends GHIssue implements Refreshable { * @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 class GHPullRequest extends GHIssue implements Refreshable { * 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 class GHPullRequest extends GHIssue implements Refreshable { * @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 class GHPullRequest extends GHIssue implements Refreshable { * 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 class GHPullRequest extends GHIssue implements Refreshable { * 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 class GHPullRequest extends GHIssue implements Refreshable { */ 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 class GHPullRequest extends GHIssue implements Refreshable { * 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 class GHPullRequest extends GHIssue implements Refreshable { * 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 1a86bf407..65e60533e 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -723,8 +723,9 @@ class Requester { 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 @@ class Requester { 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 @@ class Requester { // 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 ea39c8e00..aaec14d1b 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 final class ReadOnlyObjects { @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 32f2e0157..9ee51407a 100644 --- a/src/test/java/org/kohsuke/HookApp.java +++ b/src/test/java/org/kohsuke/HookApp.java @@ -26,8 +26,8 @@ public class HookApp { 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 eb9f96be7..980f3c8f6 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 class GHAppTest extends AbstractGitHubWireMockTest { 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 8717d6775..ee6c62695 100644 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -48,9 +48,14 @@ public class GHBranchProtectionTest extends AbstractGitHubApiTestBase { @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 32e0f0090..9b3d9334f 100644 --- a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java +++ b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java @@ -73,7 +73,8 @@ public class GHContentIntegrationTest extends AbstractGitHubWireMockTest { @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 4f3b92a07..481396a48 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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 class GHEventPayloadTest { @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 89d5b0f3e..83156723f 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 class GHGistUpdaterTest extends AbstractGitHubWireMockTest { 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 6fee386ca..087560ef8 100644 --- a/src/test/java/org/kohsuke/github/GHHookTest.java +++ b/src/test/java/org/kohsuke/github/GHHookTest.java @@ -58,8 +58,8 @@ public class GHHookTest { 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 d9f693ede..808d3b91b 100644 --- a/src/test/java/org/kohsuke/github/GHOrganizationTest.java +++ b/src/test/java/org/kohsuke/github/GHOrganizationTest.java @@ -33,8 +33,10 @@ public class GHOrganizationTest extends AbstractGitHubWireMockTest { 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 class GHOrganizationTest extends AbstractGitHubWireMockTest { 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 71ae5db66..4ee175090 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestTest.java @@ -85,8 +85,10 @@ public class GHPullRequestTest extends AbstractGitHubWireMockTest { 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 class GHPullRequestTest extends AbstractGitHubWireMockTest { 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 class GHPullRequestTest extends AbstractGitHubWireMockTest { 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 class GHPullRequestTest extends AbstractGitHubWireMockTest { 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 class GHPullRequestTest extends AbstractGitHubWireMockTest { 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 306d4e018..9eb62c8d8 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -56,7 +56,7 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest { // 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 class GHRepositoryTest extends AbstractGitHubWireMockTest { @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 class GHRepositoryTest extends AbstractGitHubWireMockTest { 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 class GHRepositoryTest extends AbstractGitHubWireMockTest { 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 ad892a1de..fc8ed6424 100644 --- a/src/test/java/org/kohsuke/github/LifecycleTest.java +++ b/src/test/java/org/kohsuke/github/LifecycleTest.java @@ -25,19 +25,30 @@ public class LifecycleTest extends AbstractGitHubApiTestBase { 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 @@ public class LifecycleTest extends AbstractGitHubApiTestBase { } 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 6a24a8e5c..665186a36 100644 --- a/src/test/java/org/kohsuke/github/PayloadRule.java +++ b/src/test/java/org/kohsuke/github/PayloadRule.java @@ -44,7 +44,8 @@ public class PayloadRule implements TestRule { } 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 5805ba66e..6e8969ada 100644 --- a/src/test/java/org/kohsuke/github/RepositoryMockTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryMockTest.java @@ -39,7 +39,7 @@ public class RepositoryMockTest { 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 b921d5ea4..4ba98b0a7 100644 --- a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java @@ -91,7 +91,8 @@ public class RepositoryTrafficTest extends AbstractGitHubApiTestBase { @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 class RepositoryTrafficTest extends AbstractGitHubApiTestBase { @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 975881ac7..ca69393c2 100644 --- a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java +++ b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java @@ -25,7 +25,8 @@ public class WireMockStatusReporterTest extends AbstractGitHubWireMockTest { 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 class WireMockStatusReporterTest extends AbstractGitHubWireMockTest { 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 class WireMockStatusReporterTest extends AbstractGitHubWireMockTest { 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 class WireMockStatusReporterTest extends AbstractGitHubWireMockTest { 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 5992bf84c..a60221f8d 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 class OkHttpConnectorTest extends AbstractGitHubWireMockTest { 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 class OkHttpConnectorTest extends AbstractGitHubWireMockTest { 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 class OkHttpConnectorTest extends AbstractGitHubWireMockTest { 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 class OkHttpConnectorTest extends AbstractGitHubWireMockTest { 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 @@ public class OkHttpConnectorTest extends AbstractGitHubWireMockTest { 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 47600bf0a..66f1c04e7 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 @@ public class GitHubWireMockRule extends WireMockMultiServerRule { 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 class GitHubWireMockRule extends WireMockMultiServerRule { 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 class GitHubWireMockRule extends WireMockMultiServerRule { 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 f11b4ca02..81e1a958d 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 @@ public class WireMockMultiServerRule implements MethodRule, TestRule { 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();