22
33import static jenkins .plugins .foldericon .utils .TestUtils .mockStaplerRequest ;
44import static jenkins .plugins .foldericon .utils .TestUtils .validateSymbol ;
5- import static org .junit .jupiter .api .Assertions .*;
5+ import static org .hamcrest .MatcherAssert .assertThat ;
6+ import static org .hamcrest .Matchers .contains ;
7+ import static org .hamcrest .Matchers .empty ;
8+ import static org .hamcrest .Matchers .hasSize ;
9+ import static org .hamcrest .Matchers .instanceOf ;
10+ import static org .hamcrest .Matchers .is ;
11+ import static org .hamcrest .Matchers .startsWith ;
612import static org .mockito .Mockito .mockStatic ;
713
814import com .cloudbees .hudson .plugins .folder .Folder ;
1723import jenkins .plugins .foldericon .BuildStatusFolderIcon .DescriptorImpl ;
1824import jenkins .plugins .foldericon .utils .DelayBuilder ;
1925import jenkins .plugins .foldericon .utils .ResultBuilder ;
20- import org .apache .commons .lang3 .StringUtils ;
2126import org .junit .jupiter .api .BeforeEach ;
2227import org .junit .jupiter .api .Test ;
2328import org .jvnet .hudson .test .JenkinsRule ;
@@ -50,13 +55,13 @@ void getAvailableJobs() throws Exception {
5055 BuildStatusFolderIcon customIcon = new BuildStatusFolderIcon (null );
5156 project .setIcon (customIcon );
5257
53- assertTrue (customIcon .getAvailableJobs (). isEmpty ());
58+ assertThat (customIcon .getAvailableJobs (), empty ());
5459
5560 project .createProject (FreeStyleProject .class , "Success" );
5661 project .createProject (FreeStyleProject .class , "Aborted" );
5762
58- assertEquals ( 2 , customIcon .getAvailableJobs (). size ( ));
59- assertEquals ( Set . of ( "Aborted" , "Success" ), customIcon . getAvailableJobs ( ));
63+ assertThat ( customIcon .getAvailableJobs (), hasSize ( 2 ));
64+ assertThat ( customIcon . getAvailableJobs (), contains ( "Aborted" , "Success" ));
6065 }
6166
6267 /**
@@ -127,14 +132,14 @@ void withConfiguredJobs() throws Exception {
127132 @ Test
128133 void folder () throws Exception {
129134 BuildStatusFolderIcon customIcon = new BuildStatusFolderIcon (null );
130- assertTrue ( StringUtils . startsWith ( customIcon .getDescription (), Messages .Folder_description ()));
135+ assertThat ( customIcon .getDescription (), startsWith ( Messages .Folder_description ()));
131136
132137 Folder project = r .jenkins .createProject (Folder .class , "folder" );
133138 project .setIcon (customIcon );
134139 FolderIcon icon = project .getIcon ();
135140
136- assertInstanceOf ( BuildStatusFolderIcon .class , icon );
137- assertTrue ( StringUtils . startsWith ( icon .getDescription (), project .getPronoun ()));
141+ assertThat ( icon , instanceOf ( BuildStatusFolderIcon .class ) );
142+ assertThat ( icon .getDescription (), startsWith ( project .getPronoun ()));
138143 }
139144
140145 /**
@@ -145,14 +150,14 @@ void folder() throws Exception {
145150 @ Test
146151 void organizationFolder () throws Exception {
147152 BuildStatusFolderIcon customIcon = new BuildStatusFolderIcon (null );
148- assertTrue ( StringUtils . startsWith ( customIcon .getDescription (), Messages .Folder_description ()));
153+ assertThat ( customIcon .getDescription (), startsWith ( Messages .Folder_description ()));
149154
150155 OrganizationFolder project = r .jenkins .createProject (OrganizationFolder .class , "org" );
151156 project .setIcon (customIcon );
152157 FolderIcon icon = project .getIcon ();
153158
154- assertInstanceOf ( BuildStatusFolderIcon .class , icon );
155- assertTrue ( StringUtils . startsWith ( icon .getDescription (), project .getPronoun ()));
159+ assertThat ( icon , instanceOf ( BuildStatusFolderIcon .class ) );
160+ assertThat ( icon .getDescription (), startsWith ( project .getPronoun ()));
156161 }
157162
158163 /**
@@ -162,8 +167,8 @@ void organizationFolder() throws Exception {
162167 void descriptor () {
163168 BuildStatusFolderIcon customIcon = new BuildStatusFolderIcon (null );
164169 DescriptorImpl descriptor = customIcon .getDescriptor ();
165- assertEquals ( Messages . BuildStatusFolderIcon_description (), descriptor . getDisplayName ( ));
166- assertTrue (descriptor .isApplicable (null ));
170+ assertThat ( descriptor . getDisplayName (), is ( Messages . BuildStatusFolderIcon_description () ));
171+ assertThat (descriptor .isApplicable (null ), is ( true ));
167172 }
168173
169174 /**
@@ -178,7 +183,7 @@ void finishedBuildStatusIcon() throws Exception {
178183 project .setIcon (customIcon );
179184 FolderIcon icon = project .getIcon ();
180185
181- assertInstanceOf ( BuildStatusFolderIcon .class , icon );
186+ assertThat ( icon , instanceOf ( BuildStatusFolderIcon .class ) );
182187
183188 try (MockedStatic <Stapler > stapler = mockStatic (Stapler .class )) {
184189 mockStaplerRequest (stapler );
@@ -234,7 +239,7 @@ void runningBuildStatusIcon() throws Exception {
234239 project .setIcon (customIcon );
235240 FolderIcon icon = project .getIcon ();
236241
237- assertInstanceOf ( BuildStatusFolderIcon .class , icon );
242+ assertThat ( icon , instanceOf ( BuildStatusFolderIcon .class ) );
238243
239244 try (MockedStatic <Stapler > stapler = mockStatic (Stapler .class )) {
240245 mockStaplerRequest (stapler );
@@ -271,7 +276,7 @@ void runningNoPreviousBuildStatusIcon() throws Exception {
271276 project .setIcon (customIcon );
272277 FolderIcon icon = project .getIcon ();
273278
274- assertInstanceOf ( BuildStatusFolderIcon .class , icon );
279+ assertThat ( icon , instanceOf ( BuildStatusFolderIcon .class ) );
275280
276281 try (MockedStatic <Stapler > stapler = mockStatic (Stapler .class )) {
277282 mockStaplerRequest (stapler );
@@ -302,7 +307,7 @@ void disabledBuildStatusIcon() throws Exception {
302307 project .setIcon (customIcon );
303308 FolderIcon icon = project .getIcon ();
304309
305- assertInstanceOf ( BuildStatusFolderIcon .class , icon );
310+ assertThat ( icon , instanceOf ( BuildStatusFolderIcon .class ) );
306311
307312 try (MockedStatic <Stapler > stapler = mockStatic (Stapler .class )) {
308313 mockStaplerRequest (stapler );
@@ -311,8 +316,8 @@ void disabledBuildStatusIcon() throws Exception {
311316 FreeStyleProject disabled = project .createProject (FreeStyleProject .class , "Disabled" );
312317 disabled .setDisabled (true );
313318
314- assertFalse (disabled .isBuildable ());
315- assertTrue (disabled .isDisabled ());
319+ assertThat (disabled .isBuildable (), is ( false ));
320+ assertThat (disabled .isDisabled (), is ( true ));
316321 validateSymbol (icon , BallColor .DISABLED .getImage (), BallColor .DISABLED .getIconName ());
317322 }
318323 }
@@ -329,7 +334,7 @@ void noBuildStatusIcon() throws Exception {
329334 project .setIcon (customIcon );
330335 FolderIcon icon = project .getIcon ();
331336
332- assertInstanceOf ( BuildStatusFolderIcon .class , icon );
337+ assertThat ( icon , instanceOf ( BuildStatusFolderIcon .class ) );
333338
334339 try (MockedStatic <Stapler > stapler = mockStatic (Stapler .class )) {
335340 mockStaplerRequest (stapler );
0 commit comments