Skip to content

Commit aaf9b3a

Browse files
committed
StashBuildTrigger: Use correct getter names for config.jelly fields
Getter names for fields referenced in config.jelly should start with "get" followed by the capitalized property name. "is" is not supported.
1 parent 5719ae1 commit aaf9b3a

File tree

3 files changed

+71
-15
lines changed

3 files changed

+71
-15
lines changed

src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuildTrigger.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public String getCron() {
115115
}
116116

117117
// Needed for Jelly Config
118-
public String getcredentialsId() {
118+
public String getCredentialsId() {
119119
return this.credentialsId;
120120
}
121121

@@ -157,7 +157,7 @@ public boolean getCheckDestinationCommit() {
157157
return checkDestinationCommit;
158158
}
159159

160-
public boolean isIgnoreSsl() {
160+
public boolean getIgnoreSsl() {
161161
return ignoreSsl;
162162
}
163163

@@ -173,7 +173,7 @@ public boolean getMergeOnSuccess() {
173173
return mergeOnSuccess;
174174
}
175175

176-
public boolean isCancelOutdatedJobsEnabled() {
176+
public boolean getCancelOutdatedJobsEnabled() {
177177
return cancelOutdatedJobsEnabled;
178178
}
179179

@@ -215,19 +215,19 @@ public void stop() {
215215
super.stop();
216216
}
217217

218-
public boolean isCheckMergeable() {
218+
public boolean getCheckMergeable() {
219219
return checkMergeable;
220220
}
221221

222-
public boolean isCheckNotConflicted() {
222+
public boolean getCheckNotConflicted() {
223223
return checkNotConflicted;
224224
}
225225

226-
public boolean isCheckProbeMergeStatus() {
226+
public boolean getCheckProbeMergeStatus() {
227227
return checkProbeMergeStatus;
228228
}
229229

230-
public boolean isOnlyBuildOnComment() {
230+
public boolean getOnlyBuildOnComment() {
231231
return onlyBuildOnComment;
232232
}
233233

src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepository.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void init() {
8686
trigger.getPassword(),
8787
trigger.getProjectCode(),
8888
trigger.getRepositoryName(),
89-
trigger.isIgnoreSsl());
89+
trigger.getIgnoreSsl());
9090
}
9191

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

259-
if (trigger.isCancelOutdatedJobsEnabled()) {
259+
if (trigger.getCancelOutdatedJobsEnabled()) {
260260
cancelPreviousJobsInQueueThatMatch(cause);
261261
abortRunningJobsThatMatch(cause);
262262
}
@@ -363,9 +363,9 @@ public boolean mergePullRequest(String pullRequestId, String version) {
363363
}
364364

365365
private boolean isPullRequestMergeable(StashPullRequestResponseValue pullRequest) {
366-
if (trigger.isCheckMergeable()
367-
|| trigger.isCheckNotConflicted()
368-
|| trigger.isCheckProbeMergeStatus()) {
366+
if (trigger.getCheckMergeable()
367+
|| trigger.getCheckNotConflicted()
368+
|| trigger.getCheckProbeMergeStatus()) {
369369
/* Request PR status from Stash, and consult our configuration
370370
* toggles on whether we care about certain verdicts in that
371371
* JSON answer, parsed into fields of the "response" object.
@@ -374,11 +374,11 @@ private boolean isPullRequestMergeable(StashPullRequestResponseValue pullRequest
374374
StashPullRequestMergeableResponse mergeable =
375375
client.getPullRequestMergeStatus(pullRequest.getId());
376376
boolean res = true;
377-
if (trigger.isCheckMergeable()) {
377+
if (trigger.getCheckMergeable()) {
378378
res &= mergeable.getCanMerge();
379379
}
380380

381-
if (trigger.isCheckNotConflicted()) {
381+
if (trigger.getCheckNotConflicted()) {
382382
res &= !mergeable.getConflicted();
383383
}
384384

@@ -455,7 +455,7 @@ private boolean isBuildTarget(StashPullRequestResponseValue pullRequest) {
455455
return false;
456456
}
457457

458-
boolean isOnlyBuildOnComment = trigger.isOnlyBuildOnComment();
458+
boolean isOnlyBuildOnComment = trigger.getOnlyBuildOnComment();
459459

460460
if (isOnlyBuildOnComment) {
461461
shouldBuild = false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package stashpullrequestbuilder.stashpullrequestbuilder;
2+
3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.hamcrest.Matchers.is;
5+
import static org.hamcrest.Matchers.notNullValue;
6+
7+
import hudson.model.Descriptor.PropertyType;
8+
import java.util.Arrays;
9+
import org.junit.Rule;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
import org.jvnet.hudson.test.JenkinsRule;
13+
import org.mockito.junit.MockitoJUnit;
14+
import org.mockito.junit.MockitoJUnitRunner;
15+
import org.mockito.junit.MockitoRule;
16+
import org.mockito.quality.Strictness;
17+
import stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.StashBuildTriggerDescriptor;
18+
19+
@RunWith(MockitoJUnitRunner.class)
20+
public class StashBuildTriggerTest {
21+
22+
@Rule public JenkinsRule jenkinsRule = new JenkinsRule();
23+
@Rule public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
24+
25+
@Test
26+
public void check_getters() throws Exception {
27+
StashBuildTriggerDescriptor descriptor = StashBuildTrigger.descriptor;
28+
29+
// Field names from config.jelly
30+
Iterable<String> properties =
31+
Arrays.asList(
32+
"cron",
33+
"stashHost",
34+
"credentialsId",
35+
"projectCode",
36+
"repositoryName",
37+
"ignoreSsl",
38+
"targetBranchesToBuild",
39+
"checkDestinationCommit",
40+
"checkNotConflicted",
41+
"checkMergeable",
42+
"checkProbeMergeStatus",
43+
"mergeOnSuccess",
44+
"deletePreviousBuildFinishComments",
45+
"cancelOutdatedJobsEnabled",
46+
"ciSkipPhrases",
47+
"onlyBuildOnComment",
48+
"ciBuildPhrases");
49+
50+
for (String property : properties) {
51+
System.out.println(property);
52+
PropertyType propertyType = descriptor.getPropertyType(property);
53+
assertThat(propertyType, is(notNullValue()));
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)