Class BooleanArrayAssert


public class BooleanArrayAssert extends ArrayAssert<boolean[]>
Understands assertion methods for boolean arrays. To create a new instance of this class use the method Assertions.assertThat(boolean[]).
  • Constructor Details

    • BooleanArrayAssert

      protected BooleanArrayAssert(boolean... actual)
      Creates a new BooleanArrayAssert.
      Parameters:
      actual - the target to verify.
  • Method Details

    • as

      public BooleanArrayAssert 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 GroupAssert<boolean[]>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • describedAs

      public BooleanArrayAssert 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 GroupAssert<boolean[]>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • as

      public BooleanArrayAssert 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 GroupAssert<boolean[]>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • describedAs

      public BooleanArrayAssert 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 GroupAssert<boolean[]>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • contains

      public BooleanArrayAssert contains(boolean... values)
      Verifies that the actual boolean array contains the given values.
      Parameters:
      values - the values to look for.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is null.
      NullPointerException - if the given boolean array is null.
      AssertionError - if the actual boolean array does not contain the given values.
    • containsOnly

      public BooleanArrayAssert containsOnly(boolean... values)
      Verifies that the actual boolean array contains the given values only.
      Parameters:
      values - the values to look for.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is null.
      NullPointerException - if the given boolean array is null.
      AssertionError - if the actual boolean array does not contain the given objects, or if the actual boolean array contains elements other than the ones specified.
    • excludes

      public BooleanArrayAssert excludes(boolean... values)
      Verifies that the actual boolean array does not contain the given values.
      Parameters:
      values - the values the array should exclude.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is null.
      NullPointerException - if the given boolean array is null.
      AssertionError - if the actual boolean array contains any of the given values.
    • satisfies

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

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

      public BooleanArrayAssert is(Condition<boolean[]> condition)
      Specified by:
      is in class GenericAssert<boolean[]>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual boolean array does not satisfy the given condition.
      Since:
      1.2
    • isNot

      public BooleanArrayAssert isNot(Condition<boolean[]> condition)
      Specified by:
      isNot in class GenericAssert<boolean[]>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual boolean array satisfies the given condition.
      Since:
      1.2
    • isNotNull

      public BooleanArrayAssert isNotNull()
      Verifies that the actual boolean array is not null.
      Specified by:
      isNotNull in class GenericAssert<boolean[]>
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is null.
    • isNotEmpty

      public BooleanArrayAssert isNotEmpty()
      Verifies that the actual boolean array contains at least on element.
      Specified by:
      isNotEmpty in class GroupAssert<boolean[]>
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is null.
      AssertionError - if the actual boolean array is empty.
    • isEqualTo

      public BooleanArrayAssert isEqualTo(boolean[] expected)
      Verifies that the actual boolean array is equal to the given array. Array equality is checked by Arrays.equals(boolean[], boolean[]).
      Specified by:
      isEqualTo in class GenericAssert<boolean[]>
      Parameters:
      expected - the given array to compare the actual array to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is not equal to the given one.
    • isNotEqualTo

      public BooleanArrayAssert isNotEqualTo(boolean[] array)
      Verifies that the actual boolean array is not equal to the given array. Array equality is checked by Arrays.equals(boolean[], boolean[]).
      Specified by:
      isNotEqualTo in class GenericAssert<boolean[]>
      Parameters:
      array - the given array to compare the actual array to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is equal to the given one.
    • hasSize

      public BooleanArrayAssert hasSize(int expected)
      Verifies that the number of elements in the actual boolean array is equal to the given one.
      Specified by:
      hasSize in class GroupAssert<boolean[]>
      Parameters:
      expected - the expected number of elements in the actual boolean array.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is null.
      AssertionError - if the number of elements in the actual boolean array is not equal to the given one.
    • isSameAs

      public BooleanArrayAssert isSameAs(boolean[] expected)
      Verifies that the actual boolean array is the same as the given array.
      Specified by:
      isSameAs in class GenericAssert<boolean[]>
      Parameters:
      expected - the given array to compare the actual array to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is not the same as the given one.
    • isNotSameAs

      public BooleanArrayAssert isNotSameAs(boolean[] expected)
      Verifies that the actual boolean array is not the same as the given array.
      Specified by:
      isNotSameAs in class GenericAssert<boolean[]>
      Parameters:
      expected - the given array to compare the actual array to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual boolean array is the same as the given one.
    • overridingErrorMessage

      public BooleanArrayAssert 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 GroupAssert<boolean[]>
      Parameters:
      message - the given error message, which will replace the default one.
      Returns:
      this assertion.