From 94d215ee60c08f454fb9a5b8d94fd8721697c317 Mon Sep 17 00:00:00 2001 From: George Tay Date: Sun, 21 Jan 2024 13:15:20 +0800 Subject: [PATCH 1/2] Implement JSON object checks --- .../java/reposense/util/SystemTestUtil.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/systemtest/java/reposense/util/SystemTestUtil.java b/src/systemtest/java/reposense/util/SystemTestUtil.java index 6d1ac7a506..7d67551607 100644 --- a/src/systemtest/java/reposense/util/SystemTestUtil.java +++ b/src/systemtest/java/reposense/util/SystemTestUtil.java @@ -7,6 +7,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import org.junit.jupiter.api.Assertions; import com.google.gson.JsonObject; @@ -63,10 +65,16 @@ public static void assertSummaryJson(Path expectedSummaryJsonPath, Path actualSu */ public static void assertJson(Path expectedJsonPath, Path actualJsonPath) { Assertions.assertTrue(Files.exists(actualJsonPath)); - try { - Assertions.assertTrue(TestUtil.compareFileContents(expectedJsonPath, actualJsonPath)); - } catch (Exception e) { - Assertions.fail(e.getMessage()); + + try (FileReader fileReaderExpected = new FileReader(expectedJsonPath.toFile()); + FileReader fileReaderActual = new FileReader(actualJsonPath.toFile())) { + + JsonElement jsonExpected = JsonParser.parseReader(fileReaderExpected); + JsonElement jsonActual = JsonParser.parseReader(fileReaderActual); + + Assertions.assertEquals(jsonExpected, jsonActual); + } catch (IOException ex) { + Assertions.fail(ex.getMessage()); } } } From f98c571050ff6de57fcb8b6387654eba0a549e91 Mon Sep 17 00:00:00 2001 From: George Tay Date: Sun, 21 Jan 2024 13:16:43 +0800 Subject: [PATCH 2/2] Fix checkstyle mistakes --- src/systemtest/java/reposense/util/SystemTestUtil.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/systemtest/java/reposense/util/SystemTestUtil.java b/src/systemtest/java/reposense/util/SystemTestUtil.java index 7d67551607..722d767758 100644 --- a/src/systemtest/java/reposense/util/SystemTestUtil.java +++ b/src/systemtest/java/reposense/util/SystemTestUtil.java @@ -7,10 +7,9 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import org.junit.jupiter.api.Assertions; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser;