org.assertj.core.api
Class AbstractShortArrayAssert<S extends AbstractShortArrayAssert<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,short[],Short>
              extended by org.assertj.core.api.AbstractShortArrayAssert<S>
All Implemented Interfaces:
ArraySortedAssert<AbstractArrayAssert<S,short[],Short>,Short>, Assert<S,short[]>, Descriptable<S>, EnumerableAssert<AbstractEnumerableAssert<S,short[],Short>,Short>, ExtensionPoints<S,short[]>
Direct Known Subclasses:
ShortArrayAssert

public abstract class AbstractShortArrayAssert<S extends AbstractShortArrayAssert<S>>
extends AbstractArrayAssert<S,short[],Short>


Field Summary
protected  ShortArrays arrays
           
 
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself
 
Constructor Summary
AbstractShortArrayAssert(short[] actual, Class<?> selfType)
           
 
Method Summary
 S contains(short... values)
          Verifies that the actual array contains the given values, in any order.
 S contains(short value, Index index)
          Verifies that the actual array contains the given value at the given index.
 S containsExactly(short... values)
          Verifies that the actual group contains only the given values and nothing else, in order.
 S containsOnly(short... values)
          Verifies that the actual array contains only the given values and nothing else, in any order.
 S containsOnlyOnce(short... values)
          Verifies that the actual array contains the given values only once.
 S containsSequence(short... sequence)
          Verifies that the actual array contains the given sequence, without any other values between them.
 S containsSubsequence(short... subsequence)
          Verifies that the actual array contains the given subsequence (possibly with other values between them).
 S doesNotContain(short... values)
          Verifies that the actual array does not contain the given values.
 S doesNotContain(short 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(short... 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 Short> 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(short... sequence)
          Verifies that the actual array starts with the given sequence of values, without any other values between them.
 S usingDefaultElementComparator()
          Revert to standard comparison for incoming assertion group element checks.
 S usingElementComparator(Comparator<? super Short> customComparator)
          Use given custom comparator instead of relying on actual type A equals method to compare group elements for incoming assertion checks.
 
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 ShortArrays arrays
Constructor Detail

AbstractShortArrayAssert

public AbstractShortArrayAssert(short[] 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.

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.

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

contains

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

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(short... values)
Verifies that the actual array contains only the given values and nothing else, in any order.

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(short... values)
Verifies that the actual array contains the given values only once.

Examples :

 // assertion will pass
 assertThat(new short[] { 1, 2, 3 }).containsOnlyOnce(1, 2);
 
 // assertions will fail
 assertThat(new short[] { 1, 2, 1 }).containsOnlyOnce(1);
 assertThat(new short[] { 1, 2, 3 }).containsOnlyOnce(4);
 assertThat(new short[] { 1, 2, 3, 3 }).containsOnlyOnce(0, 1, 2, 3, 4, 5);
 

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(short... sequence)
Verifies that the actual array contains the given sequence, without any other values between them.

Example:

 // assertion will pass
 assertThat(new short[] { 1, 2, 3 }).containsSequence(1, 2);
 
 // assertion will fail
 assertThat(new short[] { 1, 2, 3 }).containsSequence(1, 3);
 assertThat(new short[] { 1, 2, 3 }).containsSequence(2, 1);
 

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(short... subsequence)
Verifies that the actual array contains the given subsequence (possibly with other values between them).

Example:

 // assertion will pass
 assertThat(new short[] { 1, 2, 3 }).containsSubsequence(1, 2);
 assertThat(new short[] { 1, 2, 3 }).containsSubsequence(1, 3);
 
 // assertion will fail
 assertThat(new short[] { 1, 2, 3 }).containsSubsequence(2, 1);
 

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(short value,
                  Index index)
Verifies that the actual array contains the given value at the given index.

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(short... values)
Verifies that the actual array does not contain the given values.

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(short value,
                        Index index)
Verifies that the actual array does not contain the given value at the given index.

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.

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

startsWith

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

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(short... sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to containsSequence(short...), but it also verifies that the last element in the sequence is also last element of the actual array.

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 Short> 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

public S usingElementComparator(Comparator<? super Short> customComparator)
Use given custom comparator instead of relying on actual type A equals method to compare group elements for incoming assertion checks.

Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.

Examples :

 // compares invoices by payee 
 assertThat(invoiceList).usingComparator(invoicePayeeComparator).isEqualTo(expectedInvoiceList).
 
 // compares invoices by date, doesNotHaveDuplicates and contains both use the given invoice date comparator
 assertThat(invoiceList).usingComparator(invoiceDateComparator).doesNotHaveDuplicates().contains(may2010Invoice)
 
 // as assertThat(invoiceList) creates a new assertion, it falls back to standard comparison strategy 
 // based on Invoice's equal method to compare invoiceList elements to lowestInvoice.                                                      
 assertThat(invoiceList).contains(lowestInvoice).
 
 // standard comparison : the fellowshipOfTheRing includes Gandalf but not Sauron (believe me) ...
 assertThat(fellowshipOfTheRing).contains(gandalf)
                                .doesNotContain(sauron);
 
 // ... but if we compare only races, Sauron is in fellowshipOfTheRing because he's a Maia like Gandalf.
 assertThat(fellowshipOfTheRing).usingElementComparator(raceComparator)
                                .contains(sauron);
 

Parameters:
customComparator - the comparator to use for incoming assertion checks.
Returns:
this assertion object.

usingDefaultElementComparator

public S usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks.

This method should be used to disable a custom comparison strategy set by calling EnumerableAssert.usingElementComparator(Comparator).

Returns:
this assertion object.

containsExactly

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

Example :

 short[] shorts = { 1, 2, 3 };
 
 // assertion will pass
 assertThat(shorts).containsExactly(1, 2, 3);
 
 // assertion will fail as actual and expected orders differ.
 assertThat(shorts).containsExactly(2, 1, 3);
 

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.