org.hamcrest.collection
Class IsMapWithSize<K,V>

java.lang.Object
  extended by org.hamcrest.BaseMatcher<T>
      extended by org.hamcrest.TypeSafeDiagnosingMatcher<T>
          extended by org.hamcrest.FeatureMatcher<Map<? extends K,? extends V>,Integer>
              extended by org.hamcrest.collection.IsMapWithSize<K,V>
All Implemented Interfaces:
Matcher<Map<? extends K,? extends V>>, SelfDescribing

public final class IsMapWithSize<K,V>
extends FeatureMatcher<Map<? extends K,? extends V>,Integer>

Matches if map size satisfies a nested matcher.


Constructor Summary
IsMapWithSize(Matcher<? super Integer> sizeMatcher)
           
 
Method Summary
static
<K,V> Matcher<Map<? extends K,? extends V>>
aMapWithSize(int size)
          Creates a matcher for Maps that matches when the size() method returns a value equal to the specified size.
static
<K,V> Matcher<Map<? extends K,? extends V>>
aMapWithSize(Matcher<? super Integer> sizeMatcher)
          Creates a matcher for Maps that matches when the size() method returns a value that satisfies the specified matcher.
static
<K,V> Matcher<Map<? extends K,? extends V>>
anEmptyMap()
          Creates a matcher for Maps that matches when the size() method returns zero.
protected  Integer featureValueOf(Map<? extends K,? extends V> actual)
           
 
Methods inherited from class org.hamcrest.FeatureMatcher
describeTo, matchesSafely
 
Methods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher
describeMismatch, matches
 
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IsMapWithSize

public IsMapWithSize(Matcher<? super Integer> sizeMatcher)
Method Detail

featureValueOf

protected Integer featureValueOf(Map<? extends K,? extends V> actual)
Specified by:
featureValueOf in class FeatureMatcher<Map<? extends K,? extends V>,Integer>

aMapWithSize

public static <K,V> Matcher<Map<? extends K,? extends V>> aMapWithSize(Matcher<? super Integer> sizeMatcher)
Creates a matcher for Maps that matches when the size() method returns a value that satisfies the specified matcher.

For example:

assertThat(myMap, is(aMapWithSize(equalTo(2))))

Parameters:
sizeMatcher - a matcher for the size of an examined Map

aMapWithSize

public static <K,V> Matcher<Map<? extends K,? extends V>> aMapWithSize(int size)
Creates a matcher for Maps that matches when the size() method returns a value equal to the specified size.

For example:

assertThat(myMap, is(aMapWithSize(2)))

Parameters:
size - the expected size of an examined Map

anEmptyMap

public static <K,V> Matcher<Map<? extends K,? extends V>> anEmptyMap()
Creates a matcher for Maps that matches when the size() method returns zero.

For example:

assertThat(myMap, is(anEmptyMap()))



Copyright © 2014. All rights reserved.