Package org.fest.assertions
Class ByteArrayAssert
java.lang.Object
org.fest.assertions.Assert
org.fest.assertions.GenericAssert<T>
org.fest.assertions.GroupAssert<T>
org.fest.assertions.ItemGroupAssert<T>
org.fest.assertions.ArrayAssert<byte[]>
org.fest.assertions.ByteArrayAssert
Understands assertion methods for
byte arrays. To create a new instance of this class use the
method Assertions.assertThat(byte[]).-
Field Summary
Fields inherited from class org.fest.assertions.GenericAssert
actual -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedByteArrayAssert(byte... actual) Creates a newByteArrayAssert. -
Method Summary
Modifier and TypeMethodDescriptionSets the description of the actual value, to be used in as message of anythrown when an assertion fails.AssertionErroras(Description description) Sets the description of the actual value, to be used in as message of anythrown when an assertion fails.AssertionErrorcontains(byte... values) Verifies that the actualbytearray contains the given values.containsOnly(byte... values) Verifies that the actualbytearray contains the given values only.describedAs(String description) Alias for, since "as" is a keyword in Groovy.GenericAssert.as(String)describedAs(Description description) Alias for, since "as" is a keyword in Groovy.GenericAssert.as(Description)doesNotSatisfy(Condition<byte[]> condition) Verifies that the actualbytearray does not satisfy the given condition.excludes(byte... values) Verifies that the actualbytearray does not contain the given values.hasSize(int expected) Verifies that the number of elements in the actualbytearray is equal to the given one.Alias for.satisfies(Condition)isEqualTo(byte[] expected) Verifies that the actualbytearray is equal to the given array.Alias for.doesNotSatisfy(Condition)Verifies that the actualbytearray contains at least on element.isNotEqualTo(byte[] array) Verifies that the actualbytearray is not equal to the given array.Verifies that the actualbytearray is notnull.isNotSameAs(byte[] expected) Verifies that the actualbytearray is not the same as the given array.isSameAs(byte[] expected) Verifies that the actualbytearray is the same as the given array.overridingErrorMessage(String message) Replaces the default message displayed in case of a failure with the given one.Verifies that the actualbytearray satisfies the given condition.Methods inherited from class org.fest.assertions.ArrayAssert
actualAsList, actualAsSet, actualGroupSizeMethods inherited from class org.fest.assertions.ItemGroupAssert
assertContains, assertContainsOnly, assertDoesNotHaveDuplicates, assertExcludes, asSet, validateIsNotNullMethods inherited from class org.fest.assertions.GroupAssert
assertHasSize, assertIsNotEmpty, isEmpty, isNullOrEmptyMethods inherited from class org.fest.assertions.GenericAssert
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNullMethods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
-
Constructor Details
-
ByteArrayAssert
protected ByteArrayAssert(byte... actual) Creates a newByteArrayAssert.- Parameters:
actual- the target to verify.
-
-
Method Details
-
as
Sets the description of the actual value, to be used in as message of anythrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.AssertionErrorFor example:
assertThat(val).as("name").isEqualTo("Frodo");- Specified by:
asin classGroupAssert<byte[]>- Parameters:
description- the description of the actual value.- Returns:
- this assertion object.
-
describedAs
Alias for, 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.GenericAssert.as(String)For example:
assertThat(val).describedAs("name").isEqualTo("Frodo");- Specified by:
describedAsin classGroupAssert<byte[]>- Parameters:
description- the description of the actual value.- Returns:
- this assertion object.
-
as
Sets the description of the actual value, to be used in as message of anythrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.AssertionErrorFor example:
assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");- Specified by:
asin classGroupAssert<byte[]>- Parameters:
description- the description of the actual value.- Returns:
- this assertion object.
-
describedAs
Alias for, 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.GenericAssert.as(Description)For example:
assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");- Specified by:
describedAsin classGroupAssert<byte[]>- Parameters:
description- the description of the actual value.- Returns:
- this assertion object.
-
contains
Verifies that the actualbytearray contains the given values.- Parameters:
values- the values to look for.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray isnull.NullPointerException- if the givenbytearray isnull.AssertionError- if the actualbytearray does not contain the given values.
-
containsOnly
Verifies that the actualbytearray contains the given values only.- Parameters:
values- the values to look for.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray isnull.NullPointerException- if the givenbytearray isnull.AssertionError- if the actualbytearray does not contain the given objects, or if the actualbytearray contains elements other than the ones specified.
-
excludes
Verifies that the actualbytearray does not contain the given values.- Parameters:
values- the values the array should exclude.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray isnull.NullPointerException- if the givenbytearray isnull.AssertionError- if the actualbytearray contains any of the given values.
-
satisfies
Verifies that the actualbytearray satisfies the given condition.- Specified by:
satisfiesin classGenericAssert<byte[]>- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the actualbytearray does not satisfy the given condition.- See Also:
-
doesNotSatisfy
Verifies that the actualbytearray does not satisfy the given condition.- Specified by:
doesNotSatisfyin classGenericAssert<byte[]>- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the actualbytearray satisfies the given condition.- See Also:
-
is
Alias for.satisfies(Condition)- Specified by:
isin classGenericAssert<byte[]>- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the actualbytearray does not satisfy the given condition.- Since:
- 1.2
-
isNot
Alias for.doesNotSatisfy(Condition)- Specified by:
isNotin classGenericAssert<byte[]>- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the actualbytearray satisfies the given condition.- Since:
- 1.2
-
isNotNull
Verifies that the actualbytearray is notnull.- Specified by:
isNotNullin classGenericAssert<byte[]>- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray isnull.
-
isNotEmpty
Verifies that the actualbytearray contains at least on element.- Specified by:
isNotEmptyin classGroupAssert<byte[]>- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray isnull.AssertionError- if the actualbytearray is empty.
-
isEqualTo
Verifies that the actualbytearray is equal to the given array. Array equality is checked by.Arrays.equals(byte[], byte[])- Specified by:
isEqualToin classGenericAssert<byte[]>- Parameters:
expected- the given array to compare the actual array to.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray is not equal to the given one.
-
isNotEqualTo
Verifies that the actualbytearray is not equal to the given array. Array equality is checked by.Arrays.equals(byte[], byte[])- Specified by:
isNotEqualToin classGenericAssert<byte[]>- Parameters:
array- the given array to compare the actual array to.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray is equal to the given one.
-
hasSize
Verifies that the number of elements in the actualbytearray is equal to the given one.- Specified by:
hasSizein classGroupAssert<byte[]>- Parameters:
expected- the expected number of elements in the actualbytearray.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray isnull.AssertionError- if the number of elements in the actualbytearray is not equal to the given one.
-
isSameAs
Verifies that the actualbytearray is the same as the given array.- Specified by:
isSameAsin classGenericAssert<byte[]>- Parameters:
expected- the given array to compare the actual array to.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray is not the same as the given one.
-
isNotSameAs
Verifies that the actualbytearray is not the same as the given array.- Specified by:
isNotSameAsin classGenericAssert<byte[]>- Parameters:
expected- the given array to compare the actual array to.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualbytearray is the same as the given one.
-
overridingErrorMessage
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:
overridingErrorMessagein classGroupAssert<byte[]>- Parameters:
message- the given error message, which will replace the default one.- Returns:
- this assertion.
-