From 5256e00aabfa9859dfc453f773f27e1e812cf446 Mon Sep 17 00:00:00 2001 From: EdwinIngJ Date: Mon, 13 Oct 2025 00:52:18 -0500 Subject: [PATCH] Used JSONAssert for comparison of JSON strings to fix flaky test --- .../tracking/ws/CargoTrackingRestServiceIntegrationTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/se/citerus/dddsample/interfaces/tracking/ws/CargoTrackingRestServiceIntegrationTest.java b/src/test/java/se/citerus/dddsample/interfaces/tracking/ws/CargoTrackingRestServiceIntegrationTest.java index 82e19d61d..a0fd86f2e 100644 --- a/src/test/java/se/citerus/dddsample/interfaces/tracking/ws/CargoTrackingRestServiceIntegrationTest.java +++ b/src/test/java/se/citerus/dddsample/interfaces/tracking/ws/CargoTrackingRestServiceIntegrationTest.java @@ -3,6 +3,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.RequestEntity; @@ -49,7 +51,7 @@ void shouldReturn200ResponseAndJsonWhenRequestingCargoWithIdABC123() throws Exce assertThat(response.getStatusCode().value()).isEqualTo(200); String expected = StreamUtils.copyToString(getClass().getResourceAsStream("/sampleCargoTrackingResponse.json"), StandardCharsets.UTF_8); assertThat(response.getHeaders().get("Content-Type")).containsExactly("application/json"); - assertThat(response.getBody()).isEqualTo(expected); + JSONAssert.assertEquals(expected, response.getBody(), JSONCompareMode.STRICT); } @Test