Class OptionalIntSubject


  • public final class OptionalIntSubject
    extends Subject
    Propositions for Java 8 OptionalInt subjects.
    Since:
    1.3.0 (previously part of truth-java8-extension)
    Author:
    Ben Douglass
    • Method Detail

      • isPresent

        public void isPresent()
        Fails if the OptionalInt is empty or the subject is null.
      • isEmpty

        public void isEmpty()
        Fails if the OptionalInt is present or the subject is null.
      • hasValue

        public void hasValue​(int expected)
        Fails if the OptionalInt does not have the given value or the subject is null. More sophisticated comparisons can be done using assertThat(optional.getAsInt())….
      • optionalInts

        @Deprecated
        public static Subject.Factory<OptionalIntSubject,​OptionalInt> 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.