|
12 | 12 | import java.io.InputStream;
|
13 | 13 | import java.io.InputStreamReader;
|
14 | 14 | import java.util.*;
|
| 15 | +import java.util.function.Consumer; |
| 16 | +import java.util.function.Function; |
15 | 17 | import java.util.stream.Collectors;
|
16 | 18 |
|
17 | 19 | import static org.junit.Assert.assertEquals;
|
@@ -78,14 +80,12 @@ public void reserializeLibrary() {
|
78 | 80 | private void assertEquivalentLionWebJson(JsonArray expected, JsonArray actual) {
|
79 | 81 | Map<String, JsonObject> expectedElements = new HashMap<>();
|
80 | 82 | Map<String, JsonObject> actualElements = new HashMap<>();
|
81 |
| - expected.forEach(e -> { |
| 83 | + Function<Map<String, JsonObject>, Consumer<JsonElement>> idCollector = collection -> e -> { |
82 | 84 | String id = e.getAsJsonObject().get("id").getAsString();
|
83 |
| - expectedElements.put(id, e.getAsJsonObject()); |
84 |
| - }); |
85 |
| - actual.forEach(e -> { |
86 |
| - String id = e.getAsJsonObject().get("id").getAsString(); |
87 |
| - actualElements.put(id, e.getAsJsonObject()); |
88 |
| - }); |
| 85 | + collection.put(id, e.getAsJsonObject()); |
| 86 | + }; |
| 87 | + expected.forEach(idCollector.apply(expectedElements)); |
| 88 | + actual.forEach(idCollector.apply(actualElements)); |
89 | 89 | Set<String> unexpectedIDs = new HashSet<>(actualElements.keySet());
|
90 | 90 | unexpectedIDs.removeAll(expectedElements.keySet());
|
91 | 91 | Set<String> missingIDs = new HashSet<>(expectedElements.keySet());
|
|
0 commit comments