Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Dec 23, 2023
1 parent 8be8aaf commit 75fd081
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,39 @@ public void supportAssertJAssertThatIsNotNullWithDescription_Object() {
.doTest();
}

@Test
public void assertJAssertThatIsNotNullUnhandled() {
makeTestHelperWithArgs(
Arrays.asList(
"-d",
temporaryFolder.getRoot().getAbsolutePath(),
"-XepOpt:NullAway:AnnotatedPackages=com.uber",
"-XepOpt:NullAway:HandleTestAssertionLibraries=true"))
.addSourceLines(
"Test.java",
"package com.uber;",
"import java.lang.Object;",
"import java.util.Objects;",
"import javax.annotation.Nullable;",
"import static org.assertj.core.api.Assertions.assertThat;",
"class Test {",
" private void foo(@Nullable Object o) {",
" org.assertj.core.api.ObjectAssert t = assertThat(o);",
" t.isNotNull();",
" // False positive",
" // BUG: Diagnostic contains: dereferenced expression",
" o.toString();",
" }",
" private void foo2(@Nullable Object o) {",
" assertThat(o).isEqualToIgnoringNullFields(o).describedAs(\"test\").isNotNull();",
" // False positive",
" // BUG: Diagnostic contains: dereferenced expression",
" o.toString();",
" }",
"}")
.doTest();
}

@Test
public void supportAssertJAssertThatIsNotNull_String() {
makeTestHelperWithArgs(
Expand Down

0 comments on commit 75fd081

Please sign in to comment.