Class ShortAssert

All Implemented Interfaces:
NumberAssert

public class ShortAssert extends GenericAssert<Short> implements NumberAssert
Understands assertion methods for Shorts and shorts. To create a new instance of this class call Assertions.assertThat(Short) Assertions.assertThat(short).
  • Field Details

  • Constructor Details

    • ShortAssert

      ShortAssert(int actual)
    • ShortAssert

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

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

    • as

      public ShortAssert 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<Short>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • describedAs

      public ShortAssert 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<Short>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • as

      public ShortAssert 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<Short>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • describedAs

      public ShortAssert 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<Short>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • isEqualTo

      public ShortAssert isEqualTo(short expected)
      Verifies that the actual Short 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 Short is not equal to the given one.
    • isEqualTo

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

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

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

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

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

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

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

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

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

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

      public ShortAssert 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<Short>
      Parameters:
      message - the given error message, which will replace the default one.
      Returns:
      this assertion.
    • satisfies

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

      public ShortAssert doesNotSatisfy(Condition<Short> condition)
      Verifies that the actual Short does not satisfy the given condition.
      Specified by:
      doesNotSatisfy in class GenericAssert<Short>
      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 ShortAssert is(Condition<Short> condition)
      Specified by:
      is in class GenericAssert<Short>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual Short does not satisfy the given condition.
      Since:
      1.3
    • isNot

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

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

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

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