org.fest.assertions
Class MapAssert

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.GenericAssert<S,A>
          extended by org.fest.assertions.GroupAssert<MapAssert,Map<?,?>>
              extended by org.fest.assertions.MapAssert

public class MapAssert
extends GroupAssert<MapAssert,Map<?,?>>

Assertions for Maps.

To create a new instance of this class invoke Assertions.assertThat(Map).

Author:
David DIDIER, Yvonne Wang, Alex Ruiz

Nested Class Summary
static class MapAssert.Entry
          An entry in a Map.
 
Field Summary
 
Fields inherited from class org.fest.assertions.GenericAssert
actual, myself
 
Constructor Summary
protected MapAssert(Map<?,?> actual)
          Creates a new MapAssert.
 
Method Summary
protected  int actualGroupSize()
          Returns the number of elements in the actual Map.
static MapAssert.Entry entry(Object key, Object value)
          Creates a new map entry.
 MapAssert excludes(MapAssert.Entry... entries)
          Verifies that the actual Map does not contain the given entries.
 MapAssert includes(MapAssert.Entry... entries)
          Verifies that the actual Map contains the given entries.
 
Methods inherited from class org.fest.assertions.GroupAssert
hasSize, isEmpty, isNotEmpty, isNullOrEmpty
 
Methods inherited from class org.fest.assertions.GenericAssert
as, as, describedAs, describedAs, doesNotSatisfy, is, isEqualTo, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs, overridingErrorMessage, satisfies
 
Methods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapAssert

protected MapAssert(Map<?,?> actual)
Creates a new MapAssert.

Parameters:
actual - the target to verify.
Method Detail

includes

public MapAssert includes(MapAssert.Entry... entries)
Verifies that the actual Map contains the given entries.

Example:

 // static import org.fest.assertions.Assertions.*;
 // static import org.fest.assertions.MapAssert.*;

 assertThat(myMap).includes(entry("jedi", yoda), entry("sith", anakin));
 

Parameters:
entries - the given entries.
Returns:
this assertion error.
Throws:
AssertionError - if the actual map is null.
AssertionError - if the actual Map does not contain any of the given entries.
NullPointerException - if the given array of entries is null.
NullPointerException - if any of the entries in the given array is null.

excludes

public MapAssert excludes(MapAssert.Entry... entries)
Verifies that the actual Map does not contain the given entries.

Example:

 // static import org.fest.assertions.Assertions.*;
 // static import org.fest.assertions.MapAssert.*;

 assertThat(myMap).excludes(entry("jedi", yoda), entry("sith", anakin));
 

Parameters:
entries - the given entries.
Returns:
this assertion error.
Throws:
AssertionError - if the actual map is null.
AssertionError - if the actual Map contains any of the given entries.
NullPointerException - if the given array of entries is null.
NullPointerException - if any of the entries in the given array is null.

entry

public static MapAssert.Entry entry(Object key,
                                    Object value)
Creates a new map entry.

Parameters:
key - the key of the entry.
value - the value of the entry.
Returns:
the created entry.
See Also:
includes(org.fest.assertions.MapAssert.Entry...)

actualGroupSize

protected int actualGroupSize()
Returns the number of elements in the actual Map.

Specified by:
actualGroupSize in class GroupAssert<MapAssert,Map<?,?>>
Returns:
the number of elements in the actual Map.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.