X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=nbinotifications%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnbinotifications%2Fserialization%2FNotificationServiceSerializerTest.java;h=4a4868bbd29d36a66f69bcd44da38b910de70372;hb=274148a8d813140f86e1f9770ba992b072c1a5cd;hp=3fe658b6bdafd1a46c69bf82e1d7a447817310e1;hpb=de218a942bf32f32e41d37b1f49f9a35e86d5dc0;p=transportpce.git diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java index 3fe658b6b..4a4868bbd 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java @@ -10,6 +10,8 @@ package org.opendaylight.transportpce.nbinotifications.serialization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -18,7 +20,7 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; @@ -26,11 +28,11 @@ public class NotificationServiceSerializerTest extends AbstractTest { @Test public void serializeTest() throws IOException { - JsonStringConverter converter = + JsonStringConverter converter = new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices()); String json = Files.readString(Paths.get("src/test/resources/event.json")); - NotificationService notificationService = converter - .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationService.QNAME), + NotificationProcessService notificationService = converter + .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationProcessService.QNAME), json, JSONCodecFactorySupplier.RFC7951); NotificationServiceSerializer serializer = new NotificationServiceSerializer(); Map configs = Map.of(ConfigConstants.CONVERTER, converter); @@ -39,6 +41,8 @@ public class NotificationServiceSerializerTest extends AbstractTest { serializer.close(); assertNotNull("Serialized data should not be null", data); 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("The event should be equals", expectedJson, new String(data, StandardCharsets.UTF_8)); } }