-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08a7710
commit 5bec7f6
Showing
3 changed files
with
83 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...rone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AssertJIsNullCheckTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package tech.picnic.errorprone.bugpatterns; | ||
|
||
import static com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH; | ||
|
||
import com.google.errorprone.BugCheckerRefactoringTestHelper; | ||
import com.google.errorprone.CompilationTestHelper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
final class AssertJIsNullCheckTest { | ||
private final CompilationTestHelper compilationTestHelper = | ||
CompilationTestHelper.newInstance(AssertJIsNullCheck.class, getClass()); | ||
private final BugCheckerRefactoringTestHelper refactoringTestHelper = | ||
BugCheckerRefactoringTestHelper.newInstance(AssertJIsNullCheck.class, getClass()); | ||
|
||
@Test | ||
void identification() { | ||
compilationTestHelper | ||
.addSourceLines( | ||
"A.java", | ||
"import static org.assertj.core.api.Assertions.assertThat;", | ||
"", | ||
"class A {", | ||
" void m() {", | ||
" assertThat(1).isEqualTo(1);", | ||
" // BUG: Diagnostic contains:", | ||
" assertThat(1).isEqualTo(null);", | ||
" // BUG: Diagnostic contains:", | ||
" assertThat(\"foo\").isEqualTo(null);", | ||
" isEqualTo(null);", | ||
" }", | ||
"", | ||
" private boolean isEqualTo(Object value) {", | ||
" return value.equals(\"bar\");", | ||
" }", | ||
"}") | ||
.doTest(); | ||
} | ||
|
||
@Test | ||
void replacement() { | ||
refactoringTestHelper | ||
.addInputLines( | ||
"A.java", | ||
"import static org.assertj.core.api.Assertions.assertThat;", | ||
"", | ||
"class A {", | ||
" void m() {", | ||
" assertThat(1).isEqualTo(null);", | ||
" assertThat(\"foo\").isEqualTo(null);", | ||
" }", | ||
"}") | ||
.addOutputLines( | ||
"A.java", | ||
"import static org.assertj.core.api.Assertions.assertThat;", | ||
"", | ||
"class A {", | ||
" void m() {", | ||
" assertThat(1).isNull();", | ||
" assertThat(\"foo\").isNull();", | ||
" }", | ||
"}") | ||
.doTest(TEXT_MATCH); | ||
} | ||
} |
86 changes: 0 additions & 86 deletions
86
...trib/src/test/java/tech/picnic/errorprone/bugpatterns/AssertThatIsNullUsageCheckTest.java
This file was deleted.
Oops, something went wrong.