MCPcopy Index your code
hub / github.com/assertj/assertj / assertContains

Method assertContains

src/main/java/org/assertj/core/internal/Maps.java:189–206  ·  view source on GitHub ↗

Asserts that the given Map contains the given entries, in any order. @param info contains information about the assertion. @param actual the given Map. @param entries the entries that are expected to be in the given Map. @throws NullPointerException if the array of entries i

(AssertionInfo info, Map<K, V> actual, MapEntry<? extends K, ? extends V>[] entries)

Source from the content-addressed store, hash-verified

187 * @throws AssertionError if the given {@code Map} does not contain the given entries.
188 */
189 public <K, V> void assertContains(AssertionInfo info, Map<K, V> actual, MapEntry<? extends K, ? extends V>[] entries) {
190 failIfNull(entries);
191 assertNotNull(info, actual);
192 // if both actual and values are empty, then assertion passes.
193 if (actual.isEmpty() && entries.length == 0)
194 return;
195 failIfEmptySinceActualIsNotEmpty(entries);
196 Set<MapEntry<? extends K, ? extends V>> notFound = new LinkedHashSet<MapEntry<? extends K, ? extends V>>();
197 for (MapEntry<? extends K, ? extends V> entry : entries) {
198 if (!containsEntry(actual, entry)) {
199 notFound.add(entry);
200 }
201 }
202 if (notFound.isEmpty()) {
203 return;
204 }
205 throw failures.failure(info, shouldContain(actual, entries, notFound));
206 }
207
208 /**
209 * Asserts that the given {@code Map} does not contain the given entries.

Calls 7

failIfNullMethod · 0.95
assertNotNullMethod · 0.95
containsEntryMethod · 0.95
isEmptyMethod · 0.65
failureMethod · 0.45
shouldContainMethod · 0.45