24
24
25
25
package com .synopsys .arc .jenkins .plugins .rolestrategy ;
26
26
27
- import org .junit .Assert ;
28
- import org .junit .Test ;
27
+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
28
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
29
+ import static org .junit .jupiter .api .Assertions .fail ;
30
+
31
+ import org .junit .jupiter .api .Assertions ;
32
+ import org .junit .jupiter .api .Test ;
29
33
30
34
/**
31
35
* Contains tests for Macro.
34
38
* @since 2.1.0
35
39
* @author Oleg Nenashev
36
40
*/
37
- public class MacroTest {
41
+ class MacroTest {
38
42
39
43
@ Test
40
- public void correctFormatsSanityCheck () {
44
+ void correctFormatsSanityCheck () {
41
45
parseMacro ("@Dummy" );
42
46
parseMacro ("@Dummy:1" );
43
47
parseMacro ("@Dummy(aaa)" );
@@ -47,7 +51,7 @@ public void correctFormatsSanityCheck() {
47
51
}
48
52
49
53
@ Test
50
- public void testValidUsers () {
54
+ void testValidUsers () {
51
55
parseWrongMacro ("test" , MacroExceptionCode .Not_Macro );
52
56
parseWrongMacro ("logged_user" , MacroExceptionCode .Not_Macro );
53
57
parseWrongMacro ("anonymous" , MacroExceptionCode .Not_Macro );
@@ -56,7 +60,7 @@ public void testValidUsers() {
56
60
}
57
61
58
62
@ Test
59
- public void testWrongBrackets () {
63
+ void testWrongBrackets () {
60
64
parseWrongMacro ("@test:1(aaa,bbb(" , MacroExceptionCode .WrongFormat );
61
65
parseWrongMacro ("@test:1(aaa,bbb(" , MacroExceptionCode .WrongFormat );
62
66
parseWrongMacro ("@test:1()(aaa,bbb)" , MacroExceptionCode .WrongFormat );
@@ -66,12 +70,12 @@ public void testWrongBrackets() {
66
70
}
67
71
68
72
@ Test
69
- public void err_WrongEnding () {
73
+ void err_WrongEnding () {
70
74
parseWrongMacro ("@test:1(aaa,bbb)error" , MacroExceptionCode .WrongFormat );
71
75
}
72
76
73
77
@ Test
74
- public void err_Quotes () {
78
+ void err_Quotes () {
75
79
parseWrongMacro ("@test':1(aaa,bbb)" , MacroExceptionCode .WrongFormat );
76
80
parseWrongMacro ("@'test':1(aaa,bbb)" , MacroExceptionCode .WrongFormat );
77
81
parseWrongMacro ("@test:1('aaa',bbb)" , MacroExceptionCode .WrongFormat );
@@ -85,13 +89,13 @@ public void err_Quotes() {
85
89
}
86
90
87
91
@ Test
88
- public void emptyParameters () {
92
+ void emptyParameters () {
89
93
parseMacro ("@Dummy()" );
90
94
parseMacro ("@Dummy:1()" );
91
95
}
92
96
93
97
@ Test
94
- public void test_MacroSanity () {
98
+ void test_MacroSanity () {
95
99
testCycle ("test1" , null , null );
96
100
testCycle ("test2" , 1 , null );
97
101
testCycle ("test3" , -1 , null );
@@ -114,13 +118,13 @@ private static void testCycle(String macroName, Integer macroId, String[] parame
114
118
}
115
119
116
120
private static void assertEquals (Macro expected , Macro actual ) {
117
- Assert .assertEquals ("Wrong name" , expected .getName (), expected .getName ());
118
- Assert .assertEquals ("Wrong index" , expected .getIndex (), expected .getIndex ());
121
+ Assertions .assertEquals (expected .getName (), actual .getName (), "Wrong name" );
122
+ Assertions .assertEquals (expected .getIndex (), actual .getIndex (), "Wrong index" );
119
123
120
124
if (expected .hasParameters ()) {
121
- Assert . assertArrayEquals ("Wrong parameters set" , expected .getParameters (), actual .getParameters ());
125
+ assertArrayEquals (expected .getParameters (), actual .getParameters (), "Wrong parameters set" );
122
126
} else {
123
- Assert . assertFalse ("Actual macro shouldn't have parameters" , actual . hasParameters () );
127
+ assertFalse (actual . hasParameters (), "Actual macro shouldn't have parameters" );
124
128
}
125
129
}
126
130
@@ -132,15 +136,15 @@ private static Macro assertParseMacroDriver(String errorMessage, String macroStr
132
136
} catch (MacroException ex ) {
133
137
ex .printStackTrace ();
134
138
if (expectException ) {
135
- Assert .assertEquals (errorMessage + ". Wrong error code" , expectedError , ex . getErrorCode () );
139
+ Assertions .assertEquals (expectedError , ex . getErrorCode (), errorMessage + ". Wrong error code" );
136
140
} else {
137
- Assert . fail (errorMessage + ". Got Macro Exception: " + ex .getMessage ());
141
+ fail (errorMessage + ". Got Macro Exception: " + ex .getMessage ());
138
142
}
139
143
return res ;
140
144
}
141
145
142
146
if (expectException ) {
143
- Assert . fail (errorMessage + ". Haven't got exception. Expected code is " + expectedError );
147
+ fail (errorMessage + ". Haven't got exception. Expected code is " + expectedError );
144
148
}
145
149
return res ;
146
150
}
0 commit comments