*/
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;
import static org.mockito.Mockito.when;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
+import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.restconf.nb.rfc8040.TestUtils;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
import org.opendaylight.yangtools.util.SingletonSet;
private static MapEntryNode mockMapEntry(final QName entryQName, final LeafNode<String> leaf) {
final MapEntryNode entry = mock(MapEntryNode.class);
- final Map<QName, Object> keyValues = new HashMap<>();
- keyValues.put(leaf.getNodeType(), "value");
- final NodeIdentifierWithPredicates nodeId = new NodeIdentifierWithPredicates(leaf.getNodeType(), keyValues);
+ final NodeIdentifierWithPredicates nodeId = NodeIdentifierWithPredicates.of(leaf.getNodeType(),
+ leaf.getNodeType(), "value");
when(entry.getIdentifier()).thenReturn(nodeId);
when(entry.getChild(any())).thenReturn(Optional.of(leaf));
return child;
}
- private String prepareJson(final DOMNotification notificationData, final SchemaPath schemaPathNotifi)
- throws Exception {
- final List<SchemaPath> paths = new ArrayList<>();
- paths.add(schemaPathNotifi);
- final List<NotificationListenerAdapter> listNotifi =
- Notificator.createNotificationListener(paths, "stream-name", NotificationOutputType.JSON.toString());
- final NotificationListenerAdapter notifi = listNotifi.get(0);
- notifi.setNotification(notificationData);
- notifi.setSchemaContext(this.schmeaCtx);
- final String result = notifi.prepareJson();
- return Preconditions.checkNotNull(result);
+ private String prepareJson(final DOMNotification notificationData, final SchemaPath schemaPathNotifi) {
+ final NotificationListenerAdapter notifiAdapter = ListenersBroker.getInstance().registerNotificationListener(
+ schemaPathNotifi, "stream-name", NotificationOutputType.JSON);
+ return requireNonNull(notifiAdapter.prepareJson(schmeaCtx, notificationData));
}
}