2 * Copyright (c) 2014, 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.test;
10 import java.util.ArrayList;
11 import java.util.List;
13 import org.opendaylight.mdsal.binding.api.NotificationService;
14 import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
15 import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener.Component;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class OpenflowpluginTestNodeConnectorNotification {
25 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestNodeConnectorNotification.class);
27 private final PortEventListener portEventListener = new PortEventListener();
28 private final NotificationService notificationService;
30 public OpenflowpluginTestNodeConnectorNotification(final NotificationService notificationService) {
31 this.notificationService = notificationService;
36 notificationService.registerCompositeListener(portEventListener.toListener());
39 private static final class PortEventListener {
40 List<NodeUpdated> nodeUpdated = new ArrayList<>();
41 List<NodeRemoved> nodeRemoved = new ArrayList<>();
42 List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
43 List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
45 CompositeListener toListener() {
46 return new CompositeListener(Set.of(
47 new Component<>(NodeConnectorRemoved.class, notification -> {
48 LOG.debug("NodeConnectorRemoved Notification");
49 LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
50 nodeConnectorRemoved.add(notification);
52 new Component<>(NodeConnectorUpdated.class, notification -> {
53 LOG.debug("NodeConnectorUpdated Notification");
54 LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
55 nodeConnectorUpdated.add(notification);
57 new Component<>(NodeRemoved.class, notification -> {
58 LOG.debug("NodeRemoved Notification");
59 LOG.debug("NodeRef {}", notification.getNodeRef());
60 nodeRemoved.add(notification);
62 new Component<>(NodeUpdated.class, notification -> {
63 LOG.debug("NodeUpdated Notification");
64 LOG.debug("NodeRef {}", notification.getNodeRef());
65 nodeUpdated.add(notification);