Skip to content

Commit

Permalink
Minimize whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sghill committed Oct 26, 2021
1 parent 6f41a39 commit 3a2d416
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ protected HttpPost createRequest(
*/
@Deprecated
protected HttpPost createRequest(
final URI uri,
final URI uri,
final JSONObject payload,
final UsernamePasswordCredentials credentials) throws AuthenticationException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ public void shouldHandleBasePathNoTrailingSlash() {
URI actual = BuildStatusUriFactory.create(baseUri, "25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");
assertThat(actual, equalTo(expected));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.jenkinsci.plugins.stashNotifier;

import com.cloudbees.plugins.credentials.CredentialsMatcher;
import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.Launcher;
Expand All @@ -15,7 +12,6 @@
import hudson.util.Secret;
import jenkins.model.Jenkins;
import jenkins.model.JenkinsLocationConfiguration;
import net.sf.json.JSONObject;
import org.acegisecurity.Authentication;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.http.HttpHost;
Expand Down Expand Up @@ -46,7 +42,6 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -55,12 +50,9 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -249,8 +241,7 @@ public void test_build_http_client_https() throws Exception {
false,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

PrintStream logger = mock(PrintStream.class);

Expand Down Expand Up @@ -502,8 +493,7 @@ public void lookupCommitSha1s() throws Exception {
false,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
Collection<String> hashes = sn.lookupCommitSha1s(build, null, buildListener);
Expand Down Expand Up @@ -531,8 +521,7 @@ private void lookupCommitSha1s_Exception(Exception e) throws InterruptedExceptio
false,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
Collection<String> hashes = sn.lookupCommitSha1s(build, null, buildListener);
Expand Down Expand Up @@ -581,21 +570,6 @@ public void test_getBuildDescription_state() {
assertThat(getBuildDescriptionWhenBuildDescriptionIsNull(StashBuildState.INPROGRESS), is("building on Jenkins @ http://localhost/"));
}

@Test
public void test_createRequest() throws Exception {
//given
UsernamePasswordCredentialsImpl credential = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "", "", "admin", "tiger");
PowerMockito.mockStatic(CredentialsMatchers.class);
when(CredentialsMatchers.firstOrNull(anyCollection(), any(CredentialsMatcher.class))).thenReturn(credential);

//when
HttpPost request = sn.createRequest(URI.create("http://localhost"), new JSONObject(), credential);

//then
assertThat(request, is(not(nullValue())));
assertThat(request.getHeaders("Authorization"), is(not(nullValue())));
}

@Test
public void test_getPushedBuildState_overwritten() {
//given
Expand All @@ -613,8 +587,7 @@ public void test_getPushedBuildState_overwritten() {
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
StashBuildState pushedBuildStatus = sn.getPushedBuildStatus(StashBuildState.FAILED);
Expand All @@ -638,8 +611,7 @@ public void test_getPushedBuildState_not_overwritten() {
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
StashBuildState pushedBuildStatus = sn.getPushedBuildStatus(StashBuildState.FAILED);
Expand All @@ -666,8 +638,7 @@ public void test_getBuildName_overwritten() {
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
String buildName = sn.getBuildName(run);
Expand All @@ -693,8 +664,7 @@ public void test_getBuildName_not_overwritten() {
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
String buildName = sn.getBuildName(run);
Expand Down Expand Up @@ -724,8 +694,7 @@ public void test_getBuildKey() throws Exception {
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
String buildKey = sn.getBuildKey(build, buildListener);
Expand Down Expand Up @@ -756,8 +725,7 @@ public void test_getBuildKey_withBuildName() {
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
String buildKey = sn.getBuildKey(build, buildListener);
Expand Down Expand Up @@ -789,8 +757,7 @@ public void test_getRunKey() throws Exception {
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
String buildKey = sn.getBuildKey(run, buildListener);
Expand Down Expand Up @@ -819,8 +786,7 @@ private void getBuildKey_Exception(Exception e) throws InterruptedException, Mac
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
String buildKey = sn.getBuildKey(build, buildListener);
Expand Down Expand Up @@ -852,8 +818,7 @@ private void getRunKey_Exception(Exception e) throws InterruptedException, Macro
true,
false,
false,
mock(JenkinsLocationConfiguration.class)
);
mock(JenkinsLocationConfiguration.class));

//when
String buildKey = sn.getBuildKey(run, buildListener);
Expand Down Expand Up @@ -899,7 +864,6 @@ private NotificationResult notifyStash(int statusCode) throws Exception {
when(buildListener.getLogger()).thenReturn(logger);
doReturn("someKey1").when(sn).getBuildKey(eq(build), eq(buildListener));
HttpPost httpPost = mock(HttpPost.class);
doReturn(httpPost).when(sn).createRequest(any(URI.class), any(JSONObject.class), eq(null));
CloseableHttpResponse resp = mock(CloseableHttpResponse.class);
StatusLine sl = mock(StatusLine.class);
when(sl.getStatusCode()).thenReturn(statusCode);
Expand Down

0 comments on commit 3a2d416

Please sign in to comment.