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>
<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>
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);
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;
}
};
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();
element.setAttributeNS(XMLNS_URI, name, namespaceURI.get());
return element;
}
- return document.createElement(qName);
+ return document.createElement(qualifiedName);
}
}
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);
* {@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()) {
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));
}
}
}
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);
}
- @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;
}
}
- @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) {
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) {
/**
* Returns all available notification paths that matches given pattern.
+ *
* @param notificationPattern pattern
* @return notification paths
*/
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());
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;
}
/**
- * 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()) {
}
/**
- * Invoke by blueprint
- * @param streamMap
+ * Invoked by blueprint.
+ *
+ * @param streamMap Stream map
*/
public void setStreamMap(Map<String, String> streamMap) {
this.streamMap = streamMap;
return node.getAugmentation(NetconfNode.class) != null;
}
- @Override public void close() {
+ @Override
+ public void close() {
listenerRegistration.close();
for (final NetconfEventSourceRegistration reg : registrationMap.values()) {
reg.close();
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;
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();
}
/**
- * 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));
/**
* Invokes create-subscription rpc on mounted device stream.
+ *
* @param stream stream
* @return rpc result
*/
}
/**
- * Returns list of streams avaliable on device
+ * Returns list of streams avaliable on device.
+ *
* @return list of streams
* @throws ReadFailedException if data read fails
*/
.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();
}
/**
* 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);
}
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;
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);
return false;
}
for (final AvailableCapability capability : netconfNode.getAvailableCapabilities().getAvailableCapability()) {
- if (capability.getCapability().startsWith(NotificationCapabilityPrefix)) {
+ if (capability.getCapability().startsWith(NOTIFICATION_CAPABILITY_PREFIX)) {
return true;
}
}
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());
}
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() {
}
}
- @Override public void close() {
+ @Override
+ public void close() {
closeEventSourceRegistration();
}
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;
/**
* Returns registered topics for given notification path.
+ *
* @param notificationPath path
* @return topicIds
*/
/**
* Checks, if notification is from namespace belonging to this registration.
+ *
* @param notificationPath path
* @return true, if notification belongs to registration namespace
*/
}
String nameSpace = notificationPath.getLastComponent().getNamespace().toString();
LOG.debug("CheckNotification - name space {} - NotificationUrnPrefix {}", nameSpace,
- getNotificationUrnPrefix());
+ getNotificationUrnPrefix());
return nameSpace.startsWith(getNotificationUrnPrefix());
}
/**
* 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
*/
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();
}
/**
- * 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() {
}
}
- @Override void deActivateNotificationSource() {
+ @Override
+ void deActivateNotificationSource() {
// no operations need
}
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;
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);
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);
}
}
- @Override public void close() throws Exception {
+ @Override
+ public void close() throws Exception {
closeStream();
}
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));
/**
* 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();
@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,
@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<>();
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);
}
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);
}
.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()));
.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();
.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()));
}
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
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;
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
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,
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);
}
.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;
}
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);
}
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();
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)
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);
}
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;
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);
}
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));