diff options
author | gjoranv <gv@verizonmedia.com> | 2021-10-19 17:54:12 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2021-10-20 10:57:38 +0200 |
commit | 78b40a7fdca63183442e2a498cda6ae04dd8f5a8 (patch) | |
tree | ffa4fe235e6849ae76f726135dc54408145c50fe /testutil/src | |
parent | 3485d5e1bf9794e19b255fe5ea764bcd08adb857 (diff) |
Compare json strings with Jackson instead of obscure & abandonded lib.
Diffstat (limited to 'testutil/src')
-rw-r--r-- | testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java b/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java index 08afb2fd95f..05532d2a504 100644 --- a/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java +++ b/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java @@ -5,11 +5,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Joiner; -import org.hamcrest.MatcherAssert; import java.io.UncheckedIOException; -import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; +import static org.junit.Assert.assertEquals; /** * @author Vegard Sjonfjell @@ -29,7 +28,13 @@ public class JsonTestHelper { /** Structurally compare two JSON encoded strings */ public static void assertJsonEquals(String inputJson, String expectedJson) { - MatcherAssert.assertThat(inputJson, sameJSONAs(expectedJson)); + try { + JsonNode expected = mapper.readTree(expectedJson); + JsonNode actual = mapper.readTree(inputJson); + assertEquals(expected, actual); + } catch (JsonProcessingException e) { + throw new RuntimeException("Exception when comparing json strings." , e); + } } /** Structurally compare a {@link JsonNode} and a JSON string. */ |