Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public String getCron() {
}

// Needed for Jelly Config
public String getcredentialsId() {
public String getCredentialsId() {
return this.credentialsId;
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public boolean getCheckDestinationCommit() {
return checkDestinationCommit;
}

public boolean isIgnoreSsl() {
public boolean getIgnoreSsl() {
return ignoreSsl;
}

Expand All @@ -178,7 +178,7 @@ public boolean getMergeOnSuccess() {
return mergeOnSuccess;
}

public boolean isCancelOutdatedJobsEnabled() {
public boolean getCancelOutdatedJobsEnabled() {
return cancelOutdatedJobsEnabled;
}

Expand Down Expand Up @@ -220,19 +220,19 @@ public void stop() {
super.stop();
}

public boolean isCheckMergeable() {
public boolean getCheckMergeable() {
return checkMergeable;
}

public boolean isCheckNotConflicted() {
public boolean getCheckNotConflicted() {
return checkNotConflicted;
}

public boolean isCheckProbeMergeStatus() {
public boolean getCheckProbeMergeStatus() {
return checkProbeMergeStatus;
}

public boolean isOnlyBuildOnComment() {
public boolean getOnlyBuildOnComment() {
return onlyBuildOnComment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static StashApiClient makeStashApiClient(StashBuildTrigger trigger) {
trigger.getPassword(),
trigger.getProjectCode(),
trigger.getRepositoryName(),
trigger.isIgnoreSsl());
trigger.getIgnoreSsl());
}

public Collection<StashPullRequestResponseValue> getTargetPullRequests() {
Expand Down Expand Up @@ -256,7 +256,7 @@ private List<ParameterValue> getParameters(StashCause cause) {
public Queue.Item startJob(StashCause cause) {
List<ParameterValue> values = getParameters(cause);

if (trigger.isCancelOutdatedJobsEnabled()) {
if (trigger.getCancelOutdatedJobsEnabled()) {
cancelPreviousJobsInQueueThatMatch(cause);
abortRunningJobsThatMatch(cause);
}
Expand Down Expand Up @@ -367,9 +367,9 @@ public boolean mergePullRequest(String pullRequestId, String version) {
}

private boolean isPullRequestMergeable(StashPullRequestResponseValue pullRequest) {
if (trigger.isCheckMergeable()
|| trigger.isCheckNotConflicted()
|| trigger.isCheckProbeMergeStatus()) {
if (trigger.getCheckMergeable()
|| trigger.getCheckNotConflicted()
|| trigger.getCheckProbeMergeStatus()) {
/* Request PR status from Stash, and consult our configuration
* toggles on whether we care about certain verdicts in that
* JSON answer, parsed into fields of the "response" object.
Expand All @@ -378,11 +378,11 @@ private boolean isPullRequestMergeable(StashPullRequestResponseValue pullRequest
StashPullRequestMergeableResponse mergeable =
client.getPullRequestMergeStatus(pullRequest.getId());
boolean res = true;
if (trigger.isCheckMergeable()) {
if (trigger.getCheckMergeable()) {
res &= mergeable.getCanMerge();
}

if (trigger.isCheckNotConflicted()) {
if (trigger.getCheckNotConflicted()) {
res &= !mergeable.getConflicted();
}

Expand Down Expand Up @@ -459,7 +459,7 @@ private boolean isBuildTarget(StashPullRequestResponseValue pullRequest) {
return false;
}

boolean isOnlyBuildOnComment = trigger.isOnlyBuildOnComment();
boolean isOnlyBuildOnComment = trigger.getOnlyBuildOnComment();

if (isOnlyBuildOnComment) {
shouldBuild = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package stashpullrequestbuilder.stashpullrequestbuilder;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

import hudson.model.Descriptor.PropertyType;
import java.util.Arrays;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.jvnet.hudson.test.JenkinsRule;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.MockitoRule;
import org.mockito.quality.Strictness;
import stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.StashBuildTriggerDescriptor;

@RunWith(MockitoJUnitRunner.class)
public class StashBuildTriggerTest {

@Rule public JenkinsRule jenkinsRule = new JenkinsRule();
@Rule public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);

@Test
public void check_getters() throws Exception {
StashBuildTriggerDescriptor descriptor = StashBuildTrigger.descriptor;

// Field names from config.jelly
Iterable<String> properties =
Arrays.asList(
"cron",
"stashHost",
"credentialsId",
"projectCode",
"repositoryName",
"ignoreSsl",
"targetBranchesToBuild",
"checkDestinationCommit",
"checkNotConflicted",
"checkMergeable",
"checkProbeMergeStatus",
"mergeOnSuccess",
"deletePreviousBuildFinishComments",
"cancelOutdatedJobsEnabled",
"ciSkipPhrases",
"onlyBuildOnComment",
"ciBuildPhrases");

for (String property : properties) {
System.out.println(property);
PropertyType propertyType = descriptor.getPropertyType(property);
assertThat(propertyType, is(notNullValue()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public void constructor_initializes_StashApiClient() throws Exception {
when(trigger.getPassword()).thenReturn("Password");
when(trigger.getProjectCode()).thenReturn(projectName);
when(trigger.getRepositoryName()).thenReturn(repositoryName);
when(trigger.isIgnoreSsl()).thenReturn(false);
when(trigger.getIgnoreSsl()).thenReturn(false);

stubFor(
get(format(
Expand Down