org.assertj.core.api
Class AbstractBooleanArrayAssert<S extends AbstractBooleanArrayAssert<S>>

java.lang.Object
  extended by org.assertj.core.api.AbstractAssert<S,A>
      extended by org.assertj.core.api.AbstractEnumerableAssert<S,A,E>
          extended by org.assertj.core.api.AbstractArrayAssert<S,boolean[],Boolean>
              extended by org.assertj.core.api.AbstractBooleanArrayAssert<S>
All Implemented Interfaces:
ArraySortedAssert<AbstractArrayAssert<S,boolean[],Boolean>,Boolean>, Assert<S,boolean[]>, Descriptable<S>, EnumerableAssert<AbstractEnumerableAssert<S,boolean[],Boolean>,Boolean>, ExtensionPoints<S,boolean[]>
Direct Known Subclasses:
BooleanArrayAssert

public abstract class AbstractBooleanArrayAssert<S extends AbstractBooleanArrayAssert<S>>
extends AbstractArrayAssert<S,boolean[],Boolean>


Field Summary
protected  BooleanArrays arrays
           
 
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself
 
Constructor Summary
AbstractBooleanArrayAssert(boolean[] actual, Class<?> selfType)
           
 
Method Summary
 S contains(boolean... values)
          Verifies that the actual array contains the given values, in any order.
 S contains(boolean value, Index index)
          Verifies that the actual array contains the given value at the given index.
 S containsExactly(boolean... values)
          Verifies that the actual group contains only the given values and nothing else, in order.
 S containsOnly(boolean... values)
          Verifies that the actual array contains only the given values and nothing else, in any order.
 S containsOnlyOnce(boolean... values)
          Verifies that the actual array contains the given values only once.
 S containsSequence(boolean... sequence)
          Verifies that the actual array contains the given sequence, without any other values between them.
 S containsSubsequence(boolean... subsequence)
          Verifies that the actual array contains the given subsequence (possibly with other values between them).
 S doesNotContain(boolean... values)
          Verifies that the actual array does not contain the given values.
 S doesNotContain(boolean value, Index index)
          Verifies that the actual array does not contain the given value at the given index.
 S doesNotHaveDuplicates()
          Verifies that the actual array does not contain duplicates.
 S endsWith(boolean... sequence)
          Verifies that the actual array ends with the given sequence of values, without any other values between them.
 S hasSameSizeAs(Iterable<?> other)
          Verifies that the actual group has the same size as given Iterable.
 S hasSize(int expected)
          Verifies that the number of values in the actual group is equal to the given one.
 void isEmpty()
          Verifies that the actual group of values is empty.
 S isNotEmpty()
          Verifies that the actual group of values is not empty.
 void isNullOrEmpty()
          Verifies that the actual group of values is null or empty.
 S isSorted()
          Verifies that the actual array is sorted into ascending order according to the natural ordering of its elements.
 S isSortedAccordingTo(Comparator<? super Boolean> comparator)
          Verifies that the actual array is sorted according to the given comparator.
Empty arrays are considered sorted whatever the comparator is.
One element arrays are considered sorted if element is compatible with comparator, otherwise an AssertionError is thrown.
 S startsWith(boolean... sequence)
          Verifies that the actual array starts with the given sequence of values, without any other values between them.
 S usingDefaultElementComparator()
          Deprecated. Custom element Comparator is not supported for Boolean array comparison.
 S usingElementComparator(Comparator<? super Boolean> customComparator)
          Deprecated. Custom element Comparator is not supported for Boolean array comparison.
 
Methods inherited from class org.assertj.core.api.AbstractEnumerableAssert
hasSameSizeAs, inBinary, inHexadecimal
 
Methods inherited from class org.assertj.core.api.AbstractAssert
as, as, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage, usingComparator, usingDefaultComparator
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arrays

protected BooleanArrays arrays
Constructor Detail

AbstractBooleanArrayAssert

public AbstractBooleanArrayAssert(boolean[] actual,
                                  Class<?> selfType)
Method Detail

isNullOrEmpty

public void isNullOrEmpty()
Verifies that the actual group of values is null or empty.


isEmpty

public void isEmpty()
Verifies that the actual group of values is empty.


isNotEmpty

public S isNotEmpty()
Verifies that the actual group of values is not empty.

Returns:
this assertion object.

hasSize

public S hasSize(int expected)
Verifies that the number of values in the actual group is equal to the given one.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).hasSize(2);
 
 // assertion will fail
 assertThat(new boolean[] { true }).hasSize(2);
 

Parameters:
expected - the expected number of values in the actual group.
Returns:
this assertion object.

hasSameSizeAs

public S hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as given Iterable.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).hasSameSizeAs(Arrays.asList(1, 2));
 
 // assertion will fail
 assertThat(new boolean[] { true, false }).hasSameSizeAs(Arrays.asList(1, 2, 3));
 

Parameters:
other - the Iterable to compare size with actual group.
Returns:
this assertion object.

contains

public S contains(boolean... values)
Verifies that the actual array contains the given values, in any order.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).contains(true, false);
 assertThat(new boolean[] { false, true }).contains(true, false);
 assertThat(new boolean[] { true, false }).contains(true);

 // assertion will fail
 assertThat(new boolean[] { true, true }).contains(false);
 

Parameters:
values - the given values.
Returns:
this assertion object.
Throws:
NullPointerException - if the given argument is null.
IllegalArgumentException - if the given argument is an empty array.
AssertionError - if the actual array is null.
AssertionError - if the actual array does not contain the given values.

containsOnly

public S containsOnly(boolean... values)
Verifies that the actual array contains only the given values and nothing else, in any order.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).containsOnly(true, false);
 assertThat(new boolean[] { true, false, false, true }).containsOnly(true, false);
 
 // assertion will fail
 assertThat(new boolean[] { true, false }).containsOnly(false);
 

Parameters:
values - the given values.
Returns:
this assertion object.
Throws:
NullPointerException - if the given argument is null.
IllegalArgumentException - if the given argument is an empty array.
AssertionError - if the actual array is null.
AssertionError - if the actual array does not contain the given values, i.e. the actual array contains some or none of the given values, or the actual array contains more values than the given ones.

containsOnlyOnce

public S containsOnlyOnce(boolean... values)
Verifies that the actual array contains the given values only once.

Examples :

 // assertion will pass
 assertThat(new boolean[] { true, false }).containsOnlyOnce(true, false);
 
 // assertions will fail
 assertThat(new boolean[] { true, false, true }).containsOnlyOnce(true);
 assertThat(new boolean[] { true }).containsOnlyOnce(false);
 assertThat(new boolean[] { true }).containsOnlyOnce(true, false);
 

Parameters:
values - the given values.
Returns:
this assertion object.
Throws:
NullPointerException - if the given argument is null.
IllegalArgumentException - if the given argument is an empty array.
AssertionError - if the actual array is null.
AssertionError - if the actual group does not contain the given values, i.e. the actual group contains some or none of the given values, or the actual group contains more than once these values.

containsSequence

public S containsSequence(boolean... sequence)
Verifies that the actual array contains the given sequence, without any other values between them.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).containsSequence(true, false);
 assertThat(new boolean[] { true, false, false, true }).containsSequence(false, true);
 
 // assertion will fail
 assertThat(new boolean[] { true, true, false }).containsSequence(false, true);
 

Parameters:
sequence - the sequence of values to look for.
Returns:
myself assertion object.
Throws:
AssertionError - if the actual array is null.
AssertionError - if the given array is null.
AssertionError - if the actual array does not contain the given sequence.

containsSubsequence

public S containsSubsequence(boolean... subsequence)
Verifies that the actual array contains the given subsequence (possibly with other values between them).

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).containsSubsequence(true, false);
 assertThat(new boolean[] { true, false, false, true }).containsSubsequence(true, true);
 
 // assertion will fail
 assertThat(new boolean[] { true, true, false }).containsSubsequence(false, true);
 

Parameters:
subsequence - the subsequence of values to look for.
Returns:
myself assertion object.
Throws:
AssertionError - if the actual array is null.
AssertionError - if the given array is null.
AssertionError - if the actual array does not contain the given subsequence.

contains

public S contains(boolean value,
                  Index index)
Verifies that the actual array contains the given value at the given index.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).contains(true, atIndex(O));
 assertThat(new boolean[] { true, false }).contains(false, atIndex(1));
 
 // assertion will fail
 assertThat(new boolean[] { true, false }).contains(false, atIndex(0));
 assertThat(new boolean[] { true, false }).contains(true, atIndex(1));
 

Parameters:
value - the value to look for.
index - the index where the value should be stored in the actual array.
Returns:
myself assertion object.
Throws:
AssertionError - if the actual array is null or empty.
NullPointerException - if the given Index is null.
IndexOutOfBoundsException - if the value of the given Index is equal to or greater than the size of the actual array.
AssertionError - if the actual array does not contain the given value at the given index.

doesNotContain

public S doesNotContain(boolean... values)
Verifies that the actual array does not contain the given values.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, true }).doesNotContain(false);
 
 // assertion will fail
 assertThat(new boolean[] { true, true, false }).doesNotContain(false);
 

Parameters:
values - the given values.
Returns:
this assertion object.
Throws:
NullPointerException - if the given argument is null.
IllegalArgumentException - if the given argument is an empty array.
AssertionError - if the actual array is null.
AssertionError - if the actual array contains any of the given values.

doesNotContain

public S doesNotContain(boolean value,
                        Index index)
Verifies that the actual array does not contain the given value at the given index.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).doesNotContain(true, atIndex(1));
 assertThat(new boolean[] { true, false }).doesNotContain(false, atIndex(0));

 // assertion will fail
 assertThat(new boolean[] { true, false }).doesNotContain(false, atIndex(1));
 assertThat(new boolean[] { true, false }).doesNotContain(true, atIndex(0));
 

Parameters:
value - the value to look for.
index - the index where the value should be stored in the actual array.
Returns:
myself assertion object.
Throws:
AssertionError - if the actual array is null.
NullPointerException - if the given Index is null.
AssertionError - if the actual array contains the given value at the given index.

doesNotHaveDuplicates

public S doesNotHaveDuplicates()
Verifies that the actual array does not contain duplicates.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false }).doesNotHaveDuplicates();
 
 // assertion will fail
 assertThat(new boolean[] { true, true, false }).doesNotHaveDuplicates();
 

Returns:
this assertion object.
Throws:
AssertionError - if the actual array is null.
AssertionError - if the actual array contains duplicates.

startsWith

public S startsWith(boolean... sequence)
Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to containsSequence(boolean...), but it also verifies that the first element in the sequence is also first element of the actual array.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false, false, true }).startsWith(true, false);
 
 // assertion will fail
 assertThat(new boolean[] { true, false, false, true }).startsWith(false, false, true);
 

Parameters:
sequence - the sequence of values to look for.
Returns:
myself assertion object.
Throws:
NullPointerException - if the given argument is null.
IllegalArgumentException - if the given argument is an empty array.
AssertionError - if the actual array is null.
AssertionError - if the actual array does not start with the given sequence.

endsWith

public S endsWith(boolean... sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to containsSequence(boolean...), but it also verifies that the last element in the sequence is also last element of the actual array.

Example:

 // assertion will pass
 assertThat(new boolean[] { true, false, false, true }).endsWith(false, false, true);

 // assertion will fail
 assertThat(new boolean[] { true, false, false, true }).endsWith(true, false);
 

Parameters:
sequence - the sequence of values to look for.
Returns:
myself assertion object.
Throws:
NullPointerException - if the given argument is null.
IllegalArgumentException - if the given argument is an empty array.
AssertionError - if the actual array is null.
AssertionError - if the actual array does not end with the given sequence.

isSorted

public S isSorted()
Verifies that the actual array is sorted into ascending order according to the natural ordering of its elements.

All array elements must be primitive or implement the Comparable interface and must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the array), examples :

Empty or one element arrays are considered sorted (unless the array element type is not Comparable).

Returns:
this assertion object.

isSortedAccordingTo

public S isSortedAccordingTo(Comparator<? super Boolean> comparator)
Verifies that the actual array is sorted according to the given comparator.
Empty arrays are considered sorted whatever the comparator is.
One element arrays are considered sorted if element is compatible with comparator, otherwise an AssertionError is thrown.

Parameters:
comparator - the Comparator used to compare array elements
Returns:
this assertion object.

usingElementComparator

@Deprecated
public final S usingElementComparator(Comparator<? super Boolean> customComparator)
Deprecated. Custom element Comparator is not supported for Boolean array comparison.

Do not use this method.

Parameters:
customComparator - the comparator to use for incoming assertion checks.
Returns:
this assertion object.
Throws:
UnsupportedOperationException - if this method is called.

usingDefaultElementComparator

@Deprecated
public final S usingDefaultElementComparator()
Deprecated. Custom element Comparator is not supported for Boolean array comparison.

Do not use this method.

Returns:
this assertion object.
Throws:
UnsupportedOperationException - if this method is called.

containsExactly

public S containsExactly(boolean... values)
Verifies that the actual group contains only the given values and nothing else, in order.

Example :

 // assertion will pass
 assertThat(new boolean[] { true, false, true }).containsExactly(true, false, true);
 
 // assertion will fail as actual and expected orders differ.
 assertThat(new boolean[] { true, false, true }).containsExactly(false, true, true);
 

Parameters:
values - the given values.
Returns:
this assertion object.
Throws:
NullPointerException - if the given argument is null.
AssertionError - if the actual group is null.
AssertionError - if the actual group does not contain the given values with same order, i.e. the actual group contains some or none of the given values, or the actual group contains more values than the given ones or values are the same but the order is not.


Copyright © 2013–2015 AssertJ. All rights reserved.