11package org .hamcrest .collection ;
22
3- import org .hamcrest .AbstractMatcherTest ;
4- import org .hamcrest .Matcher ;
5-
63import java .util .ArrayList ;
7- import java .util .Arrays ;
84import java .util .Collection ;
95
6+ import org .hamcrest .AbstractMatcherTest ;
7+ import org .hamcrest .Matcher ;
8+
9+ import static java .util .Arrays .asList ;
1010import static org .hamcrest .collection .IsEmptyCollection .empty ;
1111import static org .hamcrest .core .Is .is ;
1212
1313public class IsEmptyCollectionTest extends AbstractMatcherTest {
1414
1515 @ Override
16- protected Matcher <? > createMatcher () {
16+ protected Matcher <Collection <?> > createMatcher () {
1717 return empty ();
1818 }
1919
2020 public void testMatchesAnEmptyCollection () {
21- assertMatches ("empty collection" , empty (), Arrays . asList ());
21+ assertMatches ("empty collection" , createMatcher (), emptyCollection ());
2222 }
2323
2424 public void testDoesNotMatchACollectionWithAnItem () {
25- assertMismatchDescription ("<[one, three]>" , is (empty ()), collectionOfValues ());
25+ assertMismatchDescription ("<[one, three]>" , is (createMatcher ()), collectionOfValues ());
2626 }
2727
2828 public void testHasAReadableDescription () {
29- assertDescription ("an empty collection" , empty ());
29+ assertDescription ("an empty collection" , createMatcher ());
30+ }
31+
32+ private static Collection <String > collectionOfValues () {
33+ return new ArrayList <String >(asList ("one" , "three" ));
3034 }
3135
32- private static Collection <Object > collectionOfValues () {
33- return new ArrayList <Object >() {{ add ( "one" ); add ( "three" ); }} ;
36+ private static Collection <Integer > emptyCollection () {
37+ return new ArrayList <Integer >();
3438 }
35- }
39+ }
0 commit comments