Slight simplification of MultimapSubject. The private two-arg containsExactly method was called from exactly one place an the failVerb argument was always a fixed string literal. So we might as well simplify things my inlining both the method and the argument.
@@ -169,17 +169,6 @@ public class MultimapSubject extends Subject<MultimapSubject, Multimap<?, ?>> {
@CanIgnoreReturnValue
public Ordered containsExactlyEntriesIn(Multimap<?, ?> expectedMultimap) {
checkNotNull(expectedMultimap, "expectedMultimap");
- return containsExactly("contains exactly", expectedMultimap);
- }
-
- /** @deprecated Use {@link #containsExactlyEntriesIn} instead. */
- @Deprecated
- @CanIgnoreReturnValue
- public Ordered containsExactly(Multimap<?, ?> expectedMultimap) {
- return containsExactlyEntriesIn(expectedMultimap);
- }
-
- private Ordered containsExactly(String failVerb, Multimap<?, ?> expectedMultimap) {
ListMultimap<?, ?> missing = difference(expectedMultimap, actual());
ListMultimap<?, ?> extra = difference(actual(), expectedMultimap);
@@ -188,25 +177,35 @@ public class MultimapSubject extends Subject<MultimapSubject, Multimap<?, ?>> {
if (!missing.isEmpty()) {
if (!extra.isEmpty()) {
failWithRawMessage(
- "Not true that %s %s <%s>. It is missing <%s> and has unexpected items <%s>",
+ "Not true that %s contains exactly <%s>. "
+ + "It is missing <%s> and has unexpected items <%s>",
actualAsString(),
- failVerb,
expectedMultimap,
countDuplicatesMultimap(missing),
countDuplicatesMultimap(extra));
} else {
failWithBadResults(
- failVerb, expectedMultimap, "is missing", countDuplicatesMultimap(missing));
+ "contains exactly", expectedMultimap, "is missing", countDuplicatesMultimap(missing));
}
} else if (!extra.isEmpty()) {
failWithBadResults(
- failVerb, expectedMultimap, "has unexpected items", countDuplicatesMultimap(extra));
+ "contains exactly",
+ expectedMultimap,
+ "has unexpected items",
+ countDuplicatesMultimap(extra));
}
return new MultimapInOrder(expectedMultimap);
}
- private class IterableValuesForKey extends IterableSubject {
+ /** @deprecated Use {@link #containsExactlyEntriesIn} instead. */
+ @Deprecated
+ @CanIgnoreReturnValue
+ public Ordered containsExactly(Multimap<?, ?> expectedMultimap) {
+ return containsExactlyEntriesIn(expectedMultimap);
+ }
+
+ private static class IterableValuesForKey extends IterableSubject {
@Nullable private final Object key;
@Nullable private final String stringRepresentation;
