Class AbstractOptionalIntAssert<SELF extends AbstractOptionalIntAssert<SELF>>

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,OptionalInt>
org.assertj.core.api.AbstractOptionalIntAssert<SELF>
All Implemented Interfaces:
Assert<SELF,OptionalInt>, Descriptable<SELF>, ExtensionPoints<SELF,OptionalInt>
Direct Known Subclasses:
OptionalIntAssert

public abstract class AbstractOptionalIntAssert<SELF extends AbstractOptionalIntAssert<SELF>> extends AbstractAssert<SELF,OptionalInt>
Assertions for OptionalInt.
Author:
Jean-Christophe Gay, Alexander Bischof, Grzegorz Piwowarek
  • Constructor Details

    • AbstractOptionalIntAssert

      protected AbstractOptionalIntAssert(OptionalInt actual, Class<?> selfType)
  • Method Details

    • isPresent

      public SELF isPresent()
      Verifies that there is a value present in the actual OptionalInt.

      Assertion will pass :

       assertThat(OptionalInt.of(10)).isPresent();

      Assertion will fail :

       assertThat(OptionalInt.empty()).isPresent();
      Returns:
      this assertion object.
      Throws:
      AssertionError - if actual value is empty.
      AssertionError - if actual is null.
    • isNotPresent

      public SELF isNotPresent()
      Verifies that the actual OptionalInt is empty (alias of isEmpty()).

      Assertion will pass :

       assertThat(OptionalInt.empty()).isNotPresent();
      Assertion will fail :
       assertThat(OptionalInt.of(10)).isNotPresent();
      Returns:
      this assertion object.
    • isEmpty

      public SELF isEmpty()
      Verifies that the actual OptionalInt is empty.

      Assertion will pass :

       assertThat(OptionalInt.empty()).isEmpty();

      Assertion will fail :

       assertThat(OptionalInt.of(10)).isEmpty();
      Returns:
      this assertion object.
      Throws:
      AssertionError - if actual value is present.
      AssertionError - if actual is null.
    • isNotEmpty

      public SELF isNotEmpty()
      Verifies that there is a value present in the actual OptionalInt, it's an alias of isPresent().

      Assertion will pass :

       assertThat(OptionalInt.of(10)).isNotEmpty();

      Assertion will fail :

       assertThat(OptionalInt.empty()).isNotEmpty();
      Returns:
      this assertion object.
      Throws:
      AssertionError - if actual value is empty.
      AssertionError - if actual is null.
    • hasValue

      public SELF hasValue(int expectedValue)
      Verifies that the actual OptionalInt has the value in argument.

      Assertion will pass :

       assertThat(OptionalInt.of(8)).hasValue(8);
       assertThat(OptionalInt.of(8)).hasValue(Integer.valueOf(8));

      Assertion will fail :

       assertThat(OptionalInt.empty()).hasValue(8);
       assertThat(OptionalInt.of(7)).hasValue(8);
      Parameters:
      expectedValue - the expected value inside the OptionalInt.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if actual value is empty.
      AssertionError - if actual is null.
      AssertionError - if actual has not the value as expected.