1414import hudson .util .Secret ;
1515import jenkins .model .Jenkins ;
1616import net .sf .json .JSONObject ;
17- import org .acegisecurity .Authentication ;
1817import org .apache .http .StatusLine ;
1918import org .apache .http .client .config .CookieSpecs ;
2019import org .apache .http .client .config .RequestConfig ;
2524import org .apache .http .impl .client .CloseableHttpClient ;
2625import org .apache .http .impl .client .HttpClientBuilder ;
2726import org .jenkinsci .plugins .tokenmacro .TokenMacro ;
28- import org .junit .AfterClass ;
29- import org .junit .Before ;
30- import org .junit .BeforeClass ;
31- import org .junit .Test ;
27+ import org .junit .jupiter . api . AfterAll ;
28+ import org .junit .jupiter . api . BeforeAll ;
29+ import org .junit .jupiter . api . BeforeEach ;
30+ import org .junit .jupiter . api . Test ;
3231
3332import java .io .File ;
3433import java .io .PrintStream ;
3938
4039import org .mockito .ArgumentCaptor ;
4140import org .mockito .MockedStatic ;
41+ import org .springframework .security .core .Authentication ;
4242
4343import static org .hamcrest .MatcherAssert .assertThat ;
4444import static org .hamcrest .Matchers .is ;
5151import static org .mockito .Mockito .verify ;
5252import static org .mockito .Mockito .when ;
5353
54- public class DefaultApacheHttpNotifierTest {
54+ class DefaultApacheHttpNotifierTest {
5555
56- final static String sha1 = "1234567890123456789012345678901234567890" ;
56+ private static final String SHA_1 = "1234567890123456789012345678901234567890" ;
5757 private static CloseableHttpClient client ;
5858 private static MockedStatic <Jenkins > mockedJenkins ;
5959 private static MockedStatic <CredentialsProvider > mockedCredentialsProvider ;
@@ -65,8 +65,8 @@ public class DefaultApacheHttpNotifierTest {
6565 private static BuildListener buildListener ;
6666 private HttpClientBuilder httpClientBuilder ;
6767
68- @ BeforeClass
69- public static void setUp () throws Exception {
68+ @ BeforeAll
69+ static void beforeAll () throws Exception {
7070 mockedSecret = mockStatic (Secret .class );
7171 mockedJenkins = mockStatic (Jenkins .class );
7272 mockedStaticHttpClientBuilder = mockStatic (HttpClientBuilder .class );
@@ -100,13 +100,13 @@ public static void setUp() throws Exception {
100100 when (jenkins .getRootUrl ()).thenReturn ("http://localhost/" );
101101 when (build .getEnvironment (buildListener )).thenReturn (environment );
102102 when (action .getLastBuiltRevision ()).thenReturn (revision );
103- when (revision .getSha1String ()).thenReturn (sha1 );
103+ when (revision .getSha1String ()).thenReturn (SHA_1 );
104104 doReturn (project ).when (build ).getProject ();
105105 doReturn (project ).when (run ).getParent ();
106106 when (build .getFullDisplayName ()).thenReturn ("foo" );
107107 when (build .getUrl ()).thenReturn ("foo" );
108108 when (build .getActions (BuildData .class )).thenReturn (actions );
109- when (environment .expand (anyString ())).thenReturn (sha1 );
109+ when (environment .expand (anyString ())).thenReturn (SHA_1 );
110110 when (buildListener .getLogger ()).thenReturn (logger );
111111 when (Secret .fromString ("tiger" )).thenReturn (secret );
112112 when (Secret .toString (secret )).thenReturn ("tiger" );
@@ -118,25 +118,25 @@ public static void setUp() throws Exception {
118118 when (lastBuild .getMarked ()).thenReturn (revision );
119119
120120 when (TokenMacro .expandAll (build , buildListener , "test-project" )).thenReturn ("prepend-key" );
121- when (CredentialsProvider .lookupCredentials (
121+ when (CredentialsProvider .lookupCredentialsInItemGroup (
122122 any (),
123123 any (ItemGroup .class ),
124124 any (Authentication .class ),
125125 anyList ()
126126 )).thenReturn (new ArrayList <>());
127127 }
128128
129- @ AfterClass
130- public static void close () {
129+ @ AfterAll
130+ static void afterAll () {
131131 mockedJenkins .close ();
132132 mockedCredentialsProvider .close ();
133133 mockedSecret .close ();
134134 mockedStaticHttpClientBuilder .close ();
135135 mockedTokenMacro .close ();
136136 }
137137
138- @ Before
139- public void before () {
138+ @ BeforeEach
139+ void beforeEach () {
140140 httpClientBuilder = mock (HttpClientBuilder .class );
141141 when (HttpClientBuilder .create ()).thenReturn (httpClientBuilder );
142142 when (httpClientBuilder .build ()).thenReturn (client );
@@ -156,19 +156,19 @@ private NotificationResult notifyStash(int statusCode) throws Exception {
156156 }
157157
158158 @ Test
159- public void notifyStash_success () throws Exception {
159+ void notifyStash_success () throws Exception {
160160 NotificationResult notificationResult = notifyStash (204 );
161161 assertThat (notificationResult .indicatesSuccess , is (true ));
162162 }
163163
164164 @ Test
165- public void notifyStash_fail () throws Exception {
165+ void notifyStash_fail () throws Exception {
166166 NotificationResult notificationResult = notifyStash (400 );
167167 assertThat (notificationResult .indicatesSuccess , is (false ));
168168 }
169169
170170 @ Test
171- public void notifyStashUsesRequestParameters () throws Exception {
171+ void notifyStashUsesRequestParameters () throws Exception {
172172 notifyStash (204 );
173173
174174 final ArgumentCaptor <RequestConfig > captor = ArgumentCaptor .forClass (RequestConfig .class );
0 commit comments