X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Frestconf-nb-rfc8040%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fnb%2Frfc8040%2Fstreams%2Flisteners%2FJsonNotificationListenerTest.java;fp=restconf%2Frestconf-nb-rfc8040%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fnb%2Frfc8040%2Fstreams%2Flisteners%2FNotificationListenerTest.java;h=093f11724a78f09616640a2c98e8492668fe9556;hb=40ff777cd15b7146fea5c498a883065d60cb5bde;hp=a964815b6789a283884bea225be7f624ce52c4d9;hpb=a8a56843c3dc31f61a01d6eff31cb79a5381398a;p=netconf.git diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/JsonNotificationListenerTest.java similarity index 94% rename from restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/JsonNotificationListenerTest.java index a964815b67..093f11724a 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/JsonNotificationListenerTest.java @@ -7,7 +7,6 @@ */ package org.opendaylight.restconf.nb.rfc8040.streams.listeners; -import static java.util.Objects.requireNonNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -15,6 +14,7 @@ import static org.mockito.Mockito.when; import com.google.common.collect.Lists; import java.net.URI; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.Optional; @@ -42,9 +42,13 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RunWith(MockitoJUnitRunner.StrictStubs.class) -public class NotificationListenerTest { +public class JsonNotificationListenerTest { + private static final Logger LOG = LoggerFactory.getLogger(JsonNotificationListenerTest.class); + private static final QNameModule MODULE = QNameModule.create(URI.create("notifi:mod"), Revision.of("2016-11-23")); private static EffectiveModelContext SCHEMA_CONTEXT; @@ -73,6 +77,8 @@ public class NotificationListenerTest { final String result = prepareJson(notificationData, schemaPathNotifi); + LOG.info("json result: {}", result); + assertTrue(result.contains("ietf-restconf:notification")); assertTrue(result.contains("event-time")); assertTrue(result.contains("notifi-module:notifi-leaf")); @@ -216,9 +222,10 @@ public class NotificationListenerTest { return child; } - private static String prepareJson(final DOMNotification notificationData, final Absolute schemaPathNotifi) { + private static String prepareJson(final DOMNotification notificationData, final Absolute schemaPathNotifi) + throws Exception { final NotificationListenerAdapter notifiAdapter = ListenersBroker.getInstance().registerNotificationListener( - schemaPathNotifi, "stream-name", NotificationOutputType.JSON); - return requireNonNull(notifiAdapter.prepareJson(SCHEMA_CONTEXT, notificationData)); + schemaPathNotifi, "json-stream", NotificationOutputType.JSON); + return notifiAdapter.formatter.eventData(SCHEMA_CONTEXT, notificationData, Instant.now(), false, false).get(); } }