### Question:
StringPatternMatches { public Matcher next() { int matcherIndex = -1; int charIndex = Integer.MAX_VALUE; for (int n = 0; n < matchers.length; n++) { if (matchers[n] != null) { int start = matchers[n].start(); if (start < charIndex) { charIndex = start; matcherIndex = n; } } } if (matcherIndex == -1) { throw new NoSuchElementException(); } Matcher next = matchers[matcherIndex]; matchers[matcherIndex] = (discard ? null : patterns[matcherIndex].matcher(input)); if (matchers[matcherIndex] != null && (charIndex == input.length() - 1 || !matchers[matcherIndex].find(charIndex + 1))) { matchers[matcherIndex] = null; } return next; } StringPatternMatches(final CharSequence input, final Collection<Pattern> patterns, final boolean discard); Matcher next(); boolean hasNext();  }### Answer:
@Test(expectedExceptions = NoSuchElementException.class) public void testWithNoMatchingMatchersThrowException() throws Exception { Pattern pattern = compile("c"); StringPatternMatches matches = new StringPatternMatches("aaab", asList(pattern), true); matches.next(); }