Remove unnecessary isRelevant() check.
Change-Id: I212d5ac85c4d593bfabb04d3ad939c0199189a0b
diff --git a/providers/ovsdb/device/BUCK b/providers/ovsdb/device/BUCK
index 19f1833..582c16e 100644
--- a/providers/ovsdb/device/BUCK
+++ b/providers/ovsdb/device/BUCK
@@ -4,7 +4,12 @@
'//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
]
+TEST_DEPS = [
+ '//lib:TEST_ADAPTERS'
+]
+
osgi_jar_with_tests (
deps = COMPILE_DEPS,
+ test_deps = TEST_DEPS
)
diff --git a/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java b/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java
index 04ebf50..ced2c2c 100644
--- a/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java
+++ b/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java
@@ -191,9 +191,7 @@
@Override
public void event(DeviceEvent event) {
DeviceId deviceId = event.subject().id();
- if (!isRelevant(deviceId)) {
- return;
- }
+
if ((event.type() == DeviceEvent.Type.DEVICE_ADDED)) {
executor.execute(() -> discoverPorts(deviceId));
} else if ((event.type() == DeviceEvent.Type.DEVICE_REMOVED)) {
diff --git a/providers/ovsdb/device/src/test/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProviderTest.java b/providers/ovsdb/device/src/test/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProviderTest.java
index 2b22f40..ad37efc 100644
--- a/providers/ovsdb/device/src/test/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProviderTest.java
+++ b/providers/ovsdb/device/src/test/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProviderTest.java
@@ -24,6 +24,7 @@
import org.junit.Test;
import org.onlab.packet.IpAddress;
import org.onlab.packet.TpPort;
+import org.onosproject.mastership.MastershipServiceAdapter;
import org.onosproject.net.Annotations;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultDevice;
@@ -69,6 +70,7 @@
private final TestDeviceRegistry registry = new TestDeviceRegistry();
private final TestController controller = new TestController();
private final TestDeviceService deviceService = new TestDeviceService();
+ private final TestMastershipService mastershipService = new TestMastershipService();
private final Device ovsdbDevice = new MockDevice(
DeviceId.deviceId("ovsdb:127.0.0.1"),
@@ -86,6 +88,7 @@
provider.providerRegistry = registry;
provider.controller = controller;
provider.deviceService = deviceService;
+ provider.mastershipService = mastershipService;
provider.activate();
assertNotNull("provider should be registered", registry.provider);
}
@@ -120,8 +123,15 @@
provider.executor = MoreExecutors.newDirectExecutorService();
prepareMocks(portCount);
- deviceService.listener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, ovsdbDevice));
- deviceService.listener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, notOvsdbDevice));
+ DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, ovsdbDevice);
+ if (deviceService.listener.isRelevant(event)) {
+ deviceService.listener.event(event);
+ }
+
+ event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, notOvsdbDevice);
+ if (deviceService.listener.isRelevant(event)) {
+ deviceService.listener.event(event);
+ }
assertEquals(portCount, registry.ports.get(ovsdbDevice.id()).size());
assertEquals(0, registry.ports.get(notOvsdbDevice.id()).size());
@@ -268,6 +278,14 @@
}
}
+ private class TestMastershipService extends MastershipServiceAdapter {
+ @Override
+ public MastershipRole getLocalRole(DeviceId deviceId) {
+ return MastershipRole.MASTER;
+ }
+
+ }
+
private class TestDescription extends AbstractHandlerBehaviour implements DeviceDescriptionDiscovery {
final List<PortDescription> portDescriptions = new ArrayList<>();