diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/WrappingSystemTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/WrappingSystemTest.java index 69de4b34899..1685e1cd628 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/WrappingSystemTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/WrappingSystemTest.java @@ -14,9 +14,9 @@ package org.eclipse.jdt.junit.tests; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.util.Iterator; import java.util.List; @@ -213,10 +213,9 @@ protected void waitForTableToFill(int numExpectedTableLines, int millisecondTimeout, boolean lastItemHasImage) throws PartInitException { long startTime = System.currentTimeMillis(); while (stillWaiting(numExpectedTableLines, lastItemHasImage)) { - if (System.currentTimeMillis() - startTime > millisecondTimeout) - fail("Timeout waiting for " + numExpectedTableLines - + " lines in table. Present: " + getNumTableItems() + " items.\n" - + "The 2nd vm has " + (hasNotTerminated() ? "not " : "") + "terminated."); + assertFalse("Timeout waiting for " + numExpectedTableLines + + " lines in table. Present: " + getNumTableItems() + " items.\n" + + "The 2nd vm has " + (hasNotTerminated() ? "not " : "") + "terminated.", System.currentTimeMillis() - startTime > millisecondTimeout); dispatchEvents(); } } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java index 5e0b677e84f..6d700bc164a 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java @@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -297,7 +298,7 @@ public void testBug578547() { filter= new TypeInfoFilter("Test", scope, 0, null); assertEquals("Test", filter.getNamePattern()); - assertEquals(null, filter.getPackagePattern()); + assertNull(filter.getPackagePattern()); } } \ No newline at end of file diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java index 8045fba48b6..3b63084094f 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Hashtable; @@ -145,7 +144,7 @@ public void testCreateClass1() throws Exception { * File */ package test1; - + /** * Type */ @@ -187,9 +186,9 @@ public void testCreateClass2() throws Exception { * File */ package test1; - + import java.util.ArrayList; - + /** * Type */ @@ -241,14 +240,14 @@ public class A { * File */ package test1; - + import pack.A; - + /** * Type */ public class E extends A { - + /** * Overridden */ @@ -303,14 +302,14 @@ public class A { * File */ package test1; - + import pack.A; - + /** * Type */ public class E extends A { - + /** * Constructor */ @@ -318,12 +317,12 @@ public E(String t) { super(t); } /* class body */ - + /** * Method */ public static void main(String[] args) { - + } } """; @@ -370,9 +369,9 @@ public class A { String expected= """ package pack; - + import java.util.ArrayList; - + public class A { /** * Type @@ -380,7 +379,7 @@ public class A { public class E extends ArrayList { /* class body */ } - + public abstract void foo(T t); } """; @@ -423,11 +422,11 @@ public void testCreateClassExtraImports1() throws Exception { * File */ package test1; - + import java.io.File; import java.util.List; import java.util.Map; - + /** * Type */ @@ -486,16 +485,16 @@ public static class Inner { * File */ package test1; - + import java.util.Map; - + import pack.A; - + /** * Type */ public class E extends A { - + /** * Overridden */ @@ -526,9 +525,9 @@ public static class Inner { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String str1= """ package test1; - + import java.util.Map; - + public class B { } """; @@ -558,18 +557,18 @@ public class B { String expected= """ package test1; - + import java.util.Map; - + import pack.A; - + public class B { - + /** * Type */ public class E extends A { - + /** * Overridden */ @@ -612,9 +611,9 @@ public void testCreateInterface() throws Exception { * File */ package test1; - + import java.util.List; - + /** * Type */ @@ -652,7 +651,7 @@ public void testCreateEnum() throws Exception { * File */ package test1; - + /** * Type */ @@ -690,7 +689,7 @@ public void testCreateAnnotation() throws Exception { * File */ package test1; - + /** * Type */ @@ -811,9 +810,9 @@ public void testAttemptCreateExistingClass() throws Exception IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String str= """ package test1; - + public class Foo1 { - + } """; ICompilationUnit cu= pack1.createCompilationUnit("Foo1.java", str, false, null); @@ -823,9 +822,9 @@ public class Foo1 { pack1= fSourceFolder.createPackageFragment("test2", false, null); String str1= """ package test2; - + public class Foo3 { - + } """; pack1.createCompilationUnit("Foo3.java", str1, false, null); @@ -849,7 +848,7 @@ public void testAddFinalSuperClassError1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String test= """ package test1; - + public final class A{ } """; @@ -873,8 +872,8 @@ public final class A{ IStatus status= wizardPage.getSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(expected.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(expected, status.getMessage()); } private static ITypeBinding getTypeBinding(ICompilationUnit cu) { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest17.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest17.java index 7cdee2accae..ed08713fe11 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest17.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest17.java @@ -15,7 +15,7 @@ package org.eclipse.jdt.ui.tests.wizardapi; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.Hashtable; @@ -122,14 +122,14 @@ private void initNonModularProject() throws Exception { fpack1= fSourceFolder.createPackageFragment("test1", false, null); String test= """ package test; - + public sealed class Shape permits Square { } """; fSealedSuperCls= fpack1.createCompilationUnit("Shape.java", test, false, null); test= """ package test; - + public non-sealed class Square extends Shape { } """; @@ -137,14 +137,14 @@ public non-sealed class Square extends Shape { fSealedClsBinding= getTypeBinding(fSealedSuperCls); test= """ package test; - + public sealed interface IShape permits ISquare { } """; fSealedSuperInterface= fpack1.createCompilationUnit("IShape.java", test, false, null); test= """ package test; - + public non-sealed interface ISquare extends IShape { } """; @@ -159,14 +159,14 @@ private void initModularProject() throws Exception { fMpack1= fMSourceFolder.createPackageFragment("test1", false, null); String test= """ package test; - + public sealed class Shape permits Square { } """; fMSealedSuperCls= fMpack1.createCompilationUnit("Shape.java", test, false, null); test= """ package test; - + public non-sealed class Square extends Shape { } """; @@ -174,14 +174,14 @@ public non-sealed class Square extends Shape { fMSealedClsBinding= getTypeBinding(fMSealedSuperCls); test= """ package test; - + public sealed interface IShape permits ISquare { } """; fMSealedSuperInterface= fMpack1.createCompilationUnit("IShape.java", test, false, null); test= """ package test; - + public non-sealed interface ISquare extends IShape { } """; @@ -204,8 +204,8 @@ private void initSecondProject() throws Exception { private void createModuleInfo() throws Exception { String test= """ - - + + module modTest1 { exports test1; } @@ -220,8 +220,8 @@ private void initSecondModularProject() throws Exception { fMSourceFolder= JavaProjectHelper.addSourceContainer(fJProjectM2, "src"); fMpack1= fMSourceFolder.createPackageFragment("test3", false, null); String test= """ - - + + module modTest2 { requires modTest2; } @@ -276,8 +276,8 @@ public void testNonModularCreateClassError1() throws Exception { IStatus status= wizardPage.getSealedSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperClassInDifferentPackage.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperClassInDifferentPackage, status.getMessage()); } // Throw error if the sealed super interface is in different package to the new class @@ -301,8 +301,8 @@ public void testNonModularCreateClassError2() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperInterfaceInDifferentPackage.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperInterfaceInDifferentPackage, status.getMessage()); } // Throw error if the sealed super interface is in different package to the new interface @@ -325,8 +325,8 @@ public void testNonModularCreateInterfaceError1() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_interface_SealedSuperInterfaceInDifferentPackage.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_interface_SealedSuperInterfaceInDifferentPackage, status.getMessage()); } // Successfully Create non-sealed class which has sealed super class @@ -350,17 +350,17 @@ public void testNonModularCreateClassSuccess1() throws Exception { IStatus status= wizardPage.getSealedSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_extend_superclass_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_extend_superclass_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccNonSealed, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -371,7 +371,7 @@ public void testNonModularCreateClassSuccess1() throws Exception { * File */ package test1; - + /** * Type */ @@ -386,7 +386,7 @@ public non-sealed class E extends Shape { expected= """ package test; - + public sealed class Shape permits Square, E { } """; @@ -414,17 +414,17 @@ public void testNonModularCreateClassSuccess2() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_implement_superinterface_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_implement_superinterface_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccNonSealed, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -435,7 +435,7 @@ public void testNonModularCreateClassSuccess2() throws Exception { * File */ package test1; - + /** * Type */ @@ -450,7 +450,7 @@ public non-sealed class E implements IShape { expected= """ package test; - + public sealed interface IShape permits ISquare, E { } """; @@ -479,17 +479,17 @@ public void testNonModularCreateClassSuccess3() throws Exception { IStatus status= wizardPage.getSealedSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_extend_superclass_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_extend_superclass_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccFinal, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -500,7 +500,7 @@ public void testNonModularCreateClassSuccess3() throws Exception { * File */ package test1; - + /** * Type */ @@ -515,7 +515,7 @@ public final class E extends Shape { expected= """ package test; - + public sealed class Shape permits Square, E { } """; @@ -543,17 +543,17 @@ public void testNonModularCreateClassSuccess4() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_implement_superinterface_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_implement_superinterface_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccFinal, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -564,7 +564,7 @@ public void testNonModularCreateClassSuccess4() throws Exception { * File */ package test1; - + /** * Type */ @@ -579,7 +579,7 @@ public final class E implements IShape { expected= """ package test; - + public sealed interface IShape permits ISquare, E { } """; @@ -606,17 +606,17 @@ public void testNonModularCreateInterfaceSuccess1() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedInterface_extend_superinterface_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedInterface_extend_superinterface_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccNonSealed, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -627,7 +627,7 @@ public void testNonModularCreateInterfaceSuccess1() throws Exception { * File */ package test1; - + /** * Type */ @@ -642,7 +642,7 @@ public non-sealed interface IE extends IShape { expected= """ package test; - + public sealed interface IShape permits ISquare, IE { } """; @@ -677,8 +677,8 @@ public void testNonModularDependantCreateClassError1() throws Exception { IStatus status= wizardPage.getSealedSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperClassInDifferentProject.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperClassInDifferentProject, status.getMessage()); } // Throw error if the sealed super interface is in different project to the new class @@ -703,8 +703,8 @@ public void testNonModularDependantCreateClassError2() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperInterfaceInDifferentProject.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperInterfaceInDifferentProject, status.getMessage()); } // Throw error if the sealed super interface is in different project to the new interface @@ -728,8 +728,8 @@ public void testNonModularDependantCreateInterfaceError1() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_interface_SealedSuperInterfaceInDifferentProject.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_interface_SealedSuperInterfaceInDifferentProject, status.getMessage()); } @@ -761,17 +761,17 @@ public void testModularCreateClassSuccess1() throws Exception { IStatus status= wizardPage.getSealedSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_extend_superclass_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_extend_superclass_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccNonSealed, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -782,9 +782,9 @@ public void testModularCreateClassSuccess1() throws Exception { * File */ package test2; - + import test1.Shape; - + /** * Type */ @@ -799,9 +799,9 @@ public non-sealed class E extends Shape { expected= """ package test; - + import test2.E; - + public sealed class Shape permits Square, E { } """; @@ -832,17 +832,17 @@ public void testModularCreateClassSuccess2() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_implement_superinterface_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_implement_superinterface_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccNonSealed, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -853,9 +853,9 @@ public void testModularCreateClassSuccess2() throws Exception { * File */ package test2; - + import test1.IShape; - + /** * Type */ @@ -870,9 +870,9 @@ public non-sealed class E implements IShape { expected= """ package test; - + import test2.E; - + public sealed interface IShape permits ISquare, E { } """; @@ -904,17 +904,17 @@ public void testModularCreateClassSuccess3() throws Exception { IStatus status= wizardPage.getSealedSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_extend_superclass_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_extend_superclass_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccFinal, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -925,9 +925,9 @@ public void testModularCreateClassSuccess3() throws Exception { * File */ package test2; - + import test1.Shape; - + /** * Type */ @@ -942,9 +942,9 @@ public final class E extends Shape { expected= """ package test; - + import test2.E; - + public sealed class Shape permits Square, E { } """; @@ -975,17 +975,17 @@ public void testModularCreateClassSuccess4() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_implement_superinterface_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedClass_implement_superinterface_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccFinal, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -996,9 +996,9 @@ public void testModularCreateClassSuccess4() throws Exception { * File */ package test2; - + import test1.IShape; - + /** * Type */ @@ -1013,9 +1013,9 @@ public final class E implements IShape { expected= """ package test; - + import test2.E; - + public sealed interface IShape permits ISquare, E { } """; @@ -1045,17 +1045,17 @@ public void testModularCreateInterfaceSuccess1() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedInterface_extend_superinterface_notSelected_message.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_SealedFinalNonSealedInterface_extend_superinterface_notSelected_message, status.getMessage()); int modifiers= wizardPage.getModifiers(); wizardPage.setModifiers(modifiers | Flags.AccNonSealed, true); status= wizardPage.getSealedModifierStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.OK); + assertEquals(IStatus.OK, status.getSeverity()); wizardPage.createType(null); @@ -1066,9 +1066,9 @@ public void testModularCreateInterfaceSuccess1() throws Exception { * File */ package test2; - + import test1.IShape; - + /** * Type */ @@ -1083,9 +1083,9 @@ public non-sealed interface IE extends IShape { expected= """ package test; - + import test2.IE; - + public sealed interface IShape permits ISquare, IE { } """; @@ -1120,8 +1120,8 @@ public void testModularDependentCreateClassError1() throws Exception { IStatus status= wizardPage.getSealedSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperClassInDifferentModule.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperClassInDifferentModule, status.getMessage()); } // Throw error if the sealed super interface is in different module to the new class @@ -1146,8 +1146,8 @@ public void testModularDependentCreateClassError2() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperInterfaceInDifferentModule.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_class_SealedSuperInterfaceInDifferentModule, status.getMessage()); } // Throw error if the sealed super interface is in different module to the new interface @@ -1171,8 +1171,8 @@ public void testModularDependentCreateInterfaceError1() throws Exception { IStatus status= wizardPage.getSealedSuperInterfaceStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(NewWizardMessages.NewTypeWizardPage_error_interface_SealedSuperInterfaceInDifferentModule.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(NewWizardMessages.NewTypeWizardPage_error_interface_SealedSuperInterfaceInDifferentModule, status.getMessage()); } @Test @@ -1182,7 +1182,7 @@ public void testAddRecordSuperClassError1() throws Exception { fpack1= fSourceFolder.createPackageFragment("test1", false, null); String test= """ package test; - + public record Rec1(int x){ } """; @@ -1209,8 +1209,8 @@ public record Rec1(int x){ IStatus status= wizardPage.getSuperClassStatus(); assertNotNull(status); - assertTrue(status.getSeverity() == IStatus.ERROR); - assertTrue(expected.equals(status.getMessage())); + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(expected, status.getMessage()); } @Test @@ -1242,12 +1242,12 @@ public void testCreateRecordWithAbstractMethodStubs() throws Exception { * File */ package test1; - + /** * Type */ public record Rec1() { - + /** * Overridden */ @@ -1255,7 +1255,7 @@ public record Rec1() { public boolean equals(Object arg0) { return false; } - + /** * Overridden */ @@ -1263,7 +1263,7 @@ public boolean equals(Object arg0) { public int hashCode() { return 0; } - + /** * Overridden */ @@ -1271,7 +1271,7 @@ public int hashCode() { public String toString() { return null; } - + }""" ; StringAsserts.assertEqualStringIgnoreDelim(actual, expected); @@ -1306,12 +1306,12 @@ public void testCreateRecordWithOutAbstractMethodStubsAndMain() throws Exception * File */ package test1; - + /** * Type */ public record Rec1() { - + }""" ; StringAsserts.assertEqualStringIgnoreDelim(actual, expected); @@ -1346,19 +1346,19 @@ public void testCreateRecordWithMain() throws Exception { * File */ package test1; - + /** * Type */ public record Rec1() { - + /** * Method */ public static void main(String[] args) { - + } - + }""" ; StringAsserts.assertEqualStringIgnoreDelim(actual, expected); @@ -1393,12 +1393,12 @@ public void testCreateRecordWithAbstractMethodStubsAndMain() throws Exception { * File */ package test1; - + /** * Type */ public record Rec1() { - + /** * Overridden */ @@ -1406,7 +1406,7 @@ public record Rec1() { public boolean equals(Object arg0) { return false; } - + /** * Overridden */ @@ -1414,7 +1414,7 @@ public boolean equals(Object arg0) { public int hashCode() { return 0; } - + /** * Overridden */ @@ -1422,14 +1422,14 @@ public int hashCode() { public String toString() { return null; } - + /** * Method */ public static void main(String[] args) { - + } - + }""" ; StringAsserts.assertEqualStringIgnoreDelim(actual, expected);