org.assertj.core.internal
Class Maps

java.lang.Object
  extended by org.assertj.core.internal.Maps

public class Maps
extends Object

Reusable assertions for Maps.

Author:
Alex Ruiz, Nicolas François

Method Summary
 void assertContains(AssertionInfo info, Map<?,?> actual, MapEntry[] entries)
          Asserts that the given Map contains the given entries, in any order.
<K,V> void
assertContainsExactly(AssertionInfo info, Map<K,V> actual, MapEntry... entries)
          Verifies that the actual map contains only the given entries and nothing else, in order.
This assertion should only be used with map that have a consistent iteration order (i.e.
<K,V> void
assertContainsKeys(AssertionInfo info, Map<K,V> actual, K... keys)
          Verifies that the actual map contain the given key.
<K,V> void
assertContainsOnly(AssertionInfo info, Map<K,V> actual, MapEntry... entries)
          Verifies that the actual map contains only the given entries and nothing else, in any order.
<K,V> void
assertContainsOnlyKeys(AssertionInfo info, Map<K,V> actual, K... keys)
          Verifies that the actual map contains only the given keys and nothing else, in any order.
<K,V> void
assertContainsValue(AssertionInfo info, Map<K,V> actual, V value)
          Verifies that the actual map contain the given value.
 void assertDoesNotContain(AssertionInfo info, Map<?,?> actual, MapEntry[] entries)
          Asserts that the given Map does not contain the given entries.
<K,V> void
assertDoesNotContainKey(AssertionInfo info, Map<K,V> actual, K key)
          Verifies that the actual map not contains the given key.
<K,V> void
assertDoesNotContainValue(AssertionInfo info, Map<K,V> actual, V value)
          Verifies that the actual map not contains the given value.
 void assertEmpty(AssertionInfo info, Map<?,?> actual)
          Asserts that the given Map is empty.
 void assertHasSameSizeAs(AssertionInfo info, Map<?,?> map, Iterable<?> other)
          Asserts that the number of entries in the given Map has the same size as the other Iterable.
 void assertHasSameSizeAs(AssertionInfo info, Map<?,?> map, Map<?,?> other)
          Asserts that the size of the given Map is equal to the size of the other Map.
 void assertHasSameSizeAs(AssertionInfo info, Map<?,?> map, Object other)
          Asserts that the number of entries in the given Map has the same size as the other array.
 void assertHasSize(AssertionInfo info, Map<?,?> actual, int expectedSize)
          Asserts that the number of entries in the given Map is equal to the expected one.
 void assertNotEmpty(AssertionInfo info, Map<?,?> actual)
          Asserts that the given Map is not empty.
 void assertNullOrEmpty(AssertionInfo info, Map<?,?> actual)
          Asserts that the given Map is null or empty.
static Maps instance()
          Returns the singleton instance of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static Maps instance()
Returns the singleton instance of this class.

Returns:
the singleton instance of this class.

assertNullOrEmpty

public void assertNullOrEmpty(AssertionInfo info,
                              Map<?,?> actual)
Asserts that the given Map is null or empty.

Parameters:
info - contains information about the assertion.
actual - the given map.
Throws:
AssertionError - if the given Map is not null *and* contains one or more entries.

assertEmpty

public void assertEmpty(AssertionInfo info,
                        Map<?,?> actual)
Asserts that the given Map is empty.

Parameters:
info - contains information about the assertion.
actual - the given Map.
Throws:
AssertionError - if the given Map is null.
AssertionError - if the given Map is not empty.

assertNotEmpty

public void assertNotEmpty(AssertionInfo info,
                           Map<?,?> actual)
Asserts that the given Map is not empty.

Parameters:
info - contains information about the assertion.
actual - the given Map.
Throws:
AssertionError - if the given Map is null.
AssertionError - if the given Map is empty.

assertHasSize

public void assertHasSize(AssertionInfo info,
                          Map<?,?> actual,
                          int expectedSize)
Asserts that the number of entries in the given Map is equal to the expected one.

Parameters:
info - contains information about the assertion.
actual - the given Map.
expectedSize - the expected size of actual.
Throws:
AssertionError - if the given Map is null.
AssertionError - if the number of entries in the given Map is different than the expected one.

assertHasSameSizeAs

public void assertHasSameSizeAs(AssertionInfo info,
                                Map<?,?> map,
                                Iterable<?> other)
Asserts that the number of entries in the given Map has the same size as the other Iterable.

Parameters:
info - contains information about the assertion.
map - the given Map.
other - the group to compare
Throws:
AssertionError - if the given Map is null.
AssertionError - if the given Iterable is null.
AssertionError - if the number of entries in the given Map does not have the same size.

assertHasSameSizeAs

public void assertHasSameSizeAs(AssertionInfo info,
                                Map<?,?> map,
                                Object other)
Asserts that the number of entries in the given Map has the same size as the other array.

Parameters:
info - contains information about the assertion.
map - the given Map.
other - the group to compare
Throws:
AssertionError - if the given Map is null.
AssertionError - if the given array is null.
AssertionError - if the number of entries in the given Map does not have the same size.

assertHasSameSizeAs

public void assertHasSameSizeAs(AssertionInfo info,
                                Map<?,?> map,
                                Map<?,?> other)
Asserts that the size of the given Map is equal to the size of the other Map.

Parameters:
info - contains information about the assertion.
map - the given Map.
other - the other Map to compare
Throws:
NullPointerException - if the other Map is null.
AssertionError - if the given Map is null.
AssertionError - if the size of the given Map is not equal to the other Map size

assertContains

public void assertContains(AssertionInfo info,
                           Map<?,?> actual,
                           MapEntry[] entries)
Asserts that the given Map contains the given entries, in any order.

Parameters:
info - contains information about the assertion.
actual - the given Map.
entries - the entries that are expected to be in the given Map.
Throws:
NullPointerException - if the array of entries is null.
IllegalArgumentException - if the array of entries is empty.
NullPointerException - if any of the entries in the given array is null.
AssertionError - if the given Map is null.
AssertionError - if the given Map does not contain the given entries.

assertDoesNotContain

public void assertDoesNotContain(AssertionInfo info,
                                 Map<?,?> actual,
                                 MapEntry[] entries)
Asserts that the given Map does not contain the given entries.

Parameters:
info - contains information about the assertion.
actual - the given Map.
entries - the entries that are expected to be in the given Map.
Throws:
NullPointerException - if the array of entries is null.
IllegalArgumentException - if the array of entries is empty.
NullPointerException - if any of the entries in the given array is null.
AssertionError - if the given Map is null.
AssertionError - if the given Map contains any of the given entries.

assertContainsKeys

public <K,V> void assertContainsKeys(AssertionInfo info,
                                     Map<K,V> actual,
                                     K... keys)
Verifies that the actual map contain the given key.

Parameters:
info - contains information about the assertion.
actual - the given Map.
keys - the given keys
Throws:
AssertionError - if the actual map is null.
AssertionError - if the actual map not contains the given key.

assertDoesNotContainKey

public <K,V> void assertDoesNotContainKey(AssertionInfo info,
                                          Map<K,V> actual,
                                          K key)
Verifies that the actual map not contains the given key.

Parameters:
info - contains information about the assertion.
actual - the given Map.
key - the given key
Throws:
AssertionError - if the actual map is null.
AssertionError - if the actual map contains the given key.

assertContainsOnlyKeys

public <K,V> void assertContainsOnlyKeys(AssertionInfo info,
                                         Map<K,V> actual,
                                         K... keys)
Verifies that the actual map contains only the given keys and nothing else, in any order.

Parameters:
info - contains information about the assertion.
actual - the given Map.
keys - the keys that are expected to be in the given Map.
Throws:
NullPointerException - if the array of keys is null.
IllegalArgumentException - if the array of keys is empty.
AssertionError - if the given Map is null.
AssertionError - if the given Map does not contain the given keys or if the given Map contains keys that are not in the given array.

assertContainsValue

public <K,V> void assertContainsValue(AssertionInfo info,
                                      Map<K,V> actual,
                                      V value)
Verifies that the actual map contain the given value.

Parameters:
info - contains information about the assertion.
actual - the given Map.
value - the given value
Throws:
AssertionError - if the actual map is null.
AssertionError - if the actual map not contains the given value.

assertDoesNotContainValue

public <K,V> void assertDoesNotContainValue(AssertionInfo info,
                                            Map<K,V> actual,
                                            V value)
Verifies that the actual map not contains the given value.

Parameters:
info - contains information about the assertion.
actual - the given Map.
value - the given value
Throws:
AssertionError - if the actual map is null.
AssertionError - if the actual map contains the given value.

assertContainsOnly

public <K,V> void assertContainsOnly(AssertionInfo info,
                                     Map<K,V> actual,
                                     MapEntry... entries)
Verifies that the actual map contains only the given entries and nothing else, in any order.

Parameters:
info - contains information about the assertion.
actual - the given Map.
entries - the entries that should be in the actual map.
Throws:
AssertionError - if the actual map is null.
NullPointerException - if the given entries array is null.
IllegalArgumentException - if the given entries array is empty.
AssertionError - if the actual map does not contain the given entries, i.e. the actual map contains some or none of the given entries, or the actual map contains more entries than the given ones.

assertContainsExactly

public <K,V> void assertContainsExactly(AssertionInfo info,
                                        Map<K,V> actual,
                                        MapEntry... entries)
Verifies that the actual map contains only the given entries and nothing else, in order.
This assertion should only be used with map that have a consistent iteration order (i.e. don't use it with HashMap).

Parameters:
info - contains information about the assertion.
actual - the given Map.
entries - the given entries.
Throws:
NullPointerException - if the given entries array is null.
AssertionError - if the actual map is null.
IllegalArgumentException - if the given entries array is empty.
AssertionError - if the actual map does not contain the given entries with same order, i.e. the actual map contains some or none of the given entries, or the actual map contains more entries than the given ones or entries are the same but the order is not.


Copyright © 2013–2015 AssertJ. All rights reserved.