diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c4c873a2..d2c1b2a7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -36,17 +36,17 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 - + uses: actions/checkout@v4 + - name: Setup Java JDK - uses: actions/setup-java@v2.3.1 + uses: actions/setup-java@v4 with: - java-version: 11 - distribution: 'adopt' - + java-version: 17 + distribution: 'temurin' + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -57,7 +57,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) # - name: Autobuild - # uses: github/codeql-action/autobuild@v2 + # uses: github/codeql-action/autobuild@v3 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -65,9 +65,9 @@ jobs: # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language - + - name: Build with Maven run: mvn -DskipTests=true -V -ntp install - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/jenkins-security-scan.yml b/.github/workflows/jenkins-security-scan.yml index c7b41fc2..4a1c89b9 100644 --- a/.github/workflows/jenkins-security-scan.yml +++ b/.github/workflows/jenkins-security-scan.yml @@ -15,7 +15,7 @@ permissions: jobs: security-scan: - uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2 + uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2.2.1 with: java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate. - # java-version: 21 # Optionally specify what version of Java to set up for the build, or remove to use a recent default. + java-version: 17 # Specify Java 17 to match the project requirements diff --git a/Jenkinsfile b/Jenkinsfile index bcbc20c2..8a2983d1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,11 @@ +/* + See the documentation for more options: + https://github.com/jenkins-infra/pipeline-library/ +*/ buildPlugin( + forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests configurations: [ - [platform: 'linux', jdk: 17], + [platform: 'linux', jdk: 21], [platform: 'windows', jdk: 17], -]) - +]) \ No newline at end of file diff --git a/pom.xml b/pom.xml index c1cf90ba..9729b77c 100644 --- a/pom.xml +++ b/pom.xml @@ -18,13 +18,12 @@ 2.440 ${jenkins.baseline}.3 - 2.0.0 2.9.0 17 Bitbucket Push and Pull Request Plugin - Bitbucket plugin for Jenkins v2.138.2 or later, allowing push and pull requests + Bitbucket plugin for Jenkins allowing push and pull requests @@ -192,13 +191,6 @@ mockito-junit-jupiter test - - org.mockito - mockito-inline - 5.2.0 - test - - https://github.com/jenkinsci/bitbucket-push-and-pull-request-plugin @@ -213,13 +205,13 @@ repo.jenkins-ci.org - https://repo.jenkins.io/public/ + https://repo.jenkins-ci.org/public/ repo.jenkins-ci.org - https://repo.jenkins.io/public/ + https://repo.jenkins-ci.org/public/ @@ -243,5 +235,4 @@ - diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbe.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbe.java index 392e0eae..7c65edde 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbe.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbe.java @@ -55,7 +55,7 @@ import org.eclipse.jgit.transport.URIish; /** - * + * * @author cdelmonte * */ @@ -92,7 +92,7 @@ public void triggerMatchingJobs(BitBucketPPRHookEvent bitbucketEvent, List remoteScmUrls = bitbucketAction.getScmUrls().stream().map(makeUrl) .filter(Objects::nonNull).collect(Collectors.toList()); - try (ACLContext ctx = ACL.as(ACL.SYSTEM)) { + try (ACLContext ctx = ACL.as2(ACL.SYSTEM2)) { if (globalConfig.isSingleJobSet()) { try { Job job = (Job) Jenkins.get().getItemByFullName(globalConfig.getSingleJob()); @@ -159,7 +159,7 @@ && mPJobShouldNotBeTriggered(job, bitbucketEvent, bitbucketAction)) { return; } - Predicate checkSCM = (url) -> scm instanceof GitSCM && matchGitScm(scm, url); + Predicate checkSCM = url -> scm instanceof GitSCM && matchGitScm(scm, url); if (remotes.stream().anyMatch(checkSCM) && !scmTriggered.contains(scm)) { scmTriggered.add(scm); @@ -230,11 +230,9 @@ private boolean mPJobShouldNotBeTriggered(Job job, BitBucketPPRHookEvent b } private Optional getBitBucketTrigger(Job job) { - if (job instanceof ParameterizedJobMixIn.ParameterizedJob) { - ParameterizedJobMixIn.ParameterizedJob pJob = - (ParameterizedJobMixIn.ParameterizedJob) job; + if (job instanceof ParameterizedJobMixIn.ParameterizedJob pJob) { - return pJob.getTriggers().values().stream().filter(BitBucketPPRTrigger.class::isInstance) + return pJob.getTriggers().values().stream().filter(BitBucketPPRTrigger.class::isInstance) .findFirst().map(BitBucketPPRTrigger.class::cast); } return Optional.empty(); diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRPollResultListener.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRPollResultListener.java index 6519e39b..94c99422 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRPollResultListener.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRPollResultListener.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -26,7 +26,7 @@ public interface BitBucketPPRPollResultListener { - public void onPollSuccess(PollingResult pollingResult); + void onPollSuccess(PollingResult pollingResult); - public void onPollError(Throwable throwable); + void onPollError(Throwable throwable); } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRTrigger.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRTrigger.java index 7b208668..9e5dba6d 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRTrigger.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRTrigger.java @@ -27,17 +27,16 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.logging.Logger; import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import io.jenkins.plugins.bitbucketpushandpullrequest.action.*; import org.apache.commons.jelly.XMLOutput; import org.eclipse.jgit.transport.URIish; import org.jenkinsci.Symbol; -import org.jenkinsci.plugins.plaincredentials.StringCredentials; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -45,7 +44,6 @@ import com.cloudbees.plugins.credentials.CredentialsMatchers; import com.cloudbees.plugins.credentials.common.StandardCredentials; import com.cloudbees.plugins.credentials.common.StandardListBoxModel; -import com.cloudbees.plugins.credentials.domains.DomainRequirement; import hudson.Extension; import hudson.Util; import hudson.console.AnnotatedLargeText; @@ -54,7 +52,6 @@ import hudson.model.Job; import hudson.model.Queue; import hudson.model.Run; -import hudson.model.Build; import hudson.model.queue.QueueTaskFuture; import hudson.plugins.git.RevisionParameterAction; import hudson.scm.PollingResult; @@ -65,7 +62,6 @@ import hudson.util.ListBoxModel; import hudson.util.SequentialExecutionQueue; import io.jenkins.plugins.bitbucketpushandpullrequest.cause.BitBucketPPRTriggerCause; -import io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRUtils; import io.jenkins.plugins.bitbucketpushandpullrequest.event.BitBucketPPREventContext; import io.jenkins.plugins.bitbucketpushandpullrequest.event.BitBucketPPREventFactory; import io.jenkins.plugins.bitbucketpushandpullrequest.event.BitBucketPPREventType; @@ -152,7 +148,7 @@ public void onPost( @Override public void onPollSuccess(PollingResult pollingResult) { - matchingFilters.stream() + matchingFilters .forEach( filter -> { try { @@ -254,7 +250,7 @@ private void scheduleJob( if (f == null) return; try { - Run startedBuild = (Run) f.waitForStart(); + Run startedBuild = f.waitForStart(); logger.info(String.format("Triggering %s # %d", job.getName(), startedBuild.getNumber())); @@ -264,7 +260,7 @@ private void scheduleJob( new BitBucketPPREventContext( this, bitbucketAction, scmTrigger, startedBuild, filter))); - Run run = (Run) f.get(); + Run run = f.get(); if (f.isDone()) { observable.notifyObservers( @@ -330,8 +326,8 @@ public String getLog() throws Exception { value = "RV_RETURN_VALUE_IGNORED", justification = "I know what I'm doing") public void writeLogTo(XMLOutput out) throws Exception { - new AnnotatedLargeText( - getLogFile(), Charset.defaultCharset(), true, this) + new AnnotatedLargeText<>( + getLogFile(), Charset.defaultCharset(), true, this) .writeHtmlTo(0, out.asWriter()); } } @@ -355,10 +351,10 @@ public ListBoxModel doFillCredentialsIdItems( return new StandardListBoxModel() .includeEmptyValue() .includeMatchingAs( - ACL.SYSTEM, + ACL.SYSTEM2, context, StandardCredentials.class, - Collections.emptyList(), + Collections.emptyList(), CredentialsMatchers.always()) .includeCurrentValue(credentialsId); } @@ -370,6 +366,7 @@ public boolean isApplicable(Item item) { && item instanceof ParameterizedJobMixIn.ParameterizedJob; } + @NonNull @Override public String getDisplayName() { return "Build with BitBucket Push and Pull Request Plugin"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRAction.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRAction.java index bc06aa96..eb65e6dc 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRAction.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRAction.java @@ -29,116 +29,116 @@ public interface BitBucketPPRAction extends Action { - public BitBucketPPRPayload getPayload(); + BitBucketPPRPayload getPayload(); - public String getScm(); + String getScm(); - public default String getLinkHtml() { + default String getLinkHtml() { return null; } - public default String getLinkSelf() { + default String getLinkSelf() { return null; } - public default String getLinkApprove() throws MalformedURLException { + default String getLinkApprove() throws MalformedURLException { return null; } - public default String getLinkDecline() throws MalformedURLException { + default String getLinkDecline() throws MalformedURLException { return null; } - public default String getLinkStatuses() { + default String getLinkStatuses() { return null; } - public default String getUser() { + default String getUser() { return null; } - public default String getSourceBranch() { + default String getSourceBranch() { return null; } - public default String getTargetBranch() { + default String getTargetBranch() { return null; } - public default String getTargetBranchRefId() { + default String getTargetBranchRefId() { return null; } - public default String getType() { + default String getType() { return null; } - public default String getRepositoryName() { + default String getRepositoryName() { return null; } // TODO: do we really neeed it? - public default List getScmUrls() { + default List getScmUrls() { return null; } - public default String getPullRequestId() { + default String getPullRequestId() { return null; } - public default String getRepositoryId() { + default String getRepositoryId() { return null; } - public default String getRepositoryUrl() { + default String getRepositoryUrl() { return null; } - public default String getProjectUrl() { + default String getProjectUrl() { return null; } - public default String getPullRequestApiUrl() { + default String getPullRequestApiUrl() { return null; } - public default String getPullRequestUrl() { + default String getPullRequestUrl() { return null; } - public default String getTitle() { + default String getTitle() { return null; } - public default String getDescription() { + default String getDescription() { return null; } - public default String getComment() { + default String getComment() { return null; } - public default String getServerComment() { + default String getServerComment() { return null; } - public default String getLatestCommit() { + default String getLatestCommit() { return null; } - public default String getCommitLink() throws MalformedURLException { + default String getCommitLink() throws MalformedURLException { return null; } - public default List getCommitLinks() throws MalformedURLException { + default List getCommitLinks() throws MalformedURLException { return null; } - public default String getLatestCommitFromRef() { + default String getLatestCommitFromRef() { return null; } - public default String getLatestCommitToRef() { + default String getLatestCommitToRef() { return null; } } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestAction.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestAction.java index 02101ed3..33e8cd10 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestAction.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestAction.java @@ -21,6 +21,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.action; +import edu.umd.cs.findbugs.annotations.NonNull; import io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRUtils; import io.jenkins.plugins.bitbucketpushandpullrequest.exception.BitBucketPPRRepositoryNotParsedException; @@ -127,6 +128,7 @@ public String getDescription() { return payload.getPullRequest().getDescription(); } + @NonNull @Override public BitBucketPPRPayload getPayload() { return payload; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerAction.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerAction.java index f967635d..22be8294 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerAction.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerAction.java @@ -21,6 +21,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.action; +import edu.umd.cs.findbugs.annotations.NonNull; import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; import io.jenkins.plugins.bitbucketpushandpullrequest.exception.BitBucketPPRPayloadPropertyNotFoundException; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRHookEvent; @@ -148,6 +149,7 @@ public String getTitle() { return payload.getServerPullRequest().getTitle(); } + @NonNull @Override public BitBucketPPRPayload getPayload() { return payload; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRRepositoryAction.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRRepositoryAction.java index 57c45380..6ac88425 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRRepositoryAction.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRRepositoryAction.java @@ -21,6 +21,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.action; +import edu.umd.cs.findbugs.annotations.NonNull; import io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRUtils; import io.jenkins.plugins.bitbucketpushandpullrequest.exception.BitBucketPPRRepositoryNotParsedException; @@ -92,6 +93,7 @@ public String getRepositoryUrl() { return payload.getRepository().getLinks().getHtml().getHref(); } + @NonNull @Override public BitBucketPPRPayload getPayload() { return payload; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRServerRepositoryAction.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRServerRepositoryAction.java index 1a693180..fcc1e323 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRServerRepositoryAction.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRServerRepositoryAction.java @@ -21,7 +21,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.action; -import hudson.model.InvisibleAction; +import edu.umd.cs.findbugs.annotations.NonNull; import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.model.server.BitBucketPPRServerChange; @@ -50,7 +50,7 @@ public class BitBucketPPRServerRepositoryAction extends BitBucketPPRActionAbstra private String targetBranchRefId = null; private String type; - public BitBucketPPRServerRepositoryAction(BitBucketPPRPayload payload) { + public BitBucketPPRServerRepositoryAction(@NonNull BitBucketPPRPayload payload) { this.payload = payload; // TODO: do we need link clones or link self is enough?? @@ -97,6 +97,7 @@ public String getTargetBranchRefId() { return targetBranchRefId; } + @NonNull @Override public BitBucketPPRPayload getPayload() { return payload; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/BitBucketPPRTriggerCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/BitBucketPPRTriggerCause.java index 8892b007..d3dcd775 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/BitBucketPPRTriggerCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/BitBucketPPRTriggerCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -34,7 +34,7 @@ public class BitBucketPPRTriggerCause extends SCMTrigger.SCMTriggerCause { protected BitBucketPPRAction bitbucketAction; protected BitBucketPPRHookEvent bitBucketHookEvent; - public BitBucketPPRTriggerCause(File pollingLog, BitBucketPPRAction bitbucketAction, + public BitBucketPPRTriggerCause(File pollingLog, BitBucketPPRAction bitbucketAction, BitBucketPPRHookEvent bitBucketHookEvent) throws IOException { super(pollingLog); @@ -68,11 +68,8 @@ public boolean equals(Object obj) { return false; BitBucketPPRTriggerCause other = (BitBucketPPRTriggerCause) obj; if (bitbucketAction == null) { - if (other.bitbucketAction != null) - return false; - } else if (!bitbucketAction.equals(other.bitbucketAction)) - return false; - return true; + return other.bitbucketAction == null; + } else return bitbucketAction.equals(other.bitbucketAction); } @Override diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestApprovedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestApprovedCause.java index 37856ff6..4dcfe94a 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestApprovedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestApprovedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCause.java index 3a154889..85aba33e 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -41,7 +41,7 @@ public BitBucketPPRPullRequestCause(File pollingLog, BitBucketPPRAction bitbucke public BitBucketPPRPullRequestAction getPullRequestPayLoad() { return (BitBucketPPRPullRequestAction) super.getAction(); } - + @Override public String getShortDescription() { String pusher = bitbucketAction.getUser() != null ? bitbucketAction.getUser() : ""; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedCause.java index 7294402d..a3455697 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedCause.java index 56cfd54e..e71c9acb 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedCause.java index 01eea663..a4e89eef 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCreatedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCreatedCause.java index 28863a06..21608634 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCreatedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestCreatedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestDeclinedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestDeclinedCause.java index 2cf9ae58..616916ed 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestDeclinedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestDeclinedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestMergedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestMergedCause.java index 2e077e95..83820aee 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestMergedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestMergedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestUpdatedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestUpdatedCause.java index e301edf5..f7ba7c5b 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestUpdatedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/cloud/BitBucketPPRPullRequestUpdatedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerApprovedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerApprovedCause.java index bad0b62a..4b47cf74 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerApprovedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerApprovedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCause.java index 989e8021..e3f079dc 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -33,7 +33,7 @@ public class BitBucketPPRPullRequestServerCause extends BitBucketPPRTriggerCause { - public BitBucketPPRPullRequestServerCause(File pollingLog, BitBucketPPRAction bitbucketAction, + public BitBucketPPRPullRequestServerCause(File pollingLog, BitBucketPPRAction bitbucketAction, BitBucketPPRHookEvent bitBucketHookEvent) throws IOException { super(pollingLog, bitbucketAction, bitBucketHookEvent); diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedCause.java index d4bb17e9..db04274c 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCreatedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCreatedCause.java index da6248fb..b0d6fd10 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCreatedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerCreatedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerUpdatedCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerUpdatedCause.java index b4cef425..eed2b3ca 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerUpdatedCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/pullrequest/server/BitBucketPPRPullRequestServerUpdatedCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/repository/BitBucketPPRRepositoryCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/repository/BitBucketPPRRepositoryCause.java index c4a729b5..58af922d 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/repository/BitBucketPPRRepositoryCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/repository/BitBucketPPRRepositoryCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/repository/BitBucketPPRServerRepositoryCause.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/repository/BitBucketPPRServerRepositoryCause.java index df2daed9..7014ac8a 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/repository/BitBucketPPRServerRepositoryCause.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/cause/repository/BitBucketPPRServerRepositoryCause.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -31,7 +31,7 @@ public class BitBucketPPRServerRepositoryCause extends BitBucketPPRTriggerCause { - public BitBucketPPRServerRepositoryCause(File pollingLog, BitBucketPPRAction bitbucketAction, + public BitBucketPPRServerRepositoryCause(File pollingLog, BitBucketPPRAction bitbucketAction, BitBucketPPRHookEvent bitBucketHookEvent) throws IOException { super(pollingLog, bitbucketAction, bitBucketHookEvent); diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClient.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClient.java index 74217b1f..811bb064 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClient.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClient.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -23,7 +23,7 @@ import com.github.scribejava.core.model.Verb; public interface BitBucketPPRClient { - public void send(String url, String payload) throws Exception; - public void send(Verb verb, String url, String payload) throws Exception; - public void accept(BitBucketPPRClientVisitor visitor); + void send(String url, String payload) throws Exception; + void send(Verb verb, String url, String payload) throws Exception; + void accept(BitBucketPPRClientVisitor visitor); } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientCloudVisitor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientCloudVisitor.java index 2ca54e0e..f29a9da3 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientCloudVisitor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientCloudVisitor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2021, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -49,10 +49,10 @@ public void send(StandardCredentials credentials, String url, String payload) @Override public void send(StandardCredentials credentials, Verb verb, String url, String payload) throws InterruptedException, NoSuchMethodException { - if (credentials instanceof StandardUsernamePasswordCredentials) + if (credentials instanceof StandardUsernamePasswordCredentials usernamePasswordCredentials) try { final HttpResponse response = - this.send((StandardUsernamePasswordCredentials) credentials, verb, url, payload); + this.send(usernamePasswordCredentials, verb, url, payload); HttpEntity responseEntity = response.getEntity(); final String responseBody = responseEntity == null ? "empty" : EntityUtils.toString(responseEntity); @@ -62,16 +62,14 @@ public void send(StandardCredentials credentials, Verb verb, String url, String } catch (IOException e) { logger.log(Level.WARNING, "Error during state notification: {0} ", e.getMessage()); } - else if (credentials instanceof StringCredentials) { + else if (credentials instanceof StringCredentials stringCredentials) { try { - Response response = this.send((StringCredentials) credentials, verb, url, payload); + Response response = this.send(stringCredentials, verb, url, payload); logger.log(Level.FINEST, "Result of the state notification is: {0}, with status code: {1}", new Object[] {response.getBody(), response.getCode()}); } catch (ExecutionException | IOException e) { logger.log(Level.WARNING, "Error during state notification: {0} ", e.getMessage()); - } catch (InterruptedException e) { - throw e; } } else throw new NotImplementedException("Credentials provider for state notification not found"); diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientFactory.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientFactory.java index 8ca75686..844f1031 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientFactory.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientFactory.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientServerVisitor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientServerVisitor.java index fd24c676..762088f0 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientServerVisitor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientServerVisitor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -24,7 +24,6 @@ import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.util.concurrent.ExecutionException; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.lang.NotImplementedException; @@ -44,18 +43,18 @@ public class BitBucketPPRClientServerVisitor implements BitBucketPPRClientVisito @Override public void send(StandardCredentials credentials, String url, String payload) - throws InterruptedException, NoSuchMethodException { + throws NoSuchMethodException { send(credentials, Verb.POST, url, payload); } @Override public void send(StandardCredentials credentials, Verb verb, String url, String payload) - throws InterruptedException, NoSuchMethodException { + throws NoSuchMethodException { - if (credentials instanceof StandardUsernamePasswordCredentials) + if (credentials instanceof StandardUsernamePasswordCredentials usernamePasswordCredentials) try { final HttpResponse response = - this.send((StandardUsernamePasswordCredentials) credentials, verb, url, payload); + this.send(usernamePasswordCredentials, verb, url, payload); HttpEntity responseEntity = response.getEntity(); final String responseBody = responseEntity == null ? "empty" : EntityUtils.toString(responseEntity); @@ -65,17 +64,14 @@ public void send(StandardCredentials credentials, Verb verb, String url, String } catch (IOException e) { logger.log(Level.WARNING, "Error during state notification: {0} ", e.getMessage()); } - else if (credentials instanceof StringCredentials) + else if (credentials instanceof StringCredentials stringCredentials) try { - HttpResponse response = this.send((StringCredentials) credentials, verb, url, payload); + HttpResponse response = this.send(stringCredentials, verb, url, payload); logger.log(Level.FINEST, "Result of the state notification is: {0}, with status code: {1}", new Object[] {response.getEntity().getContent(), response.getStatusLine().getStatusCode()}); - } catch (ExecutionException | IOException | KeyManagementException | NoSuchAlgorithmException - | KeyStoreException e) { + } catch (IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) { logger.log(Level.WARNING, "Error du" + "ring state notification: {0} ", e.getMessage()); - } catch (InterruptedException e) { - throw e; } else throw new NotImplementedException("Credentials provider for state notification not found"); @@ -88,7 +84,7 @@ private HttpResponse send(StandardUsernamePasswordCredentials credentials, Verb } private HttpResponse send(StringCredentials credentials, Verb verb, String url, String payload) - throws InterruptedException, ExecutionException, IOException, KeyManagementException, + throws IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, NoSuchMethodException { logger.finest("Set BB StringCredentials for BB Server state notification"); diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientType.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientType.java index 5f9c4497..c565f807 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientType.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientType.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,5 +21,5 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.client; public enum BitBucketPPRClientType { - CLOUD, SERVER; + CLOUD, SERVER } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientVisitor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientVisitor.java index dfe1ea6b..38d067b9 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientVisitor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRClientVisitor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -25,10 +25,10 @@ import com.github.scribejava.core.model.Verb; public interface BitBucketPPRClientVisitor { - public void send(StandardCredentials credentials, String url, String payload) + void send(StandardCredentials credentials, String url, String payload) throws InterruptedException, IOException, NoSuchMethodException; - public void send(StandardCredentials credentials, Verb verb, String url, String payload) + void send(StandardCredentials credentials, Verb verb, String url, String payload) throws InterruptedException, NoSuchMethodException; } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRCloudClient.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRCloudClient.java index ab434aa5..94eb7198 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRCloudClient.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRCloudClient.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,7 +21,6 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.client; import com.github.scribejava.core.model.Verb; -import io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRUtils; import io.jenkins.plugins.bitbucketpushandpullrequest.event.BitBucketPPREventContext; @@ -45,7 +44,7 @@ public void send(final String url, String payload) throws Exception { @Override public void send(Verb verb, String url, String payload) throws Exception { - visitor.send(context.getStandardCredentials(), verb, url, payload); + visitor.send(context.getStandardCredentials(), verb, url, payload); } } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRServerClient.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRServerClient.java index 271aef1c..81c9855a 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRServerClient.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/BitBucketPPRServerClient.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,7 +21,6 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.client; import com.github.scribejava.core.model.Verb; -import io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRUtils; import io.jenkins.plugins.bitbucketpushandpullrequest.event.BitBucketPPREventContext; public class BitBucketPPRServerClient implements BitBucketPPRClient { diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRPluginConfig.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRPluginConfig.java index 3bf93965..e7ebc62b 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRPluginConfig.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRPluginConfig.java @@ -1,9 +1,23 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.config; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.logging.Logger; + +import javax.annotation.CheckForNull; + +import static org.apache.commons.lang3.StringUtils.isEmpty; +import org.kohsuke.stapler.AncestorInPath; +import org.kohsuke.stapler.DataBoundSetter; +import org.kohsuke.stapler.QueryParameter; +import org.kohsuke.stapler.StaplerRequest; + import com.cloudbees.plugins.credentials.CredentialsMatchers; import com.cloudbees.plugins.credentials.common.StandardCredentials; import com.cloudbees.plugins.credentials.common.StandardListBoxModel; -import com.cloudbees.plugins.credentials.domains.DomainRequirement; + +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.ExtensionList; import hudson.model.Item; @@ -13,18 +27,6 @@ import jenkins.model.GlobalConfiguration; import jenkins.model.Jenkins; import net.sf.json.JSONObject; -import org.kohsuke.stapler.AncestorInPath; -import org.kohsuke.stapler.DataBoundSetter; -import org.kohsuke.stapler.QueryParameter; -import org.kohsuke.stapler.StaplerRequest; - -import javax.annotation.CheckForNull; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collections; -import java.util.logging.Logger; - -import static org.apache.commons.lang3.StringUtils.isEmpty; @Extension public class BitBucketPPRPluginConfig extends GlobalConfiguration { @@ -106,7 +108,7 @@ public boolean isPropagationUrlSet() { } @DataBoundSetter - public void setNotifyBitBucket(@CheckForNull boolean notifyBitBucket) { + public void setNotifyBitBucket(boolean notifyBitBucket) { this.notifyBitBucket = notifyBitBucket; } @@ -115,7 +117,7 @@ public boolean getUseJobNameAsBuildKey() { } @DataBoundSetter - public void setUseJobNameAsBuildKey(@CheckForNull boolean useJobNameAsBuildKey) { + public void setUseJobNameAsBuildKey(boolean useJobNameAsBuildKey) { this.useJobNameAsBuildKey = useJobNameAsBuildKey; save(); } @@ -147,13 +149,14 @@ public String getSingleJob() { return singleJob; } + @NonNull @Override public String getDisplayName() { return "Bitbucket Push and Pull Request"; } @Override - public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { + public boolean configure(StaplerRequest req, JSONObject formData) { req.bindJSON(this, formData); save(); return true; @@ -172,10 +175,10 @@ public ListBoxModel doFillCredentialsIdItems( return new StandardListBoxModel() .includeEmptyValue() .includeMatchingAs( - ACL.SYSTEM, - Jenkins.getInstance(), + ACL.SYSTEM2, + Jenkins.get(), StandardCredentials.class, - Collections.emptyList(), + Collections.emptyList(), CredentialsMatchers.always()) .includeCurrentValue(credentialsId); } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/environment/BitBucketPPREnvironmentContributor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/environment/BitBucketPPREnvironmentContributor.java index 592f770a..2e7c2d63 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/environment/BitBucketPPREnvironmentContributor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/environment/BitBucketPPREnvironmentContributor.java @@ -21,10 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.environment; -import java.io.IOException; import java.util.List; import java.util.logging.Logger; import javax.annotation.Nonnull; + +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.EnvVars; import hudson.Extension; import hudson.matrix.MatrixBuild; @@ -70,19 +71,17 @@ public class BitBucketPPREnvironmentContributor extends EnvironmentContributor { static final Logger logger = Logger.getLogger(BitBucketPPREnvironmentContributor.class.getName()); @Override - public void buildEnvironmentFor(Job job, EnvVars envVars, TaskListener taskListener) - throws IOException, InterruptedException { + public void buildEnvironmentFor(@NonNull Job job, @NonNull EnvVars envVars, @NonNull TaskListener taskListener) { // NOTHING TO DO HERE } @Override - public void buildEnvironmentFor(@Nonnull Run run, EnvVars envVars, TaskListener taskListener) - throws IOException, InterruptedException { + public void buildEnvironmentFor(@Nonnull Run run, @NonNull EnvVars envVars, @NonNull TaskListener taskListener) { List causes = null; - if (run instanceof MatrixRun) { - MatrixBuild parent = ((MatrixRun) run).getParentBuild(); + if (run instanceof MatrixRun matrixRun) { + MatrixBuild parent = matrixRun.getParentBuild(); if (parent != null) { causes = parent.getCauses(); } @@ -94,30 +93,25 @@ public void buildEnvironmentFor(@Nonnull Run run, EnvVars envVars, TaskListener return; } - causes.stream().forEach((Cause cause) -> { + causes.forEach((Cause cause) -> { try { - if (cause instanceof BitBucketPPRPullRequestCause) { - BitBucketPPRPullRequestCause castedCause = (BitBucketPPRPullRequestCause) cause; - setEnvVarsForCloudPullRequest(envVars, castedCause.getPullRequestPayLoad(), + if (cause instanceof BitBucketPPRPullRequestCause castedCause) { + setEnvVarsForCloudPullRequest(envVars, castedCause.getPullRequestPayLoad(), castedCause.getHookEvent()); - } else if (cause instanceof BitBucketPPRPullRequestServerCause) { - BitBucketPPRPullRequestServerCause castedCause = - (BitBucketPPRPullRequestServerCause) cause; - setEnvVarsForServerPullRequest(envVars, castedCause.getPullRequestPayLoad(), + } else if (cause instanceof BitBucketPPRPullRequestServerCause castedCause) { + setEnvVarsForServerPullRequest(envVars, castedCause.getPullRequestPayLoad(), castedCause.getHookEvent()); - } else if (cause instanceof BitBucketPPRRepositoryCause) { - BitBucketPPRRepositoryCause castedCause = (BitBucketPPRRepositoryCause) cause; - setEnvVarsForCloudRepository(envVars, castedCause.getRepositoryPayLoad(), + } else if (cause instanceof BitBucketPPRRepositoryCause castedCause) { + setEnvVarsForCloudRepository(envVars, castedCause.getRepositoryPayLoad(), castedCause.getHookEvent()); - } else if (cause instanceof BitBucketPPRServerRepositoryCause) { - BitBucketPPRServerRepositoryCause castedCause = (BitBucketPPRServerRepositoryCause) cause; - setEnvVarsForServerRepository(envVars, castedCause.getServerRepositoryPayLoad(), + } else if (cause instanceof BitBucketPPRServerRepositoryCause castedCause) { + setEnvVarsForServerRepository(envVars, castedCause.getServerRepositoryPayLoad(), castedCause.getHookEvent()); } } catch (Exception e) { e.printStackTrace(); logger.warning(String.format("Cannot build environment variables for cause %s %s.", - cause.getShortDescription(), e.toString())); + cause.getShortDescription(), e)); } }); } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPRBuildFinished.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPRBuildFinished.java index 122025d4..c2abbbd8 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPRBuildFinished.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPRBuildFinished.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPRBuildStarted.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPRBuildStarted.java index ae24f2d8..7d7d0f2b 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPRBuildStarted.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPRBuildStarted.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREvent.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREvent.java index bcfdd359..75a695f2 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREvent.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREvent.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -23,8 +23,8 @@ import io.jenkins.plugins.bitbucketpushandpullrequest.observer.BitBucketPPRHandlerTemplate; public interface BitBucketPPREvent { - public void setContext(BitBucketPPREventContext context); - public BitBucketPPREventContext getContext(); - public void setEventHandler(BitBucketPPRHandlerTemplate handler); - public void runHandler(); + void setContext(BitBucketPPREventContext context); + BitBucketPPREventContext getContext(); + void setEventHandler(BitBucketPPRHandlerTemplate handler); + void runHandler(); } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventContext.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventContext.java index c6d2bfbb..49dad846 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventContext.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventContext.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -44,7 +44,7 @@ public class BitBucketPPREventContext { private BitBucketPPRTrigger trigger; public BitBucketPPREventContext(BitBucketPPRTrigger trigger, BitBucketPPRAction action, - SCM scmTrigger, Run run, BitBucketPPRTriggerFilter filter) throws Exception { + SCM scmTrigger, Run run, BitBucketPPRTriggerFilter filter) { this.action = action; this.scmTrigger = scmTrigger; this.run = run; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventFactory.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventFactory.java index 5295527f..9a22099c 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventFactory.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventFactory.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -23,21 +23,14 @@ public class BitBucketPPREventFactory { public static BitBucketPPREvent createEvent(BitBucketPPREventType eventType, BitBucketPPREventContext context) throws Exception { - BitBucketPPREvent event = null; + BitBucketPPREvent event = switch (eventType) { + case BUILD_STARTED -> new BitBucketPPRBuildStarted(); + case BUILD_FINISHED -> new BitBucketPPRBuildFinished(); + default -> throw new Exception(); + }; - switch (eventType) { - case BUILD_STARTED: - event = new BitBucketPPRBuildStarted(); - break; - case BUILD_FINISHED: - event = new BitBucketPPRBuildFinished(); - break; - default: - throw new Exception(); - } + event.setContext(context); - event.setContext(context); - return event; } } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventType.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventType.java index b5556f66..6e49a2b9 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventType.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/event/BitBucketPPREventType.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,7 +21,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.event; public enum BitBucketPPREventType { - BUILD_STARTED, BUILD_FINISHED; + BUILD_STARTED, BUILD_FINISHED } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/exception/BitBucketPPRObserverNotFoundException.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/exception/BitBucketPPRObserverNotFoundException.java index 8be5fafc..c60804d2 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/exception/BitBucketPPRObserverNotFoundException.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/exception/BitBucketPPRObserverNotFoundException.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,7 +20,10 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.exception; +import java.io.Serial; + public class BitBucketPPRObserverNotFoundException extends Exception { + @Serial private static final long serialVersionUID = 1L; public BitBucketPPRObserverNotFoundException(String msg) { diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/exception/JobNotStartedException.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/exception/JobNotStartedException.java index 52aea178..5ee35817 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/exception/JobNotStartedException.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/exception/JobNotStartedException.java @@ -1,6 +1,9 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.exception; +import java.io.Serial; + public class JobNotStartedException extends Exception { + @Serial private static final long serialVersionUID = 1L; public JobNotStartedException(String msg) { diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/extensions/dsl/BitBucketPPRHookJobDslContext.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/extensions/dsl/BitBucketPPRHookJobDslContext.java index 362ec159..0d246c9f 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/extensions/dsl/BitBucketPPRHookJobDslContext.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/extensions/dsl/BitBucketPPRHookJobDslContext.java @@ -356,8 +356,8 @@ public void pullRequestServerApprovedAction(boolean onlyIfReviewersApproved, new BitBucketPPRPullRequestServerTriggerFilter(pullRequestServerApprovedActionFilter); triggers.add(pullRequestServerTriggerFilter); } - - + + @Deprecated public void pullRequestServerApprovedAction(boolean onlyIfReviewersApproved, String allowedBranches, boolean isToApprove) { @@ -395,7 +395,7 @@ public void pullRequestServerCreatedAction(String allowedBranches, boolean isToA new BitBucketPPRPullRequestServerTriggerFilter(pullRequestServerCreatedActionFilter); triggers.add(pullRequestServerTriggerFilter); } - + public void pullRequestServerCreatedAction(String allowedBranches, boolean isToApprove, boolean isToDecline) { BitBucketPPRPullRequestServerCreatedActionFilter pullRequestServerCreatedActionFilter = new BitBucketPPRPullRequestServerCreatedActionFilter(); @@ -433,7 +433,7 @@ public void pullRequestServerUpdatedAction(String allowedBranches, boolean isToA new BitBucketPPRPullRequestServerTriggerFilter(pullRequestUpdatedServerActionFilter); triggers.add(pullRequestServerTriggerFilter); } - + public void pullRequestServerUpdatedAction(String allowedBranches, boolean isToApprove, boolean isToDecline) { BitBucketPPRPullRequestServerUpdatedActionFilter pullRequestUpdatedServerActionFilter = new BitBucketPPRPullRequestServerUpdatedActionFilter(); @@ -471,7 +471,7 @@ public void pullRequestServerSourceUpdatedAction(String allowedBranches, boolean new BitBucketPPRPullRequestServerTriggerFilter(pullRequestServerSourceUpdatedActionFilter); triggers.add(pullRequestServerTriggerFilter); } - + public void pullRequestServerSourceUpdatedAction(String allowedBranches, boolean isToApprove, boolean isToDecline) { BitBucketPPRPullRequestServerSourceUpdatedActionFilter pullRequestServerSourceUpdatedActionFilter = new BitBucketPPRPullRequestServerSourceUpdatedActionFilter(); diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/extensions/dsl/BitBucketPPRHookJobDslExtension.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/extensions/dsl/BitBucketPPRHookJobDslExtension.java index a9db95d9..56d58ce1 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/extensions/dsl/BitBucketPPRHookJobDslExtension.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/extensions/dsl/BitBucketPPRHookJobDslExtension.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPREventTriggerMatcher.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPREventTriggerMatcher.java index 6aec779b..500db8a4 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPREventTriggerMatcher.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPREventTriggerMatcher.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRFilterMatcher.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRFilterMatcher.java index aeb59a6e..15fec95e 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRFilterMatcher.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRFilterMatcher.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRTriggerFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRTriggerFilter.java index 07474810..ca34751e 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRTriggerFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRTriggerFilter.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -40,6 +40,6 @@ public abstract BitBucketPPRTriggerCause getCause(File pollingLog, BitBucketPPRA public abstract boolean shouldTriggerAlsoIfNothingChanged(); public abstract boolean shouldSendApprove(); - + public abstract boolean shouldSendDecline(); } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRTriggerFilterDescriptor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRTriggerFilterDescriptor.java index 8ac2933b..b000dcd1 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRTriggerFilterDescriptor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/BitBucketPPRTriggerFilterDescriptor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestActionDescriptor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestActionDescriptor.java index a962e407..39916a8c 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestActionDescriptor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestActionDescriptor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestActionFilter.java index fb249323..f0fe286c 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestActionFilter.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilter.java index 015aaed8..35805182 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilter.java @@ -24,8 +24,10 @@ import static io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst.PULL_REQUEST_REVIEWER; import java.io.File; import java.io.IOException; +import java.util.Objects; import java.util.logging.Logger; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -52,11 +54,7 @@ public BitBucketPPRPullRequestApprovedActionFilter(boolean triggerOnlyIfAllRevie @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @Override @@ -90,6 +88,7 @@ public boolean shouldSendDecline() { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Approved"; @@ -101,10 +100,7 @@ public boolean getTriggerOnlyIfAllReviewersApproved() { } private boolean allReviewersHaveApproved(BitBucketPPRAction pullRequestAction) { - return pullRequestAction.getPayload().getPullRequest().getParticipants().stream() - .filter(p -> isReviewer(p) && !p.getApproved()) - .count() - == 0; + return pullRequestAction.getPayload().getPullRequest().getParticipants().stream().noneMatch(p -> isReviewer(p) && !p.getApproved()); } private boolean isReviewer(BitBucketPPRParticipant pullRequestParticipant) { diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilter.java index 9a0969ca..a0f9327e 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -47,20 +49,12 @@ public BitBucketPPRPullRequestCommentCreatedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter public void setCommentFilter(String commentFilter) { - if (commentFilter == null) { - this.commentFilter = ""; - } else { - this.commentFilter = commentFilter; - } + this.commentFilter = Objects.requireNonNullElse(commentFilter, ""); } @Override @@ -95,6 +89,7 @@ public boolean hasInComment(String comment, EnvVars vars) { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Comment Created"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedActionFilter.java index 3d60b79e..47e6aa48 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -44,11 +46,7 @@ public BitBucketPPRPullRequestCommentDeletedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @Override @@ -78,6 +76,7 @@ public boolean shouldSendDecline() { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Comment Deleted"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilter.java index 927c2075..80e4468d 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -47,20 +49,12 @@ public BitBucketPPRPullRequestCommentUpdatedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter public void setCommentFilter(String commentFilter) { - if (commentFilter == null) { - this.commentFilter = ""; - } else { - this.commentFilter = commentFilter; - } + this.commentFilter = Objects.requireNonNullElse(commentFilter, ""); } @Override @@ -95,6 +89,7 @@ public boolean hasInComment(String comment, EnvVars vars) { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Comment Updated"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilter.java index afdb4b94..2e265fd9 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -46,11 +48,7 @@ public BitBucketPPRPullRequestCreatedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter @@ -89,6 +87,7 @@ public boolean shouldSendDecline() { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Created"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestDeclinedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestDeclinedActionFilter.java index 9fc1fc32..3ad56545 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestDeclinedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestDeclinedActionFilter.java @@ -21,6 +21,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; import io.jenkins.plugins.bitbucketpushandpullrequest.cause.BitBucketPPRTriggerCause; @@ -32,6 +33,7 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; public class BitBucketPPRPullRequestDeclinedActionFilter extends BitBucketPPRPullRequestActionFilter { @@ -42,11 +44,7 @@ public BitBucketPPRPullRequestDeclinedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @Override @@ -75,6 +73,7 @@ public boolean shouldSendDecline() { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Declined"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestMergedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestMergedActionFilter.java index f1d54927..52b21ef1 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestMergedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestMergedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -43,11 +45,7 @@ public BitBucketPPRPullRequestMergedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter @@ -81,6 +79,7 @@ public boolean shouldSendDecline() { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Merged"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestTriggerFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestTriggerFilter.java index 921ccb15..7d1b6a4f 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestTriggerFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestTriggerFilter.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.List; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -71,6 +72,7 @@ public BitBucketPPRTriggerCause getCause( @Extension public static class FilterDescriptorImpl extends BitBucketPPRTriggerFilterDescriptor { + @NonNull @Override public String getDisplayName() { return "Bitbucket Cloud Pull Request"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestTriggerMatcher.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestTriggerMatcher.java index f2e62387..cb3b8934 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestTriggerMatcher.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestTriggerMatcher.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2021, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestUpdatedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestUpdatedActionFilter.java index 86c5aefe..c2088a20 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestUpdatedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestUpdatedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -46,11 +48,7 @@ public BitBucketPPRPullRequestUpdatedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter @@ -89,6 +87,7 @@ public BitBucketPPRTriggerCause getCause( @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Updated"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerActionDescriptor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerActionDescriptor.java index cbc1e6f2..643ccc49 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerActionDescriptor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerActionDescriptor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerActionFilter.java index 47e399fb..7a0ec9ef 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerActionFilter.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2019, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -45,6 +45,6 @@ public abstract BitBucketPPRTriggerCause getCause(File pollingLog, BitBucketPPRAction pullRequestAction, BitBucketPPRHookEvent bitBucketEvent) throws IOException; public abstract boolean shouldSendApprove(); - + public abstract boolean shouldSendDecline(); } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerApprovedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerApprovedActionFilter.java index 66806f35..4208f77b 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerApprovedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerApprovedActionFilter.java @@ -24,8 +24,10 @@ import static io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst.PULL_REQUEST_REVIEWER; import java.io.File; import java.io.IOException; +import java.util.Objects; import java.util.logging.Logger; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -54,11 +56,7 @@ public BitBucketPPRPullRequestServerApprovedActionFilter( @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @Override @@ -85,6 +83,7 @@ public BitBucketPPRTriggerCause getCause( public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestServerActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Approved"; @@ -96,10 +95,7 @@ public boolean getTriggerOnlyIfAllReviewersApproved() { } private boolean allReviewersHaveApproved(BitBucketPPRAction pullRequestAction) { - return pullRequestAction.getPayload().getPullRequest().getParticipants().stream() - .filter(p -> isReviewer(p) && !p.getApproved()) - .count() - == 0; + return pullRequestAction.getPayload().getPullRequest().getParticipants().stream().noneMatch(p -> isReviewer(p) && !p.getApproved()); } private boolean isReviewer(BitBucketPPRParticipant pullRequestParticipant) { diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedActionFilter.java index 23fd44b4..ca0556eb 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -47,20 +49,12 @@ public BitBucketPPRPullRequestServerCommentCreatedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter public void setCommentFilter(String commentFilter) { - if (commentFilter == null) { - this.commentFilter = ""; - } else { - this.commentFilter = commentFilter; - } + this.commentFilter = Objects.requireNonNullElse(commentFilter, ""); } @Override @@ -97,6 +91,7 @@ public boolean hasInComment(String comment, EnvVars vars) { public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestServerActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Comment Created"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCreatedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCreatedActionFilter.java index 9f631d3e..44d7a3fb 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCreatedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCreatedActionFilter.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -46,7 +47,7 @@ public BitBucketPPRPullRequestServerCreatedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null || "".equals(allowedBranches)) { + if (allowedBranches == null || allowedBranches.isEmpty()) { this.allowedBranches = ""; } else { this.allowedBranches = allowedBranches; @@ -82,6 +83,7 @@ public BitBucketPPRTriggerCause getCause( public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestServerActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Created"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerDeclinedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerDeclinedActionFilter.java index ed6c236d..9a91f539 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerDeclinedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerDeclinedActionFilter.java @@ -21,6 +21,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.server; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; import io.jenkins.plugins.bitbucketpushandpullrequest.cause.BitBucketPPRTriggerCause; @@ -32,6 +33,7 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; public class BitBucketPPRPullRequestServerDeclinedActionFilter extends BitBucketPPRPullRequestServerActionFilter { @@ -43,11 +45,7 @@ public BitBucketPPRPullRequestServerDeclinedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @Override @@ -69,6 +67,7 @@ public BitBucketPPRTriggerCause getCause( public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestServerActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Declined"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerMergedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerMergedActionFilter.java index 8e1f2a14..28a99b49 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerMergedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerMergedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -45,11 +47,7 @@ public BitBucketPPRPullRequestServerMergedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter @@ -76,6 +74,7 @@ public BitBucketPPRTriggerCause getCause( public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestServerActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Merged"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerSourceUpdatedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerSourceUpdatedActionFilter.java index 25280c2b..9ff4e072 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerSourceUpdatedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerSourceUpdatedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -46,11 +48,7 @@ public BitBucketPPRPullRequestServerSourceUpdatedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter @@ -82,6 +80,7 @@ public BitBucketPPRTriggerCause getCause( public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestServerActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Source Branch of Pull Request Updated"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerTriggerFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerTriggerFilter.java index 67d2999c..0f75c094 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerTriggerFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerTriggerFilter.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.List; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import hudson.Extension; @@ -61,6 +62,7 @@ public BitBucketPPRTriggerCause getCause( @Extension public static class FilterDescriptorImpl extends BitBucketPPRTriggerFilterDescriptor { + @NonNull @Override public String getDisplayName() { return "Bitbucket Server Pull Request"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerUpdatedActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerUpdatedActionFilter.java index aae51f85..301e01ae 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerUpdatedActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerUpdatedActionFilter.java @@ -23,7 +23,9 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -46,11 +48,7 @@ public BitBucketPPRPullRequestServerUpdatedActionFilter() {} @DataBoundSetter public void setAllowedBranches(String allowedBranches) { - if (allowedBranches == null) { - this.allowedBranches = ""; - } else { - this.allowedBranches = allowedBranches; - } + this.allowedBranches = Objects.requireNonNullElse(allowedBranches, ""); } @DataBoundSetter @@ -82,6 +80,7 @@ public BitBucketPPRTriggerCause getCause( public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestServerActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Updated"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryActionDescriptor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryActionDescriptor.java index d6ec59d4..5d9d67ce 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryActionDescriptor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryActionDescriptor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryActionFilter.java index d3b92354..eb97131e 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryActionFilter.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -48,7 +48,7 @@ public boolean matches(String allowedBranches, String branchName, EnvVars env) { public abstract boolean shouldTriggerAlsoIfNothingChanged(); public abstract boolean shouldSendApprove(); - + public boolean shouldSendDecline() { return false; } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryPushActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryPushActionFilter.java index bd22de70..63ce603a 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryPushActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryPushActionFilter.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.util.logging.Logger; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -125,6 +126,7 @@ public boolean shouldSendApprove() { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRRepositoryActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Bitbucket Cloud Push"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryTriggerFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryTriggerFilter.java index fba60fc9..646cf985 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryTriggerFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryTriggerFilter.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.List; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.stapler.DataBoundConstructor; import hudson.Extension; @@ -68,6 +69,7 @@ public BitBucketPPRRepositoryActionFilter getActionFilter() { @Extension public static class FilterDescriptorImpl extends BitBucketPPRTriggerFilterDescriptor { + @NonNull public String getDisplayName() { return "Push"; } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryTriggerMatcher.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryTriggerMatcher.java index 04c4320f..cc60468d 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryTriggerMatcher.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryTriggerMatcher.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -37,7 +37,7 @@ public class BitBucketPPRRepositoryTriggerMatcher implements BitBucketPPREventTr @Override public boolean matchesAction(BitBucketPPRHookEvent bitbucketEvent, BitBucketPPRTriggerFilter triggerFilter) { - logger.log(Level.INFO, () -> "" + bitbucketEvent.toString()); + logger.log(Level.INFO, bitbucketEvent::toString); logger.log(Level.FINE, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRServerRepositoryPushActionFilter.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRServerRepositoryPushActionFilter.java index fc5adbe5..cb7dbc83 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRServerRepositoryPushActionFilter.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRServerRepositoryPushActionFilter.java @@ -24,6 +24,7 @@ import static java.util.Objects.isNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; import io.jenkins.plugins.bitbucketpushandpullrequest.cause.BitBucketPPRTriggerCause; @@ -132,6 +133,7 @@ public boolean shouldSendApprove() { @Extension public static class ActionFilterDescriptorImpl extends BitBucketPPRRepositoryActionDescriptor { + @NonNull @Override public String getDisplayName() { return "Bitbucket Server Push"; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRHookEvent.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRHookEvent.java index d7084327..b2555f71 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRHookEvent.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRHookEvent.java @@ -48,9 +48,9 @@ /** * Extracts event and action from the event key sent by Bitbucket and verifies that they are * supported by the plugin. - * + * * @author cdelmonte - * + * */ public class BitBucketPPRHookEvent { private String event; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRPayload.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRPayload.java index 01edb992..6cd1447b 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRPayload.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRPayload.java @@ -56,7 +56,7 @@ default BitBucketPPRActor getActor() { default BitBucketPPRApproval getApproval() { return null; } - + default BitBucketPPRComment getComment() { return null; } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRPayloadFactory.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRPayloadFactory.java index 09487326..4a096ff4 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRPayloadFactory.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPRPayloadFactory.java @@ -65,7 +65,7 @@ public static BitBucketPPRPayload getInstance(BitBucketPPRHookEvent bitbucketEve if (PULL_REQUEST_SERVER_EVENT.equals(bitbucketEvent.getEvent())) { return new BitBucketPPRServerPayload(); } - + if (DIAGNOSTICS.equals(bitbucketEvent.getEvent())) { return new BitBucketPPRServerPayload(); } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRActor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRActor.java index 7ed96e2e..77346172 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRActor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRActor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,11 +20,13 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import com.google.gson.annotations.SerializedName; public class BitBucketPPRActor implements Serializable { + @Serial private static final long serialVersionUID = 4266599260720106245L; @SerializedName("display_name") diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRApproval.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRApproval.java index 32a6f76c..02ff0c11 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRApproval.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRApproval.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,11 +20,13 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import java.util.Date; public class BitBucketPPRApproval implements Serializable { + @Serial private static final long serialVersionUID = -4394761268108854254L; private Date date; private BitBucketPPRActor user; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRBranch.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRBranch.java index 62c8cb09..e8104454 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRBranch.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRBranch.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,9 +20,11 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRBranch implements Serializable { + @Serial private static final long serialVersionUID = -846166211765005578L; private String name; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRChange.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRChange.java index c0780e47..419304f3 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRChange.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRChange.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,12 +20,14 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import java.util.List; import com.google.gson.annotations.SerializedName; public class BitBucketPPRChange implements Serializable { + @Serial private static final long serialVersionUID = 7855401280893901392L; private boolean forced; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRCloudPayload.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRCloudPayload.java index 9ebe7e94..5b893231 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRCloudPayload.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRCloudPayload.java @@ -23,7 +23,10 @@ import com.google.gson.annotations.SerializedName; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; +import java.io.Serial; + public class BitBucketPPRCloudPayload implements BitBucketPPRPayload { + @Serial private static final long serialVersionUID = -3467640601880230847L; private BitBucketPPRPush push; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRComment.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRComment.java index 9274a141..acb38a07 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRComment.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRComment.java @@ -1,9 +1,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import java.util.Date; public class BitBucketPPRComment implements Serializable { + @Serial private static final long serialVersionUID = -8486598082322838487L; String id; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRCommit.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRCommit.java index 21cf8f18..ef7fb67c 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRCommit.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRCommit.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,10 +20,12 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRCommit implements Serializable { + @Serial private static final long serialVersionUID = 795153370768402207L; private String hash; private String type; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRContent.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRContent.java index 560f9c1e..d6682ba6 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRContent.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRContent.java @@ -1,8 +1,10 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRContent implements Serializable { + @Serial private static final long serialVersionUID = 970499631277905070L; String raw; @@ -50,5 +52,5 @@ public void setType(String type) { public String toString() { return "BitBucketPPRContent [html=" + html + ", markup=" + markup + ", raw=" + raw + ", type=" + type + "]"; - } + } } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRDestination.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRDestination.java index f5d83384..0a25254b 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRDestination.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRDestination.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,9 +20,11 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRDestination implements Serializable { + @Serial private static final long serialVersionUID = -4298473654409288406L; private BitBucketPPRBranch branch; private BitBucketPPRCommit commit; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkActivity.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkActivity.java index dff07744..c9c89df7 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkActivity.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkActivity.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkActivity implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkApprove.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkApprove.java index 54a20869..20853f1c 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkApprove.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkApprove.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkApprove implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkComments.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkComments.java index 67d2e5c3..42e3d03a 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkComments.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkComments.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkComments implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkCommits.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkCommits.java index f4f7856a..8e82d538 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkCommits.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkCommits.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkCommits implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDecline.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDecline.java index fd54ee74..da2a7c13 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDecline.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDecline.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkDecline implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDiff.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDiff.java index 6c82299f..a8037a6f 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDiff.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDiff.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkDiff implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDiffStat.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDiffStat.java index f9f7e85d..6109a820 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDiffStat.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkDiffStat.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkDiffStat implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkHtml.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkHtml.java index 3757dfdc..6273b395 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkHtml.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkHtml.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -22,6 +22,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; @@ -46,7 +47,8 @@ public class BitBucketPPRLinkHtml implements Serializable { * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ - + + @Serial private static final long serialVersionUID = -6887496731660740096L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkMerge.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkMerge.java index 712bf275..5a6f80c6 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkMerge.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkMerge.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkMerge implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkStatuses.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkStatuses.java index 3586e60b..23bea54b 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkStatuses.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinkStatuses.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,9 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRLinkStatuses implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinks.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinks.java index 78e2ed4f..871c6ca3 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinks.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRLinks.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,17 +20,19 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import com.google.gson.annotations.SerializedName; public class BitBucketPPRLinks implements Serializable { + @Serial private static final long serialVersionUID = 8607244117530188175L; private BitBucketPPRLinkHtml html; @SerializedName("self") private BitBucketPPRSelf selfProperty; - + private BitBucketPPRLinkDecline decline; private BitBucketPPRLinkDiffStat diffstat; private BitBucketPPRLinkCommits commits; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRNew.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRNew.java index 6cf25ce8..f4154319 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRNew.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRNew.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,16 +20,18 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRNew implements Serializable { + @Serial private static final long serialVersionUID = -1128832514571843255L; private String type; private String name; private BitBucketPPRTarget target; - + public BitBucketPPRTarget getTarget() { return target; } diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPROwner.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPROwner.java index 1213afee..a374382e 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPROwner.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPROwner.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,11 +20,13 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import com.google.gson.annotations.SerializedName; public class BitBucketPPROwner implements Serializable { + @Serial private static final long serialVersionUID = 535433266823246782L; private String type; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRParticipant.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRParticipant.java index 7c4a8c74..e479b0a6 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRParticipant.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRParticipant.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,12 +20,14 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import java.util.Date; import com.google.gson.annotations.SerializedName; public class BitBucketPPRParticipant implements Serializable { + @Serial private static final long serialVersionUID = 7546251977007143345L; private String type; private BitBucketPPRActor user; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRProject.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRProject.java index d9ca2551..17f8bbe1 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRProject.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRProject.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,10 +20,12 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRProject implements Serializable { + @Serial private static final long serialVersionUID = 2452121553837931076L; private BitBucketPPRLinks links; private String type; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRPullRequest.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRPullRequest.java index 48f3e78c..138d7d22 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRPullRequest.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRPullRequest.java @@ -20,6 +20,7 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; @@ -27,6 +28,7 @@ import com.google.gson.annotations.SerializedName; public class BitBucketPPRPullRequest implements Serializable { + @Serial private static final long serialVersionUID = -530740975503014281L; private String id; private String title; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRPush.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRPush.java index 239aa582..a2dd5e06 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRPush.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRPush.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,12 +20,14 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; import java.util.List; public class BitBucketPPRPush implements Serializable { + @Serial private static final long serialVersionUID = 5663991681801028868L; private List changes = new ArrayList<>(); diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRRepository.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRRepository.java index 673eeca1..b0ffb714 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRRepository.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRRepository.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,11 +20,13 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; import com.google.gson.annotations.SerializedName; public class BitBucketPPRRepository implements Serializable { + @Serial private static final long serialVersionUID = -5358049446460018798L; private String scm; private String website; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRSelf.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRSelf.java index a53bfa59..24947a30 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRSelf.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRSelf.java @@ -1,8 +1,10 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRSelf implements Serializable { + @Serial private static final long serialVersionUID = -9156939739440067961L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRSource.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRSource.java index 4bd4ad10..b9be3097 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRSource.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRSource.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,10 +20,12 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRSource implements Serializable { + @Serial private static final long serialVersionUID = 8130236986503988538L; private BitBucketPPRBranch branch; private BitBucketPPRCommit commit; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRTarget.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRTarget.java index 389586c6..b6da8215 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRTarget.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/cloud/BitBucketPPRTarget.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,9 +20,11 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRTarget implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String hash; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerActor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerActor.java index 9c515883..87559603 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerActor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerActor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018-2019, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -22,9 +22,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerActor implements Serializable { + @Serial private static final long serialVersionUID = -3776450706699542277L; private String name; private String emailAddress; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerChange.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerChange.java index 4949ff59..fde0c63a 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerChange.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerChange.java @@ -1,9 +1,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerChange implements Serializable { + @Serial private static final long serialVersionUID = 49898612250869977L; private BitBucketPPRServerRef ref; private String refId; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerClone.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerClone.java index 1e72507d..abad5d64 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerClone.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerClone.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -20,10 +20,12 @@ ******************************************************************************/ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerClone implements Serializable { + @Serial private static final long serialVersionUID = 8260609430213080172L; private String href; private String name; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerComment.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerComment.java index 3a1bf5a9..86a2b773 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerComment.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerComment.java @@ -1,8 +1,10 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerComment implements Serializable{ + @Serial private static final long serialVersionUID = -4778766502864544307L; String id; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerLinks.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerLinks.java index f5d91ec7..bc33be80 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerLinks.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerLinks.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -22,6 +22,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -29,6 +30,7 @@ public class BitBucketPPRServerLinks implements Serializable { + @Serial private static final long serialVersionUID = -8908433977563131277L; @SerializedName("clone") diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerMergeCommit.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerMergeCommit.java index 9e5f58f9..be3da54b 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerMergeCommit.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerMergeCommit.java @@ -22,10 +22,12 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerMergeCommit implements Serializable { + @Serial private static final long serialVersionUID = -5347870725110898308L; private String id; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPRProperties.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPRProperties.java index ca529243..31fb3b56 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPRProperties.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPRProperties.java @@ -22,10 +22,12 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerPRProperties implements Serializable { + @Serial private static final long serialVersionUID = -4327337466069004128L; private BitBucketPPRServerMergeCommit mergeCommit; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPayload.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPayload.java index fda57d88..e0b82b51 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPayload.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPayload.java @@ -1,5 +1,6 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.util.ArrayList; import java.util.List; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -7,6 +8,7 @@ public class BitBucketPPRServerPayload implements BitBucketPPRPayload { + @Serial private static final long serialVersionUID = -5088466617368578337L; private BitBucketPPRServerActor actor; private BitBucketPPRServerPullRequest pullRequest; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerProject.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerProject.java index e847dd4f..f2649442 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerProject.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerProject.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,11 +21,13 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; import com.google.gson.annotations.SerializedName; public class BitBucketPPRServerProject implements Serializable { + @Serial private static final long serialVersionUID = -9104674017591226510L; private String key; private String id; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPullRequest.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPullRequest.java index bb2ecc6c..26206eb7 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPullRequest.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerPullRequest.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018-2019, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -22,11 +22,13 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; import java.util.List; public class BitBucketPPRServerPullRequest implements Serializable { + @Serial private static final long serialVersionUID = -2700597086308321013L; private Long id; private Long version; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRef.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRef.java index fde3ce76..e24e6161 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRef.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRef.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018-2019, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -22,10 +22,12 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerRef implements Serializable { + @Serial private static final long serialVersionUID = -8845585960950746623L; private String id; private String displayId; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRepository.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRepository.java index f04e7c55..9b953ce5 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRepository.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRepository.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018-2019, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -22,10 +22,12 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; import com.google.gson.annotations.SerializedName; public class BitBucketPPRServerRepository implements Serializable { + @Serial private static final long serialVersionUID = 2888690501986298784L; private String slug; private String id; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRepositoryRef.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRepositoryRef.java index c8c446fd..16045fd0 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRepositoryRef.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerRepositoryRef.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2018-2019, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -22,9 +22,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerRepositoryRef implements Serializable { + @Serial private static final long serialVersionUID = 5693884607853431041L; private String id; private String displayId; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerSelf.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerSelf.java index a4bf5aae..28f13c09 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerSelf.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/server/BitBucketPPRServerSelf.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -21,10 +21,12 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model.server; +import java.io.Serial; import java.io.Serializable; public class BitBucketPPRServerSelf implements Serializable { + @Serial private static final long serialVersionUID = 1433703376294956482L; private String href; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRHandlerTemplate.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRHandlerTemplate.java index 461e543d..6d39d134 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRHandlerTemplate.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRHandlerTemplate.java @@ -62,7 +62,6 @@ public void run(BitBucketPPREventType eventType) throws Exception { // @todo: do we need it also for pushs? public void setApprovedOrDeclined() throws MalformedURLException { - return; } public abstract void setBuildStatusOnFinished() throws MalformedURLException; diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObservable.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObservable.java index 867f27b1..9c9ea295 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObservable.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObservable.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObserver.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObserver.java index b0c4d54b..19dffe92 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObserver.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObserver.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObserverFactory.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObserverFactory.java index 6bf6154d..ec74686d 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObserverFactory.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRObserverFactory.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPayloadProcessorFactory.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPayloadProcessorFactory.java index eee37faa..2bd94860 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPayloadProcessorFactory.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPayloadProcessorFactory.java @@ -60,7 +60,7 @@ public static BitBucketPPRPayloadProcessor createProcessor(@Nonnull final BitBuc logger.info("Create BitBucketPPRRepositoryServerPayloadProcessor"); return new BitBucketPPRRepositoryServerPayloadProcessor(probe, bitbucketEvent); } - + // @todo: will be removed in version 3.0.0 if (REPOSITORY_EVENT.equalsIgnoreCase(bitbucketEvent.getEvent()) && REPOSITORY_POST.equalsIgnoreCase(bitbucketEvent.getAction())) { diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestServerPayloadProcessor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestServerPayloadProcessor.java index 277fd3a2..67f551c2 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestServerPayloadProcessor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestServerPayloadProcessor.java @@ -21,8 +21,6 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.processor; -import static java.util.Objects.nonNull; - import io.jenkins.plugins.bitbucketpushandpullrequest.BitBucketPPRJobProbe; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRPullRequestServerAction; @@ -41,7 +39,7 @@ public class BitBucketPPRPullRequestServerPayloadProcessor extends BitBucketPPRP public BitBucketPPRPullRequestServerPayloadProcessor( @Nonnull BitBucketPPRJobProbe jobProbe, @Nonnull BitBucketPPRHookEvent bitbucketEvent) { super(jobProbe, bitbucketEvent); - logger.fine(() -> "Processing " + bitbucketEvent.toString()); + logger.fine(() -> "Processing " + bitbucketEvent); } private BitBucketPPRAction buildActionForJobs( diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryCloudPayloadProcessor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryCloudPayloadProcessor.java index 66cd4b47..b86bef74 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryCloudPayloadProcessor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryCloudPayloadProcessor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryServerPayloadProcessor.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryServerPayloadProcessor.java index c3444c18..a4ca64d5 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryServerPayloadProcessor.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryServerPayloadProcessor.java @@ -1,17 +1,17 @@ /******************************************************************************* * The MIT License - * + * * Copyright (C) 2020, CloudBees, Inc. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiver.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiver.java index 4147caac..f3d29477 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiver.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiver.java @@ -21,33 +21,35 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.receiver; -import static io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst.HOOK_URL; - -import io.jenkins.plugins.bitbucketpushandpullrequest.exception.BitBucketPPRPayloadPropertyNotFoundException; import java.io.IOException; import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.util.logging.Level; import java.util.logging.Logger; + import javax.annotation.Nonnull; import javax.naming.OperationNotSupportedException; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; + import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; + import hudson.Extension; import hudson.model.UnprotectedRootAction; import hudson.security.csrf.CrumbExclusion; import io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst; +import static io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst.HOOK_URL; import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; +import io.jenkins.plugins.bitbucketpushandpullrequest.exception.BitBucketPPRPayloadPropertyNotFoundException; import io.jenkins.plugins.bitbucketpushandpullrequest.exception.InputStreamException; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRHookEvent; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; @@ -144,8 +146,7 @@ BitBucketPPRPayload getPayload( } static String decodeInputStream( - @Nonnull final String inputStream, @Nonnull final String contentType) - throws UnsupportedEncodingException { + @Nonnull final String inputStream, @Nonnull final String contentType) { String input = inputStream; if (StringUtils.startsWithIgnoreCase( contentType, BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED)) { diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbeTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbeTest.java index 018d5636..e69de29b 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbeTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbeTest.java @@ -1,82 +0,0 @@ -/******************************************************************************* - * The MIT License - * - * Copyright (C) 2019, CloudBees, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - * associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or - * substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ******************************************************************************/ - - -package io.jenkins.plugins.bitbucketpushandpullrequest; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -// import com.google.gson.Gson; -import org.eclipse.jgit.transport.URIish; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; - - -@ExtendWith(MockitoExtension.class) -public class BitBucketPPRJobProbeTest { - BitBucketPPRJobProbe jobProbe; - - @BeforeClass - public static void beforeClass() { - System.out.println("Starting test class" + BitBucketPPRJobProbeTest.class.getName()); - } - - @Before - public void setUp() { - System.out.println("Starting a test"); - jobProbe = new BitBucketPPRJobProbe(); - } - - // private BitBucketPPRPayload getPayload() { - // Gson gson = new Gson(); - // JsonReader reader = null; - - // try { - // ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - // InputStream is = classloader.getResourceAsStream("pullrequest_approved.json"); - // InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);O - // reader = new JsonReader(isr); - // } catch (Exception e) { - // e.printStackTrace(); - // } - - // BitBucketPPRPayload payload = null; - // try { - // payload = gson.fromJson(reader, BitBucketPPRNewPayload.class); - // } catch (JsonIOException e) { - // e.printStackTrace(); - // } catch (JsonSyntaxException e) { - // e.printStackTrace(); - // } - - // return payload; - // } -} diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRTriggerTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRTriggerTest.java index 923a711e..21e13f52 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRTriggerTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRTriggerTest.java @@ -1,5 +1,10 @@ package io.jenkins.plugins.bitbucketpushandpullrequest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import hudson.scm.SCM; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRPullRequestServerAction; import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; @@ -8,25 +13,22 @@ import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.model.server.BitBucketPPRServerClone; import io.jenkins.plugins.bitbucketpushandpullrequest.observer.BitBucketPPRObservable; -import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.MockedStatic; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.*; -import static org.mockito.Mockito.when; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; @ExtendWith(MockitoExtension.class) -public class BitBucketPPRTriggerTest { +@MockitoSettings(strictness = Strictness.LENIENT) +class BitBucketPPRTriggerTest { @Test - public void testTriggerUrlOverridesBaseUrl() { + void testTriggerUrlOverridesBaseUrl() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -41,11 +43,13 @@ public void testTriggerUrlOverridesBaseUrl() { when(mockServerClone.getHref()) .thenReturn("ssh://git@example.org/some-namespace/some-repo.git"); clones.add(mockServerClone); - when(payloadMock.getServerRepository().getLinks().getCloneProperty()).thenReturn(clones); + when(payloadMock.getServerRepository().getLinks().getCloneProperty()).thenReturn( + clones); BitBucketPPRHookEvent bitbucketEvent = mock(BitBucketPPRHookEvent.class); BitBucketPPRPullRequestServerAction bitBucketPPRServerRepositoryAction = new BitBucketPPRPullRequestServerAction(payloadMock, bitbucketEvent); - BitBucketPPRTriggerFilter bitBucketPPRTriggerFilter = mock(BitBucketPPRTriggerFilter.class); + BitBucketPPRTriggerFilter bitBucketPPRTriggerFilter = mock( + BitBucketPPRTriggerFilter.class); BitBucketPPRTrigger bitBucketPPRTrigger = new BitBucketPPRTrigger(List.of(bitBucketPPRTriggerFilter)); bitBucketPPRTrigger.setPropagationUrl( @@ -60,9 +64,6 @@ public void testTriggerUrlOverridesBaseUrl() { "https://example2.org:-1", bitBucketPPRServerRepositoryAction.getCommitLink() .split("/rest/build-status/1.0/commits/")[0]); - - } catch (Exception e) { - throw new RuntimeException(e); } } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestActionTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestActionTest.java index 75e856a0..5b4530bc 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestActionTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestActionTest.java @@ -1,19 +1,21 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.action; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRHookEvent; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; import org.mockito.Mockito; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.*; - -public class BitBucketPPRPullRequestActionTest { +class BitBucketPPRPullRequestActionTest { @Test - public void testGetMergeCommit() { + void testGetMergeCommit() { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -24,7 +26,8 @@ public void testGetMergeCommit() { when(payloadMock.getPullRequest().getMergeCommit().getHash()).thenReturn("123456"); BitBucketPPRHookEvent event = mock(BitBucketPPRHookEvent.class); when(event.getAction()).thenReturn("fulfilled"); - BitBucketPPRPullRequestAction action = new BitBucketPPRPullRequestAction(payloadMock, event); + BitBucketPPRPullRequestAction action = new BitBucketPPRPullRequestAction(payloadMock, + event); assertEquals("123456", action.getLatestCommit()); } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerActionTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerActionTest.java index 414dcad9..8dbc515a 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerActionTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerActionTest.java @@ -1,24 +1,25 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.action; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; -import io.jenkins.plugins.bitbucketpushandpullrequest.exception.BitBucketPPRPayloadPropertyNotFoundException; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRHookEvent; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.model.server.BitBucketPPRServerClone; -import org.junit.Test; -import org.mockito.MockedStatic; -import org.mockito.Mockito; - import java.util.ArrayList; import java.util.List; +import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; -import static org.junit.Assert.assertEquals; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.Mockito.*; +class BitBucketPPRPullRequestServerActionTest { -public class BitBucketPPRPullRequestServerActionTest { @Test - public void testBaseUrlSet() { + void testBaseUrlSet() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -34,31 +35,27 @@ public void testBaseUrlSet() { when(mockServerClone.getHref()) .thenReturn("ssh://git@example.org/some-namespace/some-repo.git"); clones.add(mockServerClone); - when(payloadMock.getServerRepository().getLinks().getCloneProperty()).thenReturn(clones); - BitBucketPPRPullRequestServerAction bitBucketPPRPullRequestServerAction; - try { - BitBucketPPRHookEvent bitbucketEvent = mock(BitBucketPPRHookEvent.class); - when(bitbucketEvent.getAction()).thenReturn("created"); - bitBucketPPRPullRequestServerAction = - new BitBucketPPRPullRequestServerAction(payloadMock, bitbucketEvent); - assertDoesNotThrow( - () -> { - bitBucketPPRPullRequestServerAction.getCommitLink(); - }); - } catch (BitBucketPPRPayloadPropertyNotFoundException e) { - e.printStackTrace(); - } + when(payloadMock.getServerRepository().getLinks().getCloneProperty()).thenReturn( + clones); + + BitBucketPPRHookEvent bitbucketEvent = mock(BitBucketPPRHookEvent.class); + when(bitbucketEvent.getAction()).thenReturn("created"); + BitBucketPPRPullRequestServerAction bitBucketPPRPullRequestServerAction = + new BitBucketPPRPullRequestServerAction(payloadMock, bitbucketEvent); + + assertDoesNotThrow(bitBucketPPRPullRequestServerAction::getCommitLink); } } @Test - public void testGetMergeCommit() throws BitBucketPPRPayloadPropertyNotFoundException { + void testGetMergeCommit() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); config.when(BitBucketPPRPluginConfig::getInstance).thenReturn(c); BitBucketPPRPayload payloadMock = mock(BitBucketPPRPayload.class, RETURNS_DEEP_STUBS); - when(payloadMock.getServerPullRequest().getProperties().getMergeCommit().getId()).thenReturn("123456"); + when(payloadMock.getServerPullRequest().getProperties().getMergeCommit() + .getId()).thenReturn("123456"); BitBucketPPRHookEvent event = mock(BitBucketPPRHookEvent.class); when(event.getAction()).thenReturn("merged"); BitBucketPPRPullRequestServerAction action = diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRServerRepositoryActionTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRServerRepositoryActionTest.java index 6a481c78..83bf2da4 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRServerRepositoryActionTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRServerRepositoryActionTest.java @@ -1,49 +1,49 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.action; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.model.server.BitBucketPPRServerClone; -import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.MockedStatic; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.Mockito.*; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; @ExtendWith(MockitoExtension.class) -public class BitBucketPPRServerRepositoryActionTest { - - - @Test - public void testBaseUrlSet() { - try (MockedStatic config = Mockito.mockStatic( - BitBucketPPRPluginConfig.class)) { - BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); - config.when(BitBucketPPRPluginConfig::getInstance).thenReturn(c); - when(c.getPropagationUrl()).thenReturn("https://example.org/scm/some-namespace/some-repo.git"); - - BitBucketPPRPayload payloadMock = mock(BitBucketPPRPayload.class, RETURNS_DEEP_STUBS); - List clones = new ArrayList<>(); - BitBucketPPRServerClone mockServerClone = mock(BitBucketPPRServerClone.class); - when(mockServerClone.getName()).thenReturn("ssh"); - when(mockServerClone.getHref()).thenReturn("ssh://git@example.org/some-namespace/some-repo.git"); - clones.add(mockServerClone); - when(payloadMock.getServerRepository().getLinks().getCloneProperty()).thenReturn(clones); - BitBucketPPRServerRepositoryAction bitBucketPPRServerRepositoryAction = new BitBucketPPRServerRepositoryAction(payloadMock); - - assertDoesNotThrow(() -> { - bitBucketPPRServerRepositoryAction.getCommitLinks(); - }); - } - - +@MockitoSettings(strictness = Strictness.LENIENT) +class BitBucketPPRServerRepositoryActionTest { + + @Test + void testBaseUrlSet() { + try (MockedStatic config = Mockito.mockStatic( + BitBucketPPRPluginConfig.class)) { + BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); + config.when(BitBucketPPRPluginConfig::getInstance).thenReturn(c); + when(c.getPropagationUrl()).thenReturn( + "https://example.org/scm/some-namespace/some-repo.git"); + + BitBucketPPRPayload payloadMock = mock(BitBucketPPRPayload.class, RETURNS_DEEP_STUBS); + List clones = new ArrayList<>(); + BitBucketPPRServerClone mockServerClone = mock(BitBucketPPRServerClone.class); + when(mockServerClone.getName()).thenReturn("ssh"); + when(mockServerClone.getHref()).thenReturn( + "ssh://git@example.org/some-namespace/some-repo.git"); + clones.add(mockServerClone); + when(payloadMock.getServerRepository().getLinks().getCloneProperty()).thenReturn( + clones); + BitBucketPPRServerRepositoryAction bitBucketPPRServerRepositoryAction = new BitBucketPPRServerRepositoryAction( + payloadMock); + + assertDoesNotThrow(bitBucketPPRServerRepositoryAction::getCommitLinks); } - - + } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/api/BitBucketPPRBearerAuthorizationApiConsumerTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/api/BitBucketPPRBearerAuthorizationApiConsumerTest.java index ffd3fc47..7d3c66e9 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/api/BitBucketPPRBearerAuthorizationApiConsumerTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/client/api/BitBucketPPRBearerAuthorizationApiConsumerTest.java @@ -1,26 +1,23 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.client.api; - -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; + +import com.github.scribejava.core.model.Verb; import org.apache.http.HttpResponse; import org.jenkinsci.plugins.plaincredentials.StringCredentials; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.runner.RunWith; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.jupiter.MockitoExtension; -import com.github.scribejava.core.model.Verb; - @ExtendWith(MockitoExtension.class) -public class BitBucketPPRBearerAuthorizationApiConsumerTest { +class BitBucketPPRBearerAuthorizationApiConsumerTest { - @Ignore + @Disabled @Test - public void testSend() throws Exception { + void testSend() throws Exception { StringCredentials credentials = Mockito.mock(StringCredentials.class, RETURNS_DEEP_STUBS); Mockito.when(credentials.getSecret().getPlainText()).thenReturn(""); diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/common/BitBucketPPRUtilsTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/common/BitBucketPPRUtilsTest.java index 5536d977..6a156a23 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/common/BitBucketPPRUtilsTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/common/BitBucketPPRUtilsTest.java @@ -1,49 +1,51 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.common; -import io.jenkins.plugins.bitbucketpushandpullrequest.exception.BitBucketPPRRepositoryNotParsedException; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.params.provider.Arguments.arguments; import java.util.Map; import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.params.provider.Arguments.arguments; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class BitBucketPPRUtilsTest { - @ParameterizedTest - @MethodSource("gitSSHRepos") - void testExtractRepositoryNameFromSSHUri(String repository, String expectedResultWorkspace, String expectedResultRepository) { - BitBucketPPRUtils utils = new BitBucketPPRUtils(); - Map res = utils.extractRepositoryNameFromSSHUri(repository); - - assertEquals(expectedResultWorkspace, res.get(BitBucketPPRUtils.BB_WORKSPACE)); - assertEquals(expectedResultRepository, res.get(BitBucketPPRUtils.BB_REPOSITORY)); - } - - private static Stream gitSSHRepos() { - return Stream.of( - arguments("git@bitbucket.org:work-space/reponame.git","work-space", "reponame"), - arguments("git@bitbucket.org:workspace/reponame.git", "workspace", "reponame"), - arguments("git@bitbucket.org:work&&space/reponame.git", "work&&space", "reponame")); - } - - @ParameterizedTest - @MethodSource("gitHTTPSRepos") - void testExtractRepositoryNameFromHTTPSUrl(String repository, String expectedResultWorkspace, String expectedResultRepository) throws BitBucketPPRRepositoryNotParsedException { - BitBucketPPRUtils utils = new BitBucketPPRUtils(); - Map res = utils.extractRepositoryNameFromHTTPSUrlForTest(repository); - - assertEquals(expectedResultWorkspace, res.get(BitBucketPPRUtils.BB_WORKSPACE)); - assertEquals(expectedResultRepository, res.get(BitBucketPPRUtils.BB_REPOSITORY)); - } - - private static Stream gitHTTPSRepos() { - return Stream.of( - arguments("https://username@bitbucket.org/work-space/reponame","work-space", "reponame"), - arguments("https://username@bitbucket.org/workspace/reponame", "workspace", "reponame"), - arguments("https://username@bitbucket.org/work&&space/reponame/", "work&&space", "reponame")); - } + @ParameterizedTest + @MethodSource("gitSSHRepos") + void testExtractRepositoryNameFromSSHUri(String repository, String expectedResultWorkspace, + String expectedResultRepository) { + BitBucketPPRUtils utils = new BitBucketPPRUtils(); + Map res = utils.extractRepositoryNameFromSSHUri(repository); + + assertEquals(expectedResultWorkspace, res.get(BitBucketPPRUtils.BB_WORKSPACE)); + assertEquals(expectedResultRepository, res.get(BitBucketPPRUtils.BB_REPOSITORY)); + } + + static Stream gitSSHRepos() { + return Stream.of( + arguments("git@bitbucket.org:work-space/reponame.git", "work-space", "reponame"), + arguments("git@bitbucket.org:workspace/reponame.git", "workspace", "reponame"), + arguments("git@bitbucket.org:work&&space/reponame.git", "work&&space", "reponame")); + } + + @ParameterizedTest + @MethodSource("gitHTTPSRepos") + void testExtractRepositoryNameFromHTTPSUrl(String repository, String expectedResultWorkspace, + String expectedResultRepository) throws Exception { + BitBucketPPRUtils utils = new BitBucketPPRUtils(); + Map res = utils.extractRepositoryNameFromHTTPSUrlForTest(repository); + + assertEquals(expectedResultWorkspace, res.get(BitBucketPPRUtils.BB_WORKSPACE)); + assertEquals(expectedResultRepository, res.get(BitBucketPPRUtils.BB_REPOSITORY)); + } + + static Stream gitHTTPSRepos() { + return Stream.of( + arguments("https://username@bitbucket.org/work-space/reponame", "work-space", + "reponame"), + arguments("https://username@bitbucket.org/workspace/reponame", "workspace", "reponame"), + arguments("https://username@bitbucket.org/work&&space/reponame/", "work&&space", + "reponame")); + } } \ No newline at end of file diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRConfigAttributesTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRConfigAttributesTest.java index 28dd816a..968162ec 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRConfigAttributesTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRConfigAttributesTest.java @@ -1,22 +1,21 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.config; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -import static org.junit.Assert.assertTrue; +@ExtendWith(MockitoExtension.class) +class BitBucketPPRConfigAttributesTest { -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRConfigAttributesTest { - - final private Class config = BitBucketPPRPluginConfig.class; + private final Class config = BitBucketPPRPluginConfig.class; @Test - public void settersHaveGetters() { + void settersHaveGetters() { for (Method method : config.getMethods()) { final String methodName = method.getName(); if (method.getParameterCount() != 1 || !methodName.startsWith("set")) { @@ -25,7 +24,7 @@ public void settersHaveGetters() { } final String s = methodName.substring(3); - assertTrue(s, hasGetter(s)); + assertTrue(hasGetter(s), s); } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/environment/BitBucketPPREnvironmentContributorTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/environment/BitBucketPPREnvironmentContributorTest.java index bdbc2186..a8683df6 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/environment/BitBucketPPREnvironmentContributorTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/environment/BitBucketPPREnvironmentContributorTest.java @@ -21,33 +21,16 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.environment; -import static org.hamcrest.collection.IsMapContaining.hasEntry; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.hamcrest.collection.IsMapContaining.hasEntry; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - import com.google.gson.Gson; import com.google.gson.stream.JsonReader; - -import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.MockedStatic; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; - import hudson.EnvVars; import hudson.model.Cause; import hudson.model.Run; @@ -62,25 +45,39 @@ import io.jenkins.plugins.bitbucketpushandpullrequest.cause.pullrequest.server.BitBucketPPRPullRequestServerCause; import io.jenkins.plugins.bitbucketpushandpullrequest.cause.repository.BitBucketPPRRepositoryCause; import io.jenkins.plugins.bitbucketpushandpullrequest.cause.repository.BitBucketPPRServerRepositoryCause; +import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; import io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud.BitBucketPPRPullRequestCreatedActionFilter; import io.jenkins.plugins.bitbucketpushandpullrequest.filter.repository.BitBucketPPRRepositoryPushActionFilter; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRHookEvent; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud.BitBucketPPRCloudPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.model.server.BitBucketPPRServerPayload; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -public class BitBucketPPREnvironmentContributorTest { +class BitBucketPPREnvironmentContributorTest { private EnvVars envVars; - @Before - public void buildEnvVarsSpy() { + @BeforeEach + void setUp() { envVars = spy(EnvVars.class); } @Test - public void buildEnvironmentForCloudRepoPushTest() { + void buildEnvironmentForCloudRepoPushTest() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -100,7 +97,8 @@ public void buildEnvironmentForCloudRepoPushTest() { assertThat( envVars, hasEntry( - BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "feature/do-not-merge")); + BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, + "feature/do-not-merge")); assertThat( envVars, hasEntry( @@ -128,7 +126,7 @@ public void buildEnvironmentForCloudRepoPushTest() { } @Test - public void buildEnvironmentForCloudPullRequestCreatedTest() { + void buildEnvironmentForCloudPullRequestCreatedTest() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -148,18 +146,22 @@ public void buildEnvironmentForCloudPullRequestCreatedTest() { assertThat( envVars, hasEntry( - BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "feature/do-not-merge")); + BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, + "feature/do-not-merge")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); assertThat( envVars, hasEntry( BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_LINK, "https://bitbucket.org/some-repo-namespace/some-repo/pull-requests/198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); assertThat( envVars, hasEntry( @@ -179,7 +181,7 @@ public void buildEnvironmentForCloudPullRequestCreatedTest() { } @Test - public void buildEnvironmentForCloudPullRequestMergedTest() { + void buildEnvironmentForCloudPullRequestMergedTest() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -199,18 +201,22 @@ public void buildEnvironmentForCloudPullRequestMergedTest() { assertThat( envVars, hasEntry( - BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "feature/do-not-merge")); + BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, + "feature/do-not-merge")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); assertThat( envVars, hasEntry( BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_LINK, "https://bitbucket.org/some-repo-namespace/some-repo/pull-requests/198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); assertThat( envVars, hasEntry( @@ -230,7 +236,7 @@ public void buildEnvironmentForCloudPullRequestMergedTest() { } @Test - public void buildEnvironmentForCloudPullRequestDeclinedTest() { + void buildEnvironmentForCloudPullRequestDeclinedTest() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -250,18 +256,22 @@ public void buildEnvironmentForCloudPullRequestDeclinedTest() { assertThat( envVars, hasEntry( - BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "feature/do-not-merge")); + BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, + "feature/do-not-merge")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); assertThat( envVars, hasEntry( BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_LINK, "https://bitbucket.org/some-repo-namespace/some-repo/pull-requests/198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); assertThat( envVars, hasEntry( @@ -281,7 +291,7 @@ public void buildEnvironmentForCloudPullRequestDeclinedTest() { } @Test - public void buildEnvironmentForCloudPullRequestUpdatedTest() { + void buildEnvironmentForCloudPullRequestUpdatedTest() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -301,18 +311,22 @@ public void buildEnvironmentForCloudPullRequestUpdatedTest() { assertThat( envVars, hasEntry( - BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "feature/do-not-merge")); + BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, + "feature/do-not-merge")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); assertThat( envVars, hasEntry( BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_LINK, "https://bitbucket.org/some-repo-namespace/some-repo/pull-requests/198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); assertThat( envVars, hasEntry( @@ -332,7 +346,7 @@ public void buildEnvironmentForCloudPullRequestUpdatedTest() { } @Test - public void buildEnvironmentForCloudPullRequestApprovedTest() { + void buildEnvironmentForCloudPullRequestApprovedTest() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -353,18 +367,22 @@ public void buildEnvironmentForCloudPullRequestApprovedTest() { assertThat( envVars, hasEntry( - BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "feature/do-not-merge")); + BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, + "feature/do-not-merge")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "develop")); assertThat( envVars, hasEntry( BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_LINK, "https://bitbucket.org/some-repo-namespace/some-repo/pull-requests/198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); assertThat( envVars, hasEntry( @@ -384,7 +402,7 @@ public void buildEnvironmentForCloudPullRequestApprovedTest() { } @Test - public void buildEnvironmentForCloudPullRequestCommentCreatedTest() { + void buildEnvironmentForCloudPullRequestCommentCreatedTest() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -404,20 +422,24 @@ public void buildEnvironmentForCloudPullRequestCommentCreatedTest() { assertThat( envVars, hasEntry( - BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "feature/do-not-merge")); + BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, + "feature/do-not-merge")); assertThat( envVars, hasEntry( - BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "destination-branch")); + BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, + "destination-branch")); assertThat( envVars, hasEntry( BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_LINK, "https://bitbucket.org/some-repo-namespace/some-repo/pull-requests/198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "198")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-nickname")); assertThat( envVars, hasEntry( @@ -436,15 +458,16 @@ public void buildEnvironmentForCloudPullRequestCommentCreatedTest() { } } - @Ignore + @Disabled @Test - public void buildEnvironmentForServerPullRequestOpenedTest() throws Exception { + void buildEnvironmentForServerPullRequestOpenedTest() throws Exception { BitBucketPPRServerPayload payload = getServerPayload("./server/pr_opened.json"); BitBucketPPRPullRequestServerCause cause = mock(BitBucketPPRPullRequestServerCause.class); when(cause.getPullRequestPayLoad()) .thenReturn( - new BitBucketPPRPullRequestServerAction(payload, mock(BitBucketPPRHookEvent.class))); + new BitBucketPPRPullRequestServerAction(payload, + mock(BitBucketPPRHookEvent.class))); when(cause.getHookEvent()).thenReturn("X-EVENT"); // do @@ -452,9 +475,11 @@ public void buildEnvironmentForServerPullRequestOpenedTest() throws Exception { // assert assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "61")); assertThat( @@ -462,27 +487,31 @@ public void buildEnvironmentForServerPullRequestOpenedTest() throws Exception { hasEntry( BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_LINK, "http://example.org/projects/ABC/repos/some-repo/pullrequests/61")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_DESCRIPTION, "")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PAYLOAD, payload.toString())); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); } - @Ignore + @Disabled @Test - public void buildEnvironmentForServerPullRequestModifiedTest() throws Exception { + void buildEnvironmentForServerPullRequestModifiedTest() throws Exception { BitBucketPPRServerPayload payload = getServerPayload("./server/pr_modified.json"); BitBucketPPRPullRequestServerCause cause = mock(BitBucketPPRPullRequestServerCause.class); when(cause.getPullRequestPayLoad()) .thenReturn( - new BitBucketPPRPullRequestServerAction(payload, mock(BitBucketPPRHookEvent.class))); + new BitBucketPPRPullRequestServerAction(payload, + mock(BitBucketPPRHookEvent.class))); when(cause.getHookEvent()).thenReturn("X-EVENT"); // do @@ -490,9 +519,11 @@ public void buildEnvironmentForServerPullRequestModifiedTest() throws Exception // assert assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); assertThat( envVars, hasEntry( @@ -500,27 +531,31 @@ public void buildEnvironmentForServerPullRequestModifiedTest() throws Exception "http://example.org/projects/ABC/repos/some-repo/pull-requests/13")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "13")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_DESCRIPTION, "")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PAYLOAD, payload.toString())); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); } - @Ignore + @Disabled @Test - public void buildEnvironmentForServerSourcePullRequestUpdatedTest() throws Exception { + void buildEnvironmentForServerSourcePullRequestUpdatedTest() throws Exception { BitBucketPPRServerPayload payload = getServerPayload("./server/pr_from_ref_updated.json"); BitBucketPPRPullRequestServerCause cause = mock(BitBucketPPRPullRequestServerCause.class); when(cause.getPullRequestPayLoad()) .thenReturn( - new BitBucketPPRPullRequestServerAction(payload, mock(BitBucketPPRHookEvent.class))); + new BitBucketPPRPullRequestServerAction(payload, + mock(BitBucketPPRHookEvent.class))); when(cause.getHookEvent()).thenReturn("X-EVENT"); // do @@ -528,9 +563,11 @@ public void buildEnvironmentForServerSourcePullRequestUpdatedTest() throws Excep // assert assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); assertThat( envVars, hasEntry( @@ -538,27 +575,31 @@ public void buildEnvironmentForServerSourcePullRequestUpdatedTest() throws Excep "http://example.org/projects/ABC/repos/some-repo/pull-requests/61")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "1")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_DESCRIPTION, "")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PAYLOAD, payload.toString())); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); } - @Ignore + @Disabled @Test - public void buildEnvironmentForServerPullRequestApprovedTest() throws Exception { + void buildEnvironmentForServerPullRequestApprovedTest() throws Exception { BitBucketPPRServerPayload payload = getServerPayload("./server/pr_reviewer_approved.json"); BitBucketPPRPullRequestServerCause cause = mock(BitBucketPPRPullRequestServerCause.class); when(cause.getPullRequestPayLoad()) .thenReturn( - new BitBucketPPRPullRequestServerAction(payload, mock(BitBucketPPRHookEvent.class))); + new BitBucketPPRPullRequestServerAction(payload, + mock(BitBucketPPRHookEvent.class))); when(cause.getHookEvent()).thenReturn("X-EVENT"); // do @@ -566,9 +607,11 @@ public void buildEnvironmentForServerPullRequestApprovedTest() throws Exception // assert assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); assertThat( envVars, hasEntry( @@ -579,25 +622,28 @@ public void buildEnvironmentForServerPullRequestApprovedTest() throws Exception assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "some-reviewer")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_DESCRIPTION, "")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PAYLOAD, payload.toString())); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); } - @Ignore + @Disabled @Test - public void buildEnvironmentForServerPullRequestMergedTest() throws Exception { + void buildEnvironmentForServerPullRequestMergedTest() throws Exception { BitBucketPPRServerPayload payload = getServerPayload("./server/pr_merged.json"); BitBucketPPRPullRequestServerCause cause = mock(BitBucketPPRPullRequestServerCause.class); when(cause.getPullRequestPayLoad()) .thenReturn( - new BitBucketPPRPullRequestServerAction(payload, mock(BitBucketPPRHookEvent.class))); + new BitBucketPPRPullRequestServerAction(payload, + mock(BitBucketPPRHookEvent.class))); when(cause.getHookEvent()).thenReturn("X-EVENT"); // do @@ -605,9 +651,11 @@ public void buildEnvironmentForServerPullRequestMergedTest() throws Exception { // assert assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "develop")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); assertThat( envVars, hasEntry( @@ -615,27 +663,31 @@ public void buildEnvironmentForServerPullRequestMergedTest() throws Exception { "http://example.org/projects/ABC/repos/some-repo/pull-requests/61")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "61")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "test")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_DESCRIPTION, "")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PAYLOAD, payload.toString())); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); } - @Ignore + @Disabled @Test - public void buildEnvironmentForServerPullRequestDeclinedTest() throws Exception { + void buildEnvironmentForServerPullRequestDeclinedTest() throws Exception { BitBucketPPRServerPayload payload = getServerPayload("./server/pr_declined.json"); BitBucketPPRPullRequestServerCause cause = mock(BitBucketPPRPullRequestServerCause.class); when(cause.getPullRequestPayLoad()) .thenReturn( - new BitBucketPPRPullRequestServerAction(payload, mock(BitBucketPPRHookEvent.class))); + new BitBucketPPRPullRequestServerAction(payload, + mock(BitBucketPPRHookEvent.class))); when(cause.getHookEvent()).thenReturn("X-EVENT"); // do @@ -646,7 +698,8 @@ public void buildEnvironmentForServerPullRequestDeclinedTest() throws Exception envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "bugfix/tst-2")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); assertThat( envVars, hasEntry( @@ -654,22 +707,25 @@ public void buildEnvironmentForServerPullRequestDeclinedTest() throws Exception "http://bitbucket:7990/projects/PPRPLUG/repos/hellophp/pull-requests/7")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "7")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); assertThat( envVars, - hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "dummy change")); + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, + "dummy change")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_DESCRIPTION, "")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PAYLOAD, payload.toString())); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); } - @Ignore + @Disabled @Test - public void buildEnvironmentForServerRepoPushTest() { + void buildEnvironmentForServerRepoPushTest() throws Exception { BitBucketPPRServerPayload payload = getServerPayload("./server/repo_refs_changed.json"); BitBucketPPRServerRepositoryCause cause = mock(BitBucketPPRServerRepositoryCause.class); @@ -681,24 +737,29 @@ public void buildEnvironmentForServerRepoPushTest() { runEnvironmentContributorForCause(cause); // assert - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.REPOSITORY_NAME, "some-repo")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_REPOSITORY_ID, "99")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.REPOSITORY_NAME, "some-repo")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "me-name")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_REPOSITORY_ID, "99")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PAYLOAD, payload.toString())); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); } - @Ignore + @Disabled @Test - public void buildEnvironmentForServerCommentCreatedTest() throws Exception { + void buildEnvironmentForServerCommentCreatedTest() throws Exception { BitBucketPPRServerPayload payload = getServerPayload("./server/pr_comment_created.json"); BitBucketPPRPullRequestServerCause cause = mock(BitBucketPPRPullRequestServerCause.class); when(cause.getPullRequestPayLoad()) .thenReturn( - new BitBucketPPRPullRequestServerAction(payload, mock(BitBucketPPRHookEvent.class))); + new BitBucketPPRPullRequestServerAction(payload, + mock(BitBucketPPRHookEvent.class))); when(cause.getHookEvent()).thenReturn("X-EVENT"); // do @@ -706,9 +767,11 @@ public void buildEnvironmentForServerCommentCreatedTest() throws Exception { // assert assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "test-pr2")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_SOURCE_BRANCH, "test-pr2")); assertThat( - envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); + envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_TARGET_BRANCH, "master")); assertThat( envVars, hasEntry( @@ -716,7 +779,8 @@ public void buildEnvironmentForServerCommentCreatedTest() throws Exception { "https://bitbucket.company.com/bitbucket/users/username/repos/test-repo/pull-requests/2")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_ID, "2")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "username")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_ACTOR, "username")); assertThat( envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_TITLE, "Test pr2")); @@ -731,11 +795,12 @@ public void buildEnvironmentForServerCommentCreatedTest() throws Exception { hasEntry( BitBucketPPREnvironmentContributor.BITBUCKET_PULL_REQUEST_COMMENT_TEXT, "Comment content")); - assertThat(envVars, hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); + assertThat(envVars, + hasEntry(BitBucketPPREnvironmentContributor.BITBUCKET_X_EVENT, "X-EVENT")); } @Test - public void getBitbucketEventKeyPrOpenedTest() throws Exception { + void getBitbucketEventKeyPrOpenedTest() throws Exception { String hookEventAction = "pr:opened"; String prefix = "jenkinsUnitTests"; String suffix = "environmentContributor_getBitbucketEventKeyTest"; @@ -749,13 +814,13 @@ public void getBitbucketEventKeyPrOpenedTest() throws Exception { actionFilter.getCause(pollingLog, bitbucketAction, bitBucketHookEvent); assertEquals( - "Bitbuckethook event and hockEvent property of cause object are the same.", + hookEventAction, cause.getHookEvent(), - hookEventAction); + "Bitbuckethook event and hockEvent property of cause object are the same."); } @Test - public void getBitbucketEventKeyrepoRefsChangedTest() throws Exception { + void getBitbucketEventKeyrepoRefsChangedTest() throws Exception { String hookEventAction = "repo:refs_changed"; String prefix = "jenkinsUnitTests"; String suffix = "environmentContributor_getBitbucketEventKeyTest"; @@ -772,13 +837,13 @@ public void getBitbucketEventKeyrepoRefsChangedTest() throws Exception { actionFilter.getCause(pollingLog, bitbucketAction, bitBucketHookEvent); assertEquals( - "Bitbuckethook event and hockEvent property of cause object are the same.", + hookEventAction, cause.getHookEvent(), - hookEventAction); + "Bitbuckethook event and hockEvent property of cause object are the same."); } private BitBucketPPRPayload getCloudPayload(String res) { - return (BitBucketPPRPayload) getGenericPayload(res, BitBucketPPRCloudPayload.class); + return getGenericPayload(res, BitBucketPPRCloudPayload.class); } private BitBucketPPRServerPayload getServerPayload(String res) { @@ -786,21 +851,17 @@ private BitBucketPPRServerPayload getServerPayload(String res) { } private BitBucketPPRPayload getGenericPayload(String res, Class payloadClass) { - JsonReader reader = null; - try { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream(res); - InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); - reader = new JsonReader(isr); - } catch (Exception e) { - e.printStackTrace(); - fail("Failed to parse JSON payload stub."); - } + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream(res); + assertNotNull(is); + InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); + JsonReader reader = new JsonReader(isr); return new Gson().fromJson(reader, payloadClass); } - private void runEnvironmentContributorForCause(BitBucketPPRTriggerCause cause) { + private void runEnvironmentContributorForCause(BitBucketPPRTriggerCause cause) + throws Exception { BitBucketPPREnvironmentContributor envContributor = new BitBucketPPREnvironmentContributor(); Run run = mock(Run.class); @@ -809,11 +870,6 @@ private void runEnvironmentContributorForCause(BitBucketPPRTriggerCause cause) { causes.add(cause); when(run.getCauses()).thenReturn(causes); - try { - envContributor.buildEnvironmentFor(run, envVars, mock(TaskListener.class)); - } catch (Exception e) { - e.printStackTrace(); - fail("Exception thrown"); - } + envContributor.buildEnvironmentFor(run, envVars, mock(TaskListener.class)); } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/extension/dsl/BitBucketPPRHookJobDslExtensionTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/extension/dsl/BitBucketPPRHookJobDslExtensionTest.java index bcc4e16e..79823b67 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/extension/dsl/BitBucketPPRHookJobDslExtensionTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/extension/dsl/BitBucketPPRHookJobDslExtensionTest.java @@ -21,23 +21,11 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.extension.dsl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.IOUtils; -import org.jenkinsci.plugins.workflow.job.WorkflowJob; -import org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.jvnet.hudson.test.JenkinsRule; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.model.FreeStyleProject; import hudson.triggers.Trigger; import hudson.triggers.TriggerDescriptor; @@ -48,15 +36,35 @@ import io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud.BitBucketPPRPullRequestMergedActionFilter; import io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud.BitBucketPPRPullRequestUpdatedActionFilter; import io.jenkins.plugins.bitbucketpushandpullrequest.filter.repository.BitBucketPPRRepositoryPushActionFilter; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import javaposse.jobdsl.plugin.ExecuteDslScripts; import javaposse.jobdsl.plugin.RemovedJobAction; +import org.apache.commons.io.IOUtils; +import org.jenkinsci.plugins.workflow.job.WorkflowJob; +import org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +@WithJenkins +class BitBucketPPRHookJobDslExtensionTest { -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRHookJobDslExtensionTest { - /* Global Jenkins instance mock */ - @Rule - public JenkinsRule j = new JenkinsRule(); + private JenkinsRule j; + + @BeforeEach + void setUp(JenkinsRule rule) { + j = rule; + } private void createSeedJob(String desc) throws Exception { /* Create seed job which will process DSL */ @@ -73,19 +81,14 @@ private void createSeedJob(String desc) throws Exception { } private String readDslScript(String path) throws Exception { - String script = null; - try { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream(path); - script = IOUtils.toString(is, StandardCharsets.UTF_8); - } catch (Exception e) { - e.printStackTrace(); - } - return script; + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream(path); + assertNotNull(is); + return IOUtils.toString(is, StandardCharsets.UTF_8); } @Test - public void testDslTriggerPushActionFreeStyle() throws Exception { + void testDslTriggerPushActionFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPushActionFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -98,21 +101,22 @@ public void testDslTriggerPushActionFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - BitBucketPPRRepositoryPushActionFilter tmp3 = (BitBucketPPRRepositoryPushActionFilter) tmp2.getTriggers().get(0) + BitBucketPPRRepositoryPushActionFilter tmp3 = (BitBucketPPRRepositoryPushActionFilter) tmp2.getTriggers() + .get(0) .getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRRepositoryPushActionFilter"); + assertEquals("BitBucketPPRRepositoryPushActionFilter", dispNames.get(0)); assertFalse(isToApprove); } @Test - public void testDslTriggerIsToApprovePushActionFreeStyle() throws Exception { + void testDslTriggerIsToApprovePushActionFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerIsToApprovePushActionFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -125,20 +129,21 @@ public void testDslTriggerIsToApprovePushActionFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - BitBucketPPRRepositoryPushActionFilter tmp3 = (BitBucketPPRRepositoryPushActionFilter) tmp2.getTriggers().get(0).getActionFilter(); + BitBucketPPRRepositoryPushActionFilter tmp3 = (BitBucketPPRRepositoryPushActionFilter) tmp2.getTriggers() + .get(0).getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRRepositoryPushActionFilter"); + assertEquals("BitBucketPPRRepositoryPushActionFilter", dispNames.get(0)); assertTrue(isToApprove); } @Test - public void testDslTriggerPRApprovedFreeStyle() throws Exception { + void testDslTriggerPRApprovedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRApprovedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -159,13 +164,13 @@ public void testDslTriggerPRApprovedFreeStyle() throws Exception { isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestApprovedActionFilter"); + assertEquals("BitBucketPPRPullRequestApprovedActionFilter", dispNames.get(0)); assertFalse(isToApprove); } @Test - @Ignore - public void testDslTriggerPRIsToApproveApprovedFreeStyle() throws Exception { + @Disabled + void testDslTriggerPRIsToApproveApprovedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRIsToApproveApprovedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -178,22 +183,24 @@ public void testDslTriggerPRIsToApproveApprovedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - BitBucketPPRPullRequestApprovedActionFilter tmp3 = (BitBucketPPRPullRequestApprovedActionFilter) tmp2.getTriggers().get(0) + BitBucketPPRPullRequestApprovedActionFilter tmp3 = (BitBucketPPRPullRequestApprovedActionFilter) tmp2.getTriggers() + .get(0) .getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestApprovedActionFilter"); + assertEquals("BitBucketPPRPullRequestApprovedActionFilter", dispNames.get(0)); assertTrue(isToApprove); } @Test - public void testDslTriggerPRAllowedBranchesApprovedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesApprovedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesApprovedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRAllowedBranchesApprovedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -203,16 +210,16 @@ public void testDslTriggerPRAllowedBranchesApprovedFreeStyle() throws Exception for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestApprovedActionFilter"); + assertEquals("BitBucketPPRPullRequestApprovedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRCommentCreatedFreeStyle() throws Exception { + void testDslTriggerPRCommentCreatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRCommentCreatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -224,18 +231,19 @@ public void testDslTriggerPRCommentCreatedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCommentCreatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCommentCreatedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRAllowedBranchesCommentCreatedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesCommentCreatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesCommentCreatedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRAllowedBranchesCommentCreatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -245,18 +253,19 @@ public void testDslTriggerPRAllowedBranchesCommentCreatedFreeStyle() throws Exce for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCommentCreatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCommentCreatedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRCommentFilterCommentCreatedFreeStyle() throws Exception { + void testDslTriggerPRCommentFilterCommentCreatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRCommentFilterCommentCreatedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRCommentFilterCommentCreatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -266,16 +275,16 @@ public void testDslTriggerPRCommentFilterCommentCreatedFreeStyle() throws Except for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCommentCreatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCommentCreatedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRCommentUpdatedFreeStyle() throws Exception { + void testDslTriggerPRCommentUpdatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRCommentUpdatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -287,18 +296,19 @@ public void testDslTriggerPRCommentUpdatedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCommentUpdatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCommentUpdatedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRAllowedBranchesCommentUpdatedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesCommentUpdatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesCommentUpdatedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRAllowedBranchesCommentUpdatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -308,18 +318,19 @@ public void testDslTriggerPRAllowedBranchesCommentUpdatedFreeStyle() throws Exce for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCommentUpdatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCommentUpdatedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRCommentFilterCommentUpdatedFreeStyle() throws Exception { + void testDslTriggerPRCommentFilterCommentUpdatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRCommentFilterCommentUpdatedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRCommentFilterCommentUpdatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -329,16 +340,16 @@ public void testDslTriggerPRCommentFilterCommentUpdatedFreeStyle() throws Except for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCommentUpdatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCommentUpdatedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRCommentDeletedFreeStyle() throws Exception { + void testDslTriggerPRCommentDeletedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRCommentDeletedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -350,18 +361,19 @@ public void testDslTriggerPRCommentDeletedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCommentDeletedActionFilter"); + assertEquals("BitBucketPPRPullRequestCommentDeletedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRAllowedBranchesCommentDeletedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesCommentDeletedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesCommentDeletedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRAllowedBranchesCommentDeletedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -371,16 +383,16 @@ public void testDslTriggerPRAllowedBranchesCommentDeletedFreeStyle() throws Exce for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCommentDeletedActionFilter"); + assertEquals("BitBucketPPRPullRequestCommentDeletedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRCreatedFreeStyle() throws Exception { + void testDslTriggerPRCreatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRCreatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -392,16 +404,16 @@ public void testDslTriggerPRCreatedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRAllowBranchesCreatedFreeStyle() throws Exception { + void testDslTriggerPRAllowBranchesCreatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowBranchesCreatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -414,22 +426,23 @@ public void testDslTriggerPRAllowBranchesCreatedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); BitBucketPPRPullRequestCreatedActionFilter tmp3 = (BitBucketPPRPullRequestCreatedActionFilter) tmp2.getTriggers() .get(0).getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); assertFalse(isToApprove); } @Test - public void testDslTriggerPRAllowBranchesWithApproveCreatedFreeStyle() throws Exception { + void testDslTriggerPRAllowBranchesWithApproveCreatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowBranchesWithApproveCreatedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRAllowBranchesWithApproveCreatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -440,20 +453,20 @@ public void testDslTriggerPRAllowBranchesWithApproveCreatedFreeStyle() throws Ex for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); BitBucketPPRPullRequestCreatedActionFilter tmp3 = (BitBucketPPRPullRequestCreatedActionFilter) tmp2 .getTriggers().get(0).getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); assertTrue(isToApprove); } @Test - public void testDslTriggerPRUpdatedFreeeStyle() throws Exception { + void testDslTriggerPRUpdatedFreeeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRUpdatedFreeeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -465,18 +478,19 @@ public void testDslTriggerPRUpdatedFreeeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestUpdatedActionFilter"); + assertEquals("BitBucketPPRPullRequestUpdatedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRAllowedBranchesUpdatedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesUpdatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesUpdatedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRAllowedBranchesUpdatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -487,22 +501,23 @@ public void testDslTriggerPRAllowedBranchesUpdatedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); BitBucketPPRPullRequestUpdatedActionFilter tmp3 = (BitBucketPPRPullRequestUpdatedActionFilter) tmp2.getTriggers() .get(0).getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestUpdatedActionFilter"); + assertEquals("BitBucketPPRPullRequestUpdatedActionFilter", dispNames.get(0)); assertFalse(isToApprove); } @Test - public void testDslTriggerPRAllowedBranchesWithApproveUpdatedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesWithApproveUpdatedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesWithApproveUpdatedFreeStyle.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslTriggerPRAllowedBranchesWithApproveUpdatedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -513,21 +528,21 @@ public void testDslTriggerPRAllowedBranchesWithApproveUpdatedFreeStyle() throws for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); BitBucketPPRPullRequestUpdatedActionFilter tmp3 = (BitBucketPPRPullRequestUpdatedActionFilter) tmp2.getTriggers() .get(0).getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestUpdatedActionFilter"); + assertEquals("BitBucketPPRPullRequestUpdatedActionFilter", dispNames.get(0)); assertTrue(isToApprove); } @Test - public void testDslTriggerPRMergedFreeStyle() throws Exception { + void testDslTriggerPRMergedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRMergedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -539,16 +554,16 @@ public void testDslTriggerPRMergedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestMergedActionFilter"); + assertEquals("BitBucketPPRPullRequestMergedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRDeclinedFreeStyle() throws Exception { + void testDslTriggerPRDeclinedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRDeclinedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -560,16 +575,16 @@ public void testDslTriggerPRDeclinedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestDeclinedActionFilter"); + assertEquals("BitBucketPPRPullRequestDeclinedActionFilter", dispNames.get(0)); } @Test - public void testDslTriggerPRAllowedBranchesMergedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesMergedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesMergedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -582,22 +597,23 @@ public void testDslTriggerPRAllowedBranchesMergedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); BitBucketPPRPullRequestMergedActionFilter tmp3 = (BitBucketPPRPullRequestMergedActionFilter) tmp2.getTriggers() .get(0).getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestMergedActionFilter"); + assertEquals("BitBucketPPRPullRequestMergedActionFilter", dispNames.get(0)); assertFalse(isToApprove); } @Test - public void testDslTriggerPRAllowedBranchesDeclinedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesDeclinedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesDeclinedFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerPRAllowedBranchesDeclinedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -608,22 +624,23 @@ public void testDslTriggerPRAllowedBranchesDeclinedFreeStyle() throws Exception for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); BitBucketPPRPullRequestDeclinedActionFilter tmp3 = (BitBucketPPRPullRequestDeclinedActionFilter) tmp2.getTriggers() - .get(0).getActionFilter(); + .get(0).getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestDeclinedActionFilter"); + assertEquals("BitBucketPPRPullRequestDeclinedActionFilter", dispNames.get(0)); assertFalse(isToApprove); } @Test - public void testDslTriggerPRAllowedBranchesWithApproveMergedFreeStyle() throws Exception { + void testDslTriggerPRAllowedBranchesWithApproveMergedFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerPRAllowedBranchesWithApproveMergedFreeStyle.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslTriggerPRAllowedBranchesWithApproveMergedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -634,22 +651,23 @@ public void testDslTriggerPRAllowedBranchesWithApproveMergedFreeStyle() throws E for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); BitBucketPPRPullRequestMergedActionFilter tmp3 = (BitBucketPPRPullRequestMergedActionFilter) tmp2.getTriggers() .get(0).getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestMergedActionFilter"); + assertEquals("BitBucketPPRPullRequestMergedActionFilter", dispNames.get(0)); assertTrue(isToApprove); } @Test - public void testDslTriggerCreateUpdatedApprovedPRActionsFreeStyle() throws Exception { + void testDslTriggerCreateUpdatedApprovedPRActionsFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerCreateUpdatedApprovedPRActionsFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslTriggerCreateUpdatedApprovedPRActionsFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -661,26 +679,28 @@ public void testDslTriggerCreateUpdatedApprovedPRActionsFreeStyle() throws Excep BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Three different triggers expected */ assertEquals(3, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(3, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestApprovedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestApprovedActionFilter", dispNames.get(2)); } @Test - public void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesActionsFreeStyle() throws Exception { + void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesActionsFreeStyle() + throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerCreateUpdatedMergedDeclinedApprovedPRAllowBranchesActionsFreeStyle.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslTriggerCreateUpdatedMergedDeclinedApprovedPRAllowBranchesActionsFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -692,34 +712,36 @@ public void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesActionsFreeS BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Five different triggers expected */ assertEquals(5, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(5, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestMergedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestDeclinedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestApprovedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestMergedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestDeclinedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestApprovedActionFilter", dispNames.get(4)); } @Test - public void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveActionsFreeStyle() throws Exception { + void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveActionsFreeStyle() + throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveActionsFreeStyle.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveActionsFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -731,28 +753,28 @@ public void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveA BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Three different triggers expected */ assertEquals(4, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(4, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestMergedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestApprovedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestMergedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestApprovedActionFilter", dispNames.get(3)); } @Test - public void testDslMultipleJobsInSeedFreeStyle() throws Exception { + void testDslMultipleJobsInSeedFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslMultipleJobsInSeedFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -764,12 +786,12 @@ public void testDslMultipleJobsInSeedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); /* Verify second job content */ createdJob = (FreeStyleProject) j.getInstance().getItem("test-job2"); @@ -780,16 +802,16 @@ public void testDslMultipleJobsInSeedFreeStyle() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRRepositoryPushActionFilter"); + assertEquals("BitBucketPPRRepositoryPushActionFilter", dispNames.get(0)); } @Test - public void testDslServerAllPRActionsFreeStyle() throws Exception { + void testDslServerAllPRActionsFreeStyle() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslServerAllPRActionsFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -803,34 +825,35 @@ public void testDslServerAllPRActionsFreeStyle() throws Exception { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Five different triggers expected */ assertEquals(5, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(5, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestServerMergedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestServerDeclinedActionFilter"); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestServerDeclinedActionFilter", dispNames.get(4)); } @Test - public void testDslServerAllPRAllowedBranchesActionsFreeStyle() throws Exception { + void testDslServerAllPRAllowedBranchesActionsFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslServerAllPRAllowedBranchesActionsFreeStyle.groovy")); + createSeedJob( + readDslScript("./dsl/testDslServerAllPRAllowedBranchesActionsFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -842,40 +865,41 @@ public void testDslServerAllPRAllowedBranchesActionsFreeStyle() throws Exception BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Six different triggers expected */ assertEquals(6, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(5).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(5).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(6, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestServerSourceUpdatedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestServerMergedActionFilter"); - assertEquals(dispNames.get(5), "BitBucketPPRPullRequestServerDeclinedActionFilter"); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestServerSourceUpdatedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(4)); + assertEquals("BitBucketPPRPullRequestServerDeclinedActionFilter", dispNames.get(5)); } @Test - public void testDslServerAllPRAllowedBranchesWithApproveActionsFreeStyle() throws Exception { + void testDslServerAllPRAllowedBranchesWithApproveActionsFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslServerAllPRAllowedBranchesWithApproveActionsFreeStyle.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslServerAllPRAllowedBranchesWithApproveActionsFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -887,36 +911,37 @@ public void testDslServerAllPRAllowedBranchesWithApproveActionsFreeStyle() throw BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Four different triggers expected */ assertEquals(5, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(5, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestServerSourceUpdatedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestServerMergedActionFilter"); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestServerSourceUpdatedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(4)); } @Test - public void testDslServerAllPRUnfilteredAndAllowedBranchesActionsFreeStyle() throws Exception { + void testDslServerAllPRUnfilteredAndAllowedBranchesActionsFreeStyle() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslServerAllPRUnfilteredAndAllowedBranchesActionsFreeStyle.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslServerAllPRUnfilteredAndAllowedBranchesActionsFreeStyle.groovy")); /* Fetch the newly created job and check its trigger configuration */ FreeStyleProject createdJob = (FreeStyleProject) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ @@ -928,67 +953,68 @@ public void testDslServerAllPRUnfilteredAndAllowedBranchesActionsFreeStyle() thr BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Twelve different triggers expected */ assertEquals(12, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(5).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(5).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(6).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(6).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(7).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(7).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(8).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(8).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(9).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(9).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(10).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(10).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(11).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(11).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(12, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestServerSourceUpdatedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestServerMergedActionFilter"); - assertEquals(dispNames.get(5), "BitBucketPPRPullRequestServerDeclinedActionFilter"); - - assertEquals(dispNames.get(6), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(7), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(8), "BitBucketPPRPullRequestServerSourceUpdatedActionFilter"); - assertEquals(dispNames.get(9), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(10), "BitBucketPPRPullRequestServerMergedActionFilter"); - assertEquals(dispNames.get(11), "BitBucketPPRPullRequestServerDeclinedActionFilter"); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestServerSourceUpdatedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(4)); + assertEquals("BitBucketPPRPullRequestServerDeclinedActionFilter", dispNames.get(5)); + + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(6)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(7)); + assertEquals("BitBucketPPRPullRequestServerSourceUpdatedActionFilter", dispNames.get(8)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(9)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(10)); + assertEquals("BitBucketPPRPullRequestServerDeclinedActionFilter", dispNames.get(11)); } @Test - public void testDslServerAllPRActionsPipeline() throws Exception { + void testDslServerAllPRActionsPipeline() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslServerAllPRActionsPipeline.groovy")); /* Fetch the newly created job and check its trigger configuration */ WorkflowJob createdJob = (WorkflowJob) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ - PipelineTriggersJobProperty pipelineTriggers = (PipelineTriggersJobProperty) createdJob.getProperty(PipelineTriggersJobProperty.class); + PipelineTriggersJobProperty pipelineTriggers = createdJob.getProperty( + PipelineTriggersJobProperty.class); Map> triggers = pipelineTriggers.getTriggersMap(); /* Only one 'triggers{}' closure */ assertEquals(1, triggers.size()); @@ -997,38 +1023,40 @@ public void testDslServerAllPRActionsPipeline() throws Exception { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Five different triggers expected */ assertEquals(5, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(5, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestServerMergedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestServerDeclinedActionFilter"); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestServerDeclinedActionFilter", dispNames.get(4)); } @Test - public void testDslServerAllPRAllowedBranchesActionsPipeline() throws Exception { + void testDslServerAllPRAllowedBranchesActionsPipeline() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslServerAllPRAllowedBranchesActionsPipeline.groovy")); + createSeedJob( + readDslScript("./dsl/testDslServerAllPRAllowedBranchesActionsPipeline.groovy")); /* Fetch the newly created job and check its trigger configuration */ WorkflowJob createdJob = (WorkflowJob) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ - PipelineTriggersJobProperty pipelineTriggers = (PipelineTriggersJobProperty) createdJob.getProperty(PipelineTriggersJobProperty.class); + PipelineTriggersJobProperty pipelineTriggers = createdJob.getProperty( + PipelineTriggersJobProperty.class); Map> triggers = pipelineTriggers.getTriggersMap(); /* Only one 'triggers{}' closure */ assertEquals(1, triggers.size()); @@ -1037,45 +1065,47 @@ public void testDslServerAllPRAllowedBranchesActionsPipeline() throws Exception BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Six different triggers expected */ assertEquals(6, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(5).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(5).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(6, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestServerSourceUpdatedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestServerMergedActionFilter"); - assertEquals(dispNames.get(5), "BitBucketPPRPullRequestServerDeclinedActionFilter"); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestServerSourceUpdatedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(4)); + assertEquals("BitBucketPPRPullRequestServerDeclinedActionFilter", dispNames.get(5)); } - - @Ignore + + @Disabled @Test - public void testDslServerAllPRAllowedBranchesWithApproveActionsPipeline() throws Exception { + void testDslServerAllPRAllowedBranchesWithApproveActionsPipeline() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslServerAllPRAllowedBranchesWithApproveActionsPipeline.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslServerAllPRAllowedBranchesWithApproveActionsPipeline.groovy")); /* Fetch the newly created job and check its trigger configuration */ WorkflowJob createdJob = (WorkflowJob) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ - PipelineTriggersJobProperty pipelineTriggers = (PipelineTriggersJobProperty) createdJob.getProperty(PipelineTriggersJobProperty.class); + PipelineTriggersJobProperty pipelineTriggers = createdJob.getProperty( + PipelineTriggersJobProperty.class); Map> triggers = pipelineTriggers.getTriggersMap(); /* Only one 'triggers{}' closure */ assertEquals(1, triggers.size()); @@ -1084,40 +1114,42 @@ public void testDslServerAllPRAllowedBranchesWithApproveActionsPipeline() throws BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Four different triggers expected */ assertEquals(5, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(5, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestServerSourceUpdatedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestServerMergedActionFilter"); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestServerSourceUpdatedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(4)); } - + @Test - public void testDslServerAllPRUnfilteredAndAllowedBranchesActionsPipeline() throws Exception { + void testDslServerAllPRUnfilteredAndAllowedBranchesActionsPipeline() throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslServerAllPRUnfilteredAndAllowedBranchesActionsPipeline.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslServerAllPRUnfilteredAndAllowedBranchesActionsPipeline.groovy")); /* Fetch the newly created job and check its trigger configuration */ WorkflowJob createdJob = (WorkflowJob) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ - PipelineTriggersJobProperty pipelineTriggers = (PipelineTriggersJobProperty) createdJob.getProperty(PipelineTriggersJobProperty.class); + PipelineTriggersJobProperty pipelineTriggers = createdJob.getProperty( + PipelineTriggersJobProperty.class); Map> triggers = pipelineTriggers.getTriggersMap(); /* Only one 'triggers{}' closure */ assertEquals(1, triggers.size()); @@ -1126,63 +1158,66 @@ public void testDslServerAllPRUnfilteredAndAllowedBranchesActionsPipeline() thro BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Eleven different triggers expected */ assertEquals(11, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(4).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(5).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(5).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(6).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(6).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(7).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(7).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(8).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(8).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(9).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(9).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(10).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(10).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(11, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestServerSourceUpdatedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(4), "BitBucketPPRPullRequestServerMergedActionFilter"); - assertEquals(dispNames.get(5), "BitBucketPPRPullRequestServerCreatedActionFilter"); - assertEquals(dispNames.get(6), "BitBucketPPRPullRequestServerUpdatedActionFilter"); - assertEquals(dispNames.get(7), "BitBucketPPRPullRequestServerSourceUpdatedActionFilter"); - assertEquals(dispNames.get(8), "BitBucketPPRPullRequestServerApprovedActionFilter"); - assertEquals(dispNames.get(9), "BitBucketPPRPullRequestServerMergedActionFilter"); - assertEquals(dispNames.get(10), "BitBucketPPRPullRequestServerDeclinedActionFilter"); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestServerSourceUpdatedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(3)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(4)); + assertEquals("BitBucketPPRPullRequestServerCreatedActionFilter", dispNames.get(5)); + assertEquals("BitBucketPPRPullRequestServerUpdatedActionFilter", dispNames.get(6)); + assertEquals("BitBucketPPRPullRequestServerSourceUpdatedActionFilter", dispNames.get(7)); + assertEquals("BitBucketPPRPullRequestServerApprovedActionFilter", dispNames.get(8)); + assertEquals("BitBucketPPRPullRequestServerMergedActionFilter", dispNames.get(9)); + assertEquals("BitBucketPPRPullRequestServerDeclinedActionFilter", dispNames.get(10)); } - @Ignore + @Disabled @Test - public void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveActionsPipeline() throws Exception { + void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveActionsPipeline() + throws Exception { /* Create seed job which will process DSL */ - createSeedJob(readDslScript("./dsl/testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveActionsPipeline.groovy")); + createSeedJob(readDslScript( + "./dsl/testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveActionsPipeline.groovy")); /* Fetch the newly created job and check its trigger configuration */ WorkflowJob createdJob = (WorkflowJob) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ - PipelineTriggersJobProperty pipelineTriggers = (PipelineTriggersJobProperty) createdJob.getProperty(PipelineTriggersJobProperty.class); + PipelineTriggersJobProperty pipelineTriggers = createdJob.getProperty( + PipelineTriggersJobProperty.class); Map> triggers = pipelineTriggers.getTriggersMap(); /* Only one 'triggers{}' closure */ assertEquals(1, triggers.size()); @@ -1191,59 +1226,61 @@ public void testDslTriggerCreateUpdatedMergedApprovedPRAllowBranchesWithApproveA BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* Three different triggers expected */ assertEquals(4, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(1).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(2).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - tmpNname = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); - dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + tmpName = tmp2.getTriggers().get(3).getActionFilter().getClass().getName(); + dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(4, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestUpdatedActionFilter"); - assertEquals(dispNames.get(2), "BitBucketPPRPullRequestMergedActionFilter"); - assertEquals(dispNames.get(3), "BitBucketPPRPullRequestApprovedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestUpdatedActionFilter", dispNames.get(1)); + assertEquals("BitBucketPPRPullRequestMergedActionFilter", dispNames.get(2)); + assertEquals("BitBucketPPRPullRequestApprovedActionFilter", dispNames.get(3)); } @Test - public void testDslTriggerDeclinedPRAllowBranchesPipeline() throws Exception { + void testDslTriggerDeclinedPRAllowBranchesPipeline() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerDeclinedPRAllowBranchesPipeline.groovy")); /* Fetch the newly created job and check its trigger configuration */ WorkflowJob createdJob = (WorkflowJob) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ - PipelineTriggersJobProperty pipelineTriggers = (PipelineTriggersJobProperty) createdJob.getProperty(PipelineTriggersJobProperty.class); + PipelineTriggersJobProperty pipelineTriggers = createdJob.getProperty( + PipelineTriggersJobProperty.class); Map> triggers = pipelineTriggers.getTriggersMap(); /* Only one 'triggers{}' closure */ assertEquals(1, triggers.size()); - List dispNames = new ArrayList<>(); for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; /* One triggers expected */ assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); - assertEquals(dispName, "BitBucketPPRPullRequestDeclinedActionFilter"); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); + assertEquals("BitBucketPPRPullRequestDeclinedActionFilter", dispName); - BitBucketPPRPullRequestDeclinedActionFilter actionFilter = (BitBucketPPRPullRequestDeclinedActionFilter) tmp2.getTriggers().get(0).getActionFilter(); + BitBucketPPRPullRequestDeclinedActionFilter actionFilter = (BitBucketPPRPullRequestDeclinedActionFilter) tmp2.getTriggers() + .get(0).getActionFilter(); assertEquals("**", actionFilter.allowedBranches); } } @Test - public void testDslTriggerPushActionPipeline() throws Exception { + void testDslTriggerPushActionPipeline() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslTriggerPushActionPipeline.groovy")); /* Fetch the newly created job and check its trigger configuration */ WorkflowJob createdJob = (WorkflowJob) j.getInstance().getItem("test-job"); /* Go through all triggers to validate DSL */ - PipelineTriggersJobProperty pipelineTriggers = (PipelineTriggersJobProperty) createdJob.getProperty(PipelineTriggersJobProperty.class); + PipelineTriggersJobProperty pipelineTriggers = createdJob.getProperty( + PipelineTriggersJobProperty.class); Map> triggers = pipelineTriggers.getTriggersMap(); assertEquals(1, triggers.size()); List dispNames = new ArrayList<>(); @@ -1251,21 +1288,22 @@ public void testDslTriggerPushActionPipeline() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); - BitBucketPPRRepositoryPushActionFilter tmp3 = (BitBucketPPRRepositoryPushActionFilter) tmp2.getTriggers().get(0) + BitBucketPPRRepositoryPushActionFilter tmp3 = (BitBucketPPRRepositoryPushActionFilter) tmp2.getTriggers() + .get(0) .getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRRepositoryPushActionFilter"); + assertEquals("BitBucketPPRRepositoryPushActionFilter", dispNames.get(0)); assertFalse(isToApprove); } @Test - public void testDslMultipleJobsInSeedVarious() throws Exception { + void testDslMultipleJobsInSeedVarious() throws Exception { /* Create seed job which will process DSL */ createSeedJob(readDslScript("./dsl/testDslMultipleJobsInSeedVarious.groovy")); /* Fetch the newly created job and check its trigger configuration */ @@ -1279,12 +1317,12 @@ public void testDslMultipleJobsInSeedVarious() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestCreatedActionFilter"); + assertEquals("BitBucketPPRPullRequestCreatedActionFilter", dispNames.get(0)); /* Verify second job content */ createdJob = (FreeStyleProject) j.getInstance().getItem("test-job2"); @@ -1295,17 +1333,18 @@ public void testDslMultipleJobsInSeedVarious() throws Exception { for (Trigger entry : triggers.values()) { BitBucketPPRTrigger tmp2 = (BitBucketPPRTrigger) entry; assertEquals(1, tmp2.getTriggers().size()); - String tmpNname = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); - String dispName = tmpNname.substring(tmpNname.lastIndexOf(".") + 1); + String tmpName = tmp2.getTriggers().get(0).getActionFilter().getClass().getName(); + String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestUpdatedActionFilter"); + assertEquals("BitBucketPPRPullRequestUpdatedActionFilter", dispNames.get(0)); /* Verify third job content */ createdPipelineJob = (WorkflowJob) j.getInstance().getItem("test-job3"); /* Go through all triggers to validate DSL */ - pipelineTriggers = (PipelineTriggersJobProperty) createdPipelineJob.getProperty(PipelineTriggersJobProperty.class); + pipelineTriggers = createdPipelineJob.getProperty( + PipelineTriggersJobProperty.class); triggers = pipelineTriggers.getTriggersMap(); assertEquals(1, triggers.size()); dispNames.clear(); @@ -1320,7 +1359,7 @@ public void testDslMultipleJobsInSeedVarious() throws Exception { dispNames.add(dispName); } assertEquals(2, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRRepositoryPushActionFilter"); - assertEquals(dispNames.get(1), "BitBucketPPRPullRequestCommentDeletedActionFilter"); + assertEquals("BitBucketPPRRepositoryPushActionFilter", dispNames.get(0)); + assertEquals("BitBucketPPRPullRequestCommentDeletedActionFilter", dispNames.get(1)); } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilterTest.java index a38e6c2e..950080f2 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilterTest.java @@ -1,34 +1,40 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import hudson.EnvVars; +import hudson.triggers.Trigger; +import hudson.triggers.TriggerDescriptor; +import io.jenkins.plugins.bitbucketpushandpullrequest.BitBucketPPRTrigger; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - -import hudson.model.FreeStyleProject; -import hudson.triggers.Trigger; -import hudson.triggers.TriggerDescriptor; -import io.jenkins.plugins.bitbucketpushandpullrequest.BitBucketPPRTrigger; -import javaposse.jobdsl.plugin.ExecuteDslScripts; -import javaposse.jobdsl.plugin.RemovedJobAction; import org.apache.commons.io.IOUtils; import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; -import org.jenkinsci.plugins.workflow.job.WorkflowRun; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.jvnet.hudson.test.JenkinsRule; -import org.mockito.junit.MockitoJUnitRunner; -import hudson.EnvVars; +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; +import org.mockito.junit.jupiter.MockitoExtension; -import static org.junit.Assert.*; +@ExtendWith(MockitoExtension.class) +@WithJenkins +class BitBucketPPRPullRequestApprovedActionFilterTest { -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestApprovedActionFilterTest { - @Rule public JenkinsRule j = new JenkinsRule(); + private JenkinsRule j; + + @BeforeEach + void setUp(JenkinsRule rule) { + j = rule; + } private void createSeedJob(String script) throws Exception { WorkflowJob pipelineJob = j.createProject(WorkflowJob.class, "pipelineJob"); @@ -41,7 +47,7 @@ private void createSeedJob(String script) throws Exception { } @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRPullRequestApprovedActionFilter c = @@ -91,7 +97,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -155,7 +161,7 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRPullRequestApprovedActionFilter c = @@ -170,7 +176,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; @@ -187,7 +193,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRPullRequestApprovedActionFilter c = @@ -198,7 +204,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRPullRequestApprovedActionFilter c = @@ -212,7 +218,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { + void testMatchesEmptyBranches() { String allowedBranches = ""; @@ -226,7 +232,7 @@ public void testMatchesEmptyBranches() { } @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRPullRequestApprovedActionFilter c = @@ -240,7 +246,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRPullRequestApprovedActionFilter c = @@ -256,20 +262,14 @@ public void testUsesJavaPatternToExcludeMultipleBranches() { } private String readScript(String path) throws Exception { - String script = null; - try { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream(path); - script = IOUtils.toString(is, StandardCharsets.UTF_8); - } catch (Exception e) { - e.printStackTrace(); - } - return script; + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream(path); + assertNotNull(is); + return IOUtils.toString(is, StandardCharsets.UTF_8); } @Test - public void testPipelineTrigger() throws Exception { - + void testPipelineTrigger() throws Exception { createSeedJob( readScript("./pipelines/testPipelineCloudTriggerPullRequestApprovedActionFilter")); // get newly created pipeline job @@ -286,12 +286,13 @@ public void testPipelineTrigger() throws Exception { String dispName = tmpName.substring(tmpName.lastIndexOf(".") + 1); dispNames.add(dispName); BitBucketPPRPullRequestApprovedActionFilter tmp3 = - (BitBucketPPRPullRequestApprovedActionFilter) tmp2.getTriggers().get(0).getActionFilter(); + (BitBucketPPRPullRequestApprovedActionFilter) tmp2.getTriggers().get(0) + .getActionFilter(); isToApprove = tmp3.shouldSendApprove(); } assertEquals(1, dispNames.size()); - assertEquals(dispNames.get(0), "BitBucketPPRPullRequestApprovedActionFilter"); + assertEquals("BitBucketPPRPullRequestApprovedActionFilter", dispNames.get(0)); assertFalse(isToApprove); } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilterTest.java index 02d42135..e4ac0607 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilterTest.java @@ -1,19 +1,20 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestCommentCreatedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestCommentCreatedActionFilterTest { @Test - public void testEmptyHayStack() { + void testEmptyHayStack() { String allowedBranches = "master"; - + String haystack = ""; String pattern = ""; EnvVars env = null; @@ -22,12 +23,12 @@ public void testEmptyHayStack() { new BitBucketPPRPullRequestCommentCreatedActionFilter(); c.setAllowedBranches(allowedBranches); c.setCommentFilter(pattern); - + assertFalse(c.hasInComment(haystack, env)); } @Test - public void testEmptyPattern() { + void testEmptyPattern() { String allowedBranches = "master"; String haystack = "Comment"; @@ -43,7 +44,7 @@ public void testEmptyPattern() { } @Test - public void testPattern001() { + void testPattern001() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -59,7 +60,7 @@ public void testPattern001() { } @Test - public void testPattern002() { + void testPattern002() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -75,7 +76,7 @@ public void testPattern002() { } @Test - public void testPattern003() { + void testPattern003() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -91,7 +92,7 @@ public void testPattern003() { } @Test - public void testPattern004() { + void testPattern004() { String allowedBranches = "master"; String haystack = "I need to find fI a reason to X.Y 1#a"; @@ -107,7 +108,7 @@ public void testPattern004() { } @Test - public void testPattern005() { + void testPattern005() { String allowedBranches = "master"; String haystack = "I need to find fI a reason to X.Y 1#a"; diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilterTest.java index bd662075..c325af42 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilterTest.java @@ -1,17 +1,18 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestCommentUpdatedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestCommentUpdatedActionFilterTest { @Test - public void testEmptyHayStack() { + void testEmptyHayStack() { String allowedBranches = "master"; String haystack = ""; @@ -27,7 +28,7 @@ public void testEmptyHayStack() { } @Test - public void testEmptyPattern() { + void testEmptyPattern() { String allowedBranches = "master"; String haystack = "Comment"; @@ -43,7 +44,7 @@ public void testEmptyPattern() { } @Test - public void testPattern001() { + void testPattern001() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -59,7 +60,7 @@ public void testPattern001() { } @Test - public void testPattern002() { + void testPattern002() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -75,7 +76,7 @@ public void testPattern002() { } @Test - public void testPattern003() { + void testPattern003() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -91,7 +92,7 @@ public void testPattern003() { } @Test - public void testPattern004() { + void testPattern004() { String allowedBranches = "master"; String haystack = "I need to find fI a reason to X.Y 1#a"; @@ -107,7 +108,7 @@ public void testPattern004() { } @Test - public void testPattern005() { + void testPattern005() { String allowedBranches = "master"; String haystack = "I need to find fI a reason to X.Y 1#a"; @@ -123,7 +124,7 @@ public void testPattern005() { } @Test - public void testPattern006() { + void testPattern006() { String allowedBranches = "master"; String haystack = "I need to find fI a reason to X Y 1#a"; diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilterTest.java index 2b977111..bc6579ac 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilterTest.java @@ -1,24 +1,24 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import java.util.HashMap; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestCreatedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestCreatedActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRPullRequestCreatedActionFilter c = new BitBucketPPRPullRequestCreatedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin/master", null)); assertFalse(c.matches(allowedBranches, "origin/something/master", null)); assertTrue(c.matches(allowedBranches, "master", null)); @@ -62,7 +62,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -79,7 +79,6 @@ public void testMatchEnv() { BitBucketPPRPullRequestCreatedActionFilter c = new BitBucketPPRPullRequestCreatedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin/master", env)); assertFalse(c.matches(allowedBranches, "origin/something/master", env)); assertTrue(c.matches(allowedBranches, "master", env)); @@ -126,13 +125,12 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRPullRequestCreatedActionFilter c = new BitBucketPPRPullRequestCreatedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "refs/heads/jenkins", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jane", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jones", null)); @@ -141,8 +139,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { - + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; BitBucketPPRPullRequestCreatedActionFilter c = new BitBucketPPRPullRequestCreatedActionFilter(); @@ -157,7 +154,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRPullRequestCreatedActionFilter c = new BitBucketPPRPullRequestCreatedActionFilter(); @@ -167,7 +164,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRPullRequestCreatedActionFilter c = new BitBucketPPRPullRequestCreatedActionFilter(); @@ -180,7 +177,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { + void testMatchesEmptyBranches() { String allowedBranches = ""; @@ -194,7 +191,7 @@ public void testMatchesEmptyBranches() { @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRPullRequestCreatedActionFilter c = new BitBucketPPRPullRequestCreatedActionFilter(); @@ -207,7 +204,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRPullRequestCreatedActionFilter c = new BitBucketPPRPullRequestCreatedActionFilter(); diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestMergedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestMergedActionFilterTest.java index 0f76f3b4..5d58c6a8 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestMergedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestMergedActionFilterTest.java @@ -1,24 +1,24 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import java.util.HashMap; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestMergedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestMergedActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin/master", null)); assertFalse(c.matches(allowedBranches, "origin/something/master", null)); assertTrue(c.matches(allowedBranches, "master", null)); @@ -62,7 +62,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -79,7 +79,6 @@ public void testMatchEnv() { BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin/master", env)); assertFalse(c.matches(allowedBranches, "origin/something/master", env)); assertTrue(c.matches(allowedBranches, "master", env)); @@ -126,7 +125,7 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); @@ -140,14 +139,12 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { - + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin", null)); assertTrue(c.matches(allowedBranches, "origin/master", null)); assertTrue(c.matches(allowedBranches, "origin/feature", null)); @@ -157,7 +154,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); @@ -167,7 +164,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); @@ -180,8 +177,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { - + void testMatchesEmptyBranches() { String allowedBranches = ""; BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); @@ -194,7 +190,7 @@ public void testMatchesEmptyBranches() { @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); @@ -207,12 +203,12 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRPullRequestMergedActionFilter c = new BitBucketPPRPullRequestMergedActionFilter(); c.setAllowedBranches(allowedBranches); - + assertTrue(c.matches(allowedBranches, "origin/branch1", null)); assertTrue(c.matches(allowedBranches, "origin/branch-2", null)); assertTrue(c.matches(allowedBranches, "origin/master123", null)); diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestUpdatedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestUpdatedActionFilterTest.java index e30188bf..db14cb51 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestUpdatedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestUpdatedActionFilterTest.java @@ -1,18 +1,19 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import java.util.HashMap; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestUpdatedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestUpdatedActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); @@ -61,7 +62,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -78,7 +79,6 @@ public void testMatchEnv() { BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin/master", env)); assertFalse(c.matches(allowedBranches, "origin/something/master", env)); assertTrue(c.matches(allowedBranches, "master", env)); @@ -125,13 +125,12 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "refs/heads/jenkins", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jane", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jones", null)); @@ -140,8 +139,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { - + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); @@ -156,7 +154,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); @@ -166,7 +164,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); @@ -179,8 +177,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { - + void testMatchesEmptyBranches() { String allowedBranches = ""; BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); @@ -193,7 +190,7 @@ public void testMatchesEmptyBranches() { @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); @@ -206,7 +203,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRPullRequestUpdatedActionFilter c = new BitBucketPPRPullRequestUpdatedActionFilter(); diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerApprovedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerApprovedActionFilterTest.java index 9bcf16c9..c2b02bd0 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerApprovedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerApprovedActionFilterTest.java @@ -1,25 +1,25 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.server; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import java.util.HashMap; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestServerApprovedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestServerApprovedActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRPullRequestServerApprovedActionFilter c = new BitBucketPPRPullRequestServerApprovedActionFilter(false); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin/master", null)); assertFalse(c.matches(allowedBranches, "origin/something/master", null)); assertTrue(c.matches(allowedBranches, "master", null)); @@ -63,7 +63,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -127,14 +127,13 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRPullRequestServerApprovedActionFilter c = new BitBucketPPRPullRequestServerApprovedActionFilter(false); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "refs/heads/jenkins", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jane", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jones", null)); @@ -143,8 +142,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { - + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; BitBucketPPRPullRequestServerApprovedActionFilter c = @@ -160,7 +158,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRPullRequestServerApprovedActionFilter c = @@ -171,7 +169,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRPullRequestServerApprovedActionFilter c = @@ -185,7 +183,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { + void testMatchesEmptyBranches() { String allowedBranches = ""; @@ -198,9 +196,8 @@ public void testMatchesEmptyBranches() { assertTrue(c.matches(allowedBranches, "feature/new-stuff", null)); } - @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRPullRequestServerApprovedActionFilter c = @@ -214,7 +211,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRPullRequestServerApprovedActionFilter c = diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedActionFilterTest.java index 535f3011..30d74458 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCommentCreatedActionFilterTest.java @@ -1,19 +1,20 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.server; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestServerCommentCreatedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestServerCommentCreatedActionFilterTest { @Test - public void testEmptyHayStack() { + void testEmptyHayStack() { String allowedBranches = "master"; - + String haystack = ""; String pattern = ""; EnvVars env = null; @@ -22,12 +23,12 @@ public void testEmptyHayStack() { new BitBucketPPRPullRequestServerCommentCreatedActionFilter(); c.setAllowedBranches(allowedBranches); c.setCommentFilter(pattern); - + assertFalse(c.hasInComment(haystack, env)); } @Test - public void testEmptyPattern() { + void testEmptyPattern() { String allowedBranches = "master"; String haystack = "Comment"; @@ -43,7 +44,7 @@ public void testEmptyPattern() { } @Test - public void testPattern001() { + void testPattern001() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -59,7 +60,7 @@ public void testPattern001() { } @Test - public void testPattern002() { + void testPattern002() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -75,7 +76,7 @@ public void testPattern002() { } @Test - public void testPattern003() { + void testPattern003() { String allowedBranches = "master"; String haystack = "I need to find a reason to X.Y 1#a"; @@ -91,7 +92,7 @@ public void testPattern003() { } @Test - public void testPattern004() { + void testPattern004() { String allowedBranches = "master"; String haystack = "I need to find fI a reason to X.Y 1#a"; @@ -107,7 +108,7 @@ public void testPattern004() { } @Test - public void testPattern005() { + void testPattern005() { String allowedBranches = "master"; String haystack = "I need to find fI a reason to X.Y 1#a"; diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCreatedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCreatedActionFilterTest.java index 6e035db2..be757af4 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCreatedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerCreatedActionFilterTest.java @@ -1,18 +1,19 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.server; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import java.util.HashMap; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestServerCreatedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestServerCreatedActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRPullRequestServerCreatedActionFilter c = @@ -62,7 +63,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -126,14 +127,13 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRPullRequestServerCreatedActionFilter c = new BitBucketPPRPullRequestServerCreatedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "refs/heads/jenkins", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jane", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jones", null)); @@ -142,7 +142,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; @@ -159,7 +159,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRPullRequestServerCreatedActionFilter c = @@ -170,7 +170,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRPullRequestServerCreatedActionFilter c = @@ -184,7 +184,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { + void testMatchesEmptyBranches() { String allowedBranches = ""; @@ -199,7 +199,7 @@ public void testMatchesEmptyBranches() { @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRPullRequestServerCreatedActionFilter c = @@ -213,7 +213,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRPullRequestServerCreatedActionFilter c = diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerMergedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerMergedActionFilterTest.java index 1eafcf53..c7b9b8c1 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerMergedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerMergedActionFilterTest.java @@ -1,18 +1,19 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.server; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import java.util.HashMap; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestServerMergedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestServerMergedActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRPullRequestServerMergedActionFilter c = @@ -62,7 +63,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -80,7 +81,6 @@ public void testMatchEnv() { new BitBucketPPRPullRequestServerMergedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin/master", env)); assertFalse(c.matches(allowedBranches, "origin/something/master", env)); assertTrue(c.matches(allowedBranches, "master", env)); @@ -127,15 +127,13 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRPullRequestServerMergedActionFilter c = new BitBucketPPRPullRequestServerMergedActionFilter(); c.setAllowedBranches(allowedBranches); - - assertTrue(c.matches(allowedBranches, "refs/heads/jenkins", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jane", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jones", null)); @@ -144,8 +142,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { - + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; BitBucketPPRPullRequestServerMergedActionFilter c = @@ -161,19 +158,18 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRPullRequestServerMergedActionFilter c = new BitBucketPPRPullRequestServerMergedActionFilter(); c.setAllowedBranches(allowedBranches); - assertFalse(c.matches(allowedBranches, "master", null)); } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRPullRequestServerMergedActionFilter c = @@ -187,8 +183,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { - + void testMatchesEmptyBranches() { String allowedBranches = ""; BitBucketPPRPullRequestServerMergedActionFilter c = @@ -202,7 +197,7 @@ public void testMatchesEmptyBranches() { @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRPullRequestServerMergedActionFilter c = @@ -216,7 +211,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRPullRequestServerMergedActionFilter c = diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerUpdatedActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerUpdatedActionFilterTest.java index 30d18ada..86f4afb1 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerUpdatedActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/server/BitBucketPPRPullRequestServerUpdatedActionFilterTest.java @@ -1,25 +1,25 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.server; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import hudson.EnvVars; +import java.util.HashMap; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestServerUpdatedActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestServerUpdatedActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRPullRequestServerUpdatedActionFilter c = new BitBucketPPRPullRequestServerUpdatedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "origin/master", null)); assertFalse(c.matches(allowedBranches, "origin/something/master", null)); assertTrue(c.matches(allowedBranches, "master", null)); @@ -63,7 +63,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -127,14 +127,13 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRPullRequestServerUpdatedActionFilter c = new BitBucketPPRPullRequestServerUpdatedActionFilter(); c.setAllowedBranches(allowedBranches); - assertTrue(c.matches(allowedBranches, "refs/heads/jenkins", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jane", null)); assertTrue(c.matches(allowedBranches, "refs/heads/jones", null)); @@ -143,8 +142,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { - + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; BitBucketPPRPullRequestServerUpdatedActionFilter c = @@ -160,7 +158,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRPullRequestServerUpdatedActionFilter c = @@ -171,7 +169,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRPullRequestServerUpdatedActionFilter c = @@ -185,8 +183,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { - + void testMatchesEmptyBranches() { String allowedBranches = ""; BitBucketPPRPullRequestServerUpdatedActionFilter c = @@ -200,7 +197,7 @@ public void testMatchesEmptyBranches() { @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRPullRequestServerUpdatedActionFilter c = @@ -214,7 +211,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRPullRequestServerUpdatedActionFilter c = diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryPushActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryPushActionFilterTest.java index 370c88a0..6c05a4bc 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryPushActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRRepositoryPushActionFilterTest.java @@ -1,22 +1,22 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.repository; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import hudson.EnvVars; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import hudson.EnvVars; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRRepositoryPushActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRRepositoryPushActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRRepositoryPushActionFilter c = @@ -65,7 +65,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -128,7 +128,7 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRRepositoryPushActionFilter c = @@ -142,8 +142,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { - + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; BitBucketPPRRepositoryPushActionFilter m = @@ -158,7 +157,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRRepositoryPushActionFilter c = @@ -168,7 +167,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRRepositoryPushActionFilter c = @@ -181,8 +180,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { - + void testMatchesEmptyBranches() { String allowedBranches = ""; BitBucketPPRRepositoryPushActionFilter c = @@ -195,7 +193,7 @@ public void testMatchesEmptyBranches() { @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRRepositoryPushActionFilter m = @@ -208,7 +206,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRRepositoryPushActionFilter m = @@ -222,9 +220,8 @@ public void testUsesJavaPatternToExcludeMultipleBranches() { assertFalse(m.matches(allowedBranches, "origin/develop", null)); } - @Test - public void shouldTriggerBuildReturnsFalseIsTypeNotSet() { + void shouldTriggerBuildReturnsFalseIsTypeNotSet() { BitBucketPPRAction bitbucketAction = Mockito.mock(BitBucketPPRAction.class); Mockito.when(bitbucketAction.getType()).thenReturn(null); BitBucketPPRRepositoryPushActionFilter c = new BitBucketPPRRepositoryPushActionFilter(false, diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRServerRepositoryPushActionFilterTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRServerRepositoryPushActionFilterTest.java index 6a5c1244..4d270f31 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRServerRepositoryPushActionFilterTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/repository/BitBucketPPRServerRepositoryPushActionFilterTest.java @@ -1,22 +1,22 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.filter.repository; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import hudson.EnvVars; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; import java.util.HashMap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import hudson.EnvVars; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRServerRepositoryPushActionFilterTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRServerRepositoryPushActionFilterTest { @Test - public void testMatches() { + void testMatches() { String allowedBranches = "master"; BitBucketPPRServerRepositoryPushActionFilter c = @@ -60,7 +60,7 @@ public void testMatches() { } @Test - public void testMatchEnv() { + void testMatchEnv() { HashMap envMap = new HashMap<>(); envMap.put("master", "master"); envMap.put("origin", "origin"); @@ -117,7 +117,7 @@ public void testMatchEnv() { } @Test - public void testUsesRefsHeads() { + void testUsesRefsHeads() { String allowedBranches = "refs/heads/j*n*"; BitBucketPPRServerRepositoryPushActionFilter c = @@ -131,7 +131,7 @@ public void testUsesRefsHeads() { } @Test - public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { + void testUsesJavaPatternDirectlyIfPrefixedWithColon() { String allowedBranches = ":^(?!(origin/prefix)).*"; BitBucketPPRServerRepositoryPushActionFilter m = @@ -146,7 +146,7 @@ public void testUsesJavaPatternDirectlyIfPrefixedWithColon() { } @Test - public void testMatchesNot1() { + void testMatchesNot1() { String allowedBranches = "*/master"; BitBucketPPRServerRepositoryPushActionFilter c = @@ -156,7 +156,7 @@ public void testMatchesNot1() { } @Test - public void testMatchesNot2() { + void testMatchesNot2() { String allowedBranches = "develop, :^(?!master$).*"; BitBucketPPRServerRepositoryPushActionFilter c = @@ -168,7 +168,7 @@ public void testMatchesNot2() { } @Test - public void testMatchesEmptyBranches() { + void testMatchesEmptyBranches() { String allowedBranches = ""; BitBucketPPRServerRepositoryPushActionFilter c = new BitBucketPPRServerRepositoryPushActionFilter(false, false, allowedBranches); @@ -179,7 +179,7 @@ public void testMatchesEmptyBranches() { } @Test - public void testUsesJavaPatternWithRepetition() { + void testUsesJavaPatternWithRepetition() { String allowedBranches = ":origin/release-\\d{8}"; BitBucketPPRServerRepositoryPushActionFilter m = @@ -191,7 +191,7 @@ public void testUsesJavaPatternWithRepetition() { } @Test - public void testUsesJavaPatternToExcludeMultipleBranches() { + void testUsesJavaPatternToExcludeMultipleBranches() { String allowedBranches = ":^(?!origin/master$|origin/develop$).*"; BitBucketPPRServerRepositoryPushActionFilter m = @@ -206,10 +206,11 @@ public void testUsesJavaPatternToExcludeMultipleBranches() { } @Test - public void shouldTriggerBuildReturnsFalseIsTypeNotSet() { + void shouldTriggerBuildReturnsFalseIsTypeNotSet() { BitBucketPPRAction bitbucketAction = Mockito.mock(BitBucketPPRAction.class); Mockito.when(bitbucketAction.getType()).thenReturn(null); - BitBucketPPRServerRepositoryPushActionFilter c = new BitBucketPPRServerRepositoryPushActionFilter(false, false, "master"); + BitBucketPPRServerRepositoryPushActionFilter c = new BitBucketPPRServerRepositoryPushActionFilter( + false, false, "master"); assertFalse(c.shouldTriggerBuild(bitbucketAction)); } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPREventTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPREventTest.java index d34228c3..4efa858f 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPREventTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/model/BitBucketPPREventTest.java @@ -21,17 +21,17 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.model; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import javax.naming.OperationNotSupportedException; +import org.junit.jupiter.api.Test; -import org.junit.Test; - -public class BitBucketPPREventTest { +class BitBucketPPREventTest { @Test - public void testRepositoryEvent() throws OperationNotSupportedException { + void testRepositoryEvent() throws Exception { String event = "repo"; String action = "push"; BitBucketPPRHookEvent bitbucketEvent = createEvent(event, action); @@ -41,7 +41,7 @@ public void testRepositoryEvent() throws OperationNotSupportedException { } @Test - public void testRepositoryEventPushAction() throws OperationNotSupportedException { + void testRepositoryEventPushAction() throws Exception { String event = "repo"; String action = "push"; BitBucketPPRHookEvent bitbucketEvent = createEvent(event, action); @@ -51,7 +51,7 @@ public void testRepositoryEventPushAction() throws OperationNotSupportedExceptio } @Test - public void testPullRequestEventCreated() throws OperationNotSupportedException { + void testPullRequestEventCreated() throws Exception { String event = "pullrequest"; String action = "created"; BitBucketPPRHookEvent bitbucketEvent = createEvent(event, action); @@ -61,7 +61,7 @@ public void testPullRequestEventCreated() throws OperationNotSupportedException } @Test - public void testPullRequestEventUpdated() throws OperationNotSupportedException { + void testPullRequestEventUpdated() throws Exception { String event = "pullrequest"; String action = "updated"; BitBucketPPRHookEvent bitbucketEvent = createEvent(event, action); @@ -71,7 +71,7 @@ public void testPullRequestEventUpdated() throws OperationNotSupportedException } @Test - public void testPullRequestEventApprovedAction() throws OperationNotSupportedException { + void testPullRequestEventApprovedAction() throws Exception { String event = "pullrequest"; String action = "approved"; BitBucketPPRHookEvent bitbucketEvent = createEvent(event, action); @@ -80,24 +80,24 @@ public void testPullRequestEventApprovedAction() throws OperationNotSupportedExc assertEquals(action, bitbucketEvent.getAction()); } - @Test(expected = OperationNotSupportedException.class) - public void testUnknownEvent() throws OperationNotSupportedException { + @Test + void testUnknownEvent() { String event = "fake"; String action = "created"; - createEvent(event, action); + assertThrows(OperationNotSupportedException.class, () -> + createEvent(event, action)); } - @Test(expected = OperationNotSupportedException.class) - public void testUnknownAction() throws OperationNotSupportedException { + @Test + void testUnknownAction() { String event = "repo"; String action = "fake"; - createEvent(event, action); + assertThrows(OperationNotSupportedException.class, () -> + createEvent(event, action)); } private BitBucketPPRHookEvent createEvent(String event, String action) - throws OperationNotSupportedException { - BitBucketPPRHookEvent bitbucketEvent = new BitBucketPPRHookEvent(event + ":" + action); - - return bitbucketEvent; + throws Exception { + return new BitBucketPPRHookEvent(event + ":" + action); } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRCloudObserverTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRCloudObserverTest.java index 0645829f..bfbadfe2 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRCloudObserverTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/observer/BitBucketPPRCloudObserverTest.java @@ -1,68 +1,56 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.observer; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.naming.OperationNotSupportedException; - import com.google.gson.Gson; import com.google.gson.stream.JsonReader; - import hudson.model.Job; import hudson.model.Run; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.MockedStatic; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; - import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRRepositoryAction; +import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; import io.jenkins.plugins.bitbucketpushandpullrequest.event.BitBucketPPREvent; import io.jenkins.plugins.bitbucketpushandpullrequest.event.BitBucketPPREventContext; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRHookEvent; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud.BitBucketPPRCloudPayload; -import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRCloudObserverTest { - public BitBucketPPRPayload payload; - public BitBucketPPRHookEvent bitbucketEvent; - - @Before - public void readPayload() { - JsonReader reader = null; - - try { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream("./cloud/repo_push.json"); - InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); - reader = new JsonReader(isr); - } catch (Exception e) { - e.printStackTrace(); - } +@ExtendWith(MockitoExtension.class) +class BitBucketPPRCloudObserverTest { + + private BitBucketPPRPayload payload; + private BitBucketPPRHookEvent bitbucketEvent; + + @BeforeEach + void setUp() throws Exception { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream("./cloud/repo_push.json"); + assertNotNull(is); + InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); + JsonReader reader = new JsonReader(isr); Gson gson = new Gson(); this.payload = gson.fromJson(reader, BitBucketPPRCloudPayload.class); - - try { - this.bitbucketEvent = new BitBucketPPRHookEvent("repo:push"); - } catch (OperationNotSupportedException e) { - e.printStackTrace(); - } + this.bitbucketEvent = new BitBucketPPRHookEvent("repo:push"); } @Test - public void testPushCloudObserver() throws Throwable { + void testPushCloudObserver() throws Exception { try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class); @@ -74,7 +62,8 @@ public void testPushCloudObserver() throws Throwable { assertEquals(links, action.getCommitLinks()); - BitBucketPPRPushCloudObserver spyObserver = Mockito.spy(BitBucketPPRPushCloudObserver.class); + BitBucketPPRPushCloudObserver spyObserver = Mockito.spy( + BitBucketPPRPushCloudObserver.class); BitBucketPPREvent event = Mockito.mock(BitBucketPPREvent.class); BitBucketPPREventContext context = Mockito.mock(BitBucketPPREventContext.class); @@ -100,8 +89,9 @@ public void testPushCloudObserver() throws Throwable { } @Test - public void testComputeBitBucketBuildKeyForInProgressBuild() { - BitBucketPPRPushCloudObserver spyObserver = Mockito.spy(BitBucketPPRPushCloudObserver.class); + void testComputeBitBucketBuildKeyForInProgressBuild() { + BitBucketPPRPushCloudObserver spyObserver = Mockito.spy( + BitBucketPPRPushCloudObserver.class); BitBucketPPREventContext context = Mockito.mock(BitBucketPPREventContext.class); BitBucketPPRPluginConfig config = Mockito.mock(BitBucketPPRPluginConfig.class); Run run = Mockito.mock(Run.class); @@ -130,8 +120,9 @@ public void testComputeBitBucketBuildKeyForInProgressBuild() { } @Test - public void testComputeBitBucketBuildKeyForFinishedBuild() { - BitBucketPPRPushCloudObserver spyObserver = Mockito.spy(BitBucketPPRPushCloudObserver.class); + void testComputeBitBucketBuildKeyForFinishedBuild() { + BitBucketPPRPushCloudObserver spyObserver = Mockito.spy( + BitBucketPPRPushCloudObserver.class); BitBucketPPREventContext context = Mockito.mock(BitBucketPPREventContext.class); BitBucketPPRPluginConfig config = Mockito.mock(BitBucketPPRPluginConfig.class); Run run = Mockito.mock(Run.class); diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestPayloadProcessorTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestPayloadProcessorTest.java index 0ea26e8b..657f05b5 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestPayloadProcessorTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestPayloadProcessorTest.java @@ -21,67 +21,52 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.processor; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import hudson.ExtensionList; -import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import javax.naming.OperationNotSupportedException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.MockedConstruction; -import org.mockito.MockedStatic; -import org.mockito.MockedStatic.Verification; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; import com.google.gson.Gson; import com.google.gson.stream.JsonReader; import io.jenkins.plugins.bitbucketpushandpullrequest.BitBucketPPRJobProbe; import io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRAction; +import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRHookEvent; import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud.BitBucketPPRCloudPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.observer.BitBucketPPRObservable; import io.jenkins.plugins.bitbucketpushandpullrequest.observer.BitBucketPPRObserverFactory; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestPayloadProcessorTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestPayloadProcessorTest { @Captor private ArgumentCaptor eventCaptor; - @Captor private ArgumentCaptor actionCaptor; - @Captor private ArgumentCaptor observableCaptor; - BitBucketPPRPullRequestCloudPayloadProcessor pullRequestPayloadProcessor; - + private BitBucketPPRPullRequestCloudPayloadProcessor pullRequestPayloadProcessor; @Test - public void testProcessPullRequestApprovalWebhookGit() throws OperationNotSupportedException { - JsonReader reader = null; - - try { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream("./cloud/pr_approved.json"); - assert is != null; - InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); - reader = new JsonReader(isr); - } catch (Exception e) { - e.printStackTrace(); - } + void testProcessPullRequestApprovalWebhookGit() throws Exception { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream("./cloud/pr_approved.json"); + assertNotNull(is); + InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); + JsonReader reader = new JsonReader(isr); try (MockedStatic config = Mockito.mockStatic( BitBucketPPRPluginConfig.class)) { @@ -91,10 +76,10 @@ public void testProcessPullRequestApprovalWebhookGit() throws OperationNotSuppor BitBucketPPRJobProbe probe = mock(BitBucketPPRJobProbe.class); Gson gson = new Gson(); - assert reader != null; BitBucketPPRPayload payload = gson.fromJson(reader, BitBucketPPRCloudPayload.class); - BitBucketPPRHookEvent bitbucketEvent = new BitBucketPPRHookEvent("pullrequest:approved"); + BitBucketPPRHookEvent bitbucketEvent = new BitBucketPPRHookEvent( + "pullrequest:approved"); pullRequestPayloadProcessor = new BitBucketPPRPullRequestCloudPayloadProcessor(probe, bitbucketEvent); diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestServerPayloadProcessorTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestServerPayloadProcessorTest.java index 48d3839f..200069c1 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestServerPayloadProcessorTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRPullRequestServerPayloadProcessorTest.java @@ -21,6 +21,12 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.processor; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + import com.google.gson.Gson; import com.google.gson.stream.JsonReader; import io.jenkins.plugins.bitbucketpushandpullrequest.BitBucketPPRJobProbe; @@ -31,46 +37,36 @@ import io.jenkins.plugins.bitbucketpushandpullrequest.model.server.BitBucketPPRServerPayload; import io.jenkins.plugins.bitbucketpushandpullrequest.observer.BitBucketPPRObservable; import io.jenkins.plugins.bitbucketpushandpullrequest.observer.BitBucketPPRObserverFactory; -import org.junit.Test; -import org.junit.jupiter.api.Assertions; -import org.junit.runner.RunWith; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.MockedStatic; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; +@ExtendWith(MockitoExtension.class) +class BitBucketPPRPullRequestServerPayloadProcessorTest { -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.*; + @Captor + private ArgumentCaptor eventCaptor; + @Captor + private ArgumentCaptor actionCaptor; + @Captor + private ArgumentCaptor observableCaptor; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRPullRequestServerPayloadProcessorTest { - - @Captor private ArgumentCaptor eventCaptor; - - @Captor private ArgumentCaptor actionCaptor; - - @Captor private ArgumentCaptor observableCaptor; - - BitBucketPPRPullRequestServerPayloadProcessor pullRequestPayloadProcessor; + private BitBucketPPRPullRequestServerPayloadProcessor pullRequestPayloadProcessor; @Test - public void testProcessPayload() throws Exception { - JsonReader reader = null; - - try { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream("./server/pr_opened.json"); - assert is != null; - InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); - reader = new JsonReader(isr); - } catch (Exception e) { - e.printStackTrace(); - } + void testProcessPayload() throws Exception { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream("./server/pr_opened.json"); + assertNotNull(is); + InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); + JsonReader reader = new JsonReader(isr); try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { @@ -80,7 +76,6 @@ public void testProcessPayload() throws Exception { BitBucketPPRJobProbe probe = mock(BitBucketPPRJobProbe.class); Gson gson = new Gson(); - assert reader != null; BitBucketPPRPayload payload = gson.fromJson(reader, BitBucketPPRServerPayload.class); BitBucketPPRHookEvent bitbucketEvent = new BitBucketPPRHookEvent("pr:opened"); @@ -103,18 +98,12 @@ public void testProcessPayload() throws Exception { } @Test - public void testProcessPayloadException() throws Exception { - JsonReader reader = null; - - try { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream("./server/pr_opened_no_clone_property.json"); - assert is != null; - InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); - reader = new JsonReader(isr); - } catch (Exception e) { - e.printStackTrace(); - } + void testProcessPayloadException() throws Exception { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream( + "./server/pr_opened_no_clone_property.json"); + InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); + JsonReader reader = new JsonReader(isr); try (MockedStatic config = Mockito.mockStatic(BitBucketPPRPluginConfig.class)) { @@ -124,7 +113,6 @@ public void testProcessPayloadException() throws Exception { BitBucketPPRJobProbe jobProbe = mock(BitBucketPPRJobProbe.class); Gson gson = new Gson(); - assert reader != null; BitBucketPPRPayload payload = gson.fromJson(reader, BitBucketPPRServerPayload.class); BitBucketPPRHookEvent bitbucketEvent = new BitBucketPPRHookEvent("pr:opened"); @@ -135,11 +123,10 @@ public void testProcessPayloadException() throws Exception { BitBucketPPRObservable observable = BitBucketPPRObserverFactory.createObservable(bitbucketEvent); - Assertions.assertThrows( + assertThrows( Exception.class, - () -> { - pullRequestPayloadProcessor.processPayload(payload, observable); - }); + () -> + pullRequestPayloadProcessor.processPayload(payload, observable)); } } } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryPayloadProcessorTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryPayloadProcessorTest.java index ce146543..702c7dc2 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryPayloadProcessorTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/processor/BitBucketPPRRepositoryPayloadProcessorTest.java @@ -1,6 +1,7 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.processor; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.verify; @@ -18,51 +19,42 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; -import javax.naming.OperationNotSupportedException; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.MockedStatic; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRRepositoryPayloadProcessorTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRRepositoryPayloadProcessorTest { - public BitBucketPPRPayload payload; - public BitBucketPPRHookEvent bitbucketEvent; - @Captor private ArgumentCaptor eventCaptor; - @Captor private ArgumentCaptor actionCaptor; - @Captor private ArgumentCaptor observableCaptor; + @Captor + private ArgumentCaptor eventCaptor; + @Captor + private ArgumentCaptor actionCaptor; + @Captor + private ArgumentCaptor observableCaptor; - @Before - public void readPayload() { - JsonReader reader = null; + private BitBucketPPRPayload payload; + private BitBucketPPRHookEvent bitbucketEvent; - try { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream("./cloud/repo_push.json"); - assert (is != null); - InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); - reader = new JsonReader(isr); - } catch (Exception e) { - e.printStackTrace(); - } + @BeforeEach + void setUp() throws Exception { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream("./cloud/repo_push.json"); + assertNotNull(is); + InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); + JsonReader reader = new JsonReader(isr); Gson gson = new Gson(); - assert (reader != null); this.payload = gson.fromJson(reader, BitBucketPPRCloudPayload.class); - - try { - this.bitbucketEvent = new BitBucketPPRHookEvent("repo:push"); - } catch (OperationNotSupportedException e) { - e.printStackTrace(); - } + this.bitbucketEvent = new BitBucketPPRHookEvent("repo:push"); } @Test - public void testRepositoryPushWebhookGit() { + void testRepositoryPushWebhookGit() { try (MockedStatic config = mockStatic(BitBucketPPRPluginConfig.class)) { BitBucketPPRPluginConfig configInstance = mock(BitBucketPPRPluginConfig.class); @@ -72,12 +64,8 @@ public void testRepositoryPushWebhookGit() { BitBucketPPRRepositoryCloudPayloadProcessor repositoryPayloadProcessor = new BitBucketPPRRepositoryCloudPayloadProcessor(probe, this.bitbucketEvent); - BitBucketPPRObservable observable = null; - try { - observable = BitBucketPPRObserverFactory.createObservable(bitbucketEvent); - } catch (Exception e) { - e.printStackTrace(); - } + BitBucketPPRObservable observable = BitBucketPPRObserverFactory.createObservable( + bitbucketEvent); repositoryPayloadProcessor.processPayload(payload, observable); diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRCrumbExclusionTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRCrumbExclusionTest.java index 43baa365..6d922396 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRCrumbExclusionTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRCrumbExclusionTest.java @@ -21,48 +21,56 @@ package io.jenkins.plugins.bitbucketpushandpullrequest.receiver; -import static org.junit.Assert.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; import static io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst.HOOK_URL; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; -import org.junit.Rule; -import org.junit.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.jvnet.hudson.test.JenkinsRule; -import org.mockito.junit.jupiter.MockitoExtension; - import org.htmlunit.HttpMethod; import org.htmlunit.WebRequest; import org.htmlunit.WebResponse; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; +import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -public class BitBucketPPRCrumbExclusionTest { +@WithJenkins +class BitBucketPPRCrumbExclusionTest { + private static final int SUCCESS_RESPONSE = 200; - @Rule - public JenkinsRule jenkins = new JenkinsRule(); + private JenkinsRule j; + + @BeforeEach + void setUp(JenkinsRule rule) { + j = rule; + } @Test - public void testTest() throws IOException { - JenkinsRule.WebClient wc = jenkins.createWebClient(); - WebRequest req = new WebRequest(new URL(wc.getContextPath() + HOOK_URL + "/"), HttpMethod.POST); + void testTest() throws Exception { + try (JenkinsRule.WebClient wc = j.createWebClient()) { + WebRequest req = new WebRequest(new URL(wc.getContextPath() + HOOK_URL + "/"), + HttpMethod.POST); - InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("./cloud/pr_updated.json"); - String jenkinsFileContent = IOUtils.toString(is, StandardCharsets.UTF_8); - assertNotNull(jenkinsFileContent); + InputStream is = Thread.currentThread().getContextClassLoader() + .getResourceAsStream("./cloud/pr_updated.json"); + assertNotNull(is); + String jenkinsFileContent = IOUtils.toString(is, StandardCharsets.UTF_8); + assertNotNull(jenkinsFileContent); - req.setAdditionalHeader("x-event-key", "pullrequest:updated"); - req.setAdditionalHeader("content-type", "application/json"); - req.setRequestBody(jenkinsFileContent); + req.setAdditionalHeader("x-event-key", "pullrequest:updated"); + req.setAdditionalHeader("content-type", "application/json"); + req.setRequestBody(jenkinsFileContent); - WebResponse resp = wc.getPage(req).getWebResponse(); - assertNotNull(resp.getContentAsString()); - assertEquals(SUCCESS_RESPONSE, resp.getStatusCode()); + WebResponse resp = wc.getPage(req).getWebResponse(); + assertNotNull(resp.getContentAsString()); + assertEquals(SUCCESS_RESPONSE, resp.getStatusCode()); + } } - } diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiverGetUrlNameTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiverGetUrlNameTest.java index dc53ee93..35fce55a 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiverGetUrlNameTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiverGetUrlNameTest.java @@ -20,31 +20,33 @@ */ package io.jenkins.plugins.bitbucketpushandpullrequest.receiver; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.MockedStatic; -import org.mockito.MockedStatic.Verification; -import org.mockito.junit.MockitoJUnitRunner; + import hudson.ExtensionList; import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.MockedStatic; +import org.mockito.MockedStatic.Verification; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class BitBucketPPRHookReceiverGetUrlNameTest { +@ExtendWith(MockitoExtension.class) +class BitBucketPPRHookReceiverGetUrlNameTest { @Test - public void testAGetUrlName() { + void testAGetUrlName() { try (MockedStatic mocked = mockStatic(ExtensionList.class)) { BitBucketPPRPluginConfig config = mock(BitBucketPPRPluginConfig.class); when(config.isHookUrlSet()).thenReturn(true); when(config.getHookUrl()).thenReturn("ABc"); - - mocked.when((Verification) ExtensionList.lookupSingleton(BitBucketPPRPluginConfig.class)) + + mocked.when( + (Verification) ExtensionList.lookupSingleton(BitBucketPPRPluginConfig.class)) .thenReturn(config); BitBucketPPRHookReceiver bitBucketPPRHookReceiver = new BitBucketPPRHookReceiver(); diff --git a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiverTest.java b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiverTest.java index 1d68a0d2..9082f1d1 100644 --- a/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiverTest.java +++ b/src/test/java/io/jenkins/plugins/bitbucketpushandpullrequest/receiver/BitBucketPPRHookReceiverTest.java @@ -20,48 +20,54 @@ */ package io.jenkins.plugins.bitbucketpushandpullrequest.receiver; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.params.provider.Arguments.arguments; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; -import java.io.UnsupportedEncodingException; -import java.util.stream.Stream; -import org.junit.Test; +import hudson.ExtensionList; +import io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst; +import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; +import java.util.stream.Stream; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.junit.runner.RunWith; import org.mockito.MockedStatic; import org.mockito.MockedStatic.Verification; -import org.mockito.junit.MockitoJUnitRunner; -import hudson.ExtensionList; -import io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst; -import io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) class BitBucketPPRHookReceiverTest { @ParameterizedTest @MethodSource("paramsProvider") - void execDecodeImputStream(String inputStream, String contentType, String expected) - throws UnsupportedEncodingException { + void execDecodeInputStream(String inputStream, String contentType, String expected) + throws Exception { try (MockedStatic mocked = mockStatic(ExtensionList.class)) { - mocked.when((Verification) ExtensionList.lookupSingleton(BitBucketPPRPluginConfig.class)) + mocked.when( + (Verification) ExtensionList.lookupSingleton(BitBucketPPRPluginConfig.class)) .thenReturn(mock(BitBucketPPRPluginConfig.class)); - assertEquals(expected, BitBucketPPRHookReceiver.decodeInputStream(inputStream, contentType)); + assertEquals(expected, + BitBucketPPRHookReceiver.decodeInputStream(inputStream, contentType)); } } static Stream paramsProvider() { return Stream.of( - arguments("here%20we%20are%2C%20isn%27t%20it%3F%3F", "abc", "here%20we%20are%2C%20isn%27t%20it%3F%3F"), - arguments("here%20we%20are%2C%20isn%27t%20it%3F%3F", "", "here%20we%20are%2C%20isn%27t%20it%3F%3F"), - arguments("payloadhere%20we%20are%2C%20isn%27t%20it%3F%3F", BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED, "payloadhere we are, isn't it??"), - arguments(BitBucketPPRConst.PAYLOAD_PFX + "here%20we%20are%2C%20isn%27t%20it%3F%3F", BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED, "here we are, isn't it??"), - arguments("", BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED, ""), - arguments("here%20we%20are%2C%20isn%27t%20it%3F%3F",BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED,"here we are, isn't it??") + arguments("here%20we%20are%2C%20isn%27t%20it%3F%3F", "abc", + "here%20we%20are%2C%20isn%27t%20it%3F%3F"), + arguments("here%20we%20are%2C%20isn%27t%20it%3F%3F", "", + "here%20we%20are%2C%20isn%27t%20it%3F%3F"), + arguments("payloadhere%20we%20are%2C%20isn%27t%20it%3F%3F", + BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED, + "payloadhere we are, isn't it??"), + arguments(BitBucketPPRConst.PAYLOAD_PFX + "here%20we%20are%2C%20isn%27t%20it%3F%3F", + BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED, "here we are, isn't it??"), + arguments("", BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED, ""), + arguments("here%20we%20are%2C%20isn%27t%20it%3F%3F", + BitBucketPPRConst.APPLICATION_X_WWW_FORM_URLENCODED, "here we are, isn't it??") ); } }