mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-148477 Handle AssertJ assertions in the same way as JUnit assertions
This commit is contained in:
+3
@@ -37,6 +37,8 @@ public class HardcodedContracts {
|
||||
|
||||
final int paramCount = method.getParameterList().getParametersCount();
|
||||
String className = owner.getQualifiedName();
|
||||
if (className == null) return Collections.emptyList();
|
||||
|
||||
String methodName = method.getName();
|
||||
|
||||
if ("java.lang.System".equals(className)) {
|
||||
@@ -76,6 +78,7 @@ public class HardcodedContracts {
|
||||
"org.junit.Assert".equals(className) ||
|
||||
"junit.framework.TestCase".equals(className) ||
|
||||
"com.google.common.truth.Truth".equals(className) ||
|
||||
className.startsWith("org.assertj.core.api.") ||
|
||||
"org.testng.Assert".equals(className) ||
|
||||
"org.testng.AssertJUnit".equals(className)) {
|
||||
return handleTestFrameworks(paramCount, className, methodName, call);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@@ -15,4 +16,9 @@ class Contracts {
|
||||
int length = test.length();
|
||||
}
|
||||
|
||||
public void checkAssertJ(@Nullable Object object) {
|
||||
Assertions.assertThat(object).isNotNull();
|
||||
System.out.println(object.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -388,6 +388,14 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
"public static <T> void assertThat(T actual, org.hamcrest.Matcher<? super T> matcher) {}\n" +
|
||||
"public static <T> void assertThat(String msg, T actual, org.hamcrest.Matcher<? super T> matcher) {}\n" +
|
||||
"}");
|
||||
|
||||
myFixture.addClass("package org.assertj.core.api; public class Assertions { " +
|
||||
"public static <T> AbstractObjectAssert<?, T> assertThat(Object actual) {}\n" +
|
||||
"}");
|
||||
myFixture.addClass("package org.assertj.core.api; public class AbstractObjectAssert<S extends AbstractObjectAssert<S, A>, A> {" +
|
||||
"public S isNotNull() {}" +
|
||||
"}");
|
||||
|
||||
myFixture.enableInspections(new DataFlowInspection());
|
||||
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user