mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-02 00:57:59 +07:00
[java] (IDEA-292972) fix of Malformed parameterized tests inspection with parameterized collections
GitOrigin-RevId: 331515798801d4ec644654b7531e4b919bbeebd9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5e4a7f329a
commit
24f3296304
+5
-1
@@ -17,6 +17,7 @@ import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager
|
||||
import com.intellij.psi.impl.source.PsiClassReferenceType
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference
|
||||
import com.intellij.psi.impl.source.tree.java.PsiNameValuePairImpl
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch
|
||||
@@ -233,7 +234,10 @@ private class NullOrEmptySourceChecker(val holder: ProblemsHolder) {
|
||||
val size = method.uastParameters.size
|
||||
val shortName = psiAnnotation.qualifiedName ?: return
|
||||
if (size == 1) {
|
||||
val type = method.uastParameters[0].type
|
||||
var type = method.uastParameters[0].type
|
||||
if (type is PsiClassReferenceType) {
|
||||
type = type.rawType()
|
||||
}
|
||||
if (type is PsiArrayType ||
|
||||
type.equalsToText(CommonClassNames.JAVA_LANG_STRING) ||
|
||||
type.equalsToText(CommonClassNames.JAVA_UTIL_LIST) ||
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.params.provider.EmptySource;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
||||
class MalformedParameterizedCollection {
|
||||
@ParameterizedTest
|
||||
@EmptySource
|
||||
void testFooSet(Set<String> input) {}
|
||||
|
||||
@ParameterizedTest
|
||||
@EmptySource
|
||||
void testFooList(List<String> input) {}
|
||||
|
||||
@ParameterizedTest
|
||||
@EmptySource
|
||||
void testFooMap(Map<String, String> input) {}
|
||||
}
|
||||
+2
-1
@@ -30,6 +30,7 @@ public class JavaJUnit5MalformedParameterizedTest extends LightJavaInspectionTes
|
||||
public void testMalformedSourcesImplicitConversion() { doTest(); }
|
||||
public void testMalformedSourcesImplicitParameters() { doTest(); }
|
||||
public void testMalformedSourcesTestInstancePerClass() { doTest(); }
|
||||
public void testMalformedParameterizedCollection() { doTest(); }
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
@@ -41,4 +42,4 @@ public class JavaJUnit5MalformedParameterizedTest extends LightJavaInspectionTes
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.EmptySource
|
||||
|
||||
object MalformedParameterizedCollectionKt {
|
||||
@ParameterizedTest
|
||||
@EmptySource
|
||||
fun testFooSet(input: Set<String?>?) {}
|
||||
|
||||
@ParameterizedTest
|
||||
@EmptySource
|
||||
fun testFooList(input: List<String?>?) {}
|
||||
|
||||
@ParameterizedTest
|
||||
@EmptySource
|
||||
fun testFooMap(input: Map<String?, String?>?) {}
|
||||
}
|
||||
+5
-1
@@ -54,6 +54,10 @@ class KotlinJUnit5MalformedParameterizedTest : JavaCodeInsightFixtureTestCase()
|
||||
myFixture.testHighlighting("CantResolveTarget.kt")
|
||||
}
|
||||
|
||||
fun `test MalformedParameterizedCollectionKt`() {
|
||||
myFixture.testHighlighting("MalformedParameterizedCollectionKt.kt")
|
||||
}
|
||||
|
||||
fun `test CantResolveTarget highlighting`() {
|
||||
myFixture.testHighlighting("CantResolveTarget.kt")
|
||||
}
|
||||
@@ -93,4 +97,4 @@ class KotlinJUnit5MalformedParameterizedTest : JavaCodeInsightFixtureTestCase()
|
||||
fun `test EnumResolve quickFixes`() {
|
||||
myFixture.testHighlighting("EnumResolve.kt")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,6 +7,8 @@ public class JUnit5TestFrameworkSetupUtil {
|
||||
public static JavaCodeInsightTestFixture setupJUnit5Library(JavaCodeInsightTestFixture fixture) {
|
||||
fixture.addClass( "package org.junit.jupiter.params.provider;\n" +
|
||||
"public @interface MethodSource {String[] value() default \"\";}");
|
||||
fixture.addClass( "package org.junit.jupiter.params.provider;\n" +
|
||||
"public @interface EmptySource {}");
|
||||
fixture.addClass( "package org.junit.jupiter.params;\n" +
|
||||
"@org.junit.platform.commons.annotation.Testable\n" +
|
||||
"public @interface ParameterizedTest {String name() default \"\";}");
|
||||
@@ -83,4 +85,4 @@ public class JUnit5TestFrameworkSetupUtil {
|
||||
fixture.addClass("package org.junit.jupiter.api; public @interface Nested{}");
|
||||
return fixture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user