Package org.assertj.core.api
Class AbstractEnumerableAssert<SELF extends AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>,ACTUAL,ELEMENT>
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>
-
- Type Parameters:
SELF
- the "self" type of this assertion class.ACTUAL
- the type of the "actual" value which is an Array of ELEMENT.ELEMENT
- the type of the "actual" array element.
- All Implemented Interfaces:
Assert<SELF,ACTUAL>
,Descriptable<SELF>
,EnumerableAssert<AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>,ELEMENT>
,ExtensionPoints<SELF,ACTUAL>
- Direct Known Subclasses:
AbstractArrayAssert
,AtomicIntegerArrayAssert
,AtomicLongArrayAssert
public abstract class AbstractEnumerableAssert<SELF extends AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>,ACTUAL,ELEMENT> extends AbstractAssert<SELF,ACTUAL> implements EnumerableAssert<AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>,ELEMENT>
Base implementation for Enumerable class assertions.- Author:
- Joel Costigliola
-
-
Field Summary
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEnumerableAssert(ACTUAL actual, Class<?> selfType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SELF
hasSameSizeAs(Object other)
Verifies that the actual group has the same size as given array.SELF
inBinary()
Use binary object representation instead of standard representation in error messages.SELF
inHexadecimal()
Enable hexadecimal object representation of Iterable elements instead of standard java representation in error messages.-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs
-
Methods inherited from interface org.assertj.core.api.EnumerableAssert
hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, isEmpty, isNotEmpty, isNullOrEmpty, usingDefaultElementComparator, usingElementComparator
-
-
-
-
Method Detail
-
hasSameSizeAs
public SELF hasSameSizeAs(Object other)
Verifies that the actual group has the same size as given array.Parameter is declared as Object to accept both Object[] and primitive arrays (e.g. int[]).
Example:int[] oneTwoThree = {1, 2, 3}; Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya); // assertion will pass assertThat(elvesRings).hasSameSizeAs(oneTwoThree); // assertions will fail assertThat(elvesRings).hasSameSizeAs(new int[] { 1, 2}); assertThat(elvesRings).hasSameSizeAs(new int[] { 1, 2, 3, 4});
Example with byte array:
// assertions will pass assertThat(new byte[]{1, 2}).hasSameSizeAs(new byte[]{2, 3}); assertThat(new byte[]{1, 2}).hasSameSizeAs(new Byte[]{2, 3}); assertThat(new byte[]{1, 2}).hasSameSizeAs(new int[]{2, 3}); assertThat(new byte[]{1, 2}).hasSameSizeAs(new String[]{"1", "2"}); // assertion will fail assertThat(new byte[]{ 1, 2 }).hasSameSizeAs(new byte[]{ 1, 2, 3 });
- Specified by:
hasSameSizeAs
in interfaceEnumerableAssert<SELF extends AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>,ACTUAL>
- Parameters:
other
- the array to compare size with actual group.- Returns:
this
assertion object.
-
inHexadecimal
public SELF inHexadecimal()
Enable hexadecimal object representation of Iterable elements instead of standard java representation in error messages.It can be useful to better understand what the error was with a more meaningful error message.
Example
With standard error message:assertThat(new byte[]{0x10,0x20}).inHexadecimal().contains(new byte[]{0x30});
With Hexadecimal error message:Expecting: <[16, 32]> to contain: <[48]> but could not find: <[48]>
Expecting: <[0x10, 0x20]> to contain: <[0x30]> but could not find: <[0x30]>
- Overrides:
inHexadecimal
in classAbstractAssert<SELF extends AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>,ACTUAL>
- Returns:
this
assertion object.
-
inBinary
public SELF inBinary()
Description copied from class:AbstractAssert
Use binary object representation instead of standard representation in error messages.Example:
assertThat(1).inBinary().isEqualTo(2); org.junit.ComparisonFailure: Expected :0b00000000_00000000_00000000_00000010 Actual :0b00000000_00000000_00000000_00000001
- Overrides:
inBinary
in classAbstractAssert<SELF extends AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>,ACTUAL>
- Returns:
this
assertion object.
-
-