Bug 1484 - StatisticManager performance improvement refactoring
[controller.git] / opendaylight / md-sal / statistics-manager / src / test / java / test / mock / util / NotificationProviderServiceHelper.java
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/NotificationProviderServiceHelper.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/NotificationProviderServiceHelper.java
new file mode 100644 (file)
index 0000000..2d85f62
--- /dev/null
@@ -0,0 +1,29 @@
+package test.mock.util;
+
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
+import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class NotificationProviderServiceHelper {
+    private NotificationBrokerImpl notifBroker = new NotificationBrokerImpl(SingletonHolder.getDefaultNotificationExecutor());
+
+    public NotificationBrokerImpl getNotifBroker() {
+        return notifBroker;
+    }
+
+    public void pushDelayedNotification(final Notification notification, int delay) {
+        new Timer().schedule(new TimerTask() {
+            @Override
+            public void run() {
+                notifBroker.publish(notification);
+            }
+        }, delay);
+    }
+
+    public void pushNotification(final Notification notification) {
+        notifBroker.publish(notification);
+    }
+}