mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 00:20:55 +07:00
[java-inspections] IDEA-14669 fixed: suggest adding specific non-null assertions from test frameworks
(cherry picked from commit 0d22d640ea4ee77a6bdfb5b4af504332e7456b68) IJ-MR-150371 GitOrigin-RevId: 04a5fe47cf874ae78c5ad73282b55123f55e84cb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
47a2170f17
commit
5569a2965d
@@ -0,0 +1,20 @@
|
||||
// "Assert with JUnit 3 'assertNotNull(s)'" "true-preview"
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SomeJUnit3Test extends TestCase {
|
||||
@Nullable
|
||||
String getNullableString() {
|
||||
double random = Math.random();
|
||||
if (random > 0.75) return null;
|
||||
if (random > 0.50) return "";
|
||||
else return "bruh";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
assertNotNull(s);
|
||||
assertTrue(s.isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Assert with JUnit 4 'Assert.assertNotNull(s)'" "true-preview"
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class SomeJUnit4Test {
|
||||
@Nullable
|
||||
native String getNullableString();
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
Assert.assertNotNull(s);
|
||||
assertTrue(s.isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// "Assert with JUnit 4 'Assert.assertNotNull(s)'" "true-preview"
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class SomeJUnit4Test {
|
||||
@Nullable
|
||||
native String getNullableString();
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
Assert.assertNotNull(s);
|
||||
//noinspection SimplifiableConditionalExpression
|
||||
assertTrue(s.isEmpty() ? true : false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// "Assert with JUnit 5 'Assertions.assertNotNull(s)'" "true-preview"
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class SomeJUnit5Test {
|
||||
@Nullable
|
||||
String getNullableString() {
|
||||
double random = Math.random();
|
||||
if (random > 0.75) return null;
|
||||
if (random > 0.50) return "";
|
||||
else return "bruh";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
Assertions.assertNotNull(s);
|
||||
assertTrue(s.isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// "Assert with TestNG 'Assert.assertNotNull(s)'" "true-preview"
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
public class SomeTestNGTest {
|
||||
@Nullable
|
||||
String getNullableString() {
|
||||
double random = Math.random();
|
||||
if (random > 0.75) return null;
|
||||
if (random > 0.50) return "";
|
||||
else return "bruh";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
Assert.assertNotNull(s);
|
||||
assertTrue(s.isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Assert with JUnit 3 'assertNotNull(s)'" "true-preview"
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SomeJUnit3Test extends TestCase {
|
||||
@Nullable
|
||||
String getNullableString() {
|
||||
double random = Math.random();
|
||||
if (random > 0.75) return null;
|
||||
if (random > 0.50) return "";
|
||||
else return "bruh";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
assertTrue(s.isEm<caret>pty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Assert with JUnit 4 'Assert.assertNotNull(s)'" "true-preview"
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class SomeJUnit4Test {
|
||||
@Nullable
|
||||
native String getNullableString();
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
assertTrue(s.isEm<caret>pty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Assert with JUnit 4 'Assert.assertNotNull(s)'" "true-preview"
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class SomeJUnit4Test {
|
||||
@Nullable
|
||||
native String getNullableString();
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
//noinspection SimplifiableConditionalExpression
|
||||
assertTrue(s.isEm<caret>pty() ? true : false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// "Assert with JUnit 5 'Assertions.assertNotNull(s)'" "true-preview"
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class SomeJUnit5Test {
|
||||
@Nullable
|
||||
String getNullableString() {
|
||||
double random = Math.random();
|
||||
if (random > 0.75) return null;
|
||||
if (random > 0.50) return "";
|
||||
else return "bruh";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
assertTrue(s.isEm<caret>pty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// "Assert with TestNG 'Assert.assertNotNull(s)'" "true-preview"
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
public class SomeTestNGTest {
|
||||
@Nullable
|
||||
String getNullableString() {
|
||||
double random = Math.random();
|
||||
if (random > 0.75) return null;
|
||||
if (random > 0.50) return "";
|
||||
else return "bruh";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String s = getNullableString();
|
||||
assertTrue(s.isEm<caret>pty());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user