Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fix npe for propagation url settings #340

Merged
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 @@ -88,7 +88,7 @@ public BitBucketPPRPullRequestServerAction(@Nonnull BitBucketPPRPayload payload)
}
}

if (!globalConfig.getPropagationUrl().isEmpty()) {
if (globalConfig.isPropagationUrlSet()) {
try {
this.baseUrl = new URL(globalConfig.getPropagationUrl());
} catch (MalformedURLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
return propagationUrl;
}

public boolean isPropagationUrlSet() {
return !isEmpty(propagationUrl);

Check warning on line 105 in src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRPluginConfig.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 105 is not covered by tests
}

@DataBoundSetter
public void setNotifyBitBucket(@CheckForNull boolean notifyBitBucket) {
this.notifyBitBucket = notifyBitBucket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public void testBaseUrlSet() {
BitBucketPPRPluginConfig.class)) {
BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class);
config.when(BitBucketPPRPluginConfig::getInstance).thenReturn(c);
when(c.isPropagationUrlSet()).thenReturn(true);
when(c.getPropagationUrl()).thenReturn("https://example.org/scm/some-namespace/some-repo.git");

BitBucketPPRPayload payloadMock = mock(BitBucketPPRPayload.class, RETURNS_DEEP_STUBS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public void testProcessPayload() throws Exception {
Mockito.mockStatic(BitBucketPPRPluginConfig.class)) {
BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class);
config.when(BitBucketPPRPluginConfig::getInstance).thenReturn(c);
when(c.getPropagationUrl()).thenReturn("");

BitBucketPPRJobProbe probe = mock(BitBucketPPRJobProbe.class);

Expand Down
Loading