Class IterableSubject<S extends IterableSubject<S,T,C>,T,C extends Iterable<T>>

    • Constructor Detail

      • IterableSubject

        protected IterableSubject(FailureStrategy failureStrategy,
                                  C list)
    • Method Detail

      • isEmpty

        public final void isEmpty()
        Fails if the subject is not empty.
      • isNotEmpty

        public final void isNotEmpty()
        Fails if the subject is empty.
      • hasSize

        public final void hasSize(int expectedSize)
        Fails if the subject does not have the given size.
      • contains

        public final void contains(Object element)
        Attests (with a side-effect failure) that the subject contains the supplied item.
      • doesNotContain

        public final void doesNotContain(Object element)
        Attests (with a side-effect failure) that the subject does not contain the supplied item.
      • containsNoDuplicates

        public final void containsNoDuplicates()
        Attests that the subject does not contain duplicate elements.
      • containsAnyOf

        public final void containsAnyOf(Object first,
                                        Object second,
                                        Object... rest)
        Attests that the subject contains at least one of the provided objects or fails.
      • containsAnyIn

        public final void containsAnyIn(Iterable<?> expected)
        Attests that a Collection contains at least one of the objects contained in the provided collection or fails.
      • containsAllOf

        public final Ordered containsAllOf(Object first,
                                           Object second,
                                           Object... rest)
        Attests that the subject contains at least all of the provided objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).

        Callers may optionally chain an inOrder() call if its expected contents must be contained in the given order.

      • containsAllIn

        public final Ordered containsAllIn(Iterable<?> expected)
        Attests that the subject contains at least all of the provided objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).

        Callers may optionally chain an inOrder() call if its expected contents must be contained in the given order.

      • containsExactly

        public final Ordered containsExactly(Object... varargs)
        Attests that a subject contains exactly the provided objects or fails.

        Multiplicity is respected. For example, an object duplicated exactly 3 times in the parameters asserts that the object must likewise be duplicated exactly 3 times in the subject.

        Callers may optionally chain an inOrder() call if its expected contents must be contained in the given order.

      • containsExactlyElementsIn

        public final Ordered containsExactlyElementsIn(Iterable<?> expected)
        Attests that a subject contains exactly the provided objects or fails.

        Multiplicity is respected. For example, an object duplicated exactly 3 times in the Iterable parameter asserts that the object must likewise be duplicated exactly 3 times in the subject.

        Callers may optionally chain an inOrder() call if its expected contents must be contained in the given order.

      • failWithBadResultsAndSuffix

        protected final void failWithBadResultsAndSuffix(String verb,
                                                         Object expected,
                                                         String failVerb,
                                                         Object actual,
                                                         String suffix)
        Fails with the bad results and a suffix.
        Parameters:
        verb - the proposition being asserted
        expected - the expectations against which the subject is compared
        failVerb - the failure of the proposition being asserted
        actual - the actual value the subject was compared against
        suffix - a suffix to append to the failure message
      • containsNoneOf

        public final void containsNoneOf(Object first,
                                         Object second,
                                         Object... rest)
        Attests that a subject contains none of the provided objects or fails, eliding duplicates.
      • containsNoneIn

        public final void containsNoneIn(Iterable<?> excluded)
        Attests that a Collection contains none of the objects contained in the provided collection or fails, eliding duplicates.
      • isStrictlyOrdered

        public final void isStrictlyOrdered()
        Fails if the iterable is not strictly ordered, according to the natural ordering of its elements. Strictly ordered means that each element in the iterable is strictly greater than the element that preceded it.
        Throws:
        ClassCastException - if any pair of elements is not mutually Comparable
        NullPointerException - if any element is null
      • isStrictlyOrdered

        public final void isStrictlyOrdered(Comparator<? super T> comparator)
        Fails if the iterable is not strictly ordered, according to the given comparator. Strictly ordered means that each element in the iterable is strictly greater than the element that preceded it.
        Throws:
        ClassCastException - if any pair of elements is not mutually Comparable
      • isOrdered

        public final void isOrdered()
        Fails if the iterable is not ordered, according to the natural ordering of its elements. Ordered means that each element in the iterable is greater than or equal to the element that preceded it.
        Throws:
        ClassCastException - if any pair of elements is not mutually Comparable
        NullPointerException - if any element is null
      • isPartiallyOrdered

        @Deprecated
        public final void isPartiallyOrdered()
        Deprecated.  Use isOrdered() instead.
      • isOrdered

        public final void isOrdered(Comparator<? super T> comparator)
        Fails if the iterable is not ordered, according to the given comparator. Ordered means that each element in the iterable is greater than or equal to the element that preceded it.
        Throws:
        ClassCastException - if any pair of elements is not mutually Comparable