Verifies that the actual map contains only the given entries and nothing else, in any order. @param info contains information about the assertion. @param actual the given Map. @param entries the entries that should be in the actual map. @throws AssertionError if the actual map is {@code nul
(AssertionInfo info, Map<K, V> actual,
@SuppressWarnings("unchecked") MapEntry<? extends K, ? extends V>... entries)
| 399 | * none of the given entries, or the actual map contains more entries than the given ones. |
| 400 | */ |
| 401 | public <K, V> void assertContainsOnly(AssertionInfo info, Map<K, V> actual, |
| 402 | @SuppressWarnings("unchecked") MapEntry<? extends K, ? extends V>... entries) { |
| 403 | doCommonContainsCheck(info, actual, entries); |
| 404 | if (actual.isEmpty() && entries.length == 0) { |
| 405 | return; |
| 406 | } |
| 407 | failIfEmpty(entries); |
| 408 | |
| 409 | Set<MapEntry<? extends K, ? extends V>> notFound = new LinkedHashSet<MapEntry<? extends K, ? extends V>>(); |
| 410 | Set<MapEntry<? extends K, ? extends V>> notExpected = new LinkedHashSet<MapEntry<? extends K, ? extends V>>(); |
| 411 | |
| 412 | compareActualMapAndExpectedEntries(actual, entries, notExpected, notFound); |
| 413 | |
| 414 | if (notFound.isEmpty() && notExpected.isEmpty()) { |
| 415 | return; |
| 416 | } |
| 417 | |
| 418 | throw failures.failure(info, shouldContainOnly(actual, entries, notFound, notExpected)); |
| 419 | } |
| 420 | |
| 421 | /** |
| 422 | * Verifies that the actual map contains only the given entries and nothing else, <b>in order</b>.<br> |