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;
@InjectMocks private PortHandler portHandler;
@Mock private NeutronL3Adapter neutronL3Adapter;
- @Mock private DistributedArpService distributedArpService;
@Mock private NodeCacheManager nodeCacheManager;
@Mock private Southbound southbound;
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<>();
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());
}
@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);
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);