+++ /dev/null
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.openflowplugin</groupId>
- <artifactId>openflowplugin-parent</artifactId>
- <version>0.14.0-SNAPSHOT</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.openflowplugin.applications</groupId>
- <artifactId>notification-supplier</artifactId>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.model</groupId>
- <artifactId>model-inventory</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.model</groupId>
- <artifactId>model-flow-base</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.model</groupId>
- <artifactId>model-flow-statistics</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin</groupId>
- <artifactId>openflowplugin-common</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.VisibleForTesting;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.NodeConnectorNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.NodeNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.FlowNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.GroupNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.MeterNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat.FlowStatNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat.FlowTableStatNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat.GroupStatNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat.MeterStatNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat.NodeConnectorStatNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat.QueueStatNotificationSupplierImpl;
-import org.opendaylight.openflowplugin.applications.notification.supplier.tools.NotificationProviderConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.node.meter.statistics.MeterStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
-
-/**
- * Provider Implementation.
- */
-public class NotificationProvider implements AutoCloseable {
-
- private final DataBroker db;
- private final NotificationProviderConfig config;
- private final NotificationPublishService nps;
-
- /* Supplier List property help for easy close method implementation and testing */
- private List<NotificationSupplierDefinition<?>> supplierList;
- private NotificationSupplierForItemRoot<FlowCapableNode, NodeUpdated, NodeRemoved> nodeSupp;
- private NotificationSupplierForItemRoot<FlowCapableNodeConnector, NodeConnectorUpdated, NodeConnectorRemoved>
- connectorSupp;
- private NotificationSupplierForItem<Flow, FlowAdded, FlowUpdated, FlowRemoved> flowSupp;
- private NotificationSupplierForItem<Meter, MeterAdded, MeterUpdated, MeterRemoved> meterSupp;
- private NotificationSupplierForItem<Group, GroupAdded, GroupUpdated, GroupRemoved> groupSupp;
- private NotificationSupplierForItemStat<FlowCapableNodeConnectorStatistics, NodeConnectorStatisticsUpdate>
- connectorStatSupp;
- private NotificationSupplierForItemStat<FlowStatistics, FlowsStatisticsUpdate> flowStatSupp;
- private NotificationSupplierForItemStat<FlowTableStatistics, FlowTableStatisticsUpdate> flowTableStatSupp;
- private NotificationSupplierForItemStat<MeterStatistics, MeterStatisticsUpdated> meterStatSupp;
- private NotificationSupplierForItemStat<GroupStatistics, GroupStatisticsUpdated> groupStatSupp;
- private NotificationSupplierForItemStat<FlowCapableNodeConnectorQueueStatisticsData, QueueStatisticsUpdate>
- queueStatSupp;
-
- /**
- * Provider constructor set all needed final parameters.
- *
- * @param nps - notifProviderService
- * @param db - dataBroker
- * @param flowSupp - Flow Support Flag
- * @param meterSupp - Meter Support Flag
- * @param groupSupp - Group Support Flag
- * @param connectorStatSupp - Connector Stat Support Flag
- * @param flowStatSupp - Flow Stat Support Flag
- * @param flowTableStatSupp - Flow Table Stat Support Flag
- * @param meterStatSupp - Meter Stat Support Flag
- * @param groupStatSupp - Group Stat Support Flag
- * @param queueStatSupp - Queue Stat Support Flag
- */
- public NotificationProvider(final NotificationPublishService nps, final DataBroker db, final boolean flowSupp,
- final boolean meterSupp, final boolean groupSupp, final boolean connectorStatSupp,
- final boolean flowStatSupp, final boolean flowTableStatSupp,
- final boolean meterStatSupp, final boolean groupStatSupp, final boolean queueStatSupp) {
- this.nps = requireNonNull(nps);
- this.db = requireNonNull(db);
- this.config = initializeNotificationProviderConfig(flowSupp, meterSupp, groupSupp, connectorStatSupp,
- flowStatSupp, flowTableStatSupp, meterStatSupp,
- groupStatSupp, queueStatSupp);
- }
-
- /**
- * Method to initialize NotificationProviderConfig.
- */
- private NotificationProviderConfig initializeNotificationProviderConfig(final boolean hasFlowSupp,
- final boolean hasMeterSupp,
- final boolean hasGroupSupp,
- final boolean hasConnectorStatSupp,
- final boolean hasFlowStatSupp,
- final boolean hasFlowTableStatSupp,
- final boolean hasMeterStatSupp,
- final boolean hasGroupStatSupp,
- final boolean hasQueueStatSupp) {
- NotificationProviderConfig.NotificationProviderConfigBuilder notif
- = new NotificationProviderConfig.NotificationProviderConfigBuilder();
- notif.setFlowSupport(hasFlowSupp);
- notif.setMeterSupport(hasMeterSupp);
- notif.setGroupSupport(hasGroupSupp);
- notif.setNodeConnectorStatSupport(hasConnectorStatSupp);
- notif.setFlowStatSupport(hasFlowStatSupp);
- notif.setFlowTableStatSupport(hasFlowTableStatSupp);
- notif.setMeterStatSupport(hasMeterStatSupp);
- notif.setGroupStatSupport(hasGroupStatSupp);
- notif.setQueueStatSupport(hasQueueStatSupp);
- return notif.build();
- }
-
- public void start() {
- nodeSupp = new NodeNotificationSupplierImpl(nps, db);
- connectorSupp = new NodeConnectorNotificationSupplierImpl(nps, db);
- flowSupp = config.isFlowSupport() ? new FlowNotificationSupplierImpl(nps, db) : null;
- meterSupp = config.isMeterSupport() ? new MeterNotificationSupplierImpl(nps, db) : null;
- groupSupp = config.isGroupSupport() ? new GroupNotificationSupplierImpl(nps, db) : null;
- connectorStatSupp = config.isNodeConnectorStatSupport() ? new NodeConnectorStatNotificationSupplierImpl(nps,
- db) :
- null;
- flowStatSupp = config.isFlowStatSupport() ? new FlowStatNotificationSupplierImpl(nps, db) : null;
- flowTableStatSupp = config.isFlowTableStatSupport() ? new FlowTableStatNotificationSupplierImpl(nps, db) : null;
- meterStatSupp = config.isMeterStatSupport() ? new MeterStatNotificationSupplierImpl(nps, db) : null;
- groupStatSupp = config.isGroupStatSupport() ? new GroupStatNotificationSupplierImpl(nps, db) : null;
- queueStatSupp = config.isQueueStatSupport() ? new QueueStatNotificationSupplierImpl(nps, db) : null;
-
- supplierList = new ArrayList<>(
- Arrays.asList(nodeSupp, connectorSupp, flowSupp, meterSupp, groupSupp, connectorStatSupp, flowStatSupp,
- flowTableStatSupp, meterStatSupp, groupStatSupp, queueStatSupp));
- }
-
- @Override
- public void close() throws Exception {
- for (NotificationSupplierDefinition<?> supplier : supplierList) {
- if (supplier != null) {
- supplier.close();
- supplier = null;
- }
- }
- }
-
- @VisibleForTesting
- List<NotificationSupplierDefinition<?>> getSupplierList() {
- return supplierList;
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier;
-
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Default definition for every Notification Supplier. Migration from notification
- * to {@link DataTreeChangeListener} has one
- * keyed component - WildCarded Path which represent a changes checker in DataStoreTreeNode
- *
- * @param <O> - {@link DataObject} represent Data Tree Item from DataStore
- */
-public interface NotificationSupplierDefinition<O extends DataObject> extends AutoCloseable, DataTreeChangeListener<O> {
-
- /**
- * Method return wildCardPath for Listener registration and for identify
- * the correct KeyInstanceIdentifier from Data Tree Item in DataStore.
- *
- * @return {@link InstanceIdentifier}
- */
- InstanceIdentifier<O> getWildCardPath();
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.notification.supplier;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Supplier Item contracts definition for every Notification. All items are described
- * by three notifications. Notification for Create, Update and Delete. So interface
- * has to contain three methods for every Notification.
- *
- * @param <O> - data tree item Object
- * @param <C> - Create notification
- * @param <U> - Update notification
- * @param <D> - Delete notification
- */
-public interface NotificationSupplierForItem<O extends DataObject, C extends Notification, U extends Notification, D
- extends Notification> extends NotificationSupplierDefinition<O> {
-
- /**
- * Method produces relevant addItem kind of {@link Notification} from
- * data tree item identified by {@link InstanceIdentifier} path.
- *
- * @param dataTreeItemObject - Data Tree Item object
- * @param path - Identifier of Data Tree Item
- * @return {@link Notification} - relevant API contract Notification
- */
- C createNotification(O dataTreeItemObject, InstanceIdentifier<O> path);
-
- /**
- * Method produces relevant updateItem kind of {@link Notification} from
- * data tree item identified by {@link InstanceIdentifier} path.
- *
- * @param dataTreeItemObject - Data Tree Item object
- * @param path - Identifier of Data Tree Item
- * @return {@link Notification} - relevant API contract Notification
- */
- U updateNotification(O dataTreeItemObject, InstanceIdentifier<O> path);
-
- /**
- * Method produces relevant deleteItem kind of {@link Notification} from
- * path {@link InstanceIdentifier} to deleted item.
- *
- * @param path - Identifier of Data Tree Item
- * @return {@link Notification} - relevant API contract Notification
- */
- D deleteNotification(InstanceIdentifier<O> path);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.notification.supplier;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Supplier Root Item contracts definition for every Notification. All root items
- * are described by two notifications. Notification for Create and Delete.
- * So interface has to contain two methods for relevant Notification.
- *
- * @param <O> - data tree item Object
- * @param <C> - Create notification
- * @param <D> - Delete notification
- */
-public interface NotificationSupplierForItemRoot<O extends DataObject, C extends Notification, D extends
- Notification> extends NotificationSupplierDefinition<O> {
-
- /**
- * Method produces relevant addItem kind of {@link Notification} from data tree item identified by
- * {@link InstanceIdentifier} path.
- *
- * @param dataTreeItemObject - Data Tree Item object
- * @param path - Identifier of Data Tree Item
- * @return {@link Notification} - relevant API contract Notification
- */
- C createNotification(O dataTreeItemObject, InstanceIdentifier<O> path);
-
- /**
- * Method produces relevant deleteItem kind of {@link Notification} from
- * path {@link InstanceIdentifier} to deleted item.
- *
- * @param path - Identifier of Data Tree Item
- * @return {@link Notification} - relevant API contract Notification
- */
- D deleteNotification(InstanceIdentifier<O> path);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.notification.supplier;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Notifications for Statistics have little bit different case,
- * because it looks like they have response for create and update.
- * But follow the statistics internal implementation processing
- * is talks only about create event.
- *
- * @param <O> - data tree item Object
- * @param <N> - Statistics Notification
- */
-public interface NotificationSupplierForItemStat<O extends DataObject, N extends Notification> extends
- NotificationSupplierDefinition<O> {
- /**
- * Method produces relevant Statistics kind of {@link Notification} from statistics data tree item identified by
- * {@link InstanceIdentifier} path.
- *
- * @param statisticsDataTreeItem - Statistics Data Tree Item
- * @param path - Identifier of Data Tree Item
- * @return {@link Notification} - relevant API contract Notification
- */
- N createNotification(O statisticsDataTreeItem, InstanceIdentifier<O> path);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierDefinition;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Public abstract basic Supplier implementation contains code for a make Supplier instance,
- * registration Supplier like {@link DataTreeChangeListener}
- * and close method. In additional case, it contains help methods for all Supplier implementations.
- *
- * @param <O> - data tree item Object extends {@link DataObject}
- */
-public abstract class AbstractNotificationSupplierBase<O extends DataObject> implements
- NotificationSupplierDefinition<O> {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractNotificationSupplierBase.class);
-
- protected final Class<O> clazz;
- private ListenerRegistration<DataTreeChangeListener<O>> listenerRegistration;
- private static final int STARTUP_LOOP_TICK = 500;
- private static final int STARTUP_LOOP_MAX_RETRIES = 8;
-
-
- final DataTreeIdentifier<O> treeId = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, getWildCardPath());
-
- /**
- * Default constructor for all Notification Supplier implementation.
- *
- * @param db - {@link DataBroker}
- * @param clazz - API contract class extended {@link DataObject}
- */
- @SuppressWarnings("IllegalCatch")
- public AbstractNotificationSupplierBase(final DataBroker db, final Class<O> clazz) {
- Preconditions.checkArgument(db != null, "DataBroker can not be null!");
- this.clazz = clazz;
-
- SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
- try {
- listenerRegistration = looper
- .loopUntilNoException(
- () -> db.registerDataTreeChangeListener(treeId, AbstractNotificationSupplierBase.this));
- } catch (final Exception ex) {
- LOG.debug("AbstractNotificationSupplierBase DataTreeChange listener registration fail ..{}",
- ex.getMessage());
- throw new IllegalStateException("Notification supplier startup fail! System needs restart.", ex);
- }
- }
-
- @Override
- public void close() {
- if (listenerRegistration != null) {
- listenerRegistration.close();
- listenerRegistration = null;
- }
- }
-
- /**
- * Method returns a wildCard {@link InstanceIdentifier} for {@link Node} from inventory
- * because this path is a base for every OF paths.
- *
- * @return WildCarded InstanceIdentifier for Node
- */
- protected static InstanceIdentifier<Node> getNodeWildII() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class);
- }
-
- /**
- * Method returns a keyed {@link InstanceIdentifier} for {@link Node} from inventory
- * because this path is a base for every OF paths.
- *
- * @param ii - key for keyed {@link Node} {@link InstanceIdentifier}
- * @return Keyed InstanceIdentifier for Node
- */
- protected static KeyedInstanceIdentifier<Node, NodeKey> getNodeII(final InstanceIdentifier<?> ii) {
- final NodeKey key = ii.firstKeyOf(Node.class);
- Preconditions.checkArgument(key != null);
- return InstanceIdentifier.create(Nodes.class).child(Node.class, key);
- }
-
- /**
- * Create a node reference.
- *
- * @param path pointer to element
- * @return extracted {@link NodeKey} and wrapped in {@link NodeRef}
- */
- public static NodeRef createNodeRef(final InstanceIdentifier<?> path) {
- final InstanceIdentifier<Node> nodePath = requireNonNull(path.firstIdentifierOf(Node.class));
- return new NodeRef(nodePath);
- }
-
- /**
- * Get the node identifier.
- *
- * @param path pointer to element
- * @return extracted {@link NodeId}
- */
- public static NodeId getNodeId(final InstanceIdentifier<?> path) {
- final NodeKey nodeKey = requireNonNull(path.firstKeyOf(Node.class));
- return nodeKey.getId();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Collection;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierForItemRoot;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Class is package protected abstract implementation for all Root Items
- * Notification Suppliers.
- *
- * @param <O> - data tree item Object
- * @param <C> - Create notification
- * @param <D> - Delete notification
- */
-public abstract class AbstractNotificationSupplierForItemRoot<O extends DataObject, C extends Notification, D extends
- Notification> extends AbstractNotificationSupplierBase<O> implements NotificationSupplierForItemRoot<O, C, D> {
-
- private final NotificationPublishService notificationProviderService;
-
- /**
- * Default constructor for all Root Item Notification Supplier implementation.
- *
- * @param notificationProviderService - notification publisher
- * @param db - DataBroker for DataTreeChangeListener registration
- * @param clazz - Statistics Notification Class
- */
- public AbstractNotificationSupplierForItemRoot(final NotificationPublishService notificationProviderService,
- final DataBroker db, final Class<O> clazz) {
- super(db, clazz);
- this.notificationProviderService = requireNonNull(notificationProviderService);
- }
-
- @Override
- public void onDataTreeChanged(final Collection<DataTreeModification<O>> changes) {
- for (DataTreeModification<O> change : changes) {
- final InstanceIdentifier<O> key = change.getRootPath().getRootIdentifier();
- final DataObjectModification<O> mod = change.getRootNode();
- switch (mod.getModificationType()) {
- case DELETE:
- remove(key, mod.getDataBefore());
- break;
- case SUBTREE_MODIFIED:
- update(key, mod.getDataBefore(), mod.getDataAfter());
- break;
- case WRITE:
- if (mod.getDataBefore() == null) {
- add(key, mod.getDataAfter());
- } else {
- update(key, mod.getDataBefore(), mod.getDataAfter());
- }
- break;
- default:
- throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
- }
- }
- }
-
-
- public void add(final InstanceIdentifier<O> identifier, final O add) {
- putNotification(createNotification(add, identifier));
- }
-
- public void remove(final InstanceIdentifier<O> identifier, final O del) {
- putNotification(deleteNotification(identifier.firstIdentifierOf(clazz)));
- }
-
- public void update(final InstanceIdentifier<O> identifier, final O before, final O after) {
- //EMPTY NO-OP
- }
-
- private void putNotification(final Notification notif) {
- if (notif != null) {
- try {
- notificationProviderService.putNotification(notif);
- } catch (InterruptedException e) {
- throw new IllegalStateException("Interrupted while publishing " + notif, e);
- }
- }
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemovedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Implementation define a contract between {@link FlowCapableNodeConnector} data object
- * and {@link NodeConnectorUpdated} and {@link NodeConnectorRemoved} notifications.
- */
-public class NodeConnectorNotificationSupplierImpl extends
- AbstractNotificationSupplierForItemRoot<FlowCapableNodeConnector, NodeConnectorUpdated, NodeConnectorRemoved> {
-
- private static final InstanceIdentifier<FlowCapableNodeConnector> FLOW_CAPABLE_NODE_CONNECTOR_INSTANCE_IDENTIFIER
- = getNodeWildII().child(NodeConnector.class).augmentation(FlowCapableNodeConnector.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public NodeConnectorNotificationSupplierImpl(final NotificationPublishService notifProviderService,
- final DataBroker db) {
- super(notifProviderService, db, FlowCapableNodeConnector.class);
- }
-
- @Override
- public InstanceIdentifier<FlowCapableNodeConnector> getWildCardPath() {
- return FLOW_CAPABLE_NODE_CONNECTOR_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public NodeConnectorUpdated createNotification(final FlowCapableNodeConnector flowCapableNodeConnector,
- final InstanceIdentifier<FlowCapableNodeConnector> path) {
- Preconditions.checkArgument(flowCapableNodeConnector != null);
- Preconditions.checkArgument(path != null);
- final NodeConnectorUpdatedBuilder notifBuilder = new NodeConnectorUpdatedBuilder();
- notifBuilder.setId(path.firstKeyOf(NodeConnector.class).getId());
- notifBuilder.setNodeConnectorRef(new NodeConnectorRef(path));
- notifBuilder.addAugmentation(new FlowCapableNodeConnectorUpdatedBuilder(flowCapableNodeConnector).build());
- return notifBuilder.build();
- }
-
- @Override
- public NodeConnectorRemoved deleteNotification(final InstanceIdentifier<FlowCapableNodeConnector> path) {
- Preconditions.checkArgument(path != null);
- final NodeConnectorRemovedBuilder notifBuilder = new NodeConnectorRemovedBuilder();
- notifBuilder.setNodeConnectorRef(new NodeConnectorRef(path));
- return notifBuilder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemovedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Implementation define a contract between {@link FlowCapableNode} data object
- * and {@link NodeUpdated} and {@link NodeRemoved} notifications.
- */
-public class NodeNotificationSupplierImpl extends AbstractNotificationSupplierForItemRoot<FlowCapableNode,
- NodeUpdated, NodeRemoved> {
-
- private static final InstanceIdentifier<FlowCapableNode> FLOW_CAPABLE_NODE_INSTANCE_IDENTIFIER = getNodeWildII()
- .augmentation(FlowCapableNode.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public NodeNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) {
- super(notifProviderService, db, FlowCapableNode.class);
- }
-
- @Override
- public InstanceIdentifier<FlowCapableNode> getWildCardPath() {
- return FLOW_CAPABLE_NODE_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public NodeUpdated createNotification(final FlowCapableNode flowCapableNode,
- final InstanceIdentifier<FlowCapableNode> ii) {
- Preconditions.checkArgument(flowCapableNode != null);
- Preconditions.checkArgument(ii != null);
- final NodeUpdatedBuilder notifBuilder = new NodeUpdatedBuilder();
- notifBuilder.setId(ii.firstKeyOf(Node.class).getId());
- notifBuilder.setNodeRef(new NodeRef(getNodeII(ii)));
- notifBuilder.addAugmentation(new FlowCapableNodeUpdatedBuilder(flowCapableNode).build());
- return notifBuilder.build();
- }
-
- @Override
- public NodeRemoved deleteNotification(final InstanceIdentifier<FlowCapableNode> path) {
- Preconditions.checkArgument(path != null);
- final NodeRemovedBuilder delNodeNotifBuilder = new NodeRemovedBuilder();
- delNodeNotifBuilder.setNodeRef(new NodeRef(path));
- return delNodeNotifBuilder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Collection;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierForItem;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.AbstractNotificationSupplierBase;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Class is package protected abstract implementation for all Old Root Items
- * Notification Suppliers.
- *
- * @param <O> - data tree item Object
- * @param <C> - Create notification
- * @param <U> - Update notification
- * @param <D> - Delete notification
- */
-public abstract class AbstractNotificationSupplierForItem<O extends DataObject, C extends Notification, U extends
- Notification, D extends Notification> extends AbstractNotificationSupplierBase<O> implements
- NotificationSupplierForItem<O, C, U, D> {
-
- private final NotificationPublishService notificationProviderService;
-
- /**
- * Default constructor for all item Notification Supplier implementation.
- *
- * @param notifProviderService - notification publisher
- * @param db - DataBroker for DataTreeChangeListener registration
- * @param clazz - Statistics Notification Class
- */
- public AbstractNotificationSupplierForItem(final NotificationPublishService notifProviderService,
- final DataBroker db, final Class<O> clazz) {
- super(db, clazz);
- this.notificationProviderService = requireNonNull(notifProviderService);
- }
-
- @Override
- public void onDataTreeChanged(final Collection<DataTreeModification<O>> changes) {
- for (DataTreeModification<O> change : changes) {
- final InstanceIdentifier<O> key = change.getRootPath().getRootIdentifier();
- final DataObjectModification<O> mod = change.getRootNode();
- switch (mod.getModificationType()) {
- case DELETE:
- remove(key, mod.getDataBefore());
- break;
- case SUBTREE_MODIFIED:
- update(key, mod.getDataBefore(), mod.getDataAfter());
- break;
- case WRITE:
- if (mod.getDataBefore() == null) {
- add(key, mod.getDataAfter());
- } else {
- update(key, mod.getDataBefore(), mod.getDataAfter());
- }
- break;
- default:
- throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
- }
- }
- }
-
- public void add(final InstanceIdentifier<O> identifier, final O add) {
- putNotification(createNotification(add, identifier));
- }
-
- public void remove(final InstanceIdentifier<O> identifier, final O del) {
- putNotification(deleteNotification(identifier.firstIdentifierOf(clazz)));
- }
-
- public void update(final InstanceIdentifier<O> identifier, final O before, final O after) {
- putNotification(updateNotification(after, identifier));
- }
-
- private void putNotification(final Notification notif) {
- if (notif != null) {
- try {
- notificationProviderService.putNotification(notif);
- } catch (InterruptedException e) {
- throw new IllegalStateException("Interrupted while publishing " + notif, e);
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Implementation define a contract between {@link Flow} data object
- * and {@link FlowAdded}, {@link FlowUpdated} and {@link FlowRemoved} notifications.
- */
-public class FlowNotificationSupplierImpl extends AbstractNotificationSupplierForItem<Flow, FlowAdded, FlowUpdated,
- FlowRemoved> {
-
- private static final InstanceIdentifier<Flow> FLOW_INSTANCE_IDENTIFIER = getNodeWildII()
- .augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public FlowNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) {
- super(notifProviderService, db, Flow.class);
- }
-
- @Override
- public InstanceIdentifier<Flow> getWildCardPath() {
- return FLOW_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public FlowAdded createNotification(final Flow dataTreeItemObject, final InstanceIdentifier<Flow> path) {
- Preconditions.checkArgument(dataTreeItemObject != null);
- Preconditions.checkArgument(path != null);
- final FlowAddedBuilder builder = new FlowAddedBuilder(dataTreeItemObject);
- builder.setFlowRef(new FlowRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-
- @Override
- public FlowUpdated updateNotification(final Flow flow, final InstanceIdentifier<Flow> path) {
- Preconditions.checkArgument(flow != null);
- Preconditions.checkArgument(path != null);
- final FlowUpdatedBuilder builder = new FlowUpdatedBuilder(flow);
- builder.setFlowRef(new FlowRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-
- @Override
- public FlowRemoved deleteNotification(final InstanceIdentifier<Flow> path) {
- Preconditions.checkArgument(path != null);
- final FlowRemovedBuilder builder = new FlowRemovedBuilder();
- builder.setFlowRef(new FlowRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAddedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemovedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Implementation define a contract between {@link Group} data object
- * and {@link GroupAdded}, {@link GroupUpdated} and {@link GroupRemoved} notifications.
- */
-public class GroupNotificationSupplierImpl extends AbstractNotificationSupplierForItem<Group, GroupAdded,
- GroupUpdated, GroupRemoved> {
-
- private static final InstanceIdentifier<Group> GROUP_INSTANCE_IDENTIFIER = getNodeWildII()
- .augmentation(FlowCapableNode.class).child(Group.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public GroupNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) {
- super(notifProviderService, db, Group.class);
- }
-
- @Override
- public InstanceIdentifier<Group> getWildCardPath() {
- return GROUP_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public GroupAdded createNotification(final Group dataTreeItemObject, final InstanceIdentifier<Group> path) {
- Preconditions.checkArgument(dataTreeItemObject != null);
- Preconditions.checkArgument(path != null);
- final GroupAddedBuilder builder = new GroupAddedBuilder(dataTreeItemObject);
- builder.setGroupRef(new GroupRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-
- @Override
- public GroupUpdated updateNotification(final Group group, final InstanceIdentifier<Group> path) {
- Preconditions.checkArgument(group != null);
- Preconditions.checkArgument(path != null);
- final GroupUpdatedBuilder builder = new GroupUpdatedBuilder(group);
- builder.setGroupRef(new GroupRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-
- @Override
- public GroupRemoved deleteNotification(final InstanceIdentifier<Group> path) {
- Preconditions.checkArgument(path != null);
- final GroupRemovedBuilder builder = new GroupRemovedBuilder();
- builder.setGroupId(path.firstKeyOf(Group.class).getGroupId());
- builder.setGroupRef(new GroupRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAddedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemovedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Implementation define a contract between {@link Meter} data object
- * and {@link MeterAdded}, {@link MeterUpdated} and {@link MeterRemoved} notifications.
- */
-public class MeterNotificationSupplierImpl extends
- AbstractNotificationSupplierForItem<Meter, MeterAdded, MeterUpdated, MeterRemoved> {
-
- private static final InstanceIdentifier<Meter> METER_INSTANCE_IDENTIFIER
- = getNodeWildII().augmentation(FlowCapableNode.class).child(Meter.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public MeterNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) {
- super(notifProviderService, db, Meter.class);
- }
-
- @Override
- public InstanceIdentifier<Meter> getWildCardPath() {
- return METER_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public MeterAdded createNotification(final Meter dataTreeItemObject, final InstanceIdentifier<Meter> path) {
- Preconditions.checkArgument(dataTreeItemObject != null);
- Preconditions.checkArgument(path != null);
- final MeterAddedBuilder builder = new MeterAddedBuilder(dataTreeItemObject);
- builder.setMeterRef(new MeterRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-
- @Override
- public MeterUpdated updateNotification(final Meter meter, final InstanceIdentifier<Meter> path) {
- Preconditions.checkArgument(meter != null);
- Preconditions.checkArgument(path != null);
- final MeterUpdatedBuilder builder = new MeterUpdatedBuilder(meter);
- builder.setMeterRef(new MeterRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-
- @Override
- public MeterRemoved deleteNotification(final InstanceIdentifier<Meter> path) {
- Preconditions.checkArgument(path != null);
- final MeterRemovedBuilder builder = new MeterRemovedBuilder();
- builder.setMeterId(path.firstKeyOf(Meter.class).getMeterId());
- builder.setMeterRef(new MeterRef(path));
- builder.setNode(createNodeRef(path));
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-/**
- * Package contains OF Items (Flow, Group, Meter ...) notification listener/supplier implementations
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item;
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Collection;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierForItemStat;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.AbstractNotificationSupplierBase;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Class is package protected abstract implementation for all Old Statistics
- * Notification Suppliers.
- *
- * @param <O> - Statistics {@link DataObject}
- * @param <N> - Statistics Notification
- */
-public abstract class AbstractNotificationSupplierForItemStat<O extends DataObject, N extends Notification> extends
- AbstractNotificationSupplierBase<O> implements NotificationSupplierForItemStat<O, N> {
-
- private final NotificationPublishService notifProviderService;
-
- /**
- * Default constructor for all Statistic Notification Supplier implementation.
- *
- * @param notifProviderService - notification publisher
- * @param db - DataBroker for DataTreeChangeListener registration
- * @param clazz - Statistics Notification Class
- */
- public AbstractNotificationSupplierForItemStat(final NotificationPublishService notifProviderService,
- final DataBroker db, final Class<O> clazz) {
- super(db, clazz);
- this.notifProviderService = requireNonNull(notifProviderService);
- }
-
- @Override
- public void onDataTreeChanged(final Collection<DataTreeModification<O>> changes) {
- for (DataTreeModification<O> change : changes) {
- final InstanceIdentifier<O> key = change.getRootPath().getRootIdentifier();
- final DataObjectModification<O> mod = change.getRootNode();
- switch (mod.getModificationType()) {
- case DELETE:
- remove(key, mod.getDataBefore());
- break;
- case SUBTREE_MODIFIED:
- update(key, mod.getDataBefore(), mod.getDataAfter());
- break;
- case WRITE:
- if (mod.getDataBefore() == null) {
- add(key, mod.getDataAfter());
- } else {
- update(key, mod.getDataBefore(), mod.getDataAfter());
- }
- break;
- default:
- throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
- }
- }
- }
-
-
- public void add(final InstanceIdentifier<O> identifier, final O add) {
- final N notif = createNotification(add, identifier);
- if (notif != null) {
- try {
- notifProviderService.putNotification(notif);
- } catch (InterruptedException e) {
- throw new IllegalStateException("Interrupted while publishing " + notif, e);
- }
- }
- }
-
- public void remove(final InstanceIdentifier<O> identifier, final O del) {
- //EMPTY NO-OP
- }
-
- public void update(final InstanceIdentifier<O> identifier, final O before, final O after) {
- //EMPTY NO-OP
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.Collections;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatistics;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Implementation define a contract between {@link FlowStatistics} data object
- * and {@link FlowsStatisticsUpdate} notification.
- */
-public class FlowStatNotificationSupplierImpl extends AbstractNotificationSupplierForItemStat<FlowStatistics,
- FlowsStatisticsUpdate> {
-
- private static final InstanceIdentifier<FlowStatistics> FLOW_STATISTICS_INSTANCE_IDENTIFIER = getNodeWildII()
- .augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class)
- .augmentation(FlowStatisticsData.class).child(FlowStatistics.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public FlowStatNotificationSupplierImpl(final NotificationPublishService notifProviderService,
- final DataBroker db) {
- super(notifProviderService, db, FlowStatistics.class);
- }
-
- @Override
- public InstanceIdentifier<FlowStatistics> getWildCardPath() {
- return FLOW_STATISTICS_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public FlowsStatisticsUpdate createNotification(final FlowStatistics flowStatistics,
- final InstanceIdentifier<FlowStatistics> path) {
- checkArgument(flowStatistics != null);
- checkArgument(path != null);
-
- return new FlowsStatisticsUpdateBuilder()
- .setId(getNodeId(path))
- .setMoreReplies(Boolean.FALSE)
- // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
- .setNodeConnector(Collections.emptyMap())
- .setFlowAndStatisticsMapList(Collections.singletonList(new FlowAndStatisticsMapListBuilder(flowStatistics)
- .setFlowId(new FlowId(path.firstKeyOf(Flow.class).getId().getValue()))
- .build()))
- .build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.util.BindingMap;
-
-/**
- * Implementation define a contract between {@link FlowTableStatistics} data object
- * and {@link FlowTableStatisticsUpdate} notification.
- */
-public class FlowTableStatNotificationSupplierImpl extends
- AbstractNotificationSupplierForItemStat<FlowTableStatistics, FlowTableStatisticsUpdate> {
-
- private static final InstanceIdentifier<FlowTableStatistics> FLOW_TABLE_STATISTICS_INSTANCE_IDENTIFIER
- = getNodeWildII().augmentation(FlowCapableNode.class).child(Table.class)
- .augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public FlowTableStatNotificationSupplierImpl(final NotificationPublishService notifProviderService,
- final DataBroker db) {
- super(notifProviderService, db, FlowTableStatistics.class);
- }
-
- @Override
- public InstanceIdentifier<FlowTableStatistics> getWildCardPath() {
- return FLOW_TABLE_STATISTICS_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics,
- final InstanceIdentifier<FlowTableStatistics> path) {
- checkArgument(flowTableStatistics != null);
- checkArgument(path != null);
-
- return new FlowTableStatisticsUpdateBuilder()
- .setId(getNodeId(path))
- .setMoreReplies(Boolean.FALSE)
- // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
- .setNodeConnector(BindingMap.of())
- .setFlowTableAndStatisticsMap(BindingMap.of(new FlowTableAndStatisticsMapBuilder(flowTableStatistics)
- .withKey(new FlowTableAndStatisticsMapKey(new TableId(path.firstKeyOf(Table.class).getId())))
- .build()))
- .build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import com.google.common.base.Preconditions;
-import java.util.Collections;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.util.BindingMap;
-
-/**
- * Implementation define a contract between {@link GroupStatistics} data object
- * and {@link GroupStatisticsUpdated} notification.
- */
-public class GroupStatNotificationSupplierImpl extends AbstractNotificationSupplierForItemStat<GroupStatistics,
- GroupStatisticsUpdated> {
-
- private static final InstanceIdentifier<GroupStatistics> GROUP_STATISTICS_INSTANCE_IDENTIFIER = getNodeWildII()
- .augmentation(FlowCapableNode.class).child(Group.class).augmentation(NodeGroupStatistics.class)
- .child(GroupStatistics.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public GroupStatNotificationSupplierImpl(final NotificationPublishService notifProviderService,
- final DataBroker db) {
- super(notifProviderService, db, GroupStatistics.class);
- }
-
- @Override
- public InstanceIdentifier<GroupStatistics> getWildCardPath() {
- return GROUP_STATISTICS_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public GroupStatisticsUpdated createNotification(final GroupStatistics groupStatistics,
- final InstanceIdentifier<GroupStatistics> path) {
- Preconditions.checkArgument(groupStatistics != null);
- Preconditions.checkArgument(path != null);
-
- final GroupStatisticsUpdatedBuilder builder = new GroupStatisticsUpdatedBuilder();
- builder.setId(getNodeId(path));
- builder.setMoreReplies(Boolean.FALSE);
- // TODO : fix if it needs, but we have to ask DataStore for the NodeConnector list
- builder.setNodeConnector(Collections.emptyMap());
- builder.setGroupStats(BindingMap.of(new GroupStatsBuilder(groupStatistics)
- .setGroupId(path.firstKeyOf(Group.class).getGroupId())
- .build()));
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import com.google.common.base.Preconditions;
-import java.util.Collections;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.node.meter.statistics.MeterStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.util.BindingMap;
-
-/**
- * Implementation define a contract between {@link MeterStatistics} data object
- * and {@link MeterStatisticsUpdated} notification.
- */
-public class MeterStatNotificationSupplierImpl extends AbstractNotificationSupplierForItemStat<MeterStatistics,
- MeterStatisticsUpdated> {
-
- private static final InstanceIdentifier<MeterStatistics> METER_STATISTICS_INSTANCE_IDENTIFIER = getNodeWildII()
- .augmentation(FlowCapableNode.class).child(Meter.class).augmentation(NodeMeterStatistics.class)
- .child(MeterStatistics.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public MeterStatNotificationSupplierImpl(final NotificationPublishService notifProviderService,
- final DataBroker db) {
- super(notifProviderService, db, MeterStatistics.class);
- }
-
- @Override
- public InstanceIdentifier<MeterStatistics> getWildCardPath() {
- return METER_STATISTICS_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public MeterStatisticsUpdated createNotification(final MeterStatistics meterStatistics,
- final InstanceIdentifier<MeterStatistics> path) {
- Preconditions.checkArgument(meterStatistics != null);
- Preconditions.checkArgument(path != null);
-
- final MeterStatisticsUpdatedBuilder builder = new MeterStatisticsUpdatedBuilder();
- builder.setId(getNodeId(path));
- builder.setMoreReplies(Boolean.FALSE);
- // TODO : fix if it needs, but we have to ask DataStore for the NodeConnector list
- builder.setNodeConnector(Collections.emptyMap());
- builder.setMeterStats(BindingMap.of(new MeterStatsBuilder(meterStatistics)
- .setMeterId(path.firstKeyOf(Meter.class).getMeterId())
- .build()));
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.util.BindingMap;
-
-/**
- * Implementation define a contract between {@link FlowCapableNodeConnectorStatistics} data object
- * and {@link NodeConnectorStatisticsUpdate} notification.
- */
-public class NodeConnectorStatNotificationSupplierImpl extends
- AbstractNotificationSupplierForItemStat<FlowCapableNodeConnectorStatistics, NodeConnectorStatisticsUpdate> {
-
- private static final InstanceIdentifier<FlowCapableNodeConnectorStatistics>
- FLOW_CAPABLE_NODE_CONNECTOR_STATISTICS_INSTANCE_IDENTIFIER = getNodeWildII().child(NodeConnector.class)
- .augmentation(FlowCapableNodeConnectorStatisticsData.class).child(FlowCapableNodeConnectorStatistics.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public NodeConnectorStatNotificationSupplierImpl(final NotificationPublishService notifProviderService,
- final DataBroker db) {
- super(notifProviderService, db, FlowCapableNodeConnectorStatistics.class);
- }
-
- @Override
- public InstanceIdentifier<FlowCapableNodeConnectorStatistics> getWildCardPath() {
- return FLOW_CAPABLE_NODE_CONNECTOR_STATISTICS_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public NodeConnectorStatisticsUpdate createNotification(
- final FlowCapableNodeConnectorStatistics flowCapableNodeConnectorStatistics,
- final InstanceIdentifier<FlowCapableNodeConnectorStatistics> path) {
- Preconditions.checkArgument(flowCapableNodeConnectorStatistics != null);
- Preconditions.checkArgument(path != null);
-
- final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
- final NodeConnectorKey ncKey = path.firstKeyOf(NodeConnector.class);
- ncBuilder.setId(ncKey.getId());
- ncBuilder.withKey(ncKey);
-
- return new NodeConnectorStatisticsUpdateBuilder()
- .setId(getNodeId(path))
- .setMoreReplies(Boolean.FALSE)
- .setNodeConnector(BindingMap.of(ncBuilder.build()))
- .setNodeConnectorStatisticsAndPortNumberMap(BindingMap.of(
- new NodeConnectorStatisticsAndPortNumberMapBuilder(flowCapableNodeConnectorStatistics)
- .setNodeConnectorId(ncKey.getId()).build()))
- .build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.util.BindingMap;
-
-/**
- * Implementation define a contract between {@link FlowCapableNodeConnectorQueueStatisticsData} data object
- * and {@link QueueStatisticsUpdate} notification.
- */
-public class QueueStatNotificationSupplierImpl extends
- AbstractNotificationSupplierForItemStat<FlowCapableNodeConnectorQueueStatisticsData, QueueStatisticsUpdate> {
-
- private static final InstanceIdentifier<FlowCapableNodeConnectorQueueStatisticsData>
- FLOW_CAPABLE_NODE_CONNECTOR_QUEUE_STATISTICS_DATA_INSTANCE_IDENTIFIER = getNodeWildII()
- .child(NodeConnector.class).augmentation(FlowCapableNodeConnector.class).child(Queue.class)
- .augmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
-
- /**
- * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
- *
- * @param notifProviderService - {@link NotificationPublishService}
- * @param db - {@link DataBroker}
- */
- public QueueStatNotificationSupplierImpl(final NotificationPublishService notifProviderService,
- final DataBroker db) {
- super(notifProviderService, db, FlowCapableNodeConnectorQueueStatisticsData.class);
- }
-
- @Override
- public InstanceIdentifier<FlowCapableNodeConnectorQueueStatisticsData> getWildCardPath() {
- return FLOW_CAPABLE_NODE_CONNECTOR_QUEUE_STATISTICS_DATA_INSTANCE_IDENTIFIER;
- }
-
- @Override
- public QueueStatisticsUpdate createNotification(
- final FlowCapableNodeConnectorQueueStatisticsData statisticsDataTreeItem,
- final InstanceIdentifier<FlowCapableNodeConnectorQueueStatisticsData> path) {
- Preconditions.checkArgument(statisticsDataTreeItem != null);
- Preconditions.checkArgument(path != null);
-
- final NodeConnectorBuilder connBuilder = new NodeConnectorBuilder();
- final NodeConnectorKey key = path.firstKeyOf(NodeConnector.class);
- connBuilder.setId(key.getId());
- connBuilder.withKey(key);
-
- final QueueIdAndStatisticsMapBuilder queueStatMapBuilder =
- new QueueIdAndStatisticsMapBuilder(statisticsDataTreeItem.getFlowCapableNodeConnectorQueueStatistics())
- .setNodeConnectorId(key.getId()).setQueueId(path.firstKeyOf(Queue.class).getQueueId());
-
- return new QueueStatisticsUpdateBuilder()
- .setId(getNodeId(path))
- .setMoreReplies(Boolean.FALSE)
- .setQueueIdAndStatisticsMap(BindingMap.of(queueStatMapBuilder.build()))
- .setNodeConnector(BindingMap.of(connBuilder.build()))
- .build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-/**
- * Package contains OF Statistics Items (Flow, Group, Meter ...) notification listener/supplier implementations
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-/**
- * Package contains notification listener/supplier implementations.
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-/**
- * Base project package for a module Provider and base notification listener/supplier interface.
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier;
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.notification.supplier.tools;
-
-/**
- * Class is designed as ConfigSubsystem settings holder.
- */
-public final class NotificationProviderConfig {
-
- private final boolean flowSupport;
- private final boolean meterSupport;
- private final boolean groupSupport;
- private final boolean nodeConnectorStatSupport;
- private final boolean flowTableStatSupport;
- private final boolean groupStatSupport;
- private final boolean meterStatSupport;
- private final boolean queueStatSupport;
- private final boolean flowStatSupport;
-
- private NotificationProviderConfig(final NotificationProviderConfigBuilder builder) {
- this.flowSupport = builder.isFlowSupport();
- this.meterSupport = builder.isMeterSupport();
- this.groupSupport = builder.isGroupSupport();
- this.nodeConnectorStatSupport = builder.isNodeConnectorStatSupport();
- this.flowTableStatSupport = builder.isFlowTableStatSupport();
- this.groupStatSupport = builder.isGroupStatSupport();
- this.meterStatSupport = builder.isMeterStatSupport();
- this.queueStatSupport = builder.isQueueStatSupport();
- this.flowStatSupport = builder.isFlowStatSupport();
- }
-
- public boolean isFlowSupport() {
- return flowSupport;
- }
-
- public boolean isMeterSupport() {
- return meterSupport;
- }
-
- public boolean isGroupSupport() {
- return groupSupport;
- }
-
- public boolean isNodeConnectorStatSupport() {
- return nodeConnectorStatSupport;
- }
-
- public boolean isFlowTableStatSupport() {
- return flowTableStatSupport;
- }
-
- public boolean isGroupStatSupport() {
- return groupStatSupport;
- }
-
- public boolean isMeterStatSupport() {
- return meterStatSupport;
- }
-
- public boolean isQueueStatSupport() {
- return queueStatSupport;
- }
-
- public boolean isFlowStatSupport() {
- return flowStatSupport;
- }
-
- public static NotificationProviderConfigBuilder builder() {
- return new NotificationProviderConfigBuilder();
- }
-
- public static class NotificationProviderConfigBuilder {
- private boolean flowSupport;
- private boolean meterSupport;
- private boolean groupSupport;
- private boolean nodeConnectorStatSupport;
- private boolean flowTableStatSupport;
- private boolean groupStatSupport;
- private boolean meterStatSupport;
- private boolean queueStatSupport;
- private boolean flowStatSupport;
-
- public boolean isFlowSupport() {
- return flowSupport;
- }
-
- public void setFlowSupport(final boolean flowSupport) {
- this.flowSupport = flowSupport;
- }
-
- public boolean isMeterSupport() {
- return meterSupport;
- }
-
- public void setMeterSupport(final boolean meterSupport) {
- this.meterSupport = meterSupport;
- }
-
- public boolean isGroupSupport() {
- return groupSupport;
- }
-
- public void setGroupSupport(final boolean groupSupport) {
- this.groupSupport = groupSupport;
- }
-
- public boolean isNodeConnectorStatSupport() {
- return nodeConnectorStatSupport;
- }
-
- public void setNodeConnectorStatSupport(final boolean nodeConnectorStatSupport) {
- this.nodeConnectorStatSupport = nodeConnectorStatSupport;
- }
-
- public boolean isFlowTableStatSupport() {
- return flowTableStatSupport;
- }
-
- public void setFlowTableStatSupport(final boolean flowTableStatSupport) {
- this.flowTableStatSupport = flowTableStatSupport;
- }
-
- public boolean isGroupStatSupport() {
- return groupStatSupport;
- }
-
- public void setGroupStatSupport(final boolean groupStatSupport) {
- this.groupStatSupport = groupStatSupport;
- }
-
- public boolean isMeterStatSupport() {
- return meterStatSupport;
- }
-
- public void setMeterStatSupport(final boolean meterStatSupport) {
- this.meterStatSupport = meterStatSupport;
- }
-
- public boolean isQueueStatSupport() {
- return queueStatSupport;
- }
-
- public void setQueueStatSupport(final boolean queueStatSupport) {
- this.queueStatSupport = queueStatSupport;
- }
-
- public boolean isFlowStatSupport() {
- return flowStatSupport;
- }
-
- public void setFlowStatSupport(final boolean flowStatSupport) {
- this.flowStatSupport = flowStatSupport;
- }
-
- public NotificationProviderConfig build() {
- return new NotificationProviderConfig(this);
- }
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-/**
- * Package for all internal helper classes.
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.tools;
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
-
- <reference id="NotificationProviderService" interface="org.opendaylight.mdsal.binding.api.NotificationPublishService"/>
-
- <bean id="NotificationProvider" class="org.opendaylight.openflowplugin.applications.notification.supplier.NotificationProvider"
- init-method="start" destroy-method="close">
- <argument ref="NotificationProviderService"/>
- <argument ref="dataBroker"/>
- <!-- Flow Support Flag, default is false -->
- <argument value="false"/>
- <!-- Meter Support Flag, default is true -->
- <argument value="true"/>
- <!-- Group Support Flag, default is true -->
- <argument value="true"/>
- <!-- Connector Stat Support Flag, default is false -->
- <argument value="false"/>
- <!-- Flow Stat Support Flag, default is false -->
- <argument value="false"/>
- <!-- Flow Table Stat Support Flag, default is false -->
- <argument value="false"/>
- <!-- Meter Stat Support Flag, default is false -->
- <argument value="false"/>
- <!-- Group Stat Support Flag, default is false -->
- <argument value="false"/>
- <!-- Queue Stat Support Flag, default is false -->
- <argument value="false"/>
-
- </bean>
-</blueprint>
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.notification.supplier;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.tools.NotificationProviderConfig;
-import org.opendaylight.openflowplugin.applications.notification.supplier.tools.NotificationProviderConfig.NotificationProviderConfigBuilder;
-
-public class NotificationProviderTest {
-
- private NotificationPublishService notificationProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initialization() {
- dataBroker = mock(DataBroker.class);
- notificationProviderService = mock(NotificationPublishService.class);
- }
-
- @Test
- public void testCreateAllSuppliers() throws Exception {
- final NotificationProviderConfig config = createAllConfigSupplier();
- try (NotificationProvider provider = new NotificationProvider(notificationProviderService, dataBroker,
- config.isFlowSupport(), config.isMeterSupport(), config.isGroupSupport(),
- config.isNodeConnectorStatSupport(), config.isFlowStatSupport(), config.isFlowTableStatSupport(),
- config.isMeterStatSupport(), config.isGroupStatSupport(), config.isQueueStatSupport())) {
- provider.start();
- final List<NotificationSupplierDefinition<?>> listSuppliers = provider.getSupplierList();
- int nrOfSuppliers = 0;
- for (final NotificationSupplierDefinition<?> supplier : listSuppliers) {
- if (supplier != null) {
- nrOfSuppliers++;
- }
- }
- assertEquals(11, nrOfSuppliers);
- }
- }
-
- @Test
- public void testCreateRootSuppliersOnly() {
- final NotificationProviderConfig config = createNonConfigSupplier();
- final NotificationProvider provider = new NotificationProvider(notificationProviderService, dataBroker,
- config.isFlowSupport(), config.isMeterSupport(),
- config.isGroupSupport(),
- config.isNodeConnectorStatSupport(),
- config.isFlowStatSupport(),
- config.isFlowTableStatSupport(),
- config.isMeterStatSupport(),
- config.isGroupStatSupport(),
- config.isQueueStatSupport());
- provider.start();
- final List<NotificationSupplierDefinition<?>> listSuppliers = provider.getSupplierList();
- int nrOfSuppliers = 0;
- for (final NotificationSupplierDefinition<?> supplier : listSuppliers) {
- if (supplier != null) {
- nrOfSuppliers++;
- }
- }
- assertEquals(2, nrOfSuppliers);
- }
-
- private NotificationProviderConfig createAllConfigSupplier() {
- final NotificationProviderConfigBuilder builder = new NotificationProviderConfigBuilder();
- builder.setFlowStatSupport(true);
- builder.setFlowSupport(true);
- builder.setFlowTableStatSupport(true);
- builder.setGroupStatSupport(true);
- builder.setGroupSupport(true);
- builder.setMeterStatSupport(true);
- builder.setMeterSupport(true);
- builder.setNodeConnectorStatSupport(true);
- builder.setQueueStatSupport(true);
- return builder.build();
- }
-
- private NotificationProviderConfig createNonConfigSupplier() {
- final NotificationProviderConfigBuilder builder = new NotificationProviderConfigBuilder();
- builder.setFlowStatSupport(false);
- builder.setFlowSupport(false);
- builder.setFlowTableStatSupport(false);
- builder.setGroupStatSupport(false);
- builder.setGroupSupport(false);
- builder.setMeterStatSupport(false);
- builder.setMeterSupport(false);
- builder.setNodeConnectorStatSupport(false);
- builder.setQueueStatSupport(false);
- return builder.build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class NodeConnectorNotificationSupplierImplTest {
-
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final String FLOW_CODE_CONNECTOR_ID = "test-con-111";
- private NodeConnectorNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new NodeConnectorNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final NodeConnectorUpdated notification = notifSupplierImpl
- .createNotification(createTestFlowCapableNodeConnecor(), createTestFlowCapableConnectorNodePath());
- assertNotNull(notification);
- assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getId().getValue());
- assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getNodeConnectorRef().getValue()
- .firstKeyOf(NodeConnector.class).getId().getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNodeConnectorRef().getValue().firstKeyOf(Node.class).getId()
- .getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<FlowCapableNodeConnector> testData = new TestData<>(createTestFlowCapableConnectorNodePath(),
- null, createTestFlowCapableNodeConnecor(), DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<FlowCapableNodeConnector>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(NodeConnectorUpdated.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestFlowCapableConnectorNodePath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestFlowCapableNodeConnecor(), null);
- }
-
- @Test
- public void testDelete() {
- final NodeConnectorRemoved notification = notifSupplierImpl
- .deleteNotification(createTestFlowCapableConnectorNodePath());
- assertNotNull(notification);
- assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getNodeConnectorRef().getValue()
- .firstKeyOf(NodeConnector.class).getId().getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNodeConnectorRef().getValue().firstKeyOf(Node.class).getId()
- .getValue());
- }
-
- @Test
- public void testDeleteChangeEvent() throws InterruptedException {
- final TestData<FlowCapableNodeConnector> testData = new TestData<>(createTestFlowCapableConnectorNodePath(),
- createTestFlowCapableNodeConnecor(), null, DataObjectModification.ModificationType.DELETE);
- Collection<DataTreeModification<FlowCapableNodeConnector>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(NodeConnectorRemoved.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDeleteFromNullPath() {
- notifSupplierImpl.deleteNotification(null);
- }
-
- private static InstanceIdentifier<FlowCapableNodeConnector> createTestFlowCapableConnectorNodePath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId(FLOW_CODE_CONNECTOR_ID)))
- .augmentation(FlowCapableNodeConnector.class);
- }
-
- private static FlowCapableNodeConnector createTestFlowCapableNodeConnecor() {
- final FlowCapableNodeConnectorBuilder builder = new FlowCapableNodeConnectorBuilder();
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class NodeNotificationSupplierImplTest {
-
- private static final String FLOW_NODE_ID = "openflow:111";
- private NodeNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new NodeNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final NodeUpdated notification = notifSupplierImpl
- .createNotification(createTestFlowCapableNode(), createTestFlowCapableNodePath());
- assertNotNull(notification);
- assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNodeRef().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<FlowCapableNode> testData = new TestData<>(createTestFlowCapableNodePath(), null,
- createTestFlowCapableNode(), DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<FlowCapableNode>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(NodeUpdated.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNode() {
- notifSupplierImpl.createNotification(null, createTestFlowCapableNodePath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestFlowCapableNode(), null);
- }
-
- @Test
- public void testDelete() {
- final NodeRemoved notification = notifSupplierImpl.deleteNotification(createTestFlowCapableNodePath());
- assertNotNull(notification);
- assertEquals(FLOW_NODE_ID,
- notification.getNodeRef().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testDeleteChangeEvent() throws InterruptedException {
- final TestData<FlowCapableNode> testData = new TestData<>(createTestFlowCapableNodePath(),
- createTestFlowCapableNode(), null, DataObjectModification.ModificationType.DELETE);
- Collection<DataTreeModification<FlowCapableNode>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(NodeRemoved.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDeleteFromNullPath() {
- notifSupplierImpl.deleteNotification(null);
- }
-
- private static InstanceIdentifier<FlowCapableNode> createTestFlowCapableNodePath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .augmentation(FlowCapableNode.class);
- }
-
- private static FlowCapableNode createTestFlowCapableNode() {
- final FlowCapableNodeBuilder builder = new FlowCapableNodeBuilder();
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public final class TestChangeEventBuildHelper {
-
- private TestChangeEventBuildHelper() {
- throw new UnsupportedOperationException("Test utility class");
- }
-
- public static Collection createEmptyTestDataTreeEvent() {
- return Collections.emptyList();
- }
-
- public static Collection createNullTestDataTreeEvent() {
- return null;
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2016 Ericsson Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper;
-
-import java.util.Collection;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.ChildOf;
-import org.opendaylight.yangtools.yang.binding.ChoiceIn;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
-
-/**
- * Created by eshuvka on 6/7/2016.
- */
-public class TestData<T extends DataObject> implements DataTreeModification<T> {
-
- private final DataTreeIdentifier<T> path;
- private final DataObjectModification<T> rootNode;
-
- public TestData(final InstanceIdentifier<T> path, final T dataBefore, final T dataAfter,
- DataObjectModification.ModificationType modType) {
- this.path = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, path);
- this.rootNode = new Test<>(dataBefore, dataAfter, modType);
- }
-
- @Override
- public DataTreeIdentifier<T> getRootPath() {
- return path;
- }
-
- @Override
- public DataObjectModification<T> getRootNode() {
- return rootNode;
- }
-
- class Test<T extends DataObject> implements DataObjectModification<T> {
-
- private final T dataObjBefore;
- private final T dataObjAfter;
- private final ModificationType modification;
-
- Test(final T dataBefore, final T dataAfter, ModificationType modType) {
- dataObjBefore = dataBefore;
- dataObjAfter = dataAfter;
- modification = modType;
- }
-
- @Override
- public PathArgument getIdentifier() {
- return null;
- }
-
- @Override
- public Class<T> getDataType() {
- return null;
- }
-
- @Override
- public ModificationType getModificationType() {
- return modification;
- }
-
- @Override
- public T getDataBefore() {
- return dataObjBefore;
- }
-
- @Override
- public T getDataAfter() {
- return dataObjAfter;
- }
-
- @Override
- public Collection<DataObjectModification<? extends DataObject>> getModifiedChildren() {
- return null;
- }
-
- @Override
- public <C extends ChildOf<? super T>> Collection<DataObjectModification<C>> getModifiedChildren(
- Class<C> childType) {
- return null;
- }
-
- @Override
- public <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>>
- Collection<DataObjectModification<C>> getModifiedChildren(Class<H> caseType, Class<C> childType) {
- return null;
- }
-
- @Override
- public <C extends ChildOf<? super T>> DataObjectModification<C> getModifiedChildContainer(Class<C> theClass) {
- return null;
- }
-
- @Override
- public <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> DataObjectModification<C>
- getModifiedChildContainer(Class<H> caseType, Class<C> child) {
- return null;
- }
-
- @Override
- public <C extends Augmentation<T> & DataObject> DataObjectModification<C> getModifiedAugmentation(
- Class<C> theClass) {
- return null;
- }
-
- @Override
- public <C extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<C>> DataObjectModification<C>
- getModifiedChildListItem(Class<C> theClass, K listKey) {
- return null;
- }
-
- @Override
- public <H extends ChoiceIn<? super T> & DataObject, C extends Identifiable<K> & ChildOf<? super H>,
- K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem(Class<H> caseType,
- Class<C> listItem, K listKey) {
- return null;
- }
-
- @Override
- public DataObjectModification<? extends DataObject> getModifiedChild(PathArgument pathArgument) {
- return null;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.verify;
-
-import org.opendaylight.mdsal.binding.api.DataBroker;
-
-public final class TestSupplierVerifyHelper {
- private TestSupplierVerifyHelper() {
- // Hidden on purpose
- }
-
- public static void verifyDataTreeChangeListenerRegistration(final DataBroker dataBroker) {
- verify(dataBroker).registerDataTreeChangeListener(any(), any());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint8;
-
-/**
- * Test for
- * {@link org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.FlowNotificationSupplierImpl}.
- */
-public class FlowNotificationSupplierImplTest {
-
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final Uint8 FLOW_TABLE_ID = Uint8.valueOf(111);
- private static final Uint8 UPDATED_FLOW_TABLE_ID = Uint8.valueOf(100);
- private static final String FLOW_ID = "test-flow-111";
- private static final String UPDATED_FLOW_ID = "test-flow-100";
- private FlowNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new FlowNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final FlowAdded notification = notifSupplierImpl.createNotification(createTestFlow(), createTestFlowPath());
- assertNotNull(notification);
- assertEquals(FLOW_ID,
- notification.getFlowRef().getValue().firstKeyOf(Flow.class).getId().getValue());
- assertEquals(FLOW_TABLE_ID,
- notification.getFlowRef().getValue().firstKeyOf(Table.class).getId());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<Flow> testData = new TestData<>(createTestFlowPath(), null, createTestFlow(),
- DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(FlowAdded.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestFlowPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestFlow(), null);
- }
-
- @Test
- public void testUpdate() {
- final FlowUpdated notification = notifSupplierImpl.updateNotification(createTestFlow(), createTestFlowPath());
- assertNotNull(notification);
- assertEquals(FLOW_ID,
- notification.getFlowRef().getValue().firstKeyOf(Flow.class).getId().getValue());
- assertEquals(FLOW_TABLE_ID,
- notification.getFlowRef().getValue().firstKeyOf(Table.class).getId());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testUpdateChangeEvent() throws InterruptedException {
- final TestData<Flow> testData = new TestData<>(createTestFlowPath(), createTestFlow(), createUpdatedTestFlow(),
- DataObjectModification.ModificationType.SUBTREE_MODIFIED);
- Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(FlowUpdated.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestFlowPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestFlow(), null);
- }
-
- @Test
- public void testDelete() {
- final FlowRemoved notification = notifSupplierImpl.deleteNotification(createTestFlowPath());
- assertNotNull(notification);
- assertEquals(FLOW_ID,
- notification.getFlowRef().getValue().firstKeyOf(Flow.class).getId().getValue());
- assertEquals(FLOW_TABLE_ID,
- notification.getFlowRef().getValue().firstKeyOf(Table.class).getId());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testDeleteChangeEvent() throws InterruptedException {
- final TestData<Flow> testData = new TestData<>(createTestFlowPath(), createTestFlow(), null,
- DataObjectModification.ModificationType.DELETE);
- Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(FlowRemoved.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDeleteFromNullPath() {
- notifSupplierImpl.deleteNotification(null);
- }
-
- private static InstanceIdentifier<Flow> createTestFlowPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(FLOW_TABLE_ID))
- .child(Flow.class, new FlowKey(new FlowId(FLOW_ID)));
- }
-
- private static Flow createTestFlow() {
- final FlowBuilder builder = new FlowBuilder();
- builder.setId(new FlowId(FLOW_ID));
- builder.setTableId(FLOW_TABLE_ID);
- return builder.build();
- }
-
- private static Flow createUpdatedTestFlow() {
- final FlowBuilder builder = new FlowBuilder();
- builder.setId(new FlowId(UPDATED_FLOW_ID));
- builder.setTableId(UPDATED_FLOW_TABLE_ID);
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint32;
-
-/**
- * Test for {@link GroupNotificationSupplierImpl}.
- */
-public class GroupNotificationSupplierImplTest {
-
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final Uint32 GROUP_ID = Uint32.valueOf(111);
- private static final Uint32 UPDATED_GROUP_ID = Uint32.valueOf(100);
-
- private GroupNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new GroupNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final GroupAdded notification = notifSupplierImpl.createNotification(createTestGroup(), createTestGroupPath());
- assertNotNull(notification);
- assertEquals(GROUP_ID, notification.getGroupId().getValue());
- assertEquals(GROUP_ID,
- notification.getGroupRef().getValue().firstKeyOf(Group.class).getGroupId()
- .getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<Group> testData = new TestData<>(createTestGroupPath(), null, createTestGroup(),
- DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<Group>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(GroupAdded.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestGroupPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestGroup(), null);
- }
-
- @Test
- public void testUpdate() {
- final GroupUpdated notification = notifSupplierImpl
- .updateNotification(createTestGroup(), createTestGroupPath());
- assertNotNull(notification);
- assertEquals(GROUP_ID, notification.getGroupId().getValue());
- assertEquals(GROUP_ID,
- notification.getGroupRef().getValue().firstKeyOf(Group.class).getGroupId()
- .getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testUpdateChangeEvent() throws InterruptedException {
- final TestData<Group> testData = new TestData<>(createTestGroupPath(), createTestGroup(),
- createUpdatedTestGroup(),
- DataObjectModification.ModificationType.SUBTREE_MODIFIED);
- Collection<DataTreeModification<Group>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(GroupUpdated.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestGroupPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestGroup(), null);
- }
-
- @Test
- public void testDelete() {
- final GroupRemoved notification = notifSupplierImpl.deleteNotification(createTestGroupPath());
- assertNotNull(notification);
- assertEquals(GROUP_ID, notification.getGroupId().getValue());
- assertEquals(GROUP_ID,
- notification.getGroupRef().getValue().firstKeyOf(Group.class).getGroupId()
- .getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testDeleteChangeEvent() throws InterruptedException {
- final TestData<Group> testData = new TestData<>(createTestGroupPath(), createTestGroup(), null,
- DataObjectModification.ModificationType.DELETE);
- Collection<DataTreeModification<Group>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(GroupRemoved.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDeleteFromNullPath() {
- notifSupplierImpl.deleteNotification(null);
- }
-
- private static InstanceIdentifier<Group> createTestGroupPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(new GroupId(GROUP_ID)));
- }
-
- private static Group createTestGroup() {
- final GroupBuilder builder = new GroupBuilder();
- builder.setGroupId(new GroupId(GROUP_ID));
- return builder.build();
- }
-
- private static Group createUpdatedTestGroup() {
- final GroupBuilder builder = new GroupBuilder();
- builder.setGroupId(new GroupId(UPDATED_GROUP_ID));
- return builder.build();
- }
-
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint32;
-
-/**
- * Test for
- * {@link org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.MeterNotificationSupplierImpl}.
- */
-public class MeterNotificationSupplierImplTest {
-
- private static final String FLOW_NODE_ID = "openfow:111";
- private static final Uint32 METER_ID = Uint32.valueOf(111);
- private static final Uint32 UPDATED_METER_ID = Uint32.valueOf(100);
-
- private MeterNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new MeterNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final MeterAdded notification = notifSupplierImpl.createNotification(createTestMeter(), createTestMeterPath());
- assertNotNull(notification);
- assertEquals(METER_ID, notification.getMeterId().getValue());
- assertEquals(METER_ID,
- notification.getMeterRef().getValue().firstKeyOf(Meter.class).getMeterId()
- .getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<Meter> testData = new TestData<>(createTestMeterPath(), null, createTestMeter(),
- DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<Meter>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(MeterAdded.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestMeterPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestMeter(), null);
- }
-
- @Test
- public void testUpdate() {
- final MeterUpdated notification = notifSupplierImpl
- .updateNotification(createTestMeter(), createTestMeterPath());
- assertNotNull(notification);
- assertEquals(METER_ID, notification.getMeterId().getValue());
- assertEquals(METER_ID,
- notification.getMeterRef().getValue().firstKeyOf(Meter.class).getMeterId()
- .getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testUdateChangeEvent() throws InterruptedException {
- final TestData<Meter> testData = new TestData<>(createTestMeterPath(), createTestMeter(),
- createUpdatedTestMeter(),
- DataObjectModification.ModificationType.SUBTREE_MODIFIED);
- Collection<DataTreeModification<Meter>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(MeterUpdated.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestMeterPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestMeter(), null);
- }
-
- @Test
- public void testDelete() {
- final MeterRemoved notification = notifSupplierImpl.deleteNotification(createTestMeterPath());
- assertNotNull(notification);
- assertEquals(METER_ID, notification.getMeterId().getValue());
- assertEquals(METER_ID,
- notification.getMeterRef().getValue().firstKeyOf(Meter.class).getMeterId()
- .getValue());
- assertEquals(FLOW_NODE_ID,
- notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue());
- }
-
- @Test
- public void testDeleteChangeEvent() throws InterruptedException {
- final TestData<Meter> testData = new TestData<>(createTestMeterPath(), createTestMeter(), null,
- DataObjectModification.ModificationType.DELETE);
- Collection<DataTreeModification<Meter>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(MeterRemoved.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDeleteFromNullPath() {
- notifSupplierImpl.deleteNotification(null);
- }
-
- private static InstanceIdentifier<Meter> createTestMeterPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(new MeterId(METER_ID)));
- }
-
- private static Meter createTestMeter() {
- final MeterBuilder builder = new MeterBuilder();
- builder.setMeterId(new MeterId(METER_ID));
- return builder.build();
- }
-
- private static Meter createUpdatedTestMeter() {
- final MeterBuilder builder = new MeterBuilder();
- builder.setMeterId(new MeterId(UPDATED_METER_ID));
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint8;
-
-public class FlowStatNotificationSupplierImplTest {
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final Uint8 FLOW_TABLE_ID = Uint8.valueOf(111);
- private static final String FLOW_ID = "test-flow-111";
-
- private FlowStatNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new FlowStatNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final FlowsStatisticsUpdate notification = notifSupplierImpl
- .createNotification(createTestFlowStat(), createTestFlowStatPath());
- assertNotNull(notification);
- assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<FlowStatistics> testData = new TestData<>(createTestFlowStatPath(), null, createTestFlowStat(),
- DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<FlowStatistics>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(FlowsStatisticsUpdate.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestFlowStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestFlowStat(), null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestFlowStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestFlowStat(), null);
- }
-
- private static InstanceIdentifier<FlowStatistics> createTestFlowStatPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(FLOW_TABLE_ID))
- .child(Flow.class, new FlowKey(new FlowId(FLOW_ID))).augmentation(FlowStatisticsData.class)
- .child(FlowStatistics.class);
- }
-
- private static FlowStatistics createTestFlowStat() {
- final FlowStatisticsBuilder builder = new FlowStatisticsBuilder();
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint8;
-
-public class FlowTableStatNotificationSupplierImplTest {
-
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final Uint8 FLOW_TABLE_ID = Uint8.valueOf(111);
- private static final String FLOW_ID = "test-flow-111";
-
- private FlowTableStatNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new FlowTableStatNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final FlowTableStatisticsUpdate notification = notifSupplierImpl
- .createNotification(createTestFlowTableStat(), createTestFlowTableStatPath());
- assertNotNull(notification);
- assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<FlowTableStatistics> testData = new TestData<>(createTestFlowTableStatPath(), null,
- createTestFlowTableStat(),
- DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<FlowTableStatistics>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(FlowTableStatisticsUpdate.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestFlowTableStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestFlowTableStat(), null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestFlowTableStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestFlowTableStat(), null);
- }
-
- private static InstanceIdentifier<FlowTableStatistics> createTestFlowTableStatPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(FLOW_TABLE_ID))
- .augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
- }
-
- private static FlowTableStatistics createTestFlowTableStat() {
- final FlowTableStatisticsBuilder builder = new FlowTableStatisticsBuilder();
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint32;
-
-public class GroupStatNotificationSupplierImplTest {
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final Uint32 FLOW_TABLE_ID = Uint32.valueOf(111);
-
- private GroupStatNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new GroupStatNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final GroupStatisticsUpdated notification = notifSupplierImpl
- .createNotification(createTestGroupStat(), createTestGroupStatPath());
- assertNotNull(notification);
- assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<GroupStatistics> testData = new TestData<>(createTestGroupStatPath(), null,
- createTestGroupStat(), DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<GroupStatistics>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(GroupStatisticsUpdated.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestGroupStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestGroupStat(), null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestGroupStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestGroupStat(), null);
- }
-
- private static InstanceIdentifier<GroupStatistics> createTestGroupStatPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(new GroupId(FLOW_TABLE_ID)))
- .augmentation(NodeGroupStatistics.class).child(GroupStatistics.class);
- }
-
- private static GroupStatistics createTestGroupStat() {
- final GroupStatisticsBuilder builder = new GroupStatisticsBuilder();
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.node.meter.statistics.MeterStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.node.meter.statistics.MeterStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint32;
-
-public class MeterStatNotificationSupplierImplTest {
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final Uint32 FLOW_METER_ID = Uint32.valueOf(111);
-
- private MeterStatNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new MeterStatNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final MeterStatisticsUpdated notification = notifSupplierImpl.createNotification(createTestMeterStat(),
- createTestMeterStatPath());
- assertNotNull(notification);
- assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<MeterStatistics> testData = new TestData<>(createTestMeterStatPath(), null,
- createTestMeterStat(), DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<MeterStatistics>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(MeterStatisticsUpdated.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestMeterStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestMeterStat(), null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestMeterStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestMeterStat(), null);
- }
-
- private static InstanceIdentifier<MeterStatistics> createTestMeterStatPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(new MeterId(FLOW_METER_ID)))
- .augmentation(NodeMeterStatistics.class).child(MeterStatistics.class);
- }
-
- private static MeterStatistics createTestMeterStat() {
- final MeterStatisticsBuilder builder = new MeterStatisticsBuilder();
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatisticsBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class NodeConnectorStatNotificationSupplierImplTest {
-
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final String FLOW_CODE_CONNECTOR_ID = "test-con-111";
- private NodeConnectorStatNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new NodeConnectorStatNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final NodeConnectorStatisticsUpdate notification = notifSupplierImpl
- .createNotification(createTestConnectorStat(), createTestConnectorStatPath());
- assertNotNull(notification);
- assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- assertEquals(FLOW_CODE_CONNECTOR_ID, notification.nonnullNodeConnector().values().iterator().next().getId()
- .getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<FlowCapableNodeConnectorStatistics> testData = new TestData<>(createTestConnectorStatPath(),
- null, createTestConnectorStat(), DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<FlowCapableNodeConnectorStatistics>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(NodeConnectorStatisticsUpdate.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestConnectorStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestConnectorStat(), null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestConnectorStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestConnectorStat(), null);
- }
-
- private static InstanceIdentifier<FlowCapableNodeConnectorStatistics> createTestConnectorStatPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId(FLOW_CODE_CONNECTOR_ID)))
- .augmentation(FlowCapableNodeConnectorStatisticsData.class)
- .child(FlowCapableNodeConnectorStatistics.class);
- }
-
- private static FlowCapableNodeConnectorStatistics createTestConnectorStat() {
- final FlowCapableNodeConnectorStatisticsBuilder builder = new FlowCapableNodeConnectorStatisticsBuilder();
- return builder.build();
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData;
-import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.flow.capable.node.connector.queue.statistics.FlowCapableNodeConnectorQueueStatisticsBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint32;
-
-public class QueueStatNotificationSupplierImplTest {
-
- private static final String FLOW_NODE_ID = "openflow:111";
- private static final String FLOW_CODE_CONNECTOR_ID = "test-con-111";
- private QueueStatNotificationSupplierImpl notifSupplierImpl;
- private NotificationPublishService notifProviderService;
- private DataBroker dataBroker;
-
- @Before
- public void initalization() {
- notifProviderService = mock(NotificationPublishService.class);
- dataBroker = mock(DataBroker.class);
- notifSupplierImpl = new QueueStatNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(null);
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
- }
-
- @Test
- public void testEmptyChangeEvent() {
- notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
- }
-
- @Test
- public void testCreate() {
- final QueueStatisticsUpdate notification = notifSupplierImpl
- .createNotification(createTestQueueStat(), createTestQueueStatPath());
- assertNotNull(notification);
- assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- assertEquals(FLOW_CODE_CONNECTOR_ID, notification.nonnullNodeConnector().values().iterator().next().getId()
- .getValue());
- }
-
- @Test
- public void testCreateChangeEvent() throws InterruptedException {
- final TestData<FlowCapableNodeConnectorQueueStatisticsData> testData = new TestData<>(createTestQueueStatPath(),
- null, createTestQueueStat(), DataObjectModification.ModificationType.WRITE);
- Collection<DataTreeModification<FlowCapableNodeConnectorQueueStatisticsData>> collection = new ArrayList<>();
- collection.add(testData);
- notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).putNotification(any(QueueStatisticsUpdate.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestQueueStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateFromNullPath() {
- notifSupplierImpl.createNotification(createTestQueueStat(), null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullNodeConnector() {
- notifSupplierImpl.createNotification(null, createTestQueueStatPath());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUpdateFromNullPath() {
- notifSupplierImpl.createNotification(createTestQueueStat(), null);
- }
-
- private static InstanceIdentifier<FlowCapableNodeConnectorQueueStatisticsData> createTestQueueStatPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(FLOW_NODE_ID)))
- .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId(FLOW_CODE_CONNECTOR_ID)))
- .augmentation(FlowCapableNodeConnector.class).child(Queue.class, new QueueKey(new QueueId(Uint32.ZERO)))
- .augmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
- }
-
- private static FlowCapableNodeConnectorQueueStatisticsData createTestQueueStat() {
- return new FlowCapableNodeConnectorQueueStatisticsDataBuilder()
- .setFlowCapableNodeConnectorQueueStatistics(new FlowCapableNodeConnectorQueueStatisticsBuilder().build())
- .build();
- }
-}
\ No newline at end of file
<module>table-miss-enforcer</module>
<module>of-switch-config-pusher</module>
<module>lldp-speaker</module>
- <!-- deprecated apps -->
- <module>notification-supplier</module>
<!-- nsf apps -->
<module>topology-manager</module>
<module>forwardingrules-manager</module>
<artifactId>of-switch-config-pusher</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}.applications</groupId>
- <artifactId>notification-supplier</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}.applications</groupId>
<artifactId>device-ownership-status-service</artifactId>
<type>xml</type>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-openflowplugin-app-notifications</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-openflowplugin-app-forwardingrules-manager</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-openflowplugin-app-notifications</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-openflowplugin-app-table-miss-enforcer</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>9.0.8</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.openflowplugin</groupId>
- <artifactId>odl-openflowplugin-app-notifications</artifactId>
- <packaging>feature</packaging>
- <version>0.14.0-SNAPSHOT</version>
-
- <name>OpenDaylight :: Openflow Plugin :: Application - notifications supplier</name>
-
- <dependencies>
- <!-- feature dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-openflowplugin-southbound</artifactId>
- <version>${project.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.openflowplugin.applications</groupId>
- <artifactId>notification-supplier</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
-</project>
<module>odl-openflowplugin-app-topology-lldp-discovery</module>
<module>odl-openflowplugin-app-topology-manager</module>
<module>odl-openflowplugin-app-bulk-o-matic</module>
- <module>odl-openflowplugin-app-notifications</module>
<module>odl-openflowplugin-app-forwardingrules-manager</module>
<module>odl-openflowplugin-app-forwardingrules-sync</module>
<module>odl-openflowplugin-app-reconciliation-framework</module>