Class GuavaOptionalSubject


  • public final class GuavaOptionalSubject
    extends Subject
    A subject for Guava Optional values.

    If you are looking for a java.util.Optional subject, see OptionalSubject.

    • Method Detail

      • isPresent

        public void isPresent()
        Checks that the actual Optional contains a value.
      • isAbsent

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

        public void hasValue​(@Nullable Object expected)
        Checks that the actual Optional contains the given value.

        To make more complex assertions on the optional's value, split your assertion in two:

        
         assertThat(myOptional).isPresent();
         assertThat(myOptional.get()).contains("foo");