org.fest.assertions
Class ShortArrayAssert

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.GenericAssert<T>
          extended by org.fest.assertions.GroupAssert<T>
              extended by org.fest.assertions.ArrayAssert<short[]>
                  extended by org.fest.assertions.ShortArrayAssert

public class ShortArrayAssert
extends ArrayAssert<short[]>

Understands assertion methods for short arrays. To create a new instance of this class use the method Assertions.assertThat(short[]).

Author:
Yvonne Wang, Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.assertions.GenericAssert
actual
 
Constructor Summary
protected ShortArrayAssert(short... actual)
          Creates a new ShortArrayAssert.
 
Method Summary
 ShortArrayAssert as(Description description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 ShortArrayAssert as(String description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 ShortArrayAssert contains(short... values)
          Verifies that the actual short array contains the given values.
 ShortArrayAssert containsOnly(short... values)
          Verifies that the actual short array contains the given values only.
 ShortArrayAssert describedAs(Description description)
          Alias for GenericAssert.as(Description), since "as" is a keyword in Groovy.
 ShortArrayAssert describedAs(String description)
          Alias for GenericAssert.as(String), since "as" is a keyword in Groovy.
 ShortArrayAssert doesNotSatisfy(Condition<short[]> condition)
          Verifies that the actual short array does not satisfy the given condition.
 ShortArrayAssert excludes(short... values)
          Verifies that the actual short array does not contain the given values.
 ShortArrayAssert hasSize(int expected)
          Verifies that the number of elements in the actual short array is equal to the given one.
 ShortArrayAssert is(Condition<short[]> condition)
          Alias for satisfies(Condition).
 ShortArrayAssert isEqualTo(short[] expected)
          Verifies that the actual short array is equal to the given array.
 ShortArrayAssert isNot(Condition<short[]> condition)
          Alias for doesNotSatisfy(Condition).
 ShortArrayAssert isNotEmpty()
          Verifies that the actual short array contains at least on element.
 ShortArrayAssert isNotEqualTo(short[] array)
          Verifies that the actual short array is not equal to the given array.
 ShortArrayAssert isNotNull()
          Verifies that the actual short array is not null.
 ShortArrayAssert isNotSameAs(short[] expected)
          Verifies that the actual short array is not the same as the given array.
 ShortArrayAssert isSameAs(short[] expected)
          Verifies that the actual short array is the same as the given array.
 ShortArrayAssert overridingErrorMessage(String message)
          Replaces the default message displayed in case of a failure with the given one.
 ShortArrayAssert satisfies(Condition<short[]> condition)
          Verifies that the actual short array satisfies the given condition.
 
Methods inherited from class org.fest.assertions.ArrayAssert
actualGroupSize, actualInBrackets, assertContains, assertContainsOnly, assertExcludes, assertThatActualHasSize, assertThatActualIsNotEmpty, assertThatActualIsNotNull, isEmpty, isNullOrEmpty
 
Methods inherited from class org.fest.assertions.GenericAssert
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNull
 
Methods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShortArrayAssert

protected ShortArrayAssert(short... actual)
Creates a new ShortArrayAssert.

Parameters:
actual - the target to verify.
Method Detail

as

public ShortArrayAssert 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 ShortArrayAssert 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 ShortArrayAssert 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 ShortArrayAssert 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.

contains

public ShortArrayAssert contains(short... values)
Verifies that the actual short array contains the given values.

Parameters:
values - the values to look for.
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is null.
NullPointerException - if the given short array is null.
AssertionError - if the actual short array does not contain the given values.

containsOnly

public ShortArrayAssert containsOnly(short... values)
Verifies that the actual short array contains the given values only.

Parameters:
values - the values to look for.
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is null.
NullPointerException - if the given short array is null.
AssertionError - if the actual short array does not contain the given objects, or if the actual short array contains elements other than the ones specified.

excludes

public ShortArrayAssert excludes(short... values)
Verifies that the actual short array does not contain the given values.

Parameters:
values - the values the array should exclude.
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is null.
NullPointerException - if the given short array is null.
AssertionError - if the actual Object array contains any of the given values.

satisfies

public ShortArrayAssert satisfies(Condition<short[]> condition)
Verifies that the actual short array 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 array does not satisfy the given condition.
See Also:
is(Condition)

doesNotSatisfy

public ShortArrayAssert doesNotSatisfy(Condition<short[]> condition)
Verifies that the actual short array 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 short array satisfies the given condition.
See Also:
isNot(Condition)

is

public ShortArrayAssert is(Condition<short[]> condition)
Alias for satisfies(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 array does not satisfy the given condition.
Since:
1.2

isNot

public ShortArrayAssert isNot(Condition<short[]> condition)
Alias for doesNotSatisfy(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 array satisfies the given condition.
Since:
1.2

isNotNull

public ShortArrayAssert isNotNull()
Verifies that the actual short array is not null.

Specified by:
isNotNull in class GenericAssert<short[]>
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is null.

isNotEmpty

public ShortArrayAssert isNotEmpty()
Verifies that the actual short array contains at least on element.

Specified by:
isNotEmpty in class GroupAssert<short[]>
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is null.
AssertionError - if the actual short array is empty.

isEqualTo

public ShortArrayAssert isEqualTo(short[] expected)
Verifies that the actual short array is equal to the given array. Array equality is checked by Arrays.equals(short[], short[]).

Specified by:
isEqualTo in class GenericAssert<short[]>
Parameters:
expected - the given array to compare the actual array to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is not equal to the given one.

isNotEqualTo

public ShortArrayAssert isNotEqualTo(short[] array)
Verifies that the actual short array is not equal to the given array. Array equality is checked by Arrays.equals(short[], short[]).

Specified by:
isNotEqualTo in class GenericAssert<short[]>
Parameters:
array - the given array to compare the actual array to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is equal to the given one.

hasSize

public ShortArrayAssert hasSize(int expected)
Verifies that the number of elements in the actual short array is equal to the given one.

Specified by:
hasSize in class GroupAssert<short[]>
Parameters:
expected - the expected number of elements in the actual short array.
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is null.
AssertionError - if the number of elements in the actual short array is not equal to the given one.

isSameAs

public ShortArrayAssert isSameAs(short[] expected)
Verifies that the actual short array is the same as the given array.

Specified by:
isSameAs in class GenericAssert<short[]>
Parameters:
expected - the given array to compare the actual array to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is not the same as the given one.

isNotSameAs

public ShortArrayAssert isNotSameAs(short[] expected)
Verifies that the actual short array is not the same as the given array.

Specified by:
isNotSameAs in class GenericAssert<short[]>
Parameters:
expected - the given array to compare the actual array to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual short array is the same as the given one.

overridingErrorMessage

public ShortArrayAssert 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.


Copyright © 2007-2010 FEST (Fixtures for Easy Software Testing). All Rights Reserved.