[ONOS-4164] PceManager device and link event handling
Change-Id: I55d8f60e0fcc0e23f4c14045a8e20bd89f635913
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/MockDeviceService.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/MockDeviceService.java
new file mode 100644
index 0000000..a0ed08b
--- /dev/null
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/util/MockDeviceService.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.util;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceServiceAdapter;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Test fixture for the device service.
+ */
+public class MockDeviceService extends DeviceServiceAdapter {
+ private List<Device> devices = new LinkedList<>();
+ private DeviceListener listener;
+
+ public void addDevice(Device dev) {
+ devices.add(dev);
+ }
+
+ public void removeDevice(Device dev) {
+ devices.remove(dev);
+ }
+
+ @Override
+ public Device getDevice(DeviceId deviceId) {
+ for (Device dev : devices) {
+ if (dev.id().equals(deviceId)) {
+ return dev;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Iterable<Device> getAvailableDevices() {
+ return devices;
+ }
+
+ @Override
+ public void addListener(DeviceListener listener) {
+ this.listener = listener;
+ }
+
+ /**
+ * Get the listener.
+ */
+ public DeviceListener getListener() {
+ return listener;
+ }
+}