diff --git a/core/src/main/java/com/google/common/truth/Truth.java b/core/src/main/java/com/google/common/truth/Truth.java index 6cf4ca7e8..7ca25d6fc 100644 --- a/core/src/main/java/com/google/common/truth/Truth.java +++ b/core/src/main/java/com/google/common/truth/Truth.java @@ -23,6 +23,8 @@ import com.google.common.collect.Table; import java.math.BigDecimal; import java.util.Map; +import java.util.Optional; +import java.util.stream.Stream; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -249,6 +251,18 @@ public static TableSubject assertThat(@Nullable Table actual) { return assert_().that(actual); } + @SuppressWarnings("Java7ApiChecker") // no more dangerous that wherever the user got the Optional + @GwtIncompatible // creates ambiguities (Eclipse bug 577808 or similar?) + public static OptionalSubject assertThat(@Nullable Optional actual) { + return assert_().that(actual); + } + + @SuppressWarnings("Java7ApiChecker") // no more dangerous that wherever the user got the Stream + @GwtIncompatible // creates ambiguities (Eclipse bug 577808 or similar?) + public static StreamSubject assertThat(@Nullable Stream actual) { + return assert_().that(actual); + } + /** * An {@code AssertionError} that (a) always supports a cause, even under old versions of Android * and (b) omits "java.lang.AssertionError:" from the beginning of its toString() representation. diff --git a/core/src/test/java/com/google/common/truth/TruthAssertThatTest.java b/core/src/test/java/com/google/common/truth/TruthAssertThatTest.java index 1d1205c9a..cb75b934e 100644 --- a/core/src/test/java/com/google/common/truth/TruthAssertThatTest.java +++ b/core/src/test/java/com/google/common/truth/TruthAssertThatTest.java @@ -25,8 +25,6 @@ import com.google.common.reflect.TypeToken; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.Optional; -import java.util.stream.Stream; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -47,9 +45,6 @@ public void staticAssertThatMethodsMatchStandardSubjectBuilderInstanceMethods() ImmutableSortedSet> verbTypes = FluentIterable.from(asList(StandardSubjectBuilder.class.getMethods())) .filter(input -> input.getName().equals("that")) - // TODO: b/166630734 - Remove this when we add the assertThat overloads. - .filter(input -> input.getParameterTypes()[0] != Optional.class) - .filter(input -> input.getParameterTypes()[0] != Stream.class) .transform(TruthAssertThatTest::methodToReturnTypeToken) .toSortedSet(Ordering.usingToString()); ImmutableSortedSet> truthTypes =