From 6bdd5dd97d8b0c48d3f002f8cf8e10be83f741be Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Tue, 15 Oct 2019 12:58:30 +0700 Subject: [PATCH] Constant condition and some other warnings fixed in tests GitOrigin-RevId: 83df50ec2b2364a51b14ba361f739555389fcb90 --- .../intellij/uiDesigner/core/EliminateTest.java | 2 +- .../FrameworkDetectionInWizardTest.java | 4 ++-- .../java/codeInsight/ParameterInfoTest.java | 4 ++-- .../codeInspection/DataFlowInspectionTest.java | 2 +- .../java/compiler/CompilerReferencesTest.java | 1 - ...ingProcessingOnDocumentModificationTest.java | 3 +-- .../propertyBased/JavaCompletionPolicy.java | 2 +- .../intellij/java/refactoring/PushDownTest.java | 2 +- .../java/refactoring/RemoveMiddleManTest.java | 3 --- .../ReplaceConstructorWithFactoryTest.java | 4 ++-- .../impl/JsonBySchemaHeavyCompletionTest.java | 1 + .../extensions/impl/ExtensionPointImplTest.java | 4 ++-- .../TestExternalSystemConfigurable.java | 2 +- .../searcheverywhere/MultiThreadSearchTest.java | 2 +- .../searcheverywhere/SearchModelTest.java | 2 +- .../largeFilesEditor/file/MockVirtualFile.java | 17 ++++++++--------- .../execution/impl/ConsoleViewImplTest.java | 3 +-- .../actions/EditorMultiCaretActionTest.java | 2 +- .../openapi/editor/actions/MatchBraceTest.java | 2 +- .../com/intellij/structureView/TestGrouper.java | 2 +- .../intellij/ui/mac/touchbar/NSTLibTest.java | 2 +- .../sm/runner/MockRuntimeConfiguration.java | 2 +- .../intellij/openapi/vcs/PatchAutoInitTest.java | 4 ++-- .../xdebugger/XDebuggerHistoryManagerTest.java | 2 +- .../CoverageAnnotatorIntegrationTest.java | 5 ++--- .../git4idea/tests/git4idea/test/RefParser.java | 7 ++----- ...edPropertiesCompletionAndResolutionTest.java | 2 +- .../idea/svn/SvnNativeClientAuthTest.java | 12 +++++------- .../jetbrains/idea/svn/SvnProtocolsTest.java | 9 ++++----- .../svn/SvnResolveTreeAcceptVariantsTest.java | 2 +- .../uiDesigner/core/AsmCodeGeneratorTest.java | 4 ++-- .../YamlByJsonSchemaHeavyCompletionTest.java | 1 + .../quickFixes/PyRenameElementQuickFixTest.java | 2 +- .../spellchecker/inspector/SplitterTest.java | 3 ++- .../psi/formatter/HtmlFormatterTest.java | 2 +- 35 files changed, 56 insertions(+), 67 deletions(-) diff --git a/java/compiler/forms-compiler/testSrc/com/intellij/uiDesigner/core/EliminateTest.java b/java/compiler/forms-compiler/testSrc/com/intellij/uiDesigner/core/EliminateTest.java index 259494502f4a..7201f749f0e0 100644 --- a/java/compiler/forms-compiler/testSrc/com/intellij/uiDesigner/core/EliminateTest.java +++ b/java/compiler/forms-compiler/testSrc/com/intellij/uiDesigner/core/EliminateTest.java @@ -198,7 +198,7 @@ public final class EliminateTest extends TestCase{ for (int j = 0; j < spans.length; j++) { System.out.println("i=" + j + " expected ("+expected[j][0] + "," + expected[j][1] +"), result (" + cells[j] + "," + spans[j]+")"); } - assertTrue(false); + fail(); } } } diff --git a/java/idea-ui/testSrc/com/intellij/framework/detection/FrameworkDetectionInWizardTest.java b/java/idea-ui/testSrc/com/intellij/framework/detection/FrameworkDetectionInWizardTest.java index de25d929e6f1..ef737226b85d 100644 --- a/java/idea-ui/testSrc/com/intellij/framework/detection/FrameworkDetectionInWizardTest.java +++ b/java/idea-ui/testSrc/com/intellij/framework/detection/FrameworkDetectionInWizardTest.java @@ -18,7 +18,7 @@ import com.intellij.mock.MockProgressIndicator; import com.intellij.openapi.application.ex.PathManagerEx; import com.intellij.openapi.module.StdModuleTypes; import com.intellij.openapi.util.io.FileUtil; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; @@ -67,8 +67,8 @@ public class FrameworkDetectionInWizardTest extends FrameworkDetectionTestCase { return Collections.singletonList(descriptor); } + @NotNull @Override - @Nullable protected String getContentPath() { return FileUtil.toSystemIndependentName(path); } diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/ParameterInfoTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/ParameterInfoTest.java index d67b23480f4f..816eac10410e 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/ParameterInfoTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/ParameterInfoTest.java @@ -514,7 +514,7 @@ public class ParameterInfoTest extends AbstractParameterInfoTestCase { return null; } - @Nullable + @NotNull @Override public Object findElementForParameterInfo(@NotNull CreateParameterInfoContext context) { context.setItemsToShow(new Object[]{this}); @@ -526,7 +526,7 @@ public class ParameterInfoTest extends AbstractParameterInfoTestCase { context.showHint(context.getFile(), context.getOffset(), this); } - @Nullable + @NotNull @Override public Object findElementForUpdatingParameterInfo(@NotNull UpdateParameterInfoContext context) { return this; diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java index 4ad639d8f156..a65dc33ed171 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java @@ -554,7 +554,7 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase { @Override public boolean isImplicitlyNotNullInitialized(@NotNull PsiElement element) { - return element instanceof PsiField && ((PsiField)element).getName() != null && ((PsiField)element).getName().startsWith("field"); + return element instanceof PsiField && ((PsiField)element).getName().startsWith("field"); } @Override diff --git a/java/java-tests/testSrc/com/intellij/java/compiler/CompilerReferencesTest.java b/java/java-tests/testSrc/com/intellij/java/compiler/CompilerReferencesTest.java index 46d9a28f1e9c..a8acc281753d 100644 --- a/java/java-tests/testSrc/com/intellij/java/compiler/CompilerReferencesTest.java +++ b/java/java-tests/testSrc/com/intellij/java/compiler/CompilerReferencesTest.java @@ -126,7 +126,6 @@ public class CompilerReferencesTest extends CompilerReferencesTestBase { .range(1, 7) .mapToObj(idx -> "Foo" + idx) .map(className -> myFixture.findClass(className)) - .filter(Objects::nonNull) .toArray(PsiClass[]::new); assertSize(6, classes); diff --git a/java/java-tests/testSrc/com/intellij/java/openapi/editor/impl/FoldingProcessingOnDocumentModificationTest.java b/java/java-tests/testSrc/com/intellij/java/openapi/editor/impl/FoldingProcessingOnDocumentModificationTest.java index af3cd6262d00..cb18f28b4ddc 100644 --- a/java/java-tests/testSrc/com/intellij/java/openapi/editor/impl/FoldingProcessingOnDocumentModificationTest.java +++ b/java/java-tests/testSrc/com/intellij/java/openapi/editor/impl/FoldingProcessingOnDocumentModificationTest.java @@ -32,7 +32,6 @@ import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiDocumentManager; import com.intellij.testFramework.TestFileType; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.Collections; @@ -144,7 +143,7 @@ public class FoldingProcessingOnDocumentModificationTest extends AbstractEditorT return FoldingDescriptor.EMPTY; } - @Nullable + @NotNull @Override public String getPlaceholderText(@NotNull ASTNode node) { return Integer.toString(valuePlaceholder[0]); diff --git a/java/java-tests/testSrc/com/intellij/java/propertyBased/JavaCompletionPolicy.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/JavaCompletionPolicy.java index d178afcd22f3..0f038f606936 100644 --- a/java/java-tests/testSrc/com/intellij/java/propertyBased/JavaCompletionPolicy.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/JavaCompletionPolicy.java @@ -90,7 +90,7 @@ class JavaCompletionPolicy extends CompletionPolicy { if (target instanceof PsiVariable && PsiTreeUtil.isAncestor(target, ref, false)) { return false; } - return target != null; + return true; } private static boolean isStaticWithInstanceQualifier(PsiJavaCodeReferenceElement ref, @NotNull PsiElement target) { diff --git a/java/java-tests/testSrc/com/intellij/java/refactoring/PushDownTest.java b/java/java-tests/testSrc/com/intellij/java/refactoring/PushDownTest.java index 97220d9f4808..c64dc6f6f424 100644 --- a/java/java-tests/testSrc/com/intellij/java/refactoring/PushDownTest.java +++ b/java/java-tests/testSrc/com/intellij/java/refactoring/PushDownTest.java @@ -213,7 +213,7 @@ public class PushDownTest extends LightRefactoringTestCase { for (MemberInfo member : members) { member.setChecked(true); if (toAbstract) { - member.setToAbstract(toAbstract); + member.setToAbstract(true); } } diff --git a/java/java-tests/testSrc/com/intellij/java/refactoring/RemoveMiddleManTest.java b/java/java-tests/testSrc/com/intellij/java/refactoring/RemoveMiddleManTest.java index ef9b58bc3888..a6a0f4201e6f 100644 --- a/java/java-tests/testSrc/com/intellij/java/refactoring/RemoveMiddleManTest.java +++ b/java/java-tests/testSrc/com/intellij/java/refactoring/RemoveMiddleManTest.java @@ -43,9 +43,6 @@ public class RemoveMiddleManTest extends LightMultiFileTestCase { doTest(() -> { PsiClass aClass = myFixture.findClass("Test"); - if (aClass == null) aClass = myFixture.findClass("p.Test"); - assertNotNull("Class Test not found", aClass); - final PsiField field = aClass.findFieldByName("myField", false); final Set methods = DelegationUtils.getDelegatingMethodsForField(field); List infos = new ArrayList<>(); diff --git a/java/java-tests/testSrc/com/intellij/java/refactoring/ReplaceConstructorWithFactoryTest.java b/java/java-tests/testSrc/com/intellij/java/refactoring/ReplaceConstructorWithFactoryTest.java index 234591ab5395..194e17a569bb 100644 --- a/java/java-tests/testSrc/com/intellij/java/refactoring/ReplaceConstructorWithFactoryTest.java +++ b/java/java-tests/testSrc/com/intellij/java/refactoring/ReplaceConstructorWithFactoryTest.java @@ -63,7 +63,7 @@ public class ReplaceConstructorWithFactoryTest extends LightRefactoringTestCase PsiClass aClass = null; while (true) { if (element == null || element instanceof PsiFile) { - assertTrue(false); + fail(); return; } @@ -81,7 +81,7 @@ public class ReplaceConstructorWithFactoryTest extends LightRefactoringTestCase PsiClass targetClass = null; if (targetClassName != null) { targetClass = JavaPsiFacade.getInstance(getProject()).findClass(targetClassName, GlobalSearchScope.allScope(getProject())); - assertTrue(targetClass != null); + assertNotNull(targetClass); } final ReplaceConstructorWithFactoryProcessor replaceConstructorWithFactoryProcessor; diff --git a/json/tests/test/com/jetbrains/jsonSchema/impl/JsonBySchemaHeavyCompletionTest.java b/json/tests/test/com/jetbrains/jsonSchema/impl/JsonBySchemaHeavyCompletionTest.java index 7afcff26c736..e7f4f3ff3b57 100644 --- a/json/tests/test/com/jetbrains/jsonSchema/impl/JsonBySchemaHeavyCompletionTest.java +++ b/json/tests/test/com/jetbrains/jsonSchema/impl/JsonBySchemaHeavyCompletionTest.java @@ -138,6 +138,7 @@ public class JsonBySchemaHeavyCompletionTest extends JsonBySchemaHeavyCompletion Assert.assertTrue(idx > 0); PsiElement element = schema.findElementAt(idx); element = element instanceof JsonStringLiteral ? element : PsiTreeUtil.getParentOfType(element, JsonStringLiteral.class); + Assert.assertNotNull(element); Assert.assertTrue(element instanceof JsonStringLiteral); final PsiFile dummy = PsiFileFactory.getInstance(getProject()).createFileFromText("test.json", JsonFileType.INSTANCE, diff --git a/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionPointImplTest.java b/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionPointImplTest.java index f0ca49e35973..3acf28075d95 100644 --- a/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionPointImplTest.java +++ b/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionPointImplTest.java @@ -335,7 +335,7 @@ public class ExtensionPointImplTest { @NotNull @Override public MessageBus getMessageBus() { - return null; + throw new UnsupportedOperationException(); } @Override @@ -346,7 +346,7 @@ public class ExtensionPointImplTest { @NotNull @Override public Condition getDisposed() { - return null; + throw new UnsupportedOperationException(); } @Override diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/settings/TestExternalSystemConfigurable.java b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/settings/TestExternalSystemConfigurable.java index 186332edf14e..19d6cd516605 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/settings/TestExternalSystemConfigurable.java +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/settings/TestExternalSystemConfigurable.java @@ -35,7 +35,7 @@ public class TestExternalSystemConfigurable @NotNull @Override protected TestExternalProjectSettings newProjectSettings() { - return null; + throw new UnsupportedOperationException(); } @NotNull diff --git a/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/MultiThreadSearchTest.java b/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/MultiThreadSearchTest.java index 9da698dc50c7..58baab160372 100644 --- a/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/MultiThreadSearchTest.java +++ b/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/MultiThreadSearchTest.java @@ -239,7 +239,7 @@ public class MultiThreadSearchTest extends BasePlatformTestCase { @NotNull @Override public ListCellRenderer getElementsRenderer() { - return null; + throw new UnsupportedOperationException(); } @Override diff --git a/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/SearchModelTest.java b/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/SearchModelTest.java index 59677edda5ad..618cac61ce0f 100644 --- a/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/SearchModelTest.java +++ b/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/SearchModelTest.java @@ -148,7 +148,7 @@ public class SearchModelTest extends BasePlatformTestCase { @NotNull @Override public ListCellRenderer getElementsRenderer() { - return null; + throw new UnsupportedOperationException(); } @Nullable diff --git a/platform/lang-impl/testSources/com/intellij/largeFilesEditor/file/MockVirtualFile.java b/platform/lang-impl/testSources/com/intellij/largeFilesEditor/file/MockVirtualFile.java index 0b76f54a10e5..ca5d0b72a7b2 100644 --- a/platform/lang-impl/testSources/com/intellij/largeFilesEditor/file/MockVirtualFile.java +++ b/platform/lang-impl/testSources/com/intellij/largeFilesEditor/file/MockVirtualFile.java @@ -7,7 +7,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -28,19 +27,19 @@ class MockVirtualFile extends VirtualFile { @NotNull @Override public String getName() { - return null; + throw new UnsupportedOperationException(); } @NotNull @Override public VirtualFileSystem getFileSystem() { - return null; + throw new UnsupportedOperationException(); } @NotNull @Override public String getPath() { - return null; + throw new UnsupportedOperationException(); } @Override @@ -65,18 +64,18 @@ class MockVirtualFile extends VirtualFile { @Override public VirtualFile[] getChildren() { - return new VirtualFile[0]; + return VirtualFile.EMPTY_ARRAY; } @NotNull @Override - public OutputStream getOutputStream(Object requestor, long newModificationStamp, long newTimeStamp) throws IOException { - return null; + public OutputStream getOutputStream(Object requestor, long newModificationStamp, long newTimeStamp) { + throw new UnsupportedOperationException(); } @NotNull @Override - public byte[] contentsToByteArray() throws IOException { + public byte[] contentsToByteArray() { return new byte[0]; } @@ -96,7 +95,7 @@ class MockVirtualFile extends VirtualFile { } @Override - public InputStream getInputStream() throws IOException { + public InputStream getInputStream() { return null; } } diff --git a/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java b/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java index cb69c693fda2..f1e6c7cbe786 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java @@ -40,7 +40,6 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.junit.Assert; import java.io.ByteArrayOutputStream; @@ -562,7 +561,7 @@ public class ConsoleViewImplTest extends LightPlatformTestCase { return line.contains("FOO"); } - @Nullable + @NotNull @Override public String getPlaceholderText(@NotNull Project project, @NotNull List lines) { return "folded"; diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorMultiCaretActionTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorMultiCaretActionTest.java index 1f3b1f8f2f6f..939d12ad9ceb 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorMultiCaretActionTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorMultiCaretActionTest.java @@ -40,7 +40,7 @@ public class EditorMultiCaretActionTest extends LightPlatformCodeInsightTestCase if (pos < 0) { return null; } - return pos < 0 ? null : fileName.substring(0, pos) + '(' + fileName.substring(pos + 8) + ')'; + return fileName.substring(0, pos) + '(' + fileName.substring(pos + 8) + ')'; } private String getBeforeFileName() { diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/MatchBraceTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/MatchBraceTest.java index f22d14526da7..b0ffb4496951 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/MatchBraceTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/MatchBraceTest.java @@ -47,7 +47,7 @@ public class MatchBraceTest extends LightPlatformCodeInsightTestCase implements if (pos < 0) { return null; } - return pos < 0 ? null : fileName.substring(0, pos) + '(' + fileName.substring(pos + 8) + ')'; + return fileName.substring(0, pos) + '(' + fileName.substring(pos + 8) + ')'; } private String getBeforeFileName() { diff --git a/platform/platform-tests/testSrc/com/intellij/structureView/TestGrouper.java b/platform/platform-tests/testSrc/com/intellij/structureView/TestGrouper.java index c02062772c2f..774c0fb92fe7 100644 --- a/platform/platform-tests/testSrc/com/intellij/structureView/TestGrouper.java +++ b/platform/platform-tests/testSrc/com/intellij/structureView/TestGrouper.java @@ -72,7 +72,7 @@ public class TestGrouper implements Grouper { @NotNull @Override public ItemPresentation getPresentation() { - return null; + throw new UnsupportedOperationException(); } public String toString() { diff --git a/platform/platform-tests/testSrc/com/intellij/ui/mac/touchbar/NSTLibTest.java b/platform/platform-tests/testSrc/com/intellij/ui/mac/touchbar/NSTLibTest.java index b14bee3ddead..8591d561bd30 100644 --- a/platform/platform-tests/testSrc/com/intellij/ui/mac/touchbar/NSTLibTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ui/mac/touchbar/NSTLibTest.java @@ -28,7 +28,7 @@ public class NSTLibTest extends TestCase { // small check that loaded library can create native objects final ID test = lib.createTouchBar("test", (uid) -> ID.NIL, null); assertNotNull("Failed to create native touchbar object, result is null", test); - assertFalse("Failed to create native touchbar object, result is ID.NIL", test == ID.NIL); + assertNotSame("Failed to create native touchbar object, result is ID.NIL", ID.NIL, test); if (test != ID.NIL) lib.releaseTouchBar(test); } catch (RuntimeException e) { diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/MockRuntimeConfiguration.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/MockRuntimeConfiguration.java index 9ea0373719d5..23ca5a9f6e8e 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/MockRuntimeConfiguration.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/MockRuntimeConfiguration.java @@ -34,7 +34,7 @@ public final class MockRuntimeConfiguration extends LocatableConfigurationBase i @NotNull @Override public SettingsEditor getConfigurationEditor() { - return null; + throw new UnsupportedOperationException(); } @Override diff --git a/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/PatchAutoInitTest.java b/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/PatchAutoInitTest.java index b65876ea1aeb..730cb1c32393 100644 --- a/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/PatchAutoInitTest.java +++ b/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/PatchAutoInitTest.java @@ -313,8 +313,8 @@ public class PatchAutoInitTest extends HeavyPlatformTestCase { return; } } - assertTrue("Failed for (first base only shown) '" + bases.iterator().next().getPath() + " + " + path + " " + strip + - "'; results: " + printPatches(filePatchInProgresses), false); + fail("Failed for (first base only shown) '" + bases.iterator().next().getPath() + " + " + path + " " + strip + + "'; results: " + printPatches(filePatchInProgresses)); } private static String printPatches(final List filePatchInProgresses) { diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerHistoryManagerTest.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerHistoryManagerTest.java index 8b2e734ea983..648a16d0b33c 100644 --- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerHistoryManagerTest.java +++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerHistoryManagerTest.java @@ -57,7 +57,7 @@ public class XDebuggerHistoryManagerTest extends HeavyPlatformTestCase { checkExpression(expressionsBySecondId.get(0), "10", null, null, EvaluationMode.EXPRESSION); List expressionsByThirdId = manager.getRecentExpressions("id3"); - assertTrue(expressionsByThirdId == null || expressionsByThirdId.isEmpty()); + assertTrue(expressionsByThirdId.isEmpty()); } private static void checkExpression(@NotNull XExpression expression, diff --git a/plugins/coverage/testSrc/com/intellij/coverage/CoverageAnnotatorIntegrationTest.java b/plugins/coverage/testSrc/com/intellij/coverage/CoverageAnnotatorIntegrationTest.java index 7656ac3a596e..e980fcae2fe9 100644 --- a/plugins/coverage/testSrc/com/intellij/coverage/CoverageAnnotatorIntegrationTest.java +++ b/plugins/coverage/testSrc/com/intellij/coverage/CoverageAnnotatorIntegrationTest.java @@ -17,7 +17,6 @@ import com.intellij.rt.coverage.data.ProjectData; import com.intellij.testFramework.CompilerTester; import com.intellij.testFramework.JavaModuleTestCase; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.junit.Assert; import java.util.HashMap; @@ -64,7 +63,7 @@ public class CoverageAnnotatorIntegrationTest extends JavaModuleTestCase { } }; CoverageSuitesBundle suite = new CoverageSuitesBundle(new JavaCoverageSuite(engine)) { - @Nullable + @NotNull @Override public ProjectData getCoverageData() { return new ProjectData() { @@ -85,7 +84,7 @@ public class CoverageAnnotatorIntegrationTest extends JavaModuleTestCase { public void testMultipleSourceRoots() { CoverageSuitesBundle suite = new CoverageSuitesBundle(new JavaCoverageSuite(new JavaCoverageEngine())) { - @Nullable + @NotNull @Override public ProjectData getCoverageData() { return new ProjectData() { diff --git a/plugins/git4idea/tests/git4idea/test/RefParser.java b/plugins/git4idea/tests/git4idea/test/RefParser.java index 427ff272403b..0288d806c46b 100644 --- a/plugins/git4idea/tests/git4idea/test/RefParser.java +++ b/plugins/git4idea/tests/git4idea/test/RefParser.java @@ -25,7 +25,6 @@ import com.intellij.vcs.log.impl.HashImpl; import git4idea.branch.GitBranchUtil; import git4idea.log.GitRefManager; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; @@ -52,9 +51,7 @@ class RefParser { List refs = new ArrayList<>(); for (String longRefPatch : longRefPaths) { VcsRef ref = createRef(hash, longRefPatch, root); - if (ref != null) { - refs.add(ref); - } + refs.add(ref); } return refs; } @@ -67,7 +64,7 @@ class RefParser { } // example input: fb29c80 refs/tags/92.29 - @Nullable + @NotNull private VcsRef createRef(@NotNull Hash hash, @NotNull String longRefPath, @NotNull VirtualFile root) { String name = getRefName(longRefPath); VcsRefType type = GitRefManager.getRefType(name); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java index 8723f6ffc974..237555fe73ae 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java @@ -638,6 +638,6 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom } } - assertTrue("Maven filter reference was not added", false); + fail("Maven filter reference was not added"); } } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java index 56bbdfb7ca12..cda60d356b95 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java @@ -33,8 +33,7 @@ import java.util.List; import static com.intellij.testFramework.UsefulTestCase.assertExists; import static org.jetbrains.idea.svn.SvnUtil.parseUrl; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; @Ignore public class SvnNativeClientAuthTest extends SvnTestCase { @@ -511,8 +510,7 @@ public class SvnNativeClientAuthTest extends SvnTestCase { public void checkoutCompleted() { } }, WorkingCopyFormat.ONE_DOT_SEVEN); - final int[] cnt = new int[1]; - cnt[0] = 0; + final int[] cnt = {0}; FileUtil.processFilesRecursively(root, file -> { ++ cnt[0]; return ! (cnt[0] > 1); @@ -536,7 +534,7 @@ public class SvnNativeClientAuthTest extends SvnTestCase { vcs.getUpdateEnvironment().updateDirectories(new FilePath[]{VcsUtil.getFilePath(vf)}, files, new EmptyProgressIndicator(), new Ref<>()); assertTrue(session.getExceptions() != null && !session.getExceptions().isEmpty()); - assertTrue(!session.isCanceled()); + assertFalse(session.isCanceled()); assertTrue(session.getExceptions().get(0).getMessage().contains(expectedText)); if (myIsSecure) { @@ -552,8 +550,8 @@ public class SvnNativeClientAuthTest extends SvnTestCase { final UpdateSession session = vcs.getUpdateEnvironment().updateDirectories(new FilePath[]{VcsUtil.getFilePath(vf)}, files, new EmptyProgressIndicator(), new Ref<>()); - assertTrue(session.getExceptions() == null || session.getExceptions().isEmpty()); - assertTrue(!session.isCanceled()); + assertTrue(session.getExceptions().isEmpty()); + assertFalse(session.isCanceled()); if (myIsSecure) { ++ myExpectedCreds; ++ myExpectedCert; diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java index b5c0a33f5947..2d092b6b0270 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java @@ -157,9 +157,9 @@ public class SvnProtocolsTest extends SvnTestCase { final UpdateSession session = vcs.getUpdateEnvironment().updateDirectories(new FilePath[]{VcsUtil.getFilePath(vf)}, files, new EmptyProgressIndicator(), new Ref<>()); - assertTrue(session.getExceptions() == null || session.getExceptions().isEmpty()); - assertTrue(!session.isCanceled()); - assertTrue(!files.getGroupById(FileGroup.CREATED_ID).getFiles().isEmpty()); + assertTrue(session.getExceptions().isEmpty()); + assertFalse(session.isCanceled()); + assertFalse(files.getGroupById(FileGroup.CREATED_ID).getFiles().isEmpty()); final String path = files.getGroupById(FileGroup.CREATED_ID).getFiles().iterator().next(); final String name = path.substring(path.lastIndexOf(File.separator) + 1); assertEquals(created.getName(), name); @@ -194,8 +194,7 @@ public class SvnProtocolsTest extends SvnTestCase { public void checkoutCompleted() { } }, WorkingCopyFormat.ONE_DOT_SEVEN); - final int[] cnt = new int[1]; - cnt[0] = 0; + final int[] cnt = {0}; FileUtil.processFilesRecursively(root, file -> { ++ cnt[0]; return ! (cnt[0] > 1); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java index a4295cb04231..4d2fe742c353 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java @@ -117,7 +117,7 @@ public class SvnResolveTreeAcceptVariantsTest extends SvnTestCase { if (excluded != null && asList(excluded).contains(relative)) { return true; } - assertTrue(createTestFailedComment(relative), exists); + fail(createTestFailedComment(relative)); } final File theirsFile = virtualToIoFile(file); Info theirsInfo = vcs.getInfo(theirsFile); diff --git a/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java b/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java index 4a44997c5ae4..2beba45620cb 100644 --- a/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java +++ b/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java @@ -174,10 +174,10 @@ public class AsmCodeGeneratorTest extends JpsBuildTestCase { assertNotNull("Class patching failed but no errors or warnings were returned", patchedData); } else if (errors.length > 0) { - assertTrue(errors[0].getErrorMessage(), false); + fail(errors[0].getErrorMessage()); } else { - assertTrue(warnings[0].getErrorMessage(), false); + fail(warnings[0].getErrorMessage()); } return patchedData; } diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaHeavyCompletionTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaHeavyCompletionTest.java index 189cb0ee3ad6..42456c402444 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaHeavyCompletionTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaHeavyCompletionTest.java @@ -48,6 +48,7 @@ public class YamlByJsonSchemaHeavyCompletionTest extends JsonBySchemaHeavyComple Assert.assertTrue(idx > 0); PsiElement element = schema.findElementAt(idx); element = element instanceof JsonStringLiteral ? element : PsiTreeUtil.getParentOfType(element, JsonStringLiteral.class); + Assert.assertNotNull(element); Assert.assertTrue(element instanceof JsonStringLiteral); final PsiFile dummy = PsiFileFactory.getInstance(getProject()).createFileFromText("test.json", JsonFileType.INSTANCE, diff --git a/python/testSrc/com/jetbrains/python/quickFixes/PyRenameElementQuickFixTest.java b/python/testSrc/com/jetbrains/python/quickFixes/PyRenameElementQuickFixTest.java index d6e6d4b69336..01b1cf5f16c0 100644 --- a/python/testSrc/com/jetbrains/python/quickFixes/PyRenameElementQuickFixTest.java +++ b/python/testSrc/com/jetbrains/python/quickFixes/PyRenameElementQuickFixTest.java @@ -65,7 +65,7 @@ public class PyRenameElementQuickFixTest extends PyQuickFixTestCase { @NotNull private static NameSuggestionProvider createTestNameSuggestionProvider() { return new PreferrableNameSuggestionProvider() { - @Nullable + @NotNull @Override public SuggestedNameInfo getSuggestedNames(PsiElement element, @Nullable PsiElement nameSuggestionContext, Set result) { result.add(RENAME_RESULT_BY_RENAME_HANDLER); diff --git a/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java b/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java index 13e66dbdc7e9..86a7d055ebe6 100644 --- a/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java +++ b/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java @@ -416,6 +416,7 @@ public class SplitterTest { assertEquals(0, words.size()); } + @NotNull private static List wordsToCheck(Splitter splitter, final String text) { final List words = new ArrayList<>(); splitter.split(text, TextRange.allOf(text), textRange -> words.add(textRange.substring(text))); @@ -425,7 +426,7 @@ public class SplitterTest { private static void correctListToCheck(Splitter splitter, String text, @NotNull String... expected) { List words = wordsToCheck(splitter, text); List expectedWords = Arrays.asList(expected); - assertEquals("Splitting:'" + text + "'", expectedWords.toString(), words != null ? words.toString() : "[]"); + assertEquals("Splitting:'" + text + "'", expectedWords.toString(), words.toString()); } private static String convertStreamToString(InputStream is) { diff --git a/xml/tests/src/com/intellij/psi/formatter/HtmlFormatterTest.java b/xml/tests/src/com/intellij/psi/formatter/HtmlFormatterTest.java index 441cdef0c0db..fe244adcaed6 100644 --- a/xml/tests/src/com/intellij/psi/formatter/HtmlFormatterTest.java +++ b/xml/tests/src/com/intellij/psi/formatter/HtmlFormatterTest.java @@ -255,7 +255,7 @@ public class HtmlFormatterTest extends XmlFormatterTestBase { public void testIndent() throws Exception { CommonCodeStyleSettings.IndentOptions htmlIndentOptions = getSettings().getCommonSettings(HTMLLanguage.INSTANCE).getIndentOptions(); assert htmlIndentOptions != null : "HTML Indent options not found!"; - int indentSize = htmlIndentOptions.INDENT_SIZE = 2; + int indentSize = htmlIndentOptions.INDENT_SIZE; int contIndentSize = htmlIndentOptions.CONTINUATION_INDENT_SIZE; try { htmlIndentOptions.INDENT_SIZE = 2;