Add JSON assert dependency 50/107350/6
authorBalagangadhar (Bala) Bathula <bb4341@att.com>
Tue, 17 Oct 2023 20:04:33 +0000 (16:04 -0400)
committerBalagangadhar (Bala) Bathula <bb4341@att.com>
Fri, 20 Oct 2023 15:57:26 +0000 (11:57 -0400)
Change-Id: I88d9f57683dd90965a70f12aac4b705291769a0a
Signed-off-by: Balagangadhar (Bala) Bathula <bb4341@att.com>
nbinotifications/pom.xml
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java

index 650ba41d10287da6b54398395e29904ff7f92e41..fb3b39a042cbfb7cf8ad8838f86604bb2d97d98c 100644 (file)
       <artifactId>jackson-databind</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.skyscreamer</groupId>
+      <artifactId>jsonassert</artifactId>
+      <version>1.5.1</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
index 8b267970bd4b28f8f717cdad5edfd0d96ed28179..d00845a09eb3b0c9a393b11844fda43ff93b9470 100755 (executable)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.transportpce.nbinotifications.serialization;
 
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.fasterxml.jackson.databind.JsonNode;
@@ -18,17 +16,19 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Map;
+import org.json.JSONException;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
+import org.skyscreamer.jsonassert.JSONAssert;
 
 public class NotificationAlarmServiceSerializerTest extends AbstractTest {
 
     @Test
-    void serializeTest() throws IOException {
+    void serializeTest() throws IOException, JSONException {
         JsonStringConverter<NotificationAlarmService> converter =
                 new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         String json = Files.readString(Paths.get("src/test/resources/event_alarm_service.json"));
@@ -44,6 +44,6 @@ public class NotificationAlarmServiceSerializerTest extends AbstractTest {
         String expectedJson = Files.readString(Paths.get("src/test/resources/expected_event_alarm_service.json"));
         // Minify the json string
         expectedJson = new ObjectMapper().readValue(expectedJson, JsonNode.class).toString();
-        assertEquals(expectedJson, new String(data, StandardCharsets.UTF_8), "The event should be equals");
+        JSONAssert.assertEquals(expectedJson, new String(data, StandardCharsets.UTF_8), true);
     }
 }
index 0a15d9ebc5e14a11599f641a30c136216cd788e3..0d6cb935863730ed6d2c6f8f62be2b641fb54d1a 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.transportpce.nbinotifications.serialization;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.fasterxml.jackson.databind.JsonNode;
@@ -17,17 +16,19 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Map;
+import org.json.JSONException;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
+import org.skyscreamer.jsonassert.JSONAssert;
 
 public class NotificationServiceSerializerTest extends AbstractTest {
 
     @Test
-    void serializeTest() throws IOException {
+    void serializeTest() throws IOException, JSONException {
         JsonStringConverter<NotificationProcessService> converter =
                 new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
         String json = Files.readString(Paths.get("src/test/resources/event.json"));
@@ -43,6 +44,6 @@ public class NotificationServiceSerializerTest extends AbstractTest {
         String expectedJson = Files.readString(Paths.get("src/test/resources/expected_event.json"));
         // Minify the json string
         expectedJson = new ObjectMapper().readValue(expectedJson, JsonNode.class).toString();
-        assertEquals(expectedJson, new String(data, StandardCharsets.UTF_8), "The event should be equals");
+        JSONAssert.assertEquals(expectedJson, new String(data, StandardCharsets.UTF_8), true);
     }
 }