diff options
Diffstat (limited to 'src/main/java')
2 files changed, 10 insertions, 30 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java index 10d6c98..81b5603 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java @@ -28,11 +28,6 @@ import static com.cloudbees.plugins.credentials.CredentialsMatchers.instanceOf; * Created by nishio */ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> { - /** - * Default value for {@link #getCommentTrigger()}. - */ - public static final String DEFAULT_COMMENT_TRIGGER = "test this please"; - private static final Logger logger = Logger.getLogger(BitbucketBuildTrigger.class.getName()); private final String projectPath; private final String cron; @@ -55,30 +50,6 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> { @Extension public static final BitbucketBuildTriggerDescriptor descriptor = new BitbucketBuildTriggerDescriptor(); - /** - * Sets {@link #getCommentTrigger()} to {@link #DEFAULT_COMMENT_TRIGGER}. - */ - @DataBoundConstructor - public BitbucketBuildTrigger( - String projectPath, - String cron, - String credentialsId, - String username, - String password, - String repositoryOwner, - String repositoryName, - String branchesFilter, - boolean branchesFilterBySCMIncludes, - String ciKey, - String ciName, - String ciSkipPhrases, - boolean checkDestinationCommit, - boolean approveIfSuccess - ) throws ANTLRException { - this(projectPath, cron, credentialsId, username, password, repositoryOwner, repositoryName, - branchesFilter, branchesFilterBySCMIncludes, ciKey, ciName, ciSkipPhrases, - checkDestinationCommit, approveIfSuccess, DEFAULT_COMMENT_TRIGGER); - } @DataBoundConstructor public BitbucketBuildTrigger( String projectPath, diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java index ee11e75..01da88e 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java @@ -38,6 +38,10 @@ public class BitbucketRepository { private static final String BUILD_REQUEST_DONE_MARKER = "ttp build flag"; private static final String BUILD_REQUEST_MARKER_TAG_SINGLE_RX = "\\#[\\w\\-\\d]+"; private static final String BUILD_REQUEST_MARKER_TAGS_RX = "\\[bid\\:\\s?(.*)\\]"; + /** + * Default value for comment trigger. + */ + public static final String DEFAULT_COMMENT_TRIGGER = "test this please"; private String projectPath; private BitbucketPullRequestsBuilder builder; @@ -182,7 +186,12 @@ public class BitbucketRepository { } private boolean isTTPComment(String content) { - return content.toLowerCase().contains(trigger.getCommentTrigger().toLowerCase()); + // special case: in unit tests, trigger is null and can't be mocked + String commentTrigger = DEFAULT_COMMENT_TRIGGER; + if(trigger != null && StringUtils.isNotBlank(trigger.getCommentTrigger())) { + commentTrigger = trigger.getCommentTrigger(); + } + return content.toLowerCase().contains(commentTrigger); } private boolean isTTPCommentBuildTags(String content) { |