16
16
*/
17
17
package spoon .test .refactoring ;
18
18
19
- import org .junit .Test ;
19
+ import org .junit .jupiter . api . Test ;
20
20
import spoon .Launcher ;
21
21
import spoon .OutputType ;
22
22
import spoon .SpoonModelBuilder ;
55
55
import java .util .Iterator ;
56
56
import java .util .List ;
57
57
58
- import static org .junit .Assert .assertEquals ;
59
- import static org .junit .Assert .assertFalse ;
60
- import static org .junit .Assert .assertNotNull ;
61
- import static org .junit .Assert .assertNotSame ;
62
- import static org .junit .Assert .assertNull ;
63
- import static org .junit .Assert .assertSame ;
64
- import static org .junit .Assert .assertTrue ;
65
- import static org .junit .Assert .fail ;
58
+ import static org .junit .jupiter . api . Assertions .assertEquals ;
59
+ import static org .junit .jupiter . api . Assertions .assertFalse ;
60
+ import static org .junit .jupiter . api . Assertions .assertNotNull ;
61
+ import static org .junit .jupiter . api . Assertions .assertNotSame ;
62
+ import static org .junit .jupiter . api . Assertions .assertNull ;
63
+ import static org .junit .jupiter . api . Assertions .assertSame ;
64
+ import static org .junit .jupiter . api . Assertions .assertTrue ;
65
+ import static org .junit .jupiter . api . Assertions .fail ;
66
66
67
67
public class MethodsRefactoringTest {
68
68
@@ -116,9 +116,9 @@ public void testSubInheritanceHierarchyFunction() {
116
116
117
117
private void checkContainsOnly (List <String > foundNames , String ... expectedNames ) {
118
118
for (String name : expectedNames ) {
119
- assertTrue ("The " +name +" not found" , foundNames . remove ( name ) );
119
+ assertTrue (foundNames . remove ( name ), "The " +name +" not found" );
120
120
}
121
- assertTrue ("Unexpected names found: " +foundNames , foundNames . isEmpty () );
121
+ assertTrue (foundNames . isEmpty (), "Unexpected names found: " +foundNames );
122
122
}
123
123
124
124
@ Test
@@ -141,10 +141,10 @@ public void testAllMethodsSameSignatureFunction() {
141
141
//contract: CtConstructor has no other same signature
142
142
CtConstructor <?> constructorTypeA = factory .Class ().get (TypeA .class ).getConstructors ().iterator ().next ();
143
143
CtExecutable <?> exec = constructorTypeA .map (new AllMethodsSameSignatureFunction ()).first ();
144
- assertNull ("Unexpected executable found by Constructor of TypeA " +exec , exec );
144
+ assertNull (exec , "Unexpected executable found by Constructor of TypeA " +exec );
145
145
CtConstructor <?> constructorTypeB = factory .Class ().get (TypeB .class ).getConstructors ().iterator ().next ();
146
146
exec = constructorTypeA .map (new AllMethodsSameSignatureFunction ()).first ();
147
- assertNull ("Unexpected executable found by Constructor of TypeA " +exec , exec );
147
+ assertNull (exec , "Unexpected executable found by Constructor of TypeA " +exec );
148
148
//contract: constructor is returned if includingSelf == true
149
149
assertSame (constructorTypeA , constructorTypeA .map (new AllMethodsSameSignatureFunction ().includingSelf (true )).first ());
150
150
}
@@ -173,46 +173,46 @@ private void checkMethodHierarchy(List<CtExecutable<?>> expectedExecutables, CtE
173
173
//contract: check that by default it returns lambdas
174
174
{
175
175
final List <CtExecutable <?>> executables = startExecutable .map (new AllMethodsSameSignatureFunction ()).list ();
176
- assertFalse ("Unexpected start executable " +startExecutable , containsSame ( executables , startExecutable ) );
176
+ assertFalse (containsSame ( executables , startExecutable ), "Unexpected start executable " +startExecutable );
177
177
//check that some method was found
178
178
assertFalse (executables .isEmpty ());
179
179
//check that expected methods were found and remove them
180
180
expectedExecutables .forEach (m ->{
181
181
boolean found = removeSame (executables , m );
182
182
if (startExecutable ==m ) {
183
183
//it is start method. It should not be there
184
- assertFalse ("The signature " +getQSignature (m )+" was returned too" , found );
184
+ assertFalse (found , "The signature " +getQSignature (m )+" was returned too" );
185
185
} else {
186
- assertTrue ("The signature " +getQSignature (m )+" not found" , found );
186
+ assertTrue (found , "The signature " +getQSignature (m )+" not found" );
187
187
}
188
188
});
189
189
//check that there is no unexpected executable
190
- assertTrue ("Unexpected executables: " +executables , executables . isEmpty () );
190
+ assertTrue (executables . isEmpty (), "Unexpected executables: " +executables );
191
191
}
192
192
193
193
//contract: check that includingSelf(true) returns startMethod too
194
194
//contract: check that by default it still returns lambdas
195
195
{
196
196
final List <CtExecutable <?>> executables = startExecutable .map (new AllMethodsSameSignatureFunction ().includingSelf (true )).list ();
197
- assertTrue ("Missing start executable " +startExecutable , containsSame ( executables , startExecutable ) );
197
+ assertTrue (containsSame ( executables , startExecutable ), "Missing start executable " +startExecutable );
198
198
//check that some method was found
199
199
assertFalse (executables .isEmpty ());
200
200
//check that expected methods were found and remove them
201
201
expectedExecutables .forEach (m ->{
202
- assertTrue ("The signature " +getQSignature (m )+" not found" , removeSame ( executables , m ) );
202
+ assertTrue (removeSame ( executables , m ), "The signature " +getQSignature (m )+" not found" );
203
203
});
204
204
//check that there is no unexpected executable
205
- assertTrue ("Unexpected executables: " +executables , executables . isEmpty () );
205
+ assertTrue (executables . isEmpty (), "Unexpected executables: " +executables );
206
206
}
207
207
208
208
//contract: check that includingLambdas(false) returns no lambda expressions
209
209
{
210
210
final List <CtExecutable <?>> executables = startExecutable .map (new AllMethodsSameSignatureFunction ().includingSelf (true ).includingLambdas (false )).list ();
211
211
if (startExecutable instanceof CtLambda ) {
212
212
//lambda must not be returned even if it is first
213
- assertFalse ("Unexpected start executable " +startExecutable , containsSame ( executables , startExecutable ) );
213
+ assertFalse (containsSame ( executables , startExecutable ), "Unexpected start executable " +startExecutable );
214
214
} else {
215
- assertTrue ("Missing start executable " +startExecutable , containsSame ( executables , startExecutable ) );
215
+ assertTrue (containsSame ( executables , startExecutable ), "Missing start executable " +startExecutable );
216
216
}
217
217
218
218
//check that some method was found
@@ -223,10 +223,10 @@ private void checkMethodHierarchy(List<CtExecutable<?>> expectedExecutables, CtE
223
223
//the lambdas are not expected. Do not ask for them
224
224
return ;
225
225
}
226
- assertTrue ("The signature " +getQSignature (m )+" not found" , removeSame ( executables , m ) );
226
+ assertTrue (removeSame ( executables , m ), "The signature " +getQSignature (m )+" not found" );
227
227
});
228
228
//check that there is no unexpected executable or lambda
229
- assertTrue ("Unexepcted executables " +executables , executables . isEmpty () );
229
+ assertTrue (executables . isEmpty (), "Unexepcted executables " +executables );
230
230
}
231
231
//contract: check early termination
232
232
//contract: check that first returned element is the startExecutable itself if includingSelf == true
@@ -301,7 +301,7 @@ private int checkExecutableReferenceFilter(Factory factory, List<CtExecutable<?>
301
301
return containsSame (executables , er .getDeclaration ());
302
302
}).forEach ((CtExecutableReference er )->{
303
303
//check that each expected reference was found by ExecutableReferenceFilter and remove it from that list
304
- assertTrue ("Executable reference: " +er +" not found." , refs . remove ( er ) );
304
+ assertTrue (refs . remove ( er ), "Executable reference: " +er +" not found." );
305
305
});
306
306
//check that no other reference was found by ExecutableReferenceFilter
307
307
assertSame (0 , refs .size ());
0 commit comments