Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
fslev committed Oct 2, 2022
1 parent 2399edc commit e7071d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/io/json/compare/JSONCompare.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public static void assertMatches(Object expected, Object actual, JsonComparator
List<String> diffs = new JsonMatcher(expectedJson, actualJson,
comparator == null ? new DefaultJsonComparator() : comparator, compareModes).match();
if (!diffs.isEmpty()) {
String defaultMessage = String.format("FOUND %s DIFFERENCE(S):\n\n%s\n",
diffs.size(), String.join("\n_____________________________________\n", diffs));
String defaultMessage = String.format("FOUND %s DIFFERENCE(S):\n%s\n",
diffs.size(), diffs.stream().map(diff ->
"\n_________________________DIFF__________________________\n" + diff).reduce(String::concat).get());
if (comparator == null || comparator.getClass().equals(DefaultJsonComparator.class)) {
defaultMessage += "\n\n" + ASSERTION_ERROR_HINT_MESSAGE + "\n";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public void checkInvalidOrNotFoundJsonPathErrorMessage() {
} catch (AssertionError e) {
assertTrue(e.getMessage().contains("FOUND 1 DIFFERENCE(S):\n" +
"\n" +
"_________________________DIFF__________________________\n" +
"a -> a1 -> a11 -> json path ('$.idontexist') -> No results for path: $['idontexist']"));
return;
}
Expand Down

0 comments on commit e7071d0

Please sign in to comment.