From c83ce9390f107869fff421357e21f8509a9a3ddc Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 3 Sep 2024 17:17:04 +0200 Subject: [PATCH] tests: cleanup GitOrigin-RevId: 4c0abf48343a2ad6c4ebfea78c20d66cd981c02b --- .../DaemonAnnotatorsRespondToChangesTest.java | 4 +- ...DaemonInspectionsRespondToChangesTest.java | 4 +- ...DaemonLineMarkersRespondToChangesTest.java | 9 +-- .../impl/DaemonRespondToChangesTest.java | 55 +++++++++---------- .../daemon/impl/ImportHelperTest.java | 16 +++--- .../daemon/impl/WolfTheProblemSolverTest.java | 2 +- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonAnnotatorsRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonAnnotatorsRespondToChangesTest.java index 318a1194c4b7..448c353b5b4e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonAnnotatorsRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonAnnotatorsRespondToChangesTest.java @@ -168,11 +168,11 @@ public class DaemonAnnotatorsRespondToChangesTest extends DaemonAnalyzerTestCase HighlightSeverity.ERROR); long elapsed = System.currentTimeMillis() - start; - assertEquals(0, errors.size()); + assertSize(0, errors); if (!run.get()) { fail(ThreadDumper.dumpThreadsToString()); } - assertTrue("Elapsed: "+elapsed, elapsed >= SLEEP); + assertTrue("Elapsed: " + elapsed, elapsed >= SLEEP); } public void testAddRemoveHighlighterRaceInIncorrectAnnotatorsWhichUseFileRecursiveVisit() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonInspectionsRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonInspectionsRespondToChangesTest.java index 8ed0096d3d14..961c65d90c38 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonInspectionsRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonInspectionsRespondToChangesTest.java @@ -157,7 +157,7 @@ public class DaemonInspectionsRespondToChangesTest extends DaemonAnalyzerTestCas public void testWholeFileInspection() throws Exception { configureByFile(DaemonRespondToChangesTest.BASE_PATH + "FieldCanBeLocal.java"); List infos = doHighlighting(HighlightSeverity.WARNING); - assertEquals(1, infos.size()); + assertSize(1, infos); assertEquals("Field can be converted to a local variable", infos.get(0).getDescription()); ctrlW(); @@ -172,7 +172,7 @@ public class DaemonInspectionsRespondToChangesTest extends DaemonAnalyzerTestCas type("0"); infos = doHighlighting(HighlightSeverity.WARNING); - assertEquals(1, infos.size()); + assertSize(1, infos); assertEquals("Field can be converted to a local variable", infos.get(0).getDescription()); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonLineMarkersRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonLineMarkersRespondToChangesTest.java index 71a04977eb5d..7952cdc04118 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonLineMarkersRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonLineMarkersRespondToChangesTest.java @@ -124,13 +124,13 @@ public class DaemonLineMarkersRespondToChangesTest extends DaemonAnalyzerTestCas Document document = getEditor().getDocument(); List> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject()); - assertEquals(3, markers.size()); + assertSize(3, markers); type("//xxxx"); assertEmpty(highlightErrors()); markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject()); - assertEquals(3, markers.size()); + assertSize(3, markers); } @@ -192,12 +192,13 @@ public class DaemonLineMarkersRespondToChangesTest extends DaemonAnalyzerTestCas }); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - List infosAfter = CodeInsightTestFixtureImpl.instantiateAndRun(myFile, myEditor, new int[]{/*Pass.UPDATE_ALL, Pass.LOCAL_INSPECTIONS*/}, false); + List infosAfter = + CodeInsightTestFixtureImpl.instantiateAndRun(myFile, myEditor, new int[]{/*Pass.UPDATE_ALL, Pass.LOCAL_INSPECTIONS*/}, false); assertNotEmpty(filter(infosAfter, HighlightSeverity.ERROR)); UIUtil.dispatchAllInvocationEvents(); assertEmpty(changed); List> lineMarkersAfter = DaemonCodeAnalyzerImpl.getLineMarkers(myEditor.getDocument(), getProject()); - assertEquals(lineMarkersAfter.size(), lineMarkers.size()); + assertSize(lineMarkersAfter.size(), lineMarkers); } public void testLineMarkersDoNotBlinkOnBackSpaceRightBeforeMethodIdentifier() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java index 892c905c1cd6..fe00c324576b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java @@ -218,7 +218,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { Document document = getDocument(getFile()); assertNotEmpty(highlightErrors()); List errors = DaemonCodeAnalyzerImpl.getHighlights(document, HighlightSeverity.ERROR, getProject()); - assertEquals(1, errors.size()); + assertSize(1, errors); TextRange dirty = myDaemonCodeAnalyzer.getFileStatusMap().getFileDirtyScope(document, getFile(), Pass.UPDATE_ALL); assertNull(dirty); @@ -313,24 +313,24 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { public void testUnusedFieldUpdate() { configureByText(JavaFileType.INSTANCE, """ - class Unused { - private int ffff; - void foo(int p) { - if (p==0) return; - + class Unused { + private int ffff; + void foo(int p) { + if (p==0) return; + + } } - } - """); + """); Document document = getDocument(getFile()); List infos = doHighlighting(HighlightSeverity.WARNING); - assertEquals(1, infos.size()); + assertSize(1, infos); assertEquals("Private field 'ffff' is never used", infos.get(0).getDescription()); type(" foo(ffff++);"); assertEmpty(highlightErrors()); List errors = DaemonCodeAnalyzerImpl.getHighlights(document, HighlightSeverity.WARNING, getProject()); - assertEquals(0, errors.size()); + assertSize(0, errors); } public void testUnusedMethodUpdate() { @@ -351,7 +351,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { PlatformTestUtil.invokeNamedAction(IdeActions.ACTION_COMMENT_LINE); infos = doHighlighting(HighlightSeverity.WARNING); - assertEquals(1, infos.size()); + assertSize(1, infos); assertEquals("Method 'ffff()' is never used", infos.get(0).getDescription()); } @@ -359,7 +359,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { public void testAssignedButUnreadFieldUpdate() throws Exception { configureByFile(BASE_PATH + "AssignedButUnreadField.java"); List infos = doHighlighting(HighlightSeverity.WARNING); - assertEquals(1, infos.size()); + assertSize(1, infos); assertEquals("Private field 'text' is assigned but never accessed", infos.get(0).getDescription()); ctrlW(); @@ -552,7 +552,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { }}"""); Collection infos = doHighlighting(HighlightInfoType.SYMBOL_TYPE_SEVERITY); - assertEquals(3, infos.size()); + assertSize(3, infos); AtomicInteger count = new AtomicInteger(); MarkupModelEx modelEx = (MarkupModelEx)DocumentMarkupModel.forDocument(getDocument(getFile()), getProject(), true); @@ -684,7 +684,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { try { Collection errors = highlightErrors(); - assertEquals(3, errors.size()); + assertSize(3, errors); new GotoNextErrorHandler(true).invoke(getProject(), getEditor(), getFile()); List fixes = LightQuickFixTestCase.getAvailableActions(getEditor(), getFile()); @@ -694,7 +694,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { WriteCommandAction.runWriteCommandAction(getProject(), () -> finalFix.invoke(getProject(), getEditor(), getFile())); errors = highlightErrors(); - assertEquals(2, errors.size()); + assertSize(2, errors); new GotoNextErrorHandler(true).invoke(getProject(), getEditor(), getFile()); fixes = LightQuickFixTestCase.getAvailableActions(getEditor(), getFile()); @@ -753,7 +753,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { TextRange[] highlightersAfter = getHighlightersTextRange(markup); - assertEquals(highlightersBefore.length, highlightersAfter.length); + assertSize(highlightersBefore.length, highlightersAfter); for (int i = 0; i < highlightersBefore.length; i++) { TextRange before = highlightersBefore[i]; TextRange after = highlightersAfter[i]; @@ -868,7 +868,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { configureByText(JavaFileType.INSTANCE, "@Deprecated class S { } "); List infos = doHighlighting(HighlightInfoType.SYMBOL_TYPE_SEVERITY); - assertEquals(2, infos.size()); + assertSize(2, infos); assertEquals("@Deprecated", infos.get(0).getText()); assertEquals("S", infos.get(1).getText()); @@ -888,13 +888,12 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { type(" "); after = doHighlighting(HighlightInfoType.SYMBOL_TYPE_SEVERITY); - assertEquals(2, after.size()); + assertSize(2, after); assertEquals("@Deprecated", after.get(0).getText()); assertEquals("S", after.get(1).getText()); } - public void testModificationInsideCodeBlockDoesNotAffectErrorMarkersOutside() { configureByText(JavaFileType.INSTANCE, """ class SSSSS { @@ -939,7 +938,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { }, "My", this); List errs = highlightErrors(); - assertEquals(2, errs.size()); + assertSize(2, errs); assertEquals("'}' expected", errs.get(0).getDescription()); undo(); @@ -998,10 +997,10 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { public void testApplyErrorInTheMiddle() { String text = "class X { " + """ - - { - // String x = ""; - }""".repeat(100) + + + { + // String x = ""; + }""".repeat(100) + "\n}"; configureByText(JavaFileType.INSTANCE, text); @@ -1012,7 +1011,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { type("//"); List errors = highlightErrors(); - assertEquals(2, errors.size()); + assertSize(2, errors); backspace(); backspace(); @@ -1063,16 +1062,16 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { ((EditorImpl)myEditor).getScrollPane().getViewport().setSize(1000, 1000); List infos = doHighlighting(HighlightInfoType.SYMBOL_TYPE_SEVERITY); - assertEquals(4, infos.size()); + assertSize(4, infos); type('\n'); infos = doHighlighting(HighlightInfoType.SYMBOL_TYPE_SEVERITY); - assertEquals(4, infos.size()); + assertSize(4, infos); deleteLine(); infos = doHighlighting(HighlightInfoType.SYMBOL_TYPE_SEVERITY); - assertEquals(4, infos.size()); + assertSize(4, infos); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/ImportHelperTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/ImportHelperTest.java index 8d62f09d7e04..525994e825d5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/ImportHelperTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/ImportHelperTest.java @@ -236,7 +236,7 @@ public class ImportHelperTest extends LightDaemonAnalyzerTestCase { private static void assertOrder(@NotNull PsiJavaFile file, @NonNls String @NotNull ... expectedOrder) { PsiImportStatementBase[] statements = file.getImportList().getAllImportStatements(); - assertEquals(expectedOrder.length, statements.length); + assertSize(expectedOrder.length, statements); for (int i = 0; i < statements.length; i++) { PsiImportStatementBase statement = statements[i]; String text = StringUtil.trimEnd(StringUtil.trimStart(statement.getText(), "import "), ";"); @@ -296,7 +296,7 @@ public class ImportHelperTest extends LightDaemonAnalyzerTestCase { type(" "); backspace(); - assertEquals(1, highlightErrors().size()); + assertSize(1, highlightErrors()); UIUtil.dispatchAllInvocationEvents(); int offset = getEditor().getCaretModel().getOffset(); @@ -349,7 +349,7 @@ public class ImportHelperTest extends LightDaemonAnalyzerTestCase { assertEmpty(highlightErrors()); - assertEquals(2, ((PsiJavaFile)getFile()).getImportList().getAllImportStatements().length); + assertSize(2, ((PsiJavaFile)getFile()).getImportList().getAllImportStatements()); } public void testEnsureOptimizeImportsWhenInspectionReportsErrors() throws Exception { @@ -364,7 +364,7 @@ public class ImportHelperTest extends LightDaemonAnalyzerTestCase { List errs = highlightErrors(); //error corresponding to too short class name - assertEquals(1, errs.size()); + assertSize(1, errs); assertOneImportAdded("java.util.List"); @@ -434,9 +434,9 @@ public class ImportHelperTest extends LightDaemonAnalyzerTestCase { List errs = highlightErrors(); //error in import list - assertEquals(1, errs.size()); + assertSize(1, errs); - assertEquals(1, ((PsiJavaFile)getFile()).getImportList().getAllImportStatements().length); + assertSize(1, ((PsiJavaFile)getFile()).getImportList().getAllImportStatements()); type("/* */"); doHighlighting(); @@ -505,7 +505,7 @@ public class ImportHelperTest extends LightDaemonAnalyzerTestCase { CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true; List errs = highlightErrors(); - assertEquals(1, errs.size()); + assertSize(1, errs); assertNoImportsAdded(); type("/* */"); @@ -554,7 +554,7 @@ public class ImportHelperTest extends LightDaemonAnalyzerTestCase { CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true; CodeInsightWorkspaceSettings.getInstance(getProject()).setOptimizeImportsOnTheFly(true, getTestRootDisposable()); - assertEquals(1, highlightErrors().size()); + assertSize(1, highlightErrors()); } public void testAutoImportIgnoresUnresolvedImportReferences() throws ExecutionException, InterruptedException { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/WolfTheProblemSolverTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/WolfTheProblemSolverTest.java index cd0f35a1da9d..3c680ebb9872 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/WolfTheProblemSolverTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/WolfTheProblemSolverTest.java @@ -261,7 +261,7 @@ public class WolfTheProblemSolverTest extends DaemonAnalyzerTestCase { List errors = highlightErrors(); myWolfTheProblemSolver.waitForFilesQueuedForInvalidationAreProcessed(); assertTrue(myWolfTheProblemSolver.isProblemFile(virtualFile)); - assertEquals(1, errors.size()); + assertSize(1, errors); type(';'); errors = highlightErrors(); assertEmpty(errors);