Skip to content

Commit

Permalink
fix models (#277)
Browse files Browse the repository at this point in the history
Fixes #276 

Also a couple of our existing models were broken.  Fix both the models and the tests
  • Loading branch information
msridhar committed Feb 4, 2019
1 parent ba56d5b commit 6fe4b11
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Expand Up @@ -196,6 +196,7 @@ private static class DefaultLibraryModels implements LibraryModels {
new ImmutableSetMultimap.Builder<MethodRef, Integer>()
.put(methodRef("com.google.common.base.Preconditions", "<T>checkNotNull(T)"), 0)
.put(methodRef("java.util.Objects", "<T>requireNonNull(T)"), 0)
.put(methodRef("java.util.Objects", "<T>requireNonNull(T,java.lang.String)"), 0)
.put(methodRef("org.junit.Assert", "assertNotNull(java.lang.Object)"), 0)
.put(
methodRef("org.junit.Assert", "assertNotNull(java.lang.String,java.lang.Object)"),
Expand All @@ -206,12 +207,12 @@ private static class DefaultLibraryModels implements LibraryModels {
methodRef(
"org.junit.jupiter.api.Assertions",
"assertNotNull(java.lang.Object,java.lang.String)"),
1)
0)
.put(
methodRef(
"org.junit.jupiter.api.Assertions",
"assertNotNull(java.lang.Object,java.util.function.Supplier<String>)"),
1)
"assertNotNull(java.lang.Object,java.util.function.Supplier<java.lang.String>)"),
0)
.build();

private static final ImmutableSetMultimap<MethodRef, Integer> EXPLICITLY_NULLABLE_PARAMETERS =
Expand Down
Expand Up @@ -201,17 +201,22 @@ static void immutableMapStuff() {
}
}

static void failIfNull(@Nullable Object o1, @Nullable Object o2) {
static void failIfNull(
@Nullable Object o1,
@Nullable Object o2,
@Nullable Object o3,
@Nullable Object o4,
@Nullable Object o5) {
org.junit.Assert.assertNotNull(o1);
o1.toString();
org.junit.Assert.assertNotNull("Null!", o2);
o2.toString();
org.junit.jupiter.api.Assertions.assertNotNull(o1);
o1.toString();
org.junit.jupiter.api.Assertions.assertNotNull(o2, "Null!");
o2.toString();
org.junit.jupiter.api.Assertions.assertNotNull(o2, () -> "Null!");
o2.toString();
org.junit.jupiter.api.Assertions.assertNotNull(o3);
o3.toString();
org.junit.jupiter.api.Assertions.assertNotNull(o4, "Null!");
o4.toString();
org.junit.jupiter.api.Assertions.assertNotNull(o5, () -> "Null!");
o5.toString();
}

static void nonNullParameters() {
Expand Down
Expand Up @@ -524,9 +524,11 @@ static void checkNotNull(@Nullable Object o) {
o.toString();
}

static void requireNonNull(@Nullable Object o) {
static void requireNonNull(@Nullable Object o, @Nullable Object p) {
Objects.requireNonNull(o);
o.toString();
Objects.requireNonNull(p, "should be non null");
p.toString();
}

static void isEmpty(@Nullable String s) {
Expand Down

0 comments on commit 6fe4b11

Please sign in to comment.