File tree Expand file tree Collapse file tree 4 files changed +6
-35
lines changed
test/java/org/hamcrest/collection Expand file tree Collapse file tree 4 files changed +6
-35
lines changed 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<
499
499
* @param elementMatcher the matcher to apply to elements in examined arrays
500
500
*/
501
501
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 );
503
503
}
504
504
505
505
/**
@@ -512,7 +512,7 @@ public static <T> org.hamcrest.Matcher<T[]> hasItemInArray(org.hamcrest.Matcher<
512
512
* @param element the element that should be present in examined arrays
513
513
*/
514
514
public static <T > org .hamcrest .Matcher <T []> hasItemInArray (T element ) {
515
- return org . hamcrest . collection . IsArrayContaining .hasItemInArray (element );
515
+ return MatchArrays .hasItemInArray (element );
516
516
}
517
517
518
518
/**
Original file line number Diff line number Diff line change 6
6
7
7
import java .util .Arrays ;
8
8
9
- import static org .hamcrest .core .IsEqual .equalTo ;
10
-
11
9
/**
12
10
* Matches if an array contains an item satisfying a nested matcher.
13
11
*/
@@ -40,32 +38,4 @@ public void describeTo(Description description) {
40
38
.appendDescriptionOf (elementMatcher );
41
39
}
42
40
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
- }
71
41
}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public static <T> IsArray<T> array(Matcher<? super T>... elementMatchers) {
36
36
* @param elementMatcher the matcher to apply to elements in examined arrays
37
37
*/
38
38
public static <T > Matcher <T []> hasItemInArray (Matcher <? super T > elementMatcher ) {
39
- return IsArrayContaining . hasItemInArray (elementMatcher );
39
+ return new IsArrayContaining <> (elementMatcher );
40
40
}
41
41
42
42
/**
@@ -49,7 +49,7 @@ public static <T> Matcher<T[]> hasItemInArray(Matcher<? super T> elementMatcher)
49
49
* @param element the element that should be present in examined arrays
50
50
*/
51
51
public static <T > Matcher <T []> hasItemInArray (T element ) {
52
- return IsArrayContaining . hasItemInArray (element );
52
+ return hasItemInArray (equalTo ( element ) );
53
53
}
54
54
55
55
/**
Original file line number Diff line number Diff line change 3
3
import org .hamcrest .AbstractMatcherTest ;
4
4
import org .hamcrest .Matcher ;
5
5
6
- import static org .hamcrest .collection .IsArrayContaining .hasItemInArray ;
6
+ import static org .hamcrest .collection .MatchArrays .hasItemInArray ;
7
+
7
8
8
9
public class IsArrayContainingTest extends AbstractMatcherTest {
9
10
You can’t perform that action at this time.
0 commit comments