Skip to content

Commit 7c841d5

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 b4a94aa commit 7c841d5

File tree

4 files changed

+72
-16
lines changed

4 files changed

+72
-16
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public String getCron() {
117117
}
118118

119119
// Needed for Jelly Config
120-
public String getcredentialsId() {
120+
public String getCredentialsId() {
121121
return this.credentialsId;
122122
}
123123

@@ -162,7 +162,7 @@ public boolean getCheckDestinationCommit() {
162162
return checkDestinationCommit;
163163
}
164164

165-
public boolean isIgnoreSsl() {
165+
public boolean getIgnoreSsl() {
166166
return ignoreSsl;
167167
}
168168

@@ -178,7 +178,7 @@ public boolean getMergeOnSuccess() {
178178
return mergeOnSuccess;
179179
}
180180

181-
public boolean isCancelOutdatedJobsEnabled() {
181+
public boolean getCancelOutdatedJobsEnabled() {
182182
return cancelOutdatedJobsEnabled;
183183
}
184184

@@ -220,19 +220,19 @@ public void stop() {
220220
super.stop();
221221
}
222222

223-
public boolean isCheckMergeable() {
223+
public boolean getCheckMergeable() {
224224
return checkMergeable;
225225
}
226226

227-
public boolean isCheckNotConflicted() {
227+
public boolean getCheckNotConflicted() {
228228
return checkNotConflicted;
229229
}
230230

231-
public boolean isCheckProbeMergeStatus() {
231+
public boolean getCheckProbeMergeStatus() {
232232
return checkProbeMergeStatus;
233233
}
234234

235-
public boolean isOnlyBuildOnComment() {
235+
public boolean getOnlyBuildOnComment() {
236236
return onlyBuildOnComment;
237237
}
238238

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private static StashApiClient makeStashApiClient(StashBuildTrigger trigger) {
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
}
@@ -367,9 +367,9 @@ public boolean mergePullRequest(String pullRequestId, String version) {
367367
}
368368

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

385-
if (trigger.isCheckNotConflicted()) {
385+
if (trigger.getCheckNotConflicted()) {
386386
res &= !mergeable.getConflicted();
387387
}
388388

@@ -459,7 +459,7 @@ private boolean isBuildTarget(StashPullRequestResponseValue pullRequest) {
459459
return false;
460460
}
461461

462-
boolean isOnlyBuildOnComment = trigger.isOnlyBuildOnComment();
462+
boolean isOnlyBuildOnComment = trigger.getOnlyBuildOnComment();
463463

464464
if (isOnlyBuildOnComment) {
465465
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+
}

src/test/java/stashpullrequestbuilder/stashpullrequestbuilder/StashRepositoryTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public void constructor_initializes_StashApiClient() throws Exception {
516516
when(trigger.getPassword()).thenReturn("Password");
517517
when(trigger.getProjectCode()).thenReturn(projectName);
518518
when(trigger.getRepositoryName()).thenReturn(repositoryName);
519-
when(trigger.isIgnoreSsl()).thenReturn(false);
519+
when(trigger.getIgnoreSsl()).thenReturn(false);
520520

521521
stubFor(
522522
get(format(

0 commit comments

Comments
 (0)