/** * Verifies that the given <code>{@link Iterable}</code> contains the given sequence of objects, without any other * objects between them. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param sequence the sequence of objects to look for. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given {@code Iterable} does not contain the given sequence of objects. */ public void assertContainsSequence(AssertionInfo info, Iterable<?> actual, Object[] sequence) { if (commonCheckThatIterableAssertionSucceeds(info, actual, sequence)) return; // check for elements in values that are missing in actual. List<?> actualAsList = newArrayList(actual); for (int i = 0; i < actualAsList.size(); i++) { // look for given sequence in actual starting from current index (i) if (containsSequenceAtGivenIndex(actualAsList, sequence, i)) return; } throw actualDoesNotContainSequence(info, actual, sequence); }
/** * Verifies that the given <code>{@link Iterable}</code> contains the given sequence of objects, without any other * objects between them. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param sequence the sequence of objects to look for. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given {@code Iterable} does not contain the given sequence of objects. */ public void assertContainsSequence(AssertionInfo info, Iterable<?> actual, Object[] sequence) { if (commonCheckThatIterableAssertionSucceeds(info, actual, sequence)) return; // check for elements in values that are missing in actual. List<?> actualAsList = newArrayList(actual); for (int i = 0; i < actualAsList.size(); i++) { // look for given sequence in actual starting from current index (i) if (containsSequenceAtGivenIndex(actualAsList, sequence, i)) return; } throw actualDoesNotContainSequence(info, actual, sequence); }
/** * Verifies that the given <code>{@link Iterable}</code> contains the given sequence of objects, without any other * objects between them. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param sequence the sequence of objects to look for. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given {@code Iterable} does not contain the given sequence of objects. */ public void assertContainsSequence(AssertionInfo info, Iterable<?> actual, Object[] sequence) { if (commonCheckThatIterableAssertionSucceeds(info, actual, sequence)) return; // check for elements in values that are missing in actual. List<?> actualAsList = newArrayList(actual); for (int i = 0; i < actualAsList.size(); i++) { // look for given sequence in actual starting from current index (i) if (containsSequenceAtGivenIndex(actualAsList, sequence, i)) { return; } } throw actualDoesNotContainSequence(info, actual, sequence); }