ELEMENT - the type of elements of the "actual" value.public class IterableAssert<ELEMENT> extends FactoryBasedNavigableIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
Iterable.
To create an instance of this class, invoke .
Assertions.assertThat(Iterable)
iterablesactual, info, myself| Constructor and Description |
|---|
IterableAssert(Iterable<? extends ELEMENT> actual) |
IterableAssert(Iterator<? extends ELEMENT> actual) |
| Modifier and Type | Method and Description |
|---|---|
IterableAssert<ELEMENT> |
isEqualTo(Object expected)
Verifies that the actual value is equal to the given one.
|
IterableAssert<ELEMENT> |
isExactlyInstanceOf(Class<?> type)
Verifies that the actual value is exactly an instance of the given type.
|
IterableAssert<ELEMENT> |
isInstanceOf(Class<?> type)
Verifies that the actual value is an instance of the given type.
|
IterableAssert<ELEMENT> |
isInstanceOfAny(Class<?>... types)
Verifies that the actual value is an instance of any of the given types.
|
IterableAssert<ELEMENT> |
isNotExactlyInstanceOf(Class<?> type)
Verifies that the actual value is not exactly an instance of given type.
|
IterableAssert<ELEMENT> |
isNotInstanceOf(Class<?> type)
Verifies that the actual value is not an instance of the given type.
|
IterableAssert<ELEMENT> |
isNotInstanceOfAny(Class<?>... types)
Verifies that the actual value is not an instance of any of the given types.
|
IterableAssert<ELEMENT> |
isNotOfAnyClassIn(Class<?>... types)
Verifies that the actual value type is not in given types.
|
IterableAssert<ELEMENT> |
isNotSameAs(Object expected)
Verifies that the actual value is not the same as the given one, ie using == comparison.
|
IterableAssert<ELEMENT> |
isOfAnyClassIn(Class<?>... types)
Verifies that the actual value type is in given types.
|
IterableAssert<ELEMENT> |
isSameAs(Object expected)
Verifies that the actual value is the same as the given one, ie using == comparison.
|
IterableAssert<ELEMENT> |
startsWith(ELEMENT... sequence)
Verifies that the actual group starts with the given sequence of objects, without any other objects between them.
|
toAssertare, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, as, as, contains, containsAll, containsExactly, containsExactlyElementsOf, containsExactlyInAnyOrder, containsNull, containsOnly, containsOnlyElementsOf, containsOnlyOnce, containsSequence, containsSubsequence, describedAs, describedAs, doesNotContain, doesNotContainAnyElementsOf, doesNotContainNull, doesNotHave, doesNotHaveDuplicates, doesNotHaveSameClassAs, doNotHave, element, endsWith, extracting, extracting, extracting, extracting, extractingResultOf, extractingResultOf, filteredOn, filteredOn, filteredOn, filteredOnNull, first, flatExtracting, flatExtracting, flatExtracting, has, hasAtLeastOneElementOfType, hasOnlyElementsOfType, hasSameClassAs, hasSameElementsAs, hasSameSizeAs, hasSameSizeAs, hasSize, hasToString, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, inBinary, inHexadecimal, is, isEmpty, isIn, isIn, isNot, isNotEmpty, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNullOrEmpty, isSubsetOf, isSubsetOf, last, navigationDescription, overridingErrorMessage, size, usingComparator, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparisonStrategy, usingDefaultComparator, usingDefaultElementComparator, usingElementComparator, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, withFailMessage, withThreadDumpOnErrorasList, asString, descriptionText, equals, failWithMessage, getWritableAssertionInfo, hashCode, isNull, setCustomRepresentation, withRepresentationpublic IterableAssert<ELEMENT> isEqualTo(Object expected)
AbstractAssertExample:
// assertions will pass
assertThat("abc").isEqualTo("abc");
assertThat(new HashMap<String, Integer>()).isEqualTo(new HashMap<String, Integer>());
// assertions will fail
assertThat("abc").isEqualTo("123");
assertThat(new ArrayList<String>()).isEqualTo(1);isEqualTo in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isEqualTo in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>expected - the given value to compare the actual value to.this assertion object.public IterableAssert<ELEMENT> isInstanceOf(Class<?> type)
AbstractAssertExample:
// assertions will pass
assertThat("abc").isInstanceOf(String.class);
assertThat(new HashMap<String, Integer>()).isInstanceOf(HashMap.class);
assertThat(new HashMap<String, Integer>()).isInstanceOf(Map.class);
// assertions will fail
assertThat(1).isInstanceOf(String.class);
assertThat(new ArrayList<String>()).isInstanceOf(LinkedList.class);isInstanceOf in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isInstanceOf in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>type - the type to check the actual value against.public IterableAssert<ELEMENT> isInstanceOfAny(Class<?>... types)
AbstractAssertExample:
// assertions will pass
assertThat("abc").isInstanceOfAny(String.class, Integer.class);
assertThat(new ArrayList<String>()).isInstanceOfAny(LinkedList.class, ArrayList.class);
assertThat(new HashMap<String, Integer>()).isInstanceOfAny(TreeMap.class, Map.class);
// assertions will fail
assertThat(1).isInstanceOfAny(Double.class, Float.class);
assertThat(new ArrayList<String>()).isInstanceOfAny(LinkedList.class, Vector.class);isInstanceOfAny in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isInstanceOfAny in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>types - the types to check the actual value against.public IterableAssert<ELEMENT> isOfAnyClassIn(Class<?>... types)
AbstractAssertExample:
// assertions will pass
assertThat(new HashMap<String, Integer>()).isOfAnyClassIn(HashMap.class, TreeMap.class);
assertThat(new ArrayList<String>()).isOfAnyClassIn(ArrayList.class, LinkedList.class);
// assertions will fail
assertThat(new HashMap<String, Integer>()).isOfAnyClassIn(TreeMap.class, Map.class);
assertThat(new ArrayList<String>()).isOfAnyClassIn(LinkedList.class, List.class);isOfAnyClassIn in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isOfAnyClassIn in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>types - the types to check the actual value against.public IterableAssert<ELEMENT> isExactlyInstanceOf(Class<?> type)
AbstractAssertExample:
// assertions will pass
assertThat("abc").isExactlyInstanceOf(String.class);
assertThat(new ArrayList<String>()).isExactlyInstanceOf(ArrayList.class);
assertThat(new HashMap<String, Integer>()).isExactlyInstanceOf(HashMap.class);
// assertions will fail
assertThat(1).isExactlyInstanceOf(String.class);
assertThat(new ArrayList<String>()).isExactlyInstanceOf(List.class);
assertThat(new HashMap<String, Integer>()).isExactlyInstanceOf(Map.class);isExactlyInstanceOf in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isExactlyInstanceOf in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>type - the type to check the actual value against.public IterableAssert<ELEMENT> isNotInstanceOf(Class<?> type)
AbstractAssertExample:
// assertions will pass
assertThat(1).isNotInstanceOf(Double.class);
assertThat(new ArrayList<String>()).isNotInstanceOf(LinkedList.class);
// assertions will fail
assertThat("abc").isNotInstanceOf(String.class);
assertThat(new HashMap<String, Integer>()).isNotInstanceOf(HashMap.class);
assertThat(new HashMap<String, Integer>()).isNotInstanceOf(Map.class);isNotInstanceOf in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isNotInstanceOf in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>type - the type to check the actual value against.public IterableAssert<ELEMENT> isNotInstanceOfAny(Class<?>... types)
AbstractAssertExample:
// assertions will pass
assertThat(1).isNotInstanceOfAny(Double.class, Float.class);
assertThat(new ArrayList<String>()).isNotInstanceOfAny(LinkedList.class, Vector.class);
// assertions will fail
assertThat(1).isNotInstanceOfAny(Double.class, Integer.class);
assertThat(new ArrayList<String>()).isNotInstanceOfAny(LinkedList.class, ArrayList.class);
assertThat(new HashMap<String, Integer>()).isNotInstanceOfAny(TreeMap.class, Map.class);isNotInstanceOfAny in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isNotInstanceOfAny in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>types - the types to check the actual value against.public IterableAssert<ELEMENT> isNotOfAnyClassIn(Class<?>... types)
AbstractAssertExample:
// assertions will pass
assertThat(new HashMap<String, Integer>()).isNotOfAnyClassIn(Map.class, TreeMap.class);
assertThat(new ArrayList<String>()).isNotOfAnyClassIn(LinkedList.class, List.class);
// assertions will fail
assertThat(new HashMap<String, Integer>()).isNotOfAnyClassIn(HashMap.class, TreeMap.class);
assertThat(new ArrayList<String>()).isNotOfAnyClassIn(ArrayList.class, LinkedList.class);isNotOfAnyClassIn in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isNotOfAnyClassIn in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>types - the types to check the actual value against.public IterableAssert<ELEMENT> isNotExactlyInstanceOf(Class<?> type)
AbstractAssertExample:
// assertions will pass
assertThat(1).isNotExactlyInstanceOf(String.class);
assertThat(new ArrayList<String>()).isNotExactlyInstanceOf(List.class);
assertThat(new HashMap<String, Integer>()).isNotExactlyInstanceOf(Map.class);
// assertions will fail
assertThat("abc").isNotExactlyInstanceOf(String.class);
assertThat(new ArrayList<String>()).isNotExactlyInstanceOf(ArrayList.class);
assertThat(new HashMap<String, Integer>()).isNotExactlyInstanceOf(HashMap.class);isNotExactlyInstanceOf in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isNotExactlyInstanceOf in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>type - the type to check the actual value against.public IterableAssert<ELEMENT> isSameAs(Object expected)
AbstractAssertExample:
// Name is a class with first and last fields, two Names are equals if both first and last are equals.
Name tyrion = new Name("Tyrion", "Lannister");
Name alias = tyrion;
Name clone = new Name("Tyrion", "Lannister");
// assertions succeed:
assertThat(tyrion).isSameAs(alias)
.isEqualTo(clone);
// assertion fails:
assertThat(tyrion).isSameAs(clone);isSameAs in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isSameAs in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>expected - the given value to compare the actual value to.this assertion object.public IterableAssert<ELEMENT> isNotSameAs(Object expected)
AbstractAssertExample:
// Name is a class with first and last fields, two Names are equals if both first and last are equals.
Name tyrion = new Name("Tyrion", "Lannister");
Name alias = tyrion;
Name clone = new Name("Tyrion", "Lannister");
// assertions succeed:
assertThat(clone).isNotSameAs(tyrion)
.isEqualTo(tyrion);
// assertion fails:
assertThat(alias).isNotSameAs(tyrion);isNotSameAs in interface Assert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>>isNotSameAs in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>expected - the given value to compare the actual value to.this assertion object.public IterableAssert<ELEMENT> startsWith(ELEMENT... sequence)
AbstractIterableAssertObjectEnumerableAssert.containsSequence(Object...), but it also verifies that the first element in the
sequence is also first element of the actual group.
Example :
// an Iterable is used in the example but it would also work with an array
Iterable<String> abc = newArrayList("a", "b", "c");
// assertion will pass
assertThat(abc).startsWith("a", "b");
// assertion will fail
assertThat(abc).startsWith("c");startsWith in interface ObjectEnumerableAssert<IterableAssert<ELEMENT>,ELEMENT>startsWith in class AbstractIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>sequence - the sequence of objects to look for.Copyright © 2013–2016 AssertJ. All rights reserved.