Fix NPE triggered after disabling SG on a port
[netvirt.git] / openstack / net-virt / src / test / java / org / opendaylight / netvirt / openstack / netvirt / PortHandlerTest.java
index dab134bd744ddd5c24212ad01608d293c1f2ca30..1cfd50f8435001146556e642d6e78bdded754452 100644 (file)
@@ -31,7 +31,6 @@ import org.opendaylight.netvirt.openstack.netvirt.api.NodeCacheManager;
 import org.opendaylight.netvirt.openstack.netvirt.api.Action;
 import org.opendaylight.netvirt.openstack.netvirt.api.EventDispatcher;
 import org.opendaylight.netvirt.openstack.netvirt.api.Southbound;
-import org.opendaylight.netvirt.openstack.netvirt.impl.DistributedArpService;
 import org.opendaylight.netvirt.openstack.netvirt.impl.NeutronL3Adapter;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronPort;
 import org.opendaylight.netvirt.utils.servicehelper.ServiceHelper;
@@ -50,7 +49,6 @@ public class PortHandlerTest {
     @InjectMocks private PortHandler portHandler;
 
     @Mock private NeutronL3Adapter neutronL3Adapter;
-    @Mock private DistributedArpService distributedArpService;
     @Mock private NodeCacheManager nodeCacheManager;
     @Mock private Southbound southbound;
 
@@ -84,12 +82,10 @@ public class PortHandlerTest {
 
         when(ev.getAction()).thenReturn(Action.ADD);
         portHandlerSpy.processEvent(ev);
-        verify(distributedArpService, times(1)).handlePortEvent(neutronPort, Action.ADD);
         verify(neutronL3Adapter, times(1)).handleNeutronPortEvent(neutronPort, Action.ADD);
 
         when(ev.getAction()).thenReturn(Action.UPDATE);
         portHandlerSpy.processEvent(ev);
-        verify(distributedArpService, times(1)).handlePortEvent(neutronPort, Action.UPDATE);
         verify(neutronL3Adapter, times(1)).handleNeutronPortEvent(neutronPort, Action.UPDATE);
 
         List<Node> nodes = new ArrayList<>();
@@ -99,13 +95,12 @@ public class PortHandlerTest {
         List<OvsdbTerminationPointAugmentation> ports = new ArrayList<>();
         OvsdbTerminationPointAugmentation port = mock(OvsdbTerminationPointAugmentation.class);
         ports.add(port);
-        when(southbound.getTerminationPointsOfBridge(any(Node.class))).thenReturn(ports);
+        when(southbound.readTerminationPointAugmentations(any(Node.class))).thenReturn(ports);
 
         when(southbound.getInterfaceExternalIdsValue(any(OvsdbTerminationPointAugmentation.class), anyString())).thenReturn("portUUID");
 
         when(ev.getAction()).thenReturn(Action.DELETE);
         portHandlerSpy.processEvent(ev);
-        verify(distributedArpService, times(1)).handlePortEvent(neutronPort, Action.DELETE);
         verify(neutronL3Adapter, times(1)).handleNeutronPortEvent(neutronPort, Action.DELETE);
         verify(southbound, times(1)).deleteTerminationPoint(any(Node.class), anyString());
     }
@@ -113,13 +108,11 @@ public class PortHandlerTest {
     @Test
     public void testSetDependencies() throws Exception {
         NodeCacheManager nodeCacheManager = mock(NodeCacheManager.class);
-        DistributedArpService distributedArpService = mock(DistributedArpService.class);
         NeutronL3Adapter neutronL3Adapter = mock(NeutronL3Adapter.class);
         Southbound southbound = mock(Southbound.class);
         EventDispatcher eventDispatcher = mock(EventDispatcher.class);
 
         ServiceHelper.overrideGlobalInstance(NodeCacheManager.class, nodeCacheManager);
-        ServiceHelper.overrideGlobalInstance(DistributedArpService.class, distributedArpService);
         ServiceHelper.overrideGlobalInstance(NeutronL3Adapter.class, neutronL3Adapter);
         ServiceHelper.overrideGlobalInstance(Southbound.class, southbound);
         ServiceHelper.overrideGlobalInstance(EventDispatcher.class, eventDispatcher);
@@ -127,7 +120,6 @@ public class PortHandlerTest {
         portHandler.setDependencies(mock(ServiceReference.class));
 
         assertEquals("Error, did not return the correct object", getField("nodeCacheManager"), nodeCacheManager);
-        assertEquals("Error, did not return the correct object", getField("distributedArpService"), distributedArpService);
         assertEquals("Error, did not return the correct object", getField("neutronL3Adapter"), neutronL3Adapter);
         assertEquals("Error, did not return the correct object", getField("southbound"), southbound);
         assertEquals("Error, did not return the correct object", portHandler.eventDispatcher, eventDispatcher);