Class OptionalIntSubject

java.lang.Object
com.google.common.truth.Subject
com.google.common.truth.OptionalIntSubject

public final class OptionalIntSubject extends Subject
A subject for OptionalInt values.
Since:
1.3.0 (previously part of truth-java8-extension)
Author:
Ben Douglass
  • Method Details

    • isPresent

      public void isPresent()
      Checks that the actual OptionalInt contains a value.
    • isEmpty

      public void isEmpty()
      Checks that the actual OptionalInt does not contain a value.
    • hasValue

      public void hasValue(int expected)
      Checks that the actual OptionalInt contains the given value. More sophisticated comparisons can be done using assertThat(optional.getAsInt())….
    • optionalInts

      Deprecated.
      Instead of about(optionalInts()).that(...), use just that(...). Similarly, instead of assertAbout(optionalInts()).that(...), use just assertThat(...).
      Obsolete factory instance. This factory was previously necessary for assertions like assertWithMessage(...).about(optionalInts()).that(optional)..... Now, you can perform assertions like that without the about(...) call.