Class LongAssert

All Implemented Interfaces:
NumberAssert

public class LongAssert extends GenericAssert<Long> implements NumberAssert
Understands assertion methods for Longs and longs. To create a new instance of this class call Assertions.assertThat(Long) or Assertions.assertThat(long).
  • Field Details

  • Constructor Details

    • LongAssert

      protected LongAssert(long actual)
      Creates a new LongAssert.
      Parameters:
      actual - the actual value to verify.
    • LongAssert

      protected LongAssert(Long actual)
      Creates a new LongAssert.
      Parameters:
      actual - the actual value to verify.
  • Method Details

    • as

      public LongAssert as(String description)
      Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

      For example:

       assertThat(val).as("name").isEqualTo("Frodo");
       

      Specified by:
      as in class GenericAssert<Long>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • describedAs

      public LongAssert describedAs(String description)
      Alias for GenericAssert.as(String), since "as" is a keyword in Groovy. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

      For example:

       assertThat(val).describedAs("name").isEqualTo("Frodo");
       

      Specified by:
      describedAs in class GenericAssert<Long>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • as

      public LongAssert as(Description description)
      Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

      For example:

       assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
       

      Specified by:
      as in class GenericAssert<Long>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • describedAs

      public LongAssert describedAs(Description description)
      Alias for GenericAssert.as(Description), since "as" is a keyword in Groovy. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

      For example:

       assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
       

      Specified by:
      describedAs in class GenericAssert<Long>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • isEqualTo

      public LongAssert isEqualTo(long expected)
      Verifies that the actual Long is equal to the given one.
      Parameters:
      expected - the value to compare the actual one to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not equal to the given one.
    • isEqualTo

      public LongAssert isEqualTo(Long expected)
      Verifies that the actual Long is equal to the given one.
      Specified by:
      isEqualTo in class GenericAssert<Long>
      Parameters:
      expected - the value to compare the actual Long to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not equal to the given one.
      Since:
      1.3
    • isNotEqualTo

      public LongAssert isNotEqualTo(long other)
      Verifies that the actual Long is not equal to the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is equal to the given one.
    • isNotEqualTo

      public LongAssert isNotEqualTo(Long other)
      Verifies that the actual Long is not equal to the given one.
      Specified by:
      isNotEqualTo in class GenericAssert<Long>
      Parameters:
      other - the value to compare the actual Long to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is equal to the given one.
      Since:
      1.3
    • isGreaterThan

      public LongAssert isGreaterThan(long other)
      Verifies that the actual Long is greater than the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not greater than the given one.
    • isLessThan

      public LongAssert isLessThan(long other)
      Verifies that the actual Long is less than the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not less than the given one.
    • isGreaterThanOrEqualTo

      public LongAssert isGreaterThanOrEqualTo(long other)
      Verifies that the actual Long is greater or equal to the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not greater than or equal to the given one.
    • isLessThanOrEqualTo

      public LongAssert isLessThanOrEqualTo(long other)
      Verifies that the actual Long is less or equal to the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not less than or equal to the given one.
    • isZero

      public LongAssert isZero()
      Verifies that the actual Long is equal to zero.
      Specified by:
      isZero in interface NumberAssert
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not equal to zero.
    • isPositive

      public LongAssert isPositive()
      Verifies that the actual Long is positive.
      Specified by:
      isPositive in interface NumberAssert
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not positive.
    • isNegative

      public LongAssert isNegative()
      Verifies that the actual Long is negative.
      Specified by:
      isNegative in interface NumberAssert
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not negative.
    • overridingErrorMessage

      public LongAssert overridingErrorMessage(String message)
      Replaces the default message displayed in case of a failure with the given one.

      For example, the following assertion:

       assertThat("Hello").isEqualTo("Bye");
       
      will fail with the default message "expected:<'[Bye]'> but was:<'[Hello]'>."

      We can replace this message with our own:

       assertThat("Hello").overridingErrorMessage("'Hello' should be equal to 'Bye'").isEqualTo("Bye");
       
      in this case, the assertion will fail showing the message "'Hello' should be equal to 'Bye'".

      Specified by:
      overridingErrorMessage in class GenericAssert<Long>
      Parameters:
      message - the given error message, which will replace the default one.
      Returns:
      this assertion.
    • satisfies

      public LongAssert satisfies(Condition<Long> condition)
      Verifies that the actual Long satisfies the given condition.
      Specified by:
      satisfies in class GenericAssert<Long>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual Long does not satisfy the given condition.
      Since:
      1.3
      See Also:
    • doesNotSatisfy

      public LongAssert doesNotSatisfy(Condition<Long> condition)
      Verifies that the actual Long does not satisfy the given condition.
      Specified by:
      doesNotSatisfy in class GenericAssert<Long>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual value does satisfies the given condition.
      Since:
      1.3
      See Also:
    • is

      public LongAssert is(Condition<Long> condition)
      Specified by:
      is in class GenericAssert<Long>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual Long does not satisfy the given condition.
      Since:
      1.3
    • isNot

      public LongAssert isNot(Condition<Long> condition)
      Specified by:
      isNot in class GenericAssert<Long>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual Long does not satisfy the given condition.
      Since:
      1.3
    • isNotNull

      public LongAssert isNotNull()
      Verifies that the actual Long is not null.
      Specified by:
      isNotNull in class GenericAssert<Long>
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is null.
      Since:
      1.3
    • isSameAs

      public LongAssert isSameAs(Long expected)
      Verifies that the actual Long is the same object as the given one.
      Specified by:
      isSameAs in class GenericAssert<Long>
      Parameters:
      expected - the value to compare the actual Long to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is not the same as the given one.
      Since:
      1.3
    • isNotSameAs

      public LongAssert isNotSameAs(Long other)
      Verifies that the actual Long is not the same object as the given one.
      Specified by:
      isNotSameAs in class GenericAssert<Long>
      Parameters:
      other - the value to compare the actual Long to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Long is the same as the given one.
      Since:
      1.3