From 300d110d93e9aa8ed91d060cedae47231106c31c Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 26 Mar 2016 09:33:55 +0000 Subject: Replace usages of Iterables.transform with appropriate map methods --- .../mammoth/tests/DeepReflectionMatcher.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/test/java/org') diff --git a/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java b/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java index 3b36482..dff85a8 100644 --- a/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java +++ b/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java @@ -14,8 +14,8 @@ import java.util.Set; import static com.google.common.collect.Iterables.any; import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; import static java.util.Arrays.asList; +import static org.zwobble.mammoth.internal.util.MammothIterables.lazyMap; public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { public static Matcher deepEquals(T value) { @@ -77,14 +77,14 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { if (actual.size() > expected.size()) { appendPath(mismatchDescription, path); mismatchDescription.appendText("extra elements:" + - indentedList(transform(Iterables.skip(actual, expected.size()), DeepReflectionMatcher::describeValue))); + indentedList(lazyMap(Iterables.skip(actual, expected.size()), DeepReflectionMatcher::describeValue))); return false; } if (actual.size() < expected.size()) { appendPath(mismatchDescription, path); mismatchDescription.appendText("missing elements:" + - indentedList(transform(Iterables.skip(expected, actual.size()), DeepReflectionMatcher::describeValue))); + indentedList(lazyMap(Iterables.skip(expected, actual.size()), DeepReflectionMatcher::describeValue))); return false; } @@ -105,7 +105,7 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { if (!missing.isEmpty()) { appendPath(mismatchDescription, path); mismatchDescription.appendText("missing elements:" + - indentedList(transform(missing, DeepReflectionMatcher::describeValue))); + indentedList(lazyMap(missing, DeepReflectionMatcher::describeValue))); return false; } @@ -116,7 +116,7 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { if (!extra.isEmpty()) { appendPath(mismatchDescription, path); mismatchDescription.appendText("extra elements:" + - indentedList(transform(extra, DeepReflectionMatcher::describeValue))); + indentedList(lazyMap(extra, DeepReflectionMatcher::describeValue))); return false; } @@ -145,7 +145,7 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { if (!extraElements.isEmpty()) { appendPath(mismatchDescription, path); mismatchDescription.appendText(prefix + - indentedList(transform( + indentedList(lazyMap( extraElements, key -> describeValue(key) + "=" + describeValue(actual.get(key))))); return false; @@ -205,21 +205,21 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { } } else if (value instanceof List) { List list = (List)value; - return "[" + indentedList(transform(list, DeepReflectionMatcher::describeValue)) + "]"; + return "[" + indentedList(lazyMap(list, DeepReflectionMatcher::describeValue)) + "]"; } else if (value instanceof Set) { Set list = (Set)value; - return "{" + indentedList(transform(list, DeepReflectionMatcher::describeValue)) + "}"; + return "{" + indentedList(lazyMap(list, DeepReflectionMatcher::describeValue)) + "}"; } else if (value instanceof Map) { Map map = (Map)value; String entries = indentedList( - transform( + lazyMap( map.entrySet(), entry -> describeValue(entry.getKey()) + "=" + describeValue(entry.getValue()))); return "{" + entries + "}"; } else { Class clazz = value.getClass(); List fields = fields(clazz); - Iterable fieldStrings = transform( + Iterable fieldStrings = lazyMap( fields, field -> field.getName() + "=" + describeValue(readField(value, field))); return String.format("%s(%s)", clazz.getSimpleName(), indentedList(fieldStrings)); @@ -227,7 +227,7 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { } private static String indentedList(Iterable values) { - return String.join(",", transform(values, value -> "\n " + indent(value))); + return String.join(",", lazyMap(values, value -> "\n " + indent(value))); } private static String indent(String value) { -- cgit v1.2.3