Constant condition and some other warnings fixed in tests

GitOrigin-RevId: 83df50ec2b2364a51b14ba361f739555389fcb90
This commit is contained in:
Tagir Valeev
2019-10-15 06:31:30 +00:00
committed by intellij-monorepo-bot
parent fc3c8044a0
commit 6bdd5dd97d
35 changed files with 56 additions and 67 deletions
@@ -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();
}
}
}
@@ -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);
}
@@ -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;
@@ -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
@@ -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);
@@ -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]);
@@ -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) {
@@ -213,7 +213,7 @@ public class PushDownTest extends LightRefactoringTestCase {
for (MemberInfo member : members) {
member.setChecked(true);
if (toAbstract) {
member.setToAbstract(toAbstract);
member.setToAbstract(true);
}
}
@@ -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<PsiMethod> methods = DelegationUtils.getDelegatingMethodsForField(field);
List<MemberInfo> infos = new ArrayList<>();
@@ -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;
@@ -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,
@@ -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
@@ -35,7 +35,7 @@ public class TestExternalSystemConfigurable
@NotNull
@Override
protected TestExternalProjectSettings newProjectSettings() {
return null;
throw new UnsupportedOperationException();
}
@NotNull
@@ -239,7 +239,7 @@ public class MultiThreadSearchTest extends BasePlatformTestCase {
@NotNull
@Override
public ListCellRenderer<? super Object> getElementsRenderer() {
return null;
throw new UnsupportedOperationException();
}
@Override
@@ -148,7 +148,7 @@ public class SearchModelTest extends BasePlatformTestCase {
@NotNull
@Override
public ListCellRenderer<? super Object> getElementsRenderer() {
return null;
throw new UnsupportedOperationException();
}
@Nullable
@@ -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;
}
}
@@ -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<String> lines) {
return "folded";
@@ -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() {
@@ -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() {
@@ -72,7 +72,7 @@ public class TestGrouper implements Grouper {
@NotNull
@Override
public ItemPresentation getPresentation() {
return null;
throw new UnsupportedOperationException();
}
public String toString() {
@@ -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) {
@@ -34,7 +34,7 @@ public final class MockRuntimeConfiguration extends LocatableConfigurationBase i
@NotNull
@Override
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
return null;
throw new UnsupportedOperationException();
}
@Override
@@ -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<AbstractFilePatchInProgress> filePatchInProgresses) {
@@ -57,7 +57,7 @@ public class XDebuggerHistoryManagerTest extends HeavyPlatformTestCase {
checkExpression(expressionsBySecondId.get(0), "10", null, null, EvaluationMode.EXPRESSION);
List<XExpression> expressionsByThirdId = manager.getRecentExpressions("id3");
assertTrue(expressionsByThirdId == null || expressionsByThirdId.isEmpty());
assertTrue(expressionsByThirdId.isEmpty());
}
private static void checkExpression(@NotNull XExpression expression,
@@ -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() {
@@ -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<VcsRef> 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);
@@ -638,6 +638,6 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom
}
}
assertTrue("Maven filter reference was not added", false);
fail("Maven filter reference was not added");
}
}
@@ -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;
@@ -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);
@@ -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);
@@ -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;
}
@@ -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,
@@ -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<String> result) {
result.add(RENAME_RESULT_BY_RENAME_HANDLER);
@@ -416,6 +416,7 @@ public class SplitterTest {
assertEquals(0, words.size());
}
@NotNull
private static List<String> wordsToCheck(Splitter splitter, final String text) {
final List<String> 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<String> words = wordsToCheck(splitter, text);
List<String> 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) {
@@ -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;