Class OptionalShouldContain

java.lang.Object
org.assertj.core.error.BasicErrorMessageFactory
org.assertj.core.error.OptionalShouldContain
All Implemented Interfaces:
ErrorMessageFactory

public class OptionalShouldContain extends BasicErrorMessageFactory
Build error message when an Optional, OptionalDouble, OptionalInt or OptionalLong should contain a specific value.
Author:
Jean-Christophe Gay, Nicolai Parlog, Grzegorz Piwowarek
  • Method Details

    • shouldContain

      public static <VALUE> OptionalShouldContain shouldContain(Optional<VALUE> optional, VALUE expectedValue)
      Indicates that the provided Optional does not contain the provided argument.
      Type Parameters:
      VALUE - the type of the value contained in the Optional.
      Parameters:
      optional - the Optional which contains a value.
      expectedValue - the value we expect to be in the provided Optional.
      Returns:
      a error message factory
    • shouldContain

      public static OptionalShouldContain shouldContain(OptionalDouble optional, double expectedValue)
      Indicates that the provided OptionalDouble does not contain the provided argument.
      Parameters:
      optional - the OptionalDouble which contains a value.
      expectedValue - the value we expect to be in the provided OptionalDouble.
      Returns:
      a error message factory
    • shouldContain

      public static OptionalShouldContain shouldContain(OptionalInt optional, int expectedValue)
      Indicates that the provided OptionalInt does not contain the provided argument.
      Parameters:
      optional - the OptionalInt which contains a value.
      expectedValue - the value we expect to be in the provided OptionalInt.
      Returns:
      a error message factory
    • shouldContain

      public static OptionalShouldContain shouldContain(OptionalLong optional, long expectedValue)
      Indicates that the provided OptionalLong does not contain the provided argument.
      Parameters:
      optional - the OptionalLong which contains a value.
      expectedValue - the value we expect to be in the provided OptionalLong.
      Returns:
      a error message factory
    • shouldContainSame

      public static <VALUE> OptionalShouldContain shouldContainSame(Optional<VALUE> optional, VALUE expectedValue)
      Indicates that the provided Optional does not contain the provided argument (judging by reference equality).
      Type Parameters:
      VALUE - the type of the value contained in the Optional.
      Parameters:
      optional - the Optional which contains a value.
      expectedValue - the value we expect to be in the provided Optional.
      Returns:
      a error message factory
    • shouldContain

      public static OptionalShouldContain shouldContain(Object expectedValue)
      Indicates that an Optional is empty so it doesn't contain the expected value.
      Parameters:
      expectedValue - the value we expect to be in an Optional.
      Returns:
      a error message factory.