11package hudson .plugins .throttleconcurrents ;
22
3- import static org .junit .Assert .assertEquals ;
4- import static org .junit .Assert . assertNotNull ;
5- import static org .junit .Assert . assertTrue ;
3+ import static org .junit .jupiter . api . Assertions .assertEquals ;
4+ import static org .junit .jupiter . api . Assertions . assertInstanceOf ;
5+ import static org .junit .jupiter . api . Assertions . assertNotNull ;
66
77import hudson .EnvVars ;
88import hudson .model .Computer ;
1111import hudson .model .queue .CauseOfBlockage ;
1212import hudson .slaves .DumbSlave ;
1313import hudson .slaves .RetentionStrategy ;
14+ import java .io .File ;
1415import java .util .Arrays ;
1516import java .util .Collections ;
1617import java .util .List ;
1718import java .util .Set ;
1819import jenkins .model .queue .CompositeCauseOfBlockage ;
1920import org .jenkinsci .plugins .workflow .job .WorkflowRun ;
2021import org .jenkinsci .plugins .workflow .support .steps .ExecutorStepExecution ;
21- import org .junit .rules .TemporaryFolder ;
2222import org .jvnet .hudson .test .JenkinsRule ;
2323
2424public class TestUtil {
@@ -34,13 +34,15 @@ public class TestUtil {
3434 static final ThrottleJobProperty .ThrottleCategory OTHER_ONE_PER_NODE =
3535 new ThrottleJobProperty .ThrottleCategory ("other_one_per_node" , 1 , 0 , null );
3636
37+ private TestUtil () {
38+ // Instantiation is prohibited
39+ }
40+
3741 private static DumbSlave createAgent (
38- JenkinsRule j , TemporaryFolder temporaryFolder , EnvVars env , int numExecutors , String label )
39- throws Exception {
42+ JenkinsRule j , File temporaryFolder , EnvVars env , int numExecutors , String label ) throws Exception {
4043 synchronized (j .jenkins ) {
4144 int sz = j .jenkins .getNodes ().size ();
42- DumbSlave agent =
43- new DumbSlave ("agent" + sz , temporaryFolder .getRoot ().getPath (), j .createComputerLauncher (env ));
45+ DumbSlave agent = new DumbSlave ("agent" + sz , temporaryFolder .getPath (), j .createComputerLauncher (env ));
4446 agent .setNumExecutors (numExecutors );
4547 agent .setMode (Node .Mode .NORMAL );
4648 agent .setLabelString (label == null ? "" : label );
@@ -54,12 +56,7 @@ private static DumbSlave createAgent(
5456 }
5557
5658 static Node setupAgent (
57- JenkinsRule j ,
58- TemporaryFolder temporaryFolder ,
59- List <Node > agents ,
60- EnvVars env ,
61- int numExecutors ,
62- String label )
59+ JenkinsRule j , File temporaryFolder , List <Node > agents , EnvVars env , int numExecutors , String label )
6360 throws Exception {
6461 DumbSlave agent = TestUtil .createAgent (j , temporaryFolder , env , numExecutors , label );
6562
@@ -88,8 +85,7 @@ static void setupCategories(ThrottleJobProperty.ThrottleCategory... categories)
8885 }
8986
9087 static Set <String > getBlockageReasons (CauseOfBlockage cob ) {
91- if (cob instanceof CompositeCauseOfBlockage ) {
92- CompositeCauseOfBlockage ccob = (CompositeCauseOfBlockage ) cob ;
88+ if (cob instanceof CompositeCauseOfBlockage ccob ) {
9389 return ccob .uniqueReasons .keySet ();
9490 } else {
9591 return Collections .singleton (cob .getShortDescription ());
@@ -99,7 +95,9 @@ static Set<String> getBlockageReasons(CauseOfBlockage cob) {
9995 static void hasPlaceholderTaskForRun (Node n , WorkflowRun r ) throws Exception {
10096 for (Executor exec : n .toComputer ().getExecutors ()) {
10197 if (exec .getCurrentExecutable () != null ) {
102- assertTrue (exec .getCurrentExecutable ().getParent () instanceof ExecutorStepExecution .PlaceholderTask );
98+ assertInstanceOf (
99+ ExecutorStepExecution .PlaceholderTask .class ,
100+ exec .getCurrentExecutable ().getParent ());
103101 ExecutorStepExecution .PlaceholderTask task = (ExecutorStepExecution .PlaceholderTask )
104102 exec .getCurrentExecutable ().getParent ();
105103 while (task .run () == null ) {
0 commit comments