Bug 8153: Enforce check-style on messagebus-netconf 23/55223/5
authormatus.kubica <matus.kubica@pantheon.tech>
Wed, 19 Apr 2017 12:52:45 +0000 (14:52 +0200)
committerTomas Cere <tcere@cisco.com>
Fri, 28 Apr 2017 12:32:27 +0000 (12:32 +0000)
    Organize Imports for Checkstyle compliance.
    Checkstyle compliance: line length.
    Checkstyle compliance: various types of small changes.
    Checkstyle compliant Exception handling.
    Checkstyle final clean up & enforcement.

Change-Id: I51b121d8aec45999cef18a960c4b4a0a1c00c57c
Signed-off-by: matus.kubica <matus.kubica@pantheon.tech>
14 files changed:
netconf/messagebus-netconf/pom.xml
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/ConnectionNotificationTopicRegistration.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSource.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManager.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMount.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceRegistration.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NotificationTopicRegistration.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistration.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/ConnectionNotificationTopicRegistrationTest.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManagerTest.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMountTest.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceTest.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfTestUtils.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistrationTest.java

index d5876e69caf1f1f46876dc42e15192b5235a360f..b38ee885e41a39c92a76ef88606cb3ca38aba866 100644 (file)
@@ -93,4 +93,16 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <artifactId>hamcrest-core</artifactId>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
index cf340c60fe987764e67f2817d716cf661b40f469..3e6573d2438cca9e7b0ae53c3075d0eb53bc0c54 100644 (file)
@@ -39,18 +39,18 @@ class ConnectionNotificationTopicRegistration extends NotificationTopicRegistrat
     private static final Logger LOG = LoggerFactory.getLogger(ConnectionNotificationTopicRegistration.class);
 
     public static final SchemaPath EVENT_SOURCE_STATUS_PATH = SchemaPath
-        .create(true, QName.create(EventSourceStatusNotification.QNAME, "event-source-status"));
+            .create(true, QName.create(EventSourceStatusNotification.QNAME, "event-source-status"));
     private static final NodeIdentifier EVENT_SOURCE_STATUS_ARG = NodeIdentifier.create(
-        EventSourceStatusNotification.QNAME);
+            EventSourceStatusNotification.QNAME);
     private static final String XMLNS_ATTRIBUTE_KEY = "xmlns";
     private static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
 
     private final DOMNotificationListener domNotificationListener;
 
-    public ConnectionNotificationTopicRegistration(final String SourceName,
-            final DOMNotificationListener domNotificationListener) {
-        super(NotificationSourceType.ConnectionStatusChange, SourceName,
-            EVENT_SOURCE_STATUS_PATH.getLastComponent().getNamespace().toString());
+    ConnectionNotificationTopicRegistration(final String sourceName,
+                                            final DOMNotificationListener domNotificationListener) {
+        super(NotificationSourceType.ConnectionStatusChange, sourceName,
+                EVENT_SOURCE_STATUS_PATH.getLastComponent().getNamespace().toString());
         this.domNotificationListener = Preconditions.checkNotNull(domNotificationListener);
         LOG.info("Connection notification source has been initialized.");
         setActive(true);
@@ -117,20 +117,22 @@ class ConnectionNotificationTopicRegistration extends NotificationTopicRegistrat
     private void publishNotification(final EventSourceStatus eventSourceStatus) {
 
         final EventSourceStatusNotification notification = new EventSourceStatusNotificationBuilder()
-            .setStatus(eventSourceStatus).build();
+                .setStatus(eventSourceStatus).build();
         domNotificationListener.onNotification(createNotification(notification));
     }
 
     private static DOMNotification createNotification(final EventSourceStatusNotification notification) {
         final ContainerNode cn = Builders.containerBuilder().withNodeIdentifier(EVENT_SOURCE_STATUS_ARG)
-            .withChild(encapsulate(notification)).build();
+                .withChild(encapsulate(notification)).build();
         DOMNotification dn = new DOMNotification() {
 
-            @Override public SchemaPath getType() {
+            @Override
+            public SchemaPath getType() {
                 return EVENT_SOURCE_STATUS_PATH;
             }
 
-            @Override public ContainerNode getBody() {
+            @Override
+            public ContainerNode getBody() {
                 return cn;
             }
         };
@@ -148,14 +150,14 @@ class ConnectionNotificationTopicRegistration extends NotificationTopicRegistrat
         rootElement.appendChild(sourceElement);
 
         return Builders.anyXmlBuilder().withNodeIdentifier(EVENT_SOURCE_STATUS_ARG)
-            .withValue(new DOMSource(rootElement)).build();
+                .withValue(new DOMSource(rootElement)).build();
     }
 
     // Helper to create root XML element with correct namespace and attribute
-    private static Element createElement(final Document document, final String qName,
-            final Optional<String> namespaceURI) {
+    private static Element createElement(final Document document, final String qualifiedName,
+                                         final Optional<String> namespaceURI) {
         if (namespaceURI.isPresent()) {
-            final Element element = document.createElementNS(namespaceURI.get(), qName);
+            final Element element = document.createElementNS(namespaceURI.get(), qualifiedName);
             String name = XMLNS_ATTRIBUTE_KEY;
             if (element.getPrefix() != null) {
                 name += ":" + element.getPrefix();
@@ -163,6 +165,6 @@ class ConnectionNotificationTopicRegistration extends NotificationTopicRegistrat
             element.setAttributeNS(XMLNS_URI, name, namespaceURI.get());
             return element;
         }
-        return document.createElement(qName);
+        return document.createElement(qualifiedName);
     }
 }
index 31246bbea019fc6e4cc0f52261384acf55232d9a..347278c30135ce6f106e4e81c891a8e344d34168 100644 (file)
@@ -78,30 +78,34 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
 
     private static final NodeIdentifier TOPIC_NOTIFICATION_ARG = NodeIdentifier.create(TopicNotification.QNAME);
     private static final NodeIdentifier EVENT_SOURCE_ARG = NodeIdentifier.create(
-        QName.create(TopicNotification.QNAME, "node-id"));
+            QName.create(TopicNotification.QNAME, "node-id"));
     private static final NodeIdentifier TOPIC_ID_ARG = NodeIdentifier.create(
-        QName.create(TopicNotification.QNAME, "topic-id"));
+            QName.create(TopicNotification.QNAME, "topic-id"));
     private static final NodeIdentifier PAYLOAD_ARG = NodeIdentifier.create(
-        QName.create(TopicNotification.QNAME, "payload"));
-    private static final String ConnectionNotificationSourceName = "ConnectionNotificationSource";
+            QName.create(TopicNotification.QNAME, "payload"));
+    private static final String CONNECTION_NOTIFICATION_SOURCE_NAME = "ConnectionNotificationSource";
 
     private final DOMNotificationPublishService domPublish;
 
     private final Map<String, String> urnPrefixToStreamMap; // key = urnPrefix, value = StreamName
 
     /**
-     * Map notification uri -> registrations
+     * Map notification uri -> registrations.
      */
     private final Multimap<String, NotificationTopicRegistration>
             notificationTopicRegistrations = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
     private final NetconfEventSourceMount mount;
 
     /**
-     * Creates new NetconfEventSource for node. Topic notifications will be published via provided {@link DOMNotificationPublishService}
-     * @param streamMap netconf streams from device
+     * Creates new NetconfEventSource for node. Topic notifications will be published via provided
+     * {@link DOMNotificationPublishService}
+     *
+     * @param streamMap      netconf streams from device
      * @param publishService publish service
      */
-    public NetconfEventSource(final Map<String, String> streamMap, NetconfEventSourceMount mount, final DOMNotificationPublishService publishService) {
+    public NetconfEventSource(final Map<String, String> streamMap,
+                              final NetconfEventSourceMount mount,
+                              final DOMNotificationPublishService publishService) {
         this.mount = mount;
         this.urnPrefixToStreamMap = Preconditions.checkNotNull(streamMap);
         this.domPublish = Preconditions.checkNotNull(publishService);
@@ -115,9 +119,10 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
      * {@link StreamNotificationTopicRegistration} for every prefix and available stream as defined in config file.
      */
     private void initializeNotificationTopicRegistrationList() {
-        final ConnectionNotificationTopicRegistration cntr = new ConnectionNotificationTopicRegistration(ConnectionNotificationSourceName, this);
+        final ConnectionNotificationTopicRegistration cntr =
+                new ConnectionNotificationTopicRegistration(CONNECTION_NOTIFICATION_SOURCE_NAME, this);
         notificationTopicRegistrations
-            .put(cntr.getNotificationUrnPrefix(), cntr);
+                .put(cntr.getNotificationUrnPrefix(), cntr);
         Map<String, Stream> availableStreams = getAvailableStreams();
         LOG.debug("Stream configuration compare...");
         for (String urnPrefix : this.urnPrefixToStreamMap.keySet()) {
@@ -126,7 +131,8 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
             if (availableStreams.containsKey(streamName)) {
                 LOG.debug("Stream containig on device");
                 notificationTopicRegistrations
-                    .put(urnPrefix, new StreamNotificationTopicRegistration(availableStreams.get(streamName), urnPrefix, this));
+                        .put(urnPrefix, new StreamNotificationTopicRegistration(availableStreams.get(streamName),
+                                urnPrefix, this));
             }
         }
     }
@@ -149,7 +155,8 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
         return streamMap;
     }
 
-    @Override public Future<RpcResult<JoinTopicOutput>> joinTopic(final JoinTopicInput input) {
+    @Override
+    public Future<RpcResult<JoinTopicOutput>> joinTopic(final JoinTopicInput input) {
         LOG.debug("Join topic {} on {}", input.getTopicId().getValue(), mount.getNodeId());
         final NotificationPattern notificationPattern = input.getNotificationPattern();
         final List<SchemaPath> matchingNotifications = getMatchingNotifications(notificationPattern);
@@ -157,15 +164,17 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
 
     }
 
-    @Override public Future<RpcResult<Void>> disJoinTopic(DisJoinTopicInput input) {
+    @Override
+    public Future<RpcResult<Void>> disJoinTopic(DisJoinTopicInput input) {
         for (NotificationTopicRegistration reg : notificationTopicRegistrations.values()) {
             reg.unRegisterNotificationTopic(input.getTopicId());
         }
         return Util.resultRpcSuccessFor((Void) null);
     }
 
-    private synchronized Future<RpcResult<JoinTopicOutput>> registerTopic(final TopicId topicId,
-        final List<SchemaPath> notificationsToSubscribe) {
+    private synchronized Future<RpcResult<JoinTopicOutput>> registerTopic(
+            final TopicId topicId,
+            final List<SchemaPath> notificationsToSubscribe) {
         Preconditions.checkNotNull(notificationsToSubscribe);
         LOG.debug("Join topic {} - register", topicId);
         JoinTopicStatus joinTopicStatus = JoinTopicStatus.Down;
@@ -206,7 +215,8 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
         }
     }
 
-    @Override public void onNotification(final DOMNotification notification) {
+    @Override
+    public void onNotification(final DOMNotification notification) {
         SchemaPath notificationPath = notification.getType();
         Date notificationEventTime = null;
         if (notification instanceof DOMEvent) {
@@ -219,16 +229,17 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
             for (TopicId topicId : topicIdsForNotification) {
                 publishNotification(notification, topicId);
                 LOG.debug("Notification {} has been published for TopicId {}", notification.getType(),
-                    topicId.getValue());
+                        topicId.getValue());
             }
         }
     }
 
     private void publishNotification(final DOMNotification notification, TopicId topicId) {
         final ContainerNode topicNotification = Builders.containerBuilder().withNodeIdentifier(TOPIC_NOTIFICATION_ARG)
-            .withChild(ImmutableNodes.leafNode(TOPIC_ID_ARG, topicId))
-            .withChild(ImmutableNodes.leafNode(EVENT_SOURCE_ARG, mount.getNodeId())).withChild(encapsulate(notification))
-            .build();
+                .withChild(ImmutableNodes.leafNode(TOPIC_ID_ARG, topicId))
+                .withChild(ImmutableNodes.leafNode(EVENT_SOURCE_ARG, mount.getNodeId()))
+                .withChild(encapsulate(notification))
+                .build();
         try {
             domPublish.putNotification(new TopicDOMNotification(topicNotification));
         } catch (final InterruptedException e) {
@@ -257,6 +268,7 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
 
     /**
      * Returns all available notification paths that matches given pattern.
+     *
      * @param notificationPattern pattern
      * @return notification paths
      */
@@ -268,24 +280,27 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
         return Util.expandQname(availableNotifications, pattern);
     }
 
-    @Override public void close() throws Exception {
+    @Override
+    public void close() throws Exception {
         for (NotificationTopicRegistration streamReg : notificationTopicRegistrations.values()) {
             streamReg.close();
         }
     }
 
-    @Override public NodeKey getSourceNodeKey() {
+    @Override
+    public NodeKey getSourceNodeKey() {
         return mount.getNode().getKey();
     }
 
-    @Override public List<SchemaPath> getAvailableNotifications() {
+    @Override
+    public List<SchemaPath> getAvailableNotifications() {
 
         final List<SchemaPath> availNotifList = new ArrayList<>();
         // add Event Source Connection status notification
         availNotifList.add(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
 
         final Set<NotificationDefinition> availableNotifications = mount.getSchemaContext()
-            .getNotifications();
+                .getNotifications();
         // add all known notifications from netconf device
         for (final NotificationDefinition nd : availableNotifications) {
             availNotifList.add(nd.getPath());
index cdbd8d4e4386dba9cb104a74744073be57ccac46..516c595ef7e98a8e3f17d97100e6cb5088180d0d 100644 (file)
@@ -40,12 +40,13 @@ public final class NetconfEventSourceManager implements DataChangeListener, Auto
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfEventSourceManager.class);
     private static final TopologyKey NETCONF_TOPOLOGY_KEY = new TopologyKey(
-        new TopologyId(TopologyNetconf.QNAME.getLocalName()));
+            new TopologyId(TopologyNetconf.QNAME.getLocalName()));
     private static final InstanceIdentifier<Node> NETCONF_DEVICE_PATH = InstanceIdentifier.create(NetworkTopology.class)
-        .child(Topology.class, NETCONF_TOPOLOGY_KEY).child(Node.class);
+            .child(Topology.class, NETCONF_TOPOLOGY_KEY).child(Node.class);
 
     private Map<String, String> streamMap;
-    private final ConcurrentHashMap<InstanceIdentifier<?>, NetconfEventSourceRegistration> registrationMap = new ConcurrentHashMap<>();
+    private final ConcurrentHashMap<InstanceIdentifier<?>, NetconfEventSourceRegistration> registrationMap =
+            new ConcurrentHashMap<>();
     private final DOMNotificationPublishService publishService;
     private final DOMMountPointService domMounts;
     private ListenerRegistration<DataChangeListener> listenerRegistration;
@@ -67,17 +68,18 @@ public final class NetconfEventSourceManager implements DataChangeListener, Auto
     }
 
     /**
-     * Invoke by blueprint
+     * Invoked by blueprint.
      */
     public void initialize() {
         Preconditions.checkNotNull(dataBroker);
         listenerRegistration = dataBroker
-            .registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, NETCONF_DEVICE_PATH, this,
-                DataChangeScope.SUBTREE);
+                .registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, NETCONF_DEVICE_PATH, this,
+                        DataChangeScope.SUBTREE);
         LOG.info("NetconfEventSourceManager initialized.");
     }
 
-    @Override public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event) {
+    @Override
+    public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event) {
 
         LOG.debug("[DataChangeEvent<InstanceIdentifier<?>, DataObject>: {}]", event);
         for (final Map.Entry<InstanceIdentifier<?>, DataObject> changeEntry : event.getCreatedData().entrySet()) {
@@ -166,8 +168,9 @@ public final class NetconfEventSourceManager implements DataChangeListener, Auto
     }
 
     /**
-     * Invoke by blueprint
-     * @param streamMap
+     * Invoked by blueprint.
+     *
+     * @param streamMap Stream map
      */
     public void setStreamMap(Map<String, String> streamMap) {
         this.streamMap = streamMap;
@@ -177,7 +180,8 @@ public final class NetconfEventSourceManager implements DataChangeListener, Auto
         return node.getAugmentation(NetconfNode.class) != null;
     }
 
-    @Override public void close() {
+    @Override
+    public void close() {
         listenerRegistration.close();
         for (final NetconfEventSourceRegistration reg : registrationMap.values()) {
             reg.close();
index 1701afea5331b84414f37d7d6069cca007b7f191..0524bdfbc62a7866f29bd98eb3d8b6da2e328322 100644 (file)
@@ -49,25 +49,28 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 /**
- * Facade of mounted netconf device
+ * Facade of mounted netconf device.
  */
 class NetconfEventSourceMount {
 
     private static final BindingNormalizedNodeCodecRegistry CODEC_REGISTRY;
-    private static final YangInstanceIdentifier STREAMS_PATH = YangInstanceIdentifier.builder().node(Netconf.QNAME).node(Streams.QNAME).build();
+    private static final YangInstanceIdentifier STREAMS_PATH = YangInstanceIdentifier.builder().node(Netconf.QNAME)
+            .node(Streams.QNAME).build();
     private static final SchemaPath CREATE_SUBSCRIPTION = SchemaPath
             .create(true, QName.create(CreateSubscriptionInput.QNAME, "create-subscription"));
 
-    static{
+    static {
         final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
-        moduleInfoBackedContext.addModuleInfos(Collections.singletonList(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.$YangModuleInfoImpl.getInstance()));
+        moduleInfoBackedContext.addModuleInfos(Collections.singletonList(org.opendaylight.yang.gen.v1.urn.ietf.params
+                .xml.ns.netmod.notification.rev080714.$YangModuleInfoImpl.getInstance()));
         final Optional<SchemaContext> schemaContextOptional = moduleInfoBackedContext.tryToCreateSchemaContext();
         Preconditions.checkState(schemaContextOptional.isPresent());
-        SchemaContext NOTIFICATIONS_SCHEMA_CTX = schemaContextOptional.get();
+        SchemaContext notificationsSchemaCtx = schemaContextOptional.get();
 
         final JavassistUtils javassist = JavassistUtils.forClassPool(ClassPool.getDefault());
         CODEC_REGISTRY = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(javassist));
-        CODEC_REGISTRY.onBindingRuntimeContextUpdated(BindingRuntimeContext.create(moduleInfoBackedContext, NOTIFICATIONS_SCHEMA_CTX));
+        CODEC_REGISTRY.onBindingRuntimeContextUpdated(BindingRuntimeContext.create(moduleInfoBackedContext,
+                notificationsSchemaCtx));
     }
 
     private final DOMMountPoint mountPoint;
@@ -77,7 +80,7 @@ class NetconfEventSourceMount {
     private final Node node;
     private final String nodeId;
 
-    public NetconfEventSourceMount(final Node node, final DOMMountPoint mountPoint) {
+    NetconfEventSourceMount(final Node node, final DOMMountPoint mountPoint) {
         this.mountPoint = mountPoint;
         this.node = node;
         this.nodeId = node.getNodeId().getValue();
@@ -101,16 +104,19 @@ class NetconfEventSourceMount {
     }
 
     /**
-     * Invokes create-subscription rpc on mounted device stream. If lastEventTime is provided and stream supports replay,
+     * Invokes create-subscription rpc on mounted device stream. If lastEventTime is provided and stream supports
+     * replay,
      * rpc will be invoked with start time parameter.
-     * @param stream stream
+     *
+     * @param stream        stream
      * @param lastEventTime last event time
      * @return rpc result
      */
-    CheckedFuture<DOMRpcResult, DOMRpcException> invokeCreateSubscription(final Stream stream, final Optional<Date> lastEventTime) {
+    CheckedFuture<DOMRpcResult, DOMRpcException> invokeCreateSubscription(final Stream stream,
+                                                                          final Optional<Date> lastEventTime) {
         final CreateSubscriptionInputBuilder inputBuilder = new CreateSubscriptionInputBuilder()
                 .setStream(stream.getName());
-        if(lastEventTime.isPresent() && stream.isReplaySupport()) {
+        if (lastEventTime.isPresent() && stream.isReplaySupport()) {
             final ZonedDateTime dateTime = lastEventTime.get().toInstant().atZone(ZoneId.systemDefault());
             final String formattedDate = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(dateTime);
             inputBuilder.setStartTime(new DateAndTime(formattedDate));
@@ -122,6 +128,7 @@ class NetconfEventSourceMount {
 
     /**
      * Invokes create-subscription rpc on mounted device stream.
+     *
      * @param stream stream
      * @return rpc result
      */
@@ -130,7 +137,8 @@ class NetconfEventSourceMount {
     }
 
     /**
-     * Returns list of streams avaliable on device
+     * Returns list of streams avaliable on device.
+     *
      * @return list of streams
      * @throws ReadFailedException if data read fails
      */
@@ -140,8 +148,8 @@ class NetconfEventSourceMount {
                 .read(LogicalDatastoreType.OPERATIONAL, STREAMS_PATH);
         Optional<NormalizedNode<?, ?>> streams = checkFeature.checkedGet();
         if (streams.isPresent()) {
-            Streams s = (Streams) CODEC_REGISTRY.fromNormalizedNode(STREAMS_PATH, streams.get()).getValue();
-            return s.getStream();
+            Streams streams1 = (Streams) CODEC_REGISTRY.fromNormalizedNode(STREAMS_PATH, streams.get()).getValue();
+            return streams1.getStream();
         }
         return Collections.emptyList();
     }
@@ -152,12 +160,14 @@ class NetconfEventSourceMount {
 
     /**
      * Registers notification listener to receive a set of notifications.
-     * @see DOMNotificationService#registerNotificationListener(DOMNotificationListener, SchemaPath...)
-     * @param listener listener
+     *
+     * @param listener         listener
      * @param notificationPath notification path
-     * @return
+     * @return ListenerRegistration
+     * @see DOMNotificationService#registerNotificationListener(DOMNotificationListener, SchemaPath...)
      */
-    ListenerRegistration<DOMNotificationListener> registerNotificationListener(DOMNotificationListener listener, SchemaPath notificationPath) {
+    ListenerRegistration<DOMNotificationListener> registerNotificationListener(DOMNotificationListener listener,
+                                                                               SchemaPath notificationPath) {
         return notificationService.registerNotificationListener(listener, notificationPath);
     }
 
index c667976989922feccb06fc57c9c28ff5ac8b81f9..9089e92ee1ab999298f58200a88ccf7bb7876a51 100644 (file)
@@ -27,17 +27,18 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Helper class to keep connection status of netconf node  and event source registration object
+ * Helper class to keep connection status of netconf node  and event source registration object.
  */
 public class NetconfEventSourceRegistration implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfEventSourceRegistration.class);
     private static final YangInstanceIdentifier NETCONF_DEVICE_DOM_PATH = YangInstanceIdentifier.builder()
-        .node(NetworkTopology.QNAME).node(Topology.QNAME)
-        .nodeWithKey(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), TopologyNetconf.QNAME.getLocalName())
-        .node(Node.QNAME).build();
+            .node(NetworkTopology.QNAME).node(Topology.QNAME)
+            .nodeWithKey(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), TopologyNetconf.QNAME
+                    .getLocalName())
+            .node(Node.QNAME).build();
     private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "node-id");
-    private static final String NotificationCapabilityPrefix = "(urn:ietf:params:xml:ns:netconf:notification";
+    private static final String NOTIFICATION_CAPABILITY_PREFIX = "(urn:ietf:params:xml:ns:netconf:notification";
 
     private final Node node;
     private final NetconfEventSourceManager netconfEventSourceManager;
@@ -45,7 +46,7 @@ public class NetconfEventSourceRegistration implements AutoCloseable {
     private EventSourceRegistration<NetconfEventSource> eventSourceRegistration;
 
     public static NetconfEventSourceRegistration create(final InstanceIdentifier<?> instanceIdent, final Node node,
-        final NetconfEventSourceManager netconfEventSourceManager) {
+                                                        final NetconfEventSourceManager netconfEventSourceManager) {
         Preconditions.checkNotNull(instanceIdent);
         Preconditions.checkNotNull(node);
         Preconditions.checkNotNull(netconfEventSourceManager);
@@ -71,7 +72,7 @@ public class NetconfEventSourceRegistration implements AutoCloseable {
             return false;
         }
         for (final AvailableCapability capability : netconfNode.getAvailableCapabilities().getAvailableCapability()) {
-            if (capability.getCapability().startsWith(NotificationCapabilityPrefix)) {
+            if (capability.getCapability().startsWith(NOTIFICATION_CAPABILITY_PREFIX)) {
                 return true;
             }
         }
@@ -140,14 +141,14 @@ public class NetconfEventSourceRegistration implements AutoCloseable {
 
     private void registrationEventSource() {
         final Optional<DOMMountPoint> domMountPoint = netconfEventSourceManager.getDomMounts()
-            .getMountPoint(domMountPath(node.getNodeId()));
+                .getMountPoint(domMountPath(node.getNodeId()));
         EventSourceRegistration<NetconfEventSource> registration = null;
         if (domMountPoint.isPresent()/* && mountPoint.isPresent()*/) {
             NetconfEventSourceMount mount = new NetconfEventSourceMount(node, domMountPoint.get());
             final NetconfEventSource netconfEventSource = new NetconfEventSource(
-                netconfEventSourceManager.getStreamMap(),
+                    netconfEventSourceManager.getStreamMap(),
                     mount,
-                netconfEventSourceManager.getPublishService());
+                    netconfEventSourceManager.getPublishService());
             registration = netconfEventSourceManager.getEventSourceRegistry().registerEventSource(netconfEventSource);
             LOG.info("Event source {} has been registered", node.getNodeId().getValue());
         }
@@ -156,7 +157,7 @@ public class NetconfEventSourceRegistration implements AutoCloseable {
 
     private YangInstanceIdentifier domMountPath(final NodeId nodeId) {
         return YangInstanceIdentifier.builder(NETCONF_DEVICE_DOM_PATH)
-            .nodeWithKey(Node.QNAME, NODE_ID_QNAME, nodeId.getValue()).build();
+                .nodeWithKey(Node.QNAME, NODE_ID_QNAME, nodeId.getValue()).build();
     }
 
     private void closeEventSourceRegistration() {
@@ -165,7 +166,8 @@ public class NetconfEventSourceRegistration implements AutoCloseable {
         }
     }
 
-    @Override public void close() {
+    @Override
+    public void close() {
         closeEventSourceRegistration();
     }
 
index b7bfda343277fbb95500912e591c6b16afbb501d..d10ce66249f73cedcc961b9516c22b9a69fd2534 100644 (file)
@@ -38,7 +38,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
     protected final ConcurrentHashMap<SchemaPath, Set<TopicId>> notificationTopicMap = new ConcurrentHashMap<>();
 
     protected NotificationTopicRegistration(NotificationSourceType notificationSourceType, String sourceName,
-        String notificationUrnPrefix) {
+                                            String notificationUrnPrefix) {
         this.notificationSourceType = notificationSourceType;
         this.sourceName = sourceName;
         this.notificationUrnPrefix = notificationUrnPrefix;
@@ -68,6 +68,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
 
     /**
      * Returns registered topics for given notification path.
+     *
      * @param notificationPath path
      * @return topicIds
      */
@@ -78,6 +79,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
 
     /**
      * Checks, if notification is from namespace belonging to this registration.
+     *
      * @param notificationPath path
      * @return true, if notification belongs to registration namespace
      */
@@ -87,7 +89,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
         }
         String nameSpace = notificationPath.getLastComponent().getNamespace().toString();
         LOG.debug("CheckNotification - name space {} - NotificationUrnPrefix {}", nameSpace,
-            getNotificationUrnPrefix());
+                getNotificationUrnPrefix());
         return nameSpace.startsWith(getNotificationUrnPrefix());
     }
 
@@ -107,14 +109,16 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
 
     /**
      * Registers associated event source notification to topic.
+     *
      * @param notificationPath notification path
-     * @param topicId topic id
+     * @param topicId          topic id
      * @return true, if successful
      */
     abstract boolean registerNotificationTopic(SchemaPath notificationPath, TopicId topicId);
 
     /**
      * Registers associated event source notification to topic.
+     *
      * @param topicId topic id
      * @return true, if successful
      */
index d163a777cd820a38582af4736d2b6a1da4f63b24..a77dbdc2e13b9a2fafe45b8d31a90b510209ec1e 100644 (file)
@@ -32,17 +32,19 @@ class StreamNotificationTopicRegistration extends NotificationTopicRegistration
     private final String nodeId;
     private final NetconfEventSource netconfEventSource;
     private final NetconfEventSourceMount mountPoint;
-    private final ConcurrentHashMap<SchemaPath, ListenerRegistration<DOMNotificationListener>> notificationRegistrationMap = new ConcurrentHashMap<>();
+    private final ConcurrentHashMap<SchemaPath, ListenerRegistration<DOMNotificationListener>>
+            notificationRegistrationMap = new ConcurrentHashMap<>();
     private final Stream stream;
 
     /**
      * Creates registration to notification stream.
-     * @param stream stream
+     *
+     * @param stream             stream
      * @param notificationPrefix notifications namespace
      * @param netconfEventSource event source
      */
-    public StreamNotificationTopicRegistration(final Stream stream, final String notificationPrefix,
-        NetconfEventSource netconfEventSource) {
+    StreamNotificationTopicRegistration(final Stream stream, final String notificationPrefix,
+                                        NetconfEventSource netconfEventSource) {
         super(NotificationSourceType.NetconfDeviceStream, stream.getName().getValue(), notificationPrefix);
         this.netconfEventSource = netconfEventSource;
         this.mountPoint = netconfEventSource.getMount();
@@ -73,7 +75,8 @@ class StreamNotificationTopicRegistration extends NotificationTopicRegistration
     }
 
     /**
-     * Subscribes to notification stream associated with this registration. If replay is supported, notifications from last
+     * Subscribes to notification stream associated with this registration. If replay is supported, notifications
+     * from last
      * received event time will be requested.
      */
     void reActivateNotificationSource() {
@@ -91,7 +94,8 @@ class StreamNotificationTopicRegistration extends NotificationTopicRegistration
         }
     }
 
-    @Override void deActivateNotificationSource() {
+    @Override
+    void deActivateNotificationSource() {
         // no operations need
     }
 
@@ -110,7 +114,8 @@ class StreamNotificationTopicRegistration extends NotificationTopicRegistration
         return getSourceName();
     }
 
-    @Override boolean registerNotificationTopic(SchemaPath notificationPath, TopicId topicId) {
+    @Override
+    boolean registerNotificationTopic(SchemaPath notificationPath, TopicId topicId) {
         if (!checkNotificationPath(notificationPath)) {
             LOG.debug("Bad SchemaPath for notification try to register");
             return false;
@@ -119,11 +124,12 @@ class StreamNotificationTopicRegistration extends NotificationTopicRegistration
         activateNotificationSource();
         if (!isActive()) {
             LOG.warn("Stream {} is not active, listener for notification {} is not registered.", getStreamName(),
-                notificationPath.toString());
+                    notificationPath.toString());
             return false;
         }
 
-        ListenerRegistration<DOMNotificationListener> registration = mountPoint.registerNotificationListener(netconfEventSource, notificationPath);
+        ListenerRegistration<DOMNotificationListener> registration =
+                mountPoint.registerNotificationListener(netconfEventSource, notificationPath);
         notificationRegistrationMap.put(notificationPath, registration);
         Set<TopicId> topicIds = getTopicsForNotification(notificationPath);
         topicIds.add(topicId);
@@ -132,7 +138,8 @@ class StreamNotificationTopicRegistration extends NotificationTopicRegistration
         return true;
     }
 
-    @Override synchronized void unRegisterNotificationTopic(TopicId topicId) {
+    @Override
+    synchronized void unRegisterNotificationTopic(TopicId topicId) {
         List<SchemaPath> notificationPathToRemove = new ArrayList<>();
         for (SchemaPath notifKey : notificationTopicMap.keySet()) {
             Set<TopicId> topicList = notificationTopicMap.get(notifKey);
@@ -152,7 +159,8 @@ class StreamNotificationTopicRegistration extends NotificationTopicRegistration
         }
     }
 
-    @Override public void close() throws Exception {
+    @Override
+    public void close() throws Exception {
         closeStream();
     }
 
index a19f13028e866724aab2d873bf921d736bba0b52..5d3669aa0540f5a46edc21c6a4f353d53e29823e 100644 (file)
@@ -71,12 +71,14 @@ public class ConnectionNotificationTopicRegistrationTest {
         final TopicId topic1 = registerTopic("topic1");
         final TopicId topic2 = registerTopic("topic2");
         final TopicId topic3 = registerTopic("topic3");
-        final Set<TopicId> notificationTopicIds = registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
+        final Set<TopicId> notificationTopicIds =
+                registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
         Assert.assertNotNull(notificationTopicIds);
         Assert.assertThat(notificationTopicIds, hasItems(topic1, topic2, topic3));
 
         registration.unRegisterNotificationTopic(topic3);
-        final Set<TopicId> afterUnregister = registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
+        final Set<TopicId> afterUnregister =
+                registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
         Assert.assertNotNull(afterUnregister);
         Assert.assertThat(afterUnregister, hasItems(topic1, topic2));
         Assert.assertFalse(afterUnregister.contains(topic3));
@@ -91,15 +93,17 @@ public class ConnectionNotificationTopicRegistrationTest {
 
     /**
      * Checks status node of notification received by listener.
+     *
      * @param listener listener
-     * @param status expected value
+     * @param status   expected value
      */
     private static void checkStatus(DOMNotificationListener listener, EventSourceStatus status) {
         ArgumentCaptor<DOMNotification> notificationCaptor = ArgumentCaptor.forClass(DOMNotification.class);
         verify(listener).onNotification(notificationCaptor.capture());
         final DOMNotification value = notificationCaptor.getValue();
         Assert.assertEquals(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH, value.getType());
-        final Collection<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> body = value.getBody().getValue();
+        final Collection<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> body = value.getBody()
+                .getValue();
         Assert.assertEquals(1, body.size());
         final DOMSource source = (DOMSource) body.iterator().next().getValue();
         final String statusNodeValue = source.getNode().getFirstChild().getFirstChild().getNodeValue();
index 13b855107d8d9a7ef9c2e2f95668e1c485e86600..6d9938cdc81f8f9674bacde70e4aca23786b4ddd 100644 (file)
@@ -66,30 +66,36 @@ public class NetconfEventSourceManagerTest {
 
     @Before
     public void setUp() throws Exception {
-        DataBroker dataBrokerMock = mock(DataBroker.class);
-        DOMNotificationPublishService domNotificationPublishServiceMock = mock(DOMNotificationPublishService.class);
+        final DataBroker dataBrokerMock = mock(DataBroker.class);
+        final DOMNotificationPublishService domNotificationPublishServiceMock =
+                mock(DOMNotificationPublishService.class);
         domMountPointServiceMock = mock(DOMMountPointService.class);
         eventSourceTopologyMock = mock(EventSourceRegistry.class);
         rpcProviderRegistryMock = mock(RpcProviderRegistry.class);
         eventSourceRegistry = mock(EventSourceRegistry.class);
 
         listenerRegistrationMock = mock(ListenerRegistration.class);
-        doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataChangeListener(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(NetconfEventSourceManager.class), eq(
-            AsyncDataBroker.DataChangeScope.SUBTREE));
+        doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataChangeListener(eq(LogicalDatastoreType
+                .OPERATIONAL), any(InstanceIdentifier.class), any(NetconfEventSourceManager.class), eq(
+                AsyncDataBroker.DataChangeScope.SUBTREE));
 
         DOMMountPoint domMountPointMock = mock(DOMMountPoint.class);
         Optional<DOMMountPoint> optionalDomMountServiceMock = Optional.of(domMountPointMock);
-        doReturn(optionalDomMountServiceMock).when(domMountPointServiceMock).getMountPoint((YangInstanceIdentifier)notNull());
+        doReturn(optionalDomMountServiceMock).when(domMountPointServiceMock).getMountPoint((YangInstanceIdentifier)
+                notNull());
         DOMDataBroker mpDataBroker = mock(DOMDataBroker.class);
         doReturn(Optional.of(mpDataBroker)).when(domMountPointMock).getService(DOMDataBroker.class);
         doReturn(Optional.of(mock(DOMRpcService.class))).when(domMountPointMock).getService(DOMRpcService.class);
-        doReturn(Optional.of(mock(DOMNotificationService.class))).when(domMountPointMock).getService(DOMNotificationService.class);
+        doReturn(Optional.of(mock(DOMNotificationService.class))).when(domMountPointMock)
+                .getService(DOMNotificationService.class);
 
         DOMDataReadOnlyTransaction rtx = mock(DOMDataReadOnlyTransaction.class);
         doReturn(rtx).when(mpDataBroker).newReadOnlyTransaction();
-        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> checkFeature = Futures.immediateCheckedFuture(Optional.of(NetconfTestUtils.getStreamsNode("stream-1")));
+        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> checkFeature = Futures
+                .immediateCheckedFuture(Optional.of(NetconfTestUtils.getStreamsNode("stream-1")));
 
-        YangInstanceIdentifier pathStream = YangInstanceIdentifier.builder().node(Netconf.QNAME).node(Streams.QNAME).build();
+        YangInstanceIdentifier pathStream = YangInstanceIdentifier.builder().node(Netconf.QNAME).node(Streams.QNAME)
+                .build();
         doReturn(checkFeature).when(rtx).read(LogicalDatastoreType.OPERATIONAL, pathStream);
 
         netconfEventSourceManager = new NetconfEventSourceManager(dataBrokerMock,
@@ -99,33 +105,34 @@ public class NetconfEventSourceManagerTest {
 
     @Test
     public void onDataChangedCreateEventSourceTestByCreateEntry() throws Exception {
-        onDataChangedTestHelper(true,false,true, NetconfTestUtils.notification_capability_prefix);
+        onDataChangedTestHelper(true, false, true, NetconfTestUtils.NOTIFICATION_CAPABILITY_PREFIX);
         netconfEventSourceManager.onDataChanged(asyncDataChangeEventMock);
         verify(eventSourceRegistry, times(1)).registerEventSource(any(EventSource.class));
     }
 
     @Test
     public void onDataChangedCreateEventSourceTestByUpdateEntry() throws Exception {
-        onDataChangedTestHelper(false,true,true, NetconfTestUtils.notification_capability_prefix);
+        onDataChangedTestHelper(false, true, true, NetconfTestUtils.NOTIFICATION_CAPABILITY_PREFIX);
         netconfEventSourceManager.onDataChanged(asyncDataChangeEventMock);
         verify(eventSourceRegistry, times(1)).registerEventSource(any(EventSource.class));
     }
 
     @Test
     public void onDataChangedCreateEventSourceTestNotNeconf() throws Exception {
-        onDataChangedTestHelper(false,true,false, NetconfTestUtils.notification_capability_prefix);
+        onDataChangedTestHelper(false, true, false, NetconfTestUtils.NOTIFICATION_CAPABILITY_PREFIX);
         netconfEventSourceManager.onDataChanged(asyncDataChangeEventMock);
         verify(eventSourceRegistry, times(0)).registerEventSource(any(EventSource.class));
     }
 
     @Test
     public void onDataChangedCreateEventSourceTestNotNotificationCapability() throws Exception {
-        onDataChangedTestHelper(true,false,true,"bad-prefix");
+        onDataChangedTestHelper(true, false, true, "bad-prefix");
         netconfEventSourceManager.onDataChanged(asyncDataChangeEventMock);
         verify(eventSourceRegistry, times(0)).registerEventSource(any(EventSource.class));
     }
 
-    private void onDataChangedTestHelper(boolean create, boolean update, boolean isNetconf, String notificationCapabilityPrefix) throws Exception{
+    private void onDataChangedTestHelper(boolean create, boolean update, boolean isNetconf, String
+            notificationCapabilityPrefix) throws Exception {
         asyncDataChangeEventMock = mock(AsyncDataChangeEvent.class);
         Map<InstanceIdentifier, DataObject> mapCreate = new HashMap<>();
         Map<InstanceIdentifier, DataObject> mapUpdate = new HashMap<>();
@@ -135,18 +142,19 @@ public class NetconfEventSourceManagerTest {
         doReturn(mapCreate).when(asyncDataChangeEventMock).getCreatedData();
         doReturn(mapUpdate).when(asyncDataChangeEventMock).getUpdatedData();
 
-        if(isNetconf){
+        if (isNetconf) {
             node01 = NetconfTestUtils
-                .getNetconfNode(nodeId, "node01.test.local", ConnectionStatus.Connected, notificationCapabilityPrefix);
+                    .getNetconfNode(nodeId, "node01.test.local", ConnectionStatus.Connected,
+                            notificationCapabilityPrefix);
 
         } else {
             node01 = NetconfTestUtils.getNode(nodeId);
         }
 
-        if(create){
+        if (create) {
             mapCreate.put(NetconfTestUtils.getInstanceIdentifier(node01), node01);
         }
-        if(update){
+        if (update) {
             mapUpdate.put(NetconfTestUtils.getInstanceIdentifier(node01), node01);
         }
 
index 369d6b4df8da162a46752a1e8cc971bcec7f814a..d64e1a6415f539584f67ac409a5fda2325d0f424 100644 (file)
@@ -66,11 +66,14 @@ public class NetconfEventSourceMountTest {
         MockitoAnnotations.initMocks(this);
         doReturn(Optional.of(dataBroker)).when(domMountPoint).getService(DOMDataBroker.class);
         doReturn(Optional.of(rpcService)).when(domMountPoint).getService(DOMRpcService.class);
-        doReturn(Optional.of(mock(DOMNotificationService.class))).when(domMountPoint).getService(DOMNotificationService.class);
+        doReturn(Optional.of(mock(DOMNotificationService.class))).when(domMountPoint)
+                .getService(DOMNotificationService.class);
         doReturn(tx).when(dataBroker).newReadOnlyTransaction();
-        final YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(Netconf.QNAME).node(Streams.QNAME).build();
+        final YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(Netconf.QNAME).node(Streams.QNAME)
+                .build();
         final NormalizedNode<?, ?> streamsNode = NetconfTestUtils.getStreamsNode(STREAM_1, STREAM_2);
-        doReturn(Futures.immediateCheckedFuture(Optional.of(streamsNode))).when(tx).read(LogicalDatastoreType.OPERATIONAL, path);
+        doReturn(Futures.immediateCheckedFuture(Optional.of(streamsNode))).when(tx).read(LogicalDatastoreType
+                .OPERATIONAL, path);
         mount = new NetconfEventSourceMount(NetconfTestUtils.getNode("node-1"), domMountPoint);
     }
 
@@ -80,7 +83,8 @@ public class NetconfEventSourceMountTest {
                 .setName(new StreamNameType(STREAM_1))
                 .build();
         mount.invokeCreateSubscription(stream, Optional.absent());
-        final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME, "create-subscription"));
+        final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME,
+                "create-subscription"));
         ArgumentCaptor<ContainerNode> captor = ArgumentCaptor.forClass(ContainerNode.class);
         verify(rpcService).invokeRpc(eq(type), captor.capture());
         Assert.assertEquals(STREAM_1, getStreamName(captor.getValue()));
@@ -94,11 +98,13 @@ public class NetconfEventSourceMountTest {
                 .build();
         final Date date = new Date();
         mount.invokeCreateSubscription(stream, Optional.of(date));
-        final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME, "create-subscription"));
+        final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME,
+                "create-subscription"));
         ArgumentCaptor<ContainerNode> captor = ArgumentCaptor.forClass(ContainerNode.class);
         verify(rpcService).invokeRpc(eq(type), captor.capture());
         Assert.assertEquals(STREAM_1, getStreamName(captor.getValue()));
-        final String expDate = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(date.toInstant().atZone(ZoneId.systemDefault()));
+        final String expDate = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(date.toInstant().atZone(ZoneId
+                .systemDefault()));
         final Optional<LeafNode> actual = (Optional<LeafNode>) getDate(captor.getValue());
         Assert.assertTrue(actual.isPresent());
         String actualDate = (String) actual.get().getValue();
@@ -112,7 +118,8 @@ public class NetconfEventSourceMountTest {
                 .setReplaySupport(true)
                 .build();
         mount.invokeCreateSubscription(stream, Optional.absent());
-        final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME, "create-subscription"));
+        final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME,
+                "create-subscription"));
         ArgumentCaptor<ContainerNode> captor = ArgumentCaptor.forClass(ContainerNode.class);
         verify(rpcService).invokeRpc(eq(type), captor.capture());
         Assert.assertEquals(STREAM_1, getStreamName(captor.getValue()));
@@ -137,12 +144,14 @@ public class NetconfEventSourceMountTest {
     }
 
     private String getStreamName(ContainerNode value) {
-        YangInstanceIdentifier.NodeIdentifier STREAM = new YangInstanceIdentifier.NodeIdentifier(QName.create(CreateSubscriptionInput.QNAME, "stream"));
-        return (String) value.getChild(STREAM).get().getValue();
+        YangInstanceIdentifier.NodeIdentifier stream =
+                new YangInstanceIdentifier.NodeIdentifier(QName.create(CreateSubscriptionInput.QNAME, "stream"));
+        return (String) value.getChild(stream).get().getValue();
     }
 
     private Optional<?> getDate(ContainerNode value) {
-        YangInstanceIdentifier.NodeIdentifier START_TIME = new YangInstanceIdentifier.NodeIdentifier(QName.create(CreateSubscriptionInput.QNAME, "startTime"));
-        return value.getChild(START_TIME);
+        YangInstanceIdentifier.NodeIdentifier startTime =
+                new YangInstanceIdentifier.NodeIdentifier(QName.create(CreateSubscriptionInput.QNAME, "startTime"));
+        return value.getChild(startTime);
     }
 }
\ No newline at end of file
index 1a439b9ff66224cea5c85616f1bb490cee229aab..56ce4ee61ad9bfc3a29b01cf68928b738d96ee63 100644 (file)
@@ -54,8 +54,10 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 public class NetconfEventSourceTest {
 
 
-    private static final SchemaPath notification1Path = SchemaPath.create(true, QName.create("ns1", "1970-01-15", "not1"));
-    private static final SchemaPath notification2Path = SchemaPath.create(true, QName.create("ns2", "1980-02-18", "not2"));
+    private static final SchemaPath NOTIFICATION_1_PATH = SchemaPath.create(true, QName.create("ns1", "1970-01-15",
+            "not1"));
+    private static final SchemaPath NOTIFICATION_2_PATH = SchemaPath.create(true, QName.create("ns2", "1980-02-18",
+            "not2"));
 
     NetconfEventSource netconfEventSource;
 
@@ -72,14 +74,16 @@ public class NetconfEventSourceTest {
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         //init notification mocks
-        doReturn(notification1Path).when(matchnigNotification).getType();
-        doReturn(notification2Path).when(nonMachtingNotification).getType();
-        DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> body = Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("ns1", "1970-01-15", "not1data")));
+        doReturn(NOTIFICATION_1_PATH).when(matchnigNotification).getType();
+        doReturn(NOTIFICATION_2_PATH).when(nonMachtingNotification).getType();
+        DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> body = Builders
+                .containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("ns1",
+                        "1970-01-15", "not1data")));
         doReturn(body.build()).when(matchnigNotification).getBody();
         //init schema context mock
         Set<NotificationDefinition> notifications = new HashSet<>();
-        notifications.add(getNotificationDefinitionMock(notification1Path.getLastComponent()));
-        notifications.add(getNotificationDefinitionMock(notification2Path.getLastComponent()));
+        notifications.add(getNotificationDefinitionMock(NOTIFICATION_1_PATH.getLastComponent()));
+        notifications.add(getNotificationDefinitionMock(NOTIFICATION_2_PATH.getLastComponent()));
         SchemaContext schemaContext = mock(SchemaContext.class);
         doReturn(notifications).when(schemaContext).getNotifications();
         //init mount point mock
@@ -91,11 +95,12 @@ public class NetconfEventSourceTest {
         doReturn(Futures.immediateCheckedFuture(null)).when(mount).invokeCreateSubscription(any(), any());
         doReturn(Futures.immediateCheckedFuture(null)).when(mount).invokeCreateSubscription(any());
         doReturn(mock(ListenerRegistration.class)).when(mount).registerNotificationListener(any(), any());
-        final Node nodeId1 = NetconfTestUtils.getNetconfNode("NodeId1", "node.test.local", ConnectionStatus.Connected, NetconfTestUtils.notification_capability_prefix);
+        final Node nodeId1 = NetconfTestUtils.getNetconfNode("NodeId1", "node.test.local", ConnectionStatus
+                .Connected, NetconfTestUtils.NOTIFICATION_CAPABILITY_PREFIX);
         doReturn(nodeId1).when(mount).getNode();
 
         Map<String, String> streamMap = new HashMap<>();
-        streamMap.put(notification1Path.getLastComponent().getNamespace().toString(), "stream-1");
+        streamMap.put(NOTIFICATION_1_PATH.getLastComponent().getNamespace().toString(), "stream-1");
         netconfEventSource = new NetconfEventSource(
                 streamMap,
                 mount,
@@ -121,7 +126,8 @@ public class NetconfEventSourceTest {
         final TopicDOMNotification value = (TopicDOMNotification) captor.getValue();
         final QName qname = TopicNotification.QNAME;
         final YangInstanceIdentifier.NodeIdentifier topicIdNode =
-                new YangInstanceIdentifier.NodeIdentifier(QName.create(qname.getNamespace().toString(), qname.getFormattedRevision(), "topic-id"));
+                new YangInstanceIdentifier.NodeIdentifier(QName.create(qname.getNamespace().toString(), qname
+                        .getFormattedRevision(), "topic-id"));
         final Object actualTopicId = value.getBody().getChild(topicIdNode).get().getValue();
         Assert.assertEquals(topic1.getTopicId(), actualTopicId);
     }
@@ -152,10 +158,10 @@ public class NetconfEventSourceTest {
                 .build();
     }
 
-    private NotificationDefinition getNotificationDefinitionMock(QName qName) {
+    private NotificationDefinition getNotificationDefinitionMock(QName qualifiedName) {
         NotificationDefinition notification = mock(NotificationDefinition.class);
-        doReturn(qName).when(notification).getQName();
-        doReturn(SchemaPath.create(true, qName)).when(notification).getPath();
+        doReturn(qualifiedName).when(notification).getQName();
+        doReturn(SchemaPath.create(true, qualifiedName)).when(notification).getPath();
         return notification;
     }
 
index 3124d6b1f064071f0dafa3a859b8300e44f1d675..25c3a84756a0c80b3afcef498b65fd938bd3223b 100644 (file)
@@ -46,22 +46,23 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNo
 
 public final class NetconfTestUtils {
 
-    public static final String notification_capability_prefix = "(urn:ietf:params:xml:ns:netconf:notification";
+    public static final String NOTIFICATION_CAPABILITY_PREFIX = "(urn:ietf:params:xml:ns:netconf:notification";
 
     private NetconfTestUtils() {
     }
 
     public static Node getNetconfNode(String nodeIdent, String hostName, ConnectionStatus cs,
-        String notificationCapabilityPrefix) {
+                                      String notificationCapabilityPrefix) {
 
         DomainName dn = new DomainName(hostName);
         Host host = new Host(dn);
 
         List<AvailableCapability> avCapList = new ArrayList<>();
-        avCapList.add(new AvailableCapabilityBuilder().setCapability(notificationCapabilityPrefix + "_availableCapabilityString1").build());
+        avCapList.add(new AvailableCapabilityBuilder().setCapability(notificationCapabilityPrefix
+                + "_availableCapabilityString1").build());
         AvailableCapabilities avCaps = new AvailableCapabilitiesBuilder().setAvailableCapability(avCapList).build();
         NetconfNode nn = new NetconfNodeBuilder().setConnectionStatus(cs).setHost(host).setAvailableCapabilities(avCaps)
-            .build();
+                .build();
 
         NodeId nodeId = new NodeId(nodeIdent);
         NodeKey nk = new NodeKey(nodeId);
@@ -81,14 +82,14 @@ public final class NetconfTestUtils {
     }
 
     public static InstanceIdentifier<Node> getInstanceIdentifier(Node node) {
-        TopologyKey NETCONF_TOPOLOGY_KEY = new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()));
+        TopologyKey netconfTopologyKey = new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()));
         InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(NetworkTopology.class)
-            .child(Topology.class, NETCONF_TOPOLOGY_KEY).child(Node.class, node.getKey());
+                .child(Topology.class, netconfTopologyKey).child(Node.class, node.getKey());
         return nodeII;
     }
 
-    public static Optional<Streams> getAvailableStream(String Name, boolean replaySupport) {
-        Stream stream = new StreamBuilder().setName(new StreamNameType(Name)).setReplaySupport(replaySupport).build();
+    public static Optional<Streams> getAvailableStream(String name, boolean replaySupport) {
+        Stream stream = new StreamBuilder().setName(new StreamNameType(name)).setReplaySupport(replaySupport).build();
         List<Stream> streamList = new ArrayList<>();
         streamList.add(stream);
         Streams streams = new StreamsBuilder().setStream(streamList).build();
@@ -100,7 +101,8 @@ public final class NetconfTestUtils {
         Set<MapEntryNode> streamSet = new HashSet<>();
         for (String s : streamName) {
             MapEntryNode stream = Builders.mapEntryBuilder()
-                    .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(Stream.QNAME, nameNode, s))
+                    .withNodeIdentifier(new YangInstanceIdentifier
+                            .NodeIdentifierWithPredicates(Stream.QNAME, nameNode, s))
                     .withChild(Builders.leafBuilder()
                             .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(nameNode))
                             .withValue(s)
@@ -109,7 +111,8 @@ public final class NetconfTestUtils {
             streamSet.add(stream);
         }
 
-        CollectionNodeBuilder<MapEntryNode, MapNode> streams = Builders.mapBuilder().withNodeIdentifier(YangInstanceIdentifier.NodeIdentifier.create(Stream.QNAME));
+        CollectionNodeBuilder<MapEntryNode, MapNode> streams =
+                Builders.mapBuilder().withNodeIdentifier(YangInstanceIdentifier.NodeIdentifier.create(Stream.QNAME));
         for (MapEntryNode mapEntryNode : streamSet) {
             streams.withChild(mapEntryNode);
         }
index 2bf354b2c99758bf75baaac0639cd8016f6c138d..e68caa6a7fd4275d6efa44426559ba40bf889932 100644 (file)
@@ -36,7 +36,8 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration;
 public class StreamNotificationTopicRegistrationTest {
 
     private static final String STREAM_NAME = "stream-1";
-    private static final String PREFIX = ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.getLastComponent().getNamespace().toString();
+    private static final String PREFIX = ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH
+            .getLastComponent().getNamespace().toString();
 
     @Mock
     private NetconfEventSource source;
@@ -56,13 +57,15 @@ public class StreamNotificationTopicRegistrationTest {
 
         Node node = new NodeBuilder().setNodeId(NodeId.getDefaultInstance("node-id")).build();
         when(mount.getNode()).thenReturn(node);
-        when(mount.registerNotificationListener(source, ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH))
+        when(mount.registerNotificationListener(source, ConnectionNotificationTopicRegistration
+                .EVENT_SOURCE_STATUS_PATH))
                 .thenReturn(listenerRegistration);
         when(mount.invokeCreateSubscription(any(), any())).thenReturn(Futures.immediateCheckedFuture(null));
         when(mount.invokeCreateSubscription(any())).thenReturn(Futures.immediateCheckedFuture(null));
 
         when(source.getMount()).thenReturn(mount);
-        stream = new StreamBuilder().setName(StreamNameType.getDefaultInstance(STREAM_NAME)).setReplaySupport(true).build();
+        stream = new StreamBuilder().setName(StreamNameType.getDefaultInstance(STREAM_NAME)).setReplaySupport(true)
+                .build();
 
         registration = new StreamNotificationTopicRegistration(stream, PREFIX, source);
     }
@@ -107,12 +110,14 @@ public class StreamNotificationTopicRegistrationTest {
         final TopicId topic1 = registerTopic("topic1");
         final TopicId topic2 = registerTopic("topic2");
         final TopicId topic3 = registerTopic("topic3");
-        final Set<TopicId> notificationTopicIds = registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
+        final Set<TopicId> notificationTopicIds =
+                registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
         Assert.assertNotNull(notificationTopicIds);
         Assert.assertThat(notificationTopicIds, hasItems(topic1, topic2, topic3));
 
         registration.unRegisterNotificationTopic(topic3);
-        final Set<TopicId> afterUnregister = registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
+        final Set<TopicId> afterUnregister =
+                registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
         Assert.assertNotNull(afterUnregister);
         Assert.assertThat(afterUnregister, hasItems(topic1, topic2));
         Assert.assertFalse(afterUnregister.contains(topic3));