1212
1313package org .eclipse .jdt .ui .tests .refactoring ;
1414
15+ import static org .junit .Assert .assertEquals ;
1516import static org .junit .Assert .assertFalse ;
1617import static org .junit .Assert .assertTrue ;
1718
@@ -154,14 +155,14 @@ public void testArrayParameterAndReturnType() throws Exception {
154155 public void testMethodNotFound () throws Exception {
155156 //Method cannot be found
156157 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 2 , 0 , 2 , 1 );
157- assertTrue (status .getEntryWithHighestSeverity ().getMessage (). equals ( RefactoringCoreMessages .MakeStaticRefactoring_not_available_on_this_selection ) );
158+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_on_this_selection );
158159 }
159160
160161 @ Test
161162 public void testIsConstructor () throws Exception {
162163 //Check if Constructor
163164 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 2 , 12 , 2 , 15 );
164- assertTrue (status .getEntryWithHighestSeverity ().getMessage (). equals ( RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_constructors ) );
165+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_constructors );
165166 }
166167
167168 @ Test
@@ -197,61 +198,57 @@ public void testMultipleFilesInSameProject() throws Exception {
197198 public void testRecursive () throws Exception {
198199 //MethodInvocation in MethodDeclaration with object of the same Class in parameter
199200 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 3 , 10 , 3 , 13 );
200- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
201- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods ));
201+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods );
202202 }
203203
204204 @ Test
205205 public void testRecursive2 () throws Exception {
206206 //recursive invocation after invoking a method that returns a new instance of the same class
207207 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 6 , 10 , 6 , 13 );
208- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
209- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods ));
208+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods );
210209 }
211210
212211 @ Test
213212 public void testRecursive3 () throws Exception {
214213 //simple recursive invocation of instance method
215214 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 2 , 17 , 2 , 20 );
216- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
217- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods ));
215+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods );
218216 }
219217
220218 @ Test
221219 public void testInheritance () throws Exception {
222220 //Refactor of method that overrides method of supertype (Selection is set to MethodDeclaration)
223221 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SubClass" , "p.SuperClass" }, 4 , 19 , 4 , 22 );
224- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
225- .equals (RefactoringCoreMessages .MakeStaticRefactoring_explicit_super_method_invocation ));
222+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_explicit_super_method_invocation );
226223 }
227224
228225 @ Test
229226 public void testInheritance2 () throws Exception {
230227 //Refactor of method in super type that has child type overriding the method -> should fail
231228 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SuperClass" , "p.SubClass" }, 3 , 19 , 3 , 22 );
232- assertTrue (status .getEntryWithHighestSeverity ().getMessage (). equals ( RefactoringCoreMessages .MakeStaticRefactoring_method_is_overridden_in_subtype ) );
229+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_method_is_overridden_in_subtype );
233230 }
234231
235232 @ Test
236233 public void testInheritance3 () throws Exception {
237234 //Selecting SuperMethodInvocation -> should fail
238235 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SubClass" , "p.SuperClass" }, 5 , 26 , 5 , 29 );
239- assertTrue (status .getEntryWithHighestSeverity ().getMessage (). equals ( RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_super_method_invocations ) );
236+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_super_method_invocations );
240237 }
241238
242239 @ Test
243240 public void testInheritance4 () throws Exception {
244241 //Refactor method without parameters on the lowest hierarchy level ->
245242 //After refactoring it is static but has the same signature as parent type method -> should fail
246243 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SubClass" , "p.SuperClass" }, 4 , 19 , 4 , 22 );
247- assertTrue (status .getEntryWithHighestSeverity ().getMessage (). equals ( RefactoringCoreMessages .MakeStaticRefactoring_hiding_method_of_parent_type ) );
244+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_hiding_method_of_parent_type );
248245 }
249246
250247 @ Test
251248 public void testInheritance5 () throws Exception {
252249 //Inheritance with Recursion
253250 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SubClass" , "p.SuperClass" }, 4 , 10 , 4 , 13 );
254- assertTrue (status .getEntryWithHighestSeverity ().getMessage (). equals ( RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods ) );
251+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods );
255252 }
256253
257254 @ Test
@@ -265,8 +262,7 @@ public void testDuplicateParamName() throws Exception {
265262 public void testDuplicateMethod () throws Exception {
266263 //Selected method has instance usage and there is an existing method that is equal to the selected method after being refactored
267264 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 5 , 19 , 5 , 22 );
268- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
269- .equals (RefactoringCoreMessages .MakeStaticRefactoring_duplicate_method_signature ));
265+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_duplicate_method_signature );
270266 }
271267
272268 @ Test
@@ -280,8 +276,7 @@ public void testDuplicateMethod2() throws Exception {
280276 public void testMethodAlreadyStatic () throws Exception {
281277 //Selected method is already static
282278 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 2 , 24 , 2 , 27 );
283- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
284- .equals (RefactoringCoreMessages .MakeStaticRefactoring_method_already_static ));
279+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_method_already_static );
285280 }
286281
287282 @ Test
@@ -353,16 +348,14 @@ public void testGenericDeclaration8() throws Exception {
353348 public void testGenericDeclaration9 () throws Exception {
354349 //check for wildcardTypes as bounds (T extends List<?>)
355350 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 7 , 17 , 7 , 20 );
356- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
357- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_wildCardTypes_as_bound ));
351+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_wildCardTypes_as_bound );
358352 }
359353
360354 @ Test
361355 public void testGenericDeclaration10 () throws Exception {
362356 //check for wildcardTypes as bounds (T extends Map<? extends Runnable, ? extends Throwable>)
363357 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 7 , 17 , 7 , 20 );
364- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
365- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_wildCardTypes_as_bound ));
358+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_wildCardTypes_as_bound );
366359 }
367360
368361 @ Test
@@ -419,8 +412,7 @@ public void testMethodCallInNestedAnonymousClass() throws Exception {
419412 public void testVariousInstanceCases () throws Exception {
420413 //Various cases of instance access in many different forms
421414 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SubClass" , "p.SuperClass" }, 14 , 17 , 14 , 20 );
422- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
423- .equals (RefactoringCoreMessages .MakeStaticRefactoring_selected_method_uses_super_field_access ));
415+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_selected_method_uses_super_field_access );
424416 }
425417
426418 @ Test
@@ -455,8 +447,7 @@ public void testPassingInstanceReference() throws Exception {
455447 public void testSuperMethodReference () throws Exception {
456448 //Selected method is used in SuperMethodReference -> Should throw error
457449 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SuperClass" , "p.SubClass" }, 4 , 19 , 4 , 22 );
458- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
459- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_method_references ));
450+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_method_references );
460451 }
461452
462453 @ Test
@@ -477,8 +468,7 @@ public void testReturnField() throws Exception {
477468 public void testExplicitSuperMethodInvocation () throws Exception {
478469 //MethodDeclaration uses explcit SuperMethodInvocation to call method of parent type -> semantic change not allowed
479470 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SubClass" , "p.SuperClass" }, 3 , 17 , 3 , 20 );
480- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
481- .equals (RefactoringCoreMessages .MakeStaticRefactoring_explicit_super_method_invocation ));
471+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_explicit_super_method_invocation );
482472 }
483473
484474 @ Test
@@ -492,8 +482,7 @@ public void testImplicitSuperMethodInvocation() throws Exception {
492482 public void testSuperFieldAccess () throws Exception {
493483 //MethodDeclaration uses SuperFieldAccess -> throws warning but is possible
494484 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.SubClass" , "p.SuperClass" }, 6 , 17 , 6 , 20 );
495- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
496- .equals (RefactoringCoreMessages .MakeStaticRefactoring_selected_method_uses_super_field_access ));
485+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_selected_method_uses_super_field_access );
497486 }
498487
499488 @ Test
@@ -505,8 +494,7 @@ public void testConcatenatedFieldAccessAndQualifiedNames() throws Exception {
505494 @ Test
506495 public void testSourceNotAvailable () throws Exception {
507496 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 3 , 20 , 3 , 27 );
508- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
509- .equals (RefactoringCoreMessages .MakeStaticRefactoring_source_not_available_for_selected_method ));
497+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_source_not_available_for_selected_method );
510498 }
511499
512500 @ Test
@@ -527,8 +515,7 @@ public void testClassInstanceCreation() throws Exception {
527515 public void testConvertMethodReferenceToLambda () throws Exception {
528516 //MethodReference needs to be co0nverted to lambda because refactored method accepts two parameters
529517 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 10 , 10 , 10 , 13 );
530- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
531- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_method_references ));
518+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_method_references );
532519 }
533520
534521 @ Test
@@ -541,32 +528,28 @@ public void testNested() throws Exception {
541528 public void testMethodReference () throws Exception {
542529 //TypeMethodReference
543530 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 8 , 10 , 8 , 13 );
544- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
545- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_method_references ));
531+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_method_references );
546532 }
547533
548534 @ Test
549535 public void testMethodReference2 () throws Exception {
550536 //ExpressionMethodReference in anonymous class -> Refactoring not allowed in anonymous class and method references also not allowed
551537 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 4 , 26 , 4 , 29 );
552- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
553- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_local_or_anonymous_types ));
538+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_local_or_anonymous_types );
554539 }
555540
556541 @ Test
557542 public void testMethodReference3 () throws Exception {
558543 //ExpressionMethodReference with recursion
559544 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 2 , 17 , 2 , 20 );
560- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
561- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods ));
545+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_recursive_methods );
562546 }
563547
564548 @ Test
565549 public void testMethodReference4 () throws Exception {
566550 //ExpressionMethodReference
567551 RefactoringStatus status = performRefactoringAndMatchFiles (new String [] { "p.Foo" }, 8 , 17 , 8 , 20 );
568- assertTrue (status .getEntryWithHighestSeverity ().getMessage ()
569- .equals (RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_method_references ));
552+ assertEquals (status .getEntryWithHighestSeverity ().getMessage (), RefactoringCoreMessages .MakeStaticRefactoring_not_available_for_method_references );
570553 }
571554
572555 @ Test
0 commit comments