File tree Expand file tree Collapse file tree
test/java/org/hamcrest/collection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -499,7 +499,7 @@ public static <T> org.hamcrest.collection.IsArray<T> array(org.hamcrest.Matcher<
499499 * @param elementMatcher the matcher to apply to elements in examined arrays
500500 */
501501 public static <T > org .hamcrest .Matcher <T []> hasItemInArray (org .hamcrest .Matcher <? super T > elementMatcher ) {
502- return org . hamcrest . collection . IsArrayContaining .hasItemInArray (elementMatcher );
502+ return MatchArrays .hasItemInArray (elementMatcher );
503503 }
504504
505505 /**
@@ -512,7 +512,7 @@ public static <T> org.hamcrest.Matcher<T[]> hasItemInArray(org.hamcrest.Matcher<
512512 * @param element the element that should be present in examined arrays
513513 */
514514 public static <T > org .hamcrest .Matcher <T []> hasItemInArray (T element ) {
515- return org . hamcrest . collection . IsArrayContaining .hasItemInArray (element );
515+ return MatchArrays .hasItemInArray (element );
516516 }
517517
518518 /**
Original file line number Diff line number Diff line change 66
77import java .util .Arrays ;
88
9- import static org .hamcrest .core .IsEqual .equalTo ;
10-
119/**
1210 * Matches if an array contains an item satisfying a nested matcher.
1311 */
@@ -40,32 +38,4 @@ public void describeTo(Description description) {
4038 .appendDescriptionOf (elementMatcher );
4139 }
4240
43- /**
44- * Creates a matcher for arrays that matches when the examined array contains at least one item
45- * that is matched by the specified <code>elementMatcher</code>. Whilst matching, the traversal
46- * of the examined array will stop as soon as a matching element is found.
47- * For example:
48- * <pre>assertThat(new String[] {"foo", "bar"}, hasItemInArray(startsWith("ba")))</pre>
49- *
50- * @param elementMatcher
51- * the matcher to apply to elements in examined arrays
52- */
53- public static <T > Matcher <T []> hasItemInArray (Matcher <? super T > elementMatcher ) {
54- return new IsArrayContaining <>(elementMatcher );
55- }
56-
57- /**
58- * A shortcut to the frequently used <code>hasItemInArray(equalTo(x))</code>.
59- * For example:
60- * <pre>assertThat(hasItemInArray(x))</pre>
61- * instead of:
62- * <pre>assertThat(hasItemInArray(equalTo(x)))</pre>
63- *
64- * @param element
65- * the element that should be present in examined arrays
66- */
67- public static <T > Matcher <T []> hasItemInArray (T element ) {
68- Matcher <? super T > matcher = equalTo (element );
69- return IsArrayContaining .hasItemInArray (matcher );
70- }
7141}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public static <T> IsArray<T> array(Matcher<? super T>... elementMatchers) {
3636 * @param elementMatcher the matcher to apply to elements in examined arrays
3737 */
3838 public static <T > Matcher <T []> hasItemInArray (Matcher <? super T > elementMatcher ) {
39- return IsArrayContaining . hasItemInArray (elementMatcher );
39+ return new IsArrayContaining <> (elementMatcher );
4040 }
4141
4242 /**
@@ -49,7 +49,7 @@ public static <T> Matcher<T[]> hasItemInArray(Matcher<? super T> elementMatcher)
4949 * @param element the element that should be present in examined arrays
5050 */
5151 public static <T > Matcher <T []> hasItemInArray (T element ) {
52- return IsArrayContaining . hasItemInArray (element );
52+ return hasItemInArray (equalTo ( element ) );
5353 }
5454
5555 /**
Original file line number Diff line number Diff line change 33import org .hamcrest .AbstractMatcherTest ;
44import org .hamcrest .Matcher ;
55
6- import static org .hamcrest .collection .IsArrayContaining .hasItemInArray ;
6+ import static org .hamcrest .collection .MatchArrays .hasItemInArray ;
7+
78
89public class IsArrayContainingTest extends AbstractMatcherTest {
910
You can’t perform that action at this time.
0 commit comments