Merge "Unit test for ovsdb.southbound.ovsdb.transact"
[netvirt.git] / openstack / net-virt / src / test / java / org / opendaylight / ovsdb / openstack / netvirt / impl / BridgeConfigurationManagerImplTest.java
index 27d90fc89215f2170bb3a10817b1128fbc1e5bb9..dec0f7358e6e5f2a0ada969bf58375130711da19 100644 (file)
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Authors : Marcus Koontz
 */
 package org.opendaylight.ovsdb.openstack.netvirt.impl;
 
-import org.junit.runner.RunWith;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Spy;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.mockito.stubbing.Answer;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.ovsdb.lib.notation.Column;
-import org.opendaylight.ovsdb.lib.notation.Row;
-import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
-import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
-import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProvider;
-import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
-import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
-import org.opendaylight.ovsdb.schema.openvswitch.Port;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyList;
 import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.same;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.RETURNS_MOCKS;
 import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.RETURNS_MOCKS;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-@RunWith(MockitoJUnitRunner.class)
-public class BridgeConfigurationManagerImplTest {
-
-    private Node nodeMock = mock(Node.class, RETURNS_DEEP_STUBS);
-    private Bridge bridgeMock = mock(Bridge.class, RETURNS_DEEP_STUBS);
+import java.lang.reflect.Field;
+import java.util.List;
 
-    @Mock private OvsdbConfigurationService ovsdbConfigurationService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
+import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
+import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbTables;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+
+import org.osgi.framework.ServiceReference;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * Test class for BridgeConfigurationManagerImpl
+ *
+ * @author Marcus Koontz
+ * @author Alexis de Talhouet
+ * @author Sam Hague (shague@redhat.com)
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ServiceHelper.class, ConfigProperties.class})
+public class BridgeConfigurationManagerImplTest {
+    @Mock private Node node;
+    @Mock private OvsdbBridgeAugmentation bridge;
+    @Mock private OvsdbTerminationPointAugmentation port;
+    @Mock private NeutronNetwork neutronNetwork;
     @Mock private ConfigurationService configurationService;
-    @Mock private NetworkingProviderManager networkingProviderManager;
-
-
+    @Mock private Southbound southbound;
     @InjectMocks public static BridgeConfigurationManagerImpl bridgeConfigurationManagerImpl;
-    @InjectMocks public static BridgeConfigurationManagerImpl bridgeConfigMock =
-            mock(BridgeConfigurationManagerImpl.class, RETURNS_DEEP_STUBS);
-    @Spy public static BridgeConfigurationManagerImpl bridgeConfigurationManagerImplSpy;
 
-    @Test
-    public void testGetBridgeUuid() throws Exception {
-        Row row = mock(Row.class);
-        Bridge bridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
+    private static final String ADDRESS = "127.0.0.1";
+    private static final String BR_INT = "br-int";
+    private static final String ETH1 = "eth1";
+    private static final String ETH2 = "eth2";
+    private static final String ETH3 = "eth3";
+    private static final String PORT_BR_INT = "br-int";
+    private static final String BRIDGE_UUID = "f527b951-3934-4182-9f29-33fc09f6f0c6";
+    private static final String PHYSNET1 = "physnet1";
+    private static final String PHYSNET2 = "physnet2";
+    private static final String PHYSNET3 = "physnet3";
+    private static final String PROVIDER_MAPPINGS = PHYSNET1 + ":" + ETH1 + "," + PHYSNET2 + ":" + ETH2;
+    private static final String PROVIDER_MAPPINGS_DEFAULT = PHYSNET1 + ":" + ETH1;
 
-        ConcurrentHashMap<String, Row> hashMap;
-        hashMap = new ConcurrentHashMap<>();
-        hashMap.put("mockUUID", row);
-
-        verifyNoMoreInteractions(ovsdbConfigurationService);
-        verifyNoMoreInteractions(configurationService);
-        verifyNoMoreInteractions(networkingProviderManager);
-
-        when(ovsdbConfigurationService.getRows(any(Node.class), anyString())).thenReturn(hashMap);
-        when(ovsdbConfigurationService.getTypedRow(any(Node.class), same(Bridge.class),
-                any(Row.class))).thenReturn(bridge);
-        when(bridge.getName()).thenReturn("test-bridge");
-
-        assertEquals("Error, did not return UUID of correct bridge", "mockUUID",
-                bridgeConfigurationManagerImpl.getBridgeUuid(nodeMock, "test-bridge"));
-
-        verify(ovsdbConfigurationService).getTableName(nodeMock, Bridge.class);
-        verifyNoMoreInteractions(configurationService);
-        verifyNoMoreInteractions(networkingProviderManager);
+    @Test
+    public void testGetBridgeUuid() {
+        when(southbound.getBridgeUuid(any(Node.class), anyString()))
+                .thenReturn(null)
+                .thenReturn(BRIDGE_UUID);
+
+        assertEquals("Error, null should have been returned", null,
+                bridgeConfigurationManagerImpl.getBridgeUuid(node, BR_INT));
+        assertEquals("Error, did not return UUID of correct bridge", BRIDGE_UUID,
+                bridgeConfigurationManagerImpl.getBridgeUuid(node, BR_INT));
+        verify(southbound, times(2)).getBridgeUuid(any(Node.class), anyString());
     }
 
     @Test
     public void testIsNodeNeutronReady() throws Exception {
-        Row row = mock(Row.class);
-        Bridge bridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
-
-        ConcurrentHashMap<String, Row> hashMap;
-        hashMap = new ConcurrentHashMap<>();
-        hashMap.put("mockUUID", row);
+        when(southbound.getBridge(any(Node.class), anyString()))
+                .thenReturn(null)
+                .thenReturn(bridge);
 
-        verifyNoMoreInteractions(ovsdbConfigurationService);
         verifyNoMoreInteractions(configurationService);
-        verifyNoMoreInteractions(networkingProviderManager);
-
-        assertEquals("Error, did not return correct boolean from isNodeNeutronReady", false,
-                bridgeConfigurationManagerImpl.isNodeNeutronReady(nodeMock));
+        assertFalse("Error, did not return correct boolean from isNodeNeutronReady",
+                bridgeConfigurationManagerImpl.isNodeNeutronReady(node));
 
-        when(ovsdbConfigurationService.getRows(any(Node.class), anyString())).thenReturn(hashMap);
-        when(ovsdbConfigurationService.getTypedRow(any(Node.class), same(Bridge.class),
-                any(Row.class))).thenReturn(bridge);
-        when(bridge.getName()).thenReturn("test-bridge");
-        when(configurationService.getIntegrationBridgeName()).thenReturn("test-bridge");
-
-        assertEquals("Error, did not return correct boolean from isNodeNeutronReady", true,
-                bridgeConfigurationManagerImpl.isNodeNeutronReady(nodeMock));
+        when(configurationService.getIntegrationBridgeName()).thenReturn(BR_INT);
+        assertTrue("Error, did not return correct boolean from isNodeNeutronReady",
+                bridgeConfigurationManagerImpl.isNodeNeutronReady(node));
 
         verify(configurationService, times(2)).getIntegrationBridgeName();
-        verifyNoMoreInteractions(networkingProviderManager);
+        verify(southbound, times(2)).getBridge(any(Node.class), anyString());
     }
 
     @Test
     public void testIsNodeOverlayReady() throws Exception {
-        Row row = mock(Row.class);
-        Bridge bridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
+        when(southbound.getBridge(any(Node.class), anyString()))
+                .thenReturn(null)
+                .thenReturn(bridge);
 
-        ConcurrentHashMap<String, Row> hashMap;
-        hashMap = new ConcurrentHashMap<>();
-        hashMap.put("mockUUID", row);
+        BridgeConfigurationManagerImpl bridgeConfigurationManagerImplSpy =
+                PowerMockito.spy(new BridgeConfigurationManagerImpl());
+        doReturn(false).when(bridgeConfigurationManagerImplSpy).isNodeNeutronReady(any(Node.class));
+        bridgeConfigurationManagerImplSpy.setConfigurationService(configurationService);
+        bridgeConfigurationManagerImplSpy.setSouthbound(southbound);
 
-        verifyNoMoreInteractions(ovsdbConfigurationService);
         verifyNoMoreInteractions(configurationService);
-        verifyNoMoreInteractions(networkingProviderManager);
 
-        assertEquals("Error, did not return correct boolean from isNodeOverlayReady", false,
-                bridgeConfigurationManagerImpl.isNodeOverlayReady(nodeMock));
+        assertFalse("Error, did not return correct boolean from isNodeOverlayReady",
+                bridgeConfigurationManagerImplSpy.isNodeOverlayReady(node));
 
-        when(ovsdbConfigurationService.getRows(any(Node.class), anyString())).thenReturn(hashMap);
-        when(ovsdbConfigurationService.getTypedRow(any(Node.class), same(Bridge.class),
-                any(Row.class))).thenReturn(bridge);
-        when(bridge.getName()).thenReturn("test-bridge");
-        when(configurationService.getIntegrationBridgeName()).thenReturn("test-bridge");
-        when(configurationService.getNetworkBridgeName()).thenReturn("test-bridge");
+        doReturn(true).when(bridgeConfigurationManagerImplSpy).isNodeNeutronReady(any(Node.class));
 
-        assertEquals("Error, did not return correct boolean from isNodeOverlayReady", true,
-                bridgeConfigurationManagerImpl.isNodeOverlayReady(nodeMock));
+        assertFalse("Error, did not return correct boolean from isNodeOverlayReady",
+                bridgeConfigurationManagerImplSpy.isNodeOverlayReady(node));
 
-        verify(configurationService, times(2)).getIntegrationBridgeName();
-        verify(configurationService, times(1)).getNetworkBridgeName();
-        verify(ovsdbConfigurationService, times(3)).getTableName(nodeMock, Bridge.class);
-        verifyNoMoreInteractions(networkingProviderManager);
+        assertTrue("Error, did not return correct boolean from isNodeOverlayReady",
+                bridgeConfigurationManagerImplSpy.isNodeOverlayReady(node));
+
+        verify(configurationService, times(2)).getNetworkBridgeName();
+        verify(southbound, times(2)).getBridge(any(Node.class), anyString());
     }
 
     @Test
     public void testIsPortOnBridge() throws Exception {
-        UUID uuid = mock(UUID.class);
-        Set<UUID> uuidSet = new HashSet<>();
-        uuidSet.add(uuid);
-        Column<GenericTableSchema, Set<UUID>> columnMock = mock(Column.class);
-        Port port = mock(Port.class, RETURNS_DEEP_STUBS);
-        String portName = "portNameMock";
-
-        verifyNoMoreInteractions(ovsdbConfigurationService);
-        verifyNoMoreInteractions(configurationService);
-        verifyNoMoreInteractions(networkingProviderManager);
-
-        when(bridgeMock.getPortsColumn()).thenReturn(columnMock);
-        when(columnMock.getData()).thenReturn(uuidSet);
-        assertEquals("Error, did not return correct boolean from isPortOnBridge", false,
-                bridgeConfigurationManagerImpl.isPortOnBridge(nodeMock, bridgeMock, portName));
+        when(southbound.extractTerminationPointAugmentation(any(Node.class), anyString()))
+                .thenReturn(null)
+                .thenReturn(port);
+
+        assertFalse("Error, port " + PORT_BR_INT + " should not be found",
+                bridgeConfigurationManagerImpl.isPortOnBridge(node, PORT_BR_INT));
+        assertTrue("Error, port " + PORT_BR_INT + " should be found",
+                bridgeConfigurationManagerImpl.isPortOnBridge(node, PORT_BR_INT));
+        verify(southbound, times(2)).extractTerminationPointAugmentation(any(Node.class), anyString());
+    }
 
-        when(port.getName()).thenReturn(portName);
+    @Test
+    public void testIsNodeTunnelReady() throws Exception {
+        when(southbound.isBridgeOnOvsdbNode(any(Node.class), anyString()))
+                .thenReturn(false)
+                .thenReturn(true);
 
-        when(ovsdbConfigurationService.getTypedRow(any(Node.class), any(Class.class), any(Row.class))).thenReturn(port);
-        when(port.getName()).thenReturn(portName);
+        verifyNoMoreInteractions(configurationService);
+        assertFalse("Error, did not return correct boolean from isNodeTunnelReady",
+                bridgeConfigurationManagerImpl.isNodeTunnelReady(node, node));
 
-        assertEquals("Error, did not return correct boolean from isPortOnBridge", true,
-                bridgeConfigurationManagerImpl.isPortOnBridge(nodeMock, bridgeMock, portName));
+        when(configurationService.isL3ForwardingEnabled()).thenReturn(false);
+        when(configurationService.getIntegrationBridgeName()).thenReturn(BR_INT);
+        assertTrue("Error, did not return correct boolean from isNodeTunnelReady",
+                bridgeConfigurationManagerImpl.isNodeTunnelReady(node, node));
 
-        verify(bridgeMock, times(2)).getPortsColumn();
-        verify(ovsdbConfigurationService, times(2)).getRow(any(Node.class), anyString(), anyString());
-        verify(ovsdbConfigurationService, times(2)).getTableName(any(Node.class), any(Class.class));
-        verify(ovsdbConfigurationService, times(2)).getTypedRow(any(Node.class), any(Class.class), any(Row.class));
-        verifyNoMoreInteractions(networkingProviderManager);
-        verifyNoMoreInteractions(configurationService);
+        verify(configurationService, times(1)).isL3ForwardingEnabled();
+        verify(configurationService, times(3)).getIntegrationBridgeName();
+        verify(southbound, times(2)).isBridgeOnOvsdbNode(any(Node.class), anyString());
     }
 
     @Test
-    public void testIsNodeTunnelReady() throws Exception {
-        String bridgeMockName = "BridgeMockName";
+    public void testIsNodeVlanReady() throws Exception {
+        when(southbound.isBridgeOnOvsdbNode(any(Node.class), anyString()))
+                .thenReturn(false)
+                .thenReturn(true);
+
+        when(southbound.extractTerminationPointAugmentation(any(Node.class), anyString()))
+                .thenReturn(null)
+                .thenReturn(port);
+
+        when(neutronNetwork.getProviderPhysicalNetwork()).thenReturn("test");
 
-        verifyNoMoreInteractions(ovsdbConfigurationService);
         verifyNoMoreInteractions(configurationService);
-        verifyNoMoreInteractions(networkingProviderManager);
-
-        when(configurationService.getIntegrationBridgeName()).thenReturn(bridgeMockName);
-        // getBridge() is private method - cannot be mocked with mockito
-        // when(bridgeConfigurationManagerImpl.getBridge(any(Node.class), anyString())).thenReturn(bridgeMock);
-
-        // Negative testing only due to private method call
-        assertEquals("Error, did not return correct boolean from isNodeTunnelReady", false,
-                bridgeConfigurationManagerImpl.isNodeTunnelReady(nodeMock));
-
-        verify(configurationService, times(1)).getIntegrationBridgeName();
-        verify(networkingProviderManager, times(0)).getProvider(nodeMock);
-        verify(configurationService, times(0)).getNetworkBridgeName();
-        verify(ovsdbConfigurationService, times(1)).getRows(any(Node.class), anyString());
-        verify(ovsdbConfigurationService, times(1)).getTableName(any(Node.class), any(Class.class));
-        verify(ovsdbConfigurationService, times(0)).getTypedRow(any(Node.class), any(Class.class), any(Row.class));
+        assertFalse("Error, did not return correct boolean from isNodeTunnelReady",
+                bridgeConfigurationManagerImpl.isNodeVlanReady(node, node, neutronNetwork));
+
+        BridgeConfigurationManagerImpl bridgeConfigurationManagerImplSpy =
+                PowerMockito.spy(new BridgeConfigurationManagerImpl());
+        doReturn(ETH1).when(bridgeConfigurationManagerImplSpy).getPhysicalInterfaceName(any(Node.class), anyString());
+        bridgeConfigurationManagerImplSpy.setConfigurationService(configurationService);
+        bridgeConfigurationManagerImplSpy.setSouthbound(southbound);
+
+        assertFalse("Error, did not return correct boolean from isNodeVlanReady",
+                bridgeConfigurationManagerImpl.isNodeVlanReady(node, node, neutronNetwork));
+
+        assertTrue("Error, did not return correct boolean from isNodeVlanReady",
+                bridgeConfigurationManagerImpl.isNodeVlanReady(node, node, neutronNetwork));
+
+        verify(configurationService, times(3)).getIntegrationBridgeName();
+        verify(neutronNetwork, times(2)).getProviderPhysicalNetwork();
     }
 
     @Test
-    public void testIsNodeVlanReady() throws Exception {
-        NeutronNetwork neutronNetworkMock = mock(NeutronNetwork.class);
+    public void testIsNodeL3Ready() {
+        when(southbound.isBridgeOnOvsdbNode(any(Node.class), anyString())).thenReturn(true);
+        when(southbound.extractTerminationPointAugmentation(any(Node.class), anyString())).thenReturn(mock(OvsdbTerminationPointAugmentation.class));
+        when(southbound.readBridgeNode(any(Node.class), anyString())).thenReturn(mock(Node.class));
 
-        verifyNoMoreInteractions(ovsdbConfigurationService);
-        verifyNoMoreInteractions(configurationService);
-        verifyNoMoreInteractions(networkingProviderManager);
-
-        // getBridge() is private method - cannot be mocked with mockito
-        // Negative testing only due to private method call
-        assertEquals("Error, did not return correct boolean from isNodeVlanReady", false,
-                bridgeConfigurationManagerImpl.isNodeVlanReady(nodeMock, neutronNetworkMock));
-
-        verify(configurationService, times(1)).getIntegrationBridgeName();
-        verify(networkingProviderManager, times(0)).getProvider(any(Node.class));
-        verify(configurationService, times(0)).getNetworkBridgeName();
-        verify(ovsdbConfigurationService, times(1)).getRows(any(Node.class), anyString());
-        verify(ovsdbConfigurationService, times(1)).getTableName(any(Node.class), any(Class.class));
-        verify(ovsdbConfigurationService, times(0)).getTypedRow(any(Node.class), any(Class.class), any(Row.class));
-        verify(neutronNetworkMock, times(0)).getProviderPhysicalNetwork();
+        assertTrue("Error, isNodeL3Ready didn't return true", bridgeConfigurationManagerImpl.isNodeL3Ready(node, node));
     }
 
     @Test
-    public void testPrepareNode() throws Exception {
-        NetworkingProvider netProvider = mock(NetworkingProvider.class);
-        when(configurationService.getIntegrationBridgeName()).thenReturn("intBridgeName");
-        when(networkingProviderManager.getProvider(any(Node.class))).thenReturn(netProvider);
-
-        // createIntegrationBridge() is private method - cannot be mocked with mockito
-        // Negative testing only due to private method call
-        bridgeConfigurationManagerImpl.prepareNode(nodeMock);
-
-        verify(configurationService, times(1)).getIntegrationBridgeName();
-        verify(networkingProviderManager, times(0)).getProvider(any(Node.class));
-        verify(netProvider, times(0)).initializeFlowRules(any(Node.class));
+    public void testPrepareNode() {
+        when(configurationService.getIntegrationBridgeName()).thenReturn(BR_INT);
+        when(southbound.isBridgeOnOvsdbNode(any(Node.class), anyString())).thenReturn(false);
+
+        PowerMockito.mockStatic(ConfigProperties.class);
+        when(ConfigProperties.getProperty(any(Class.class), anyString())).thenReturn(ADDRESS);
+
+        when(southbound.addBridge(any(Node.class), anyString(), anyList())).thenReturn(true);
+        when(configurationService.isL3ForwardingEnabled()).thenReturn(true);
+
+        bridgeConfigurationManagerImpl.prepareNode(node);
     }
 
     @Test
     public void testCreateLocalNetwork() throws Exception {
         NeutronNetwork neutronNetworkMock = mock(NeutronNetwork.class, RETURNS_MOCKS);
         String networkTypes[] = {"vlan", "vxlan", "gre"};
+        BridgeConfigurationManagerImpl bridgeConfigurationManagerImplSpy =
+                PowerMockito.spy(new BridgeConfigurationManagerImpl());
+        bridgeConfigurationManagerImplSpy.setConfigurationService(configurationService);
+        bridgeConfigurationManagerImplSpy.setSouthbound(southbound);
 
         for (String networkType : networkTypes) {
             when(neutronNetworkMock.getProviderNetworkType()).thenReturn(networkType);
+            when(southbound.readOvsdbNode(any(Node.class))).thenReturn(node);
 
             doAnswer(new Answer<Boolean>() {
                 @Override
                 public Boolean answer(InvocationOnMock invocation) {
                     return Boolean.TRUE;
                 }
-            }).when(bridgeConfigurationManagerImplSpy).isNodeVlanReady(any(Node.class), any(NeutronNetwork.class));
+            }).when(bridgeConfigurationManagerImplSpy).isNodeVlanReady(any(Node.class), any(Node.class), any(NeutronNetwork.class));
 
             doAnswer(new Answer<Boolean>() {
                 @Override
                 public Boolean answer(InvocationOnMock invocation) {
                     return Boolean.TRUE;
                 }
-            }).when(bridgeConfigurationManagerImplSpy).isNodeTunnelReady(any(Node.class));
+            }).when(bridgeConfigurationManagerImplSpy).isNodeTunnelReady(any(Node.class), any(Node.class));
 
             assertTrue("bridgeConfigMock.isNodeVlanReady is not true",
-                    bridgeConfigurationManagerImplSpy.isNodeVlanReady(nodeMock, neutronNetworkMock));
+                    bridgeConfigurationManagerImplSpy.isNodeVlanReady(node, node, neutronNetworkMock));
             assertTrue("bridgeConfigMock.isNodeTunnelReady is not true",
-                    bridgeConfigurationManagerImplSpy.isNodeTunnelReady(nodeMock));
+                    bridgeConfigurationManagerImplSpy.isNodeTunnelReady(node, node));
 
             assertTrue("Error, isCreated is not true for " + networkType,
-                    bridgeConfigurationManagerImplSpy.createLocalNetwork(nodeMock, neutronNetworkMock));
-            if (networkType == "vlan") {
+                    bridgeConfigurationManagerImplSpy.createLocalNetwork(node, neutronNetworkMock));
+            if (networkType.equals("vlan")) {
                 verify(neutronNetworkMock, times(1)).getProviderNetworkType();
-            } else if (networkType == "vxlan") {
+            } else if (networkType.equals("vxlan")) {
                 verify(neutronNetworkMock, times(2)).getProviderNetworkType();
-            } else if (networkType == "gre") {
+            } else if (networkType.equals("gre")) {
                 verify(neutronNetworkMock, times(3)).getProviderNetworkType();
             }
             reset(neutronNetworkMock);
-            reset(nodeMock);
+            reset(node);
             reset(bridgeConfigurationManagerImplSpy);
         }
     }
 
     @Test
     public void testGetPhysicalInterfaceName() throws Exception {
-        ConcurrentHashMap ovsTable = mock(ConcurrentHashMap.class, RETURNS_DEEP_STUBS);
-        Row row = mock(Row.class);
-        OpenVSwitch ovsRowOVS = mock(OpenVSwitch.class);
-        Column<GenericTableSchema, Map<String, String>> col = mock(Column.class);
-        Map<String, String> colMap = mock(Map.class);
-
-        HashMap<String, OpenVSwitch> hashMapOVS = new HashMap<>();
-        hashMapOVS.put("ovsRow", ovsRowOVS);
-        ConcurrentHashMap<String, Row> hashMap;
-        hashMap = new ConcurrentHashMap<>();
-        hashMap.put("row1", row);
-
-        String networkNames[] = {"network-0", "network-1", "network-2", "network-3"};
-        String interfaceNames[] = {"interfaceName-0", "interfaceName-1", "interfaceName-2", "interfaceName-3"};
-        int count = 0;
-
-        for (String networkName : networkNames) {
-            when(ovsdbConfigurationService.getRows(any(Node.class), anyString())).thenReturn(hashMap);
-            when(ovsTable.values()).thenReturn(hashMapOVS.values());
-
-            when(ovsRowOVS.getOtherConfigColumn()).thenReturn(col);
-            when(col.getData()).thenReturn(colMap);
-            when(configurationService.getProviderMappingsKey()).thenReturn("network-0:interfaceName-0," +
-                    "network-1:interfaceName-1,network-2:interfaceName-2,network-3:interfaceName-3");
-            when(colMap.get(anyString())).thenReturn("network-0:interfaceName-0,network-1:interfaceName-1," +
-                    "network-2:interfaceName-2,network-3:interfaceName-3");
-
-            when(configurationService.getDefaultProviderMapping()).thenReturn("network-0:interfaceName-0," +
-                    "network-1:interfaceName-1,network-2:interfaceName-2,network-3:interfaceName-3");
-
-            when(ovsdbConfigurationService.getTypedRow(any(Node.class), same(OpenVSwitch.class),
-                    any(Row.class))).thenReturn(ovsRowOVS);
-
-            assertEquals("Error, network: " + networkName + ", did not match interface: " + interfaceNames[count],
-                    interfaceNames[count], bridgeConfigurationManagerImpl.getPhysicalInterfaceName(nodeMock,
-                            networkName));
-
-            verify(ovsdbConfigurationService, times(count + 1)).getRows(any(Node.class), anyString());
-            verify(ovsdbConfigurationService, times(count + 1)).getTableName(any(Node.class), any(Class.class));
-            verify(ovsdbConfigurationService, times(count + 1)).getTypedRow(any(Node.class), any(Class.class),
-                    any(Row.class));
-            verify(configurationService, times(count + 1)).getProviderMappingsKey();
-            verify(configurationService, times(0)).getDefaultProviderMapping();
-            count++;
+        when(southbound.getOtherConfig(any(Node.class), eq(OvsdbTables.OPENVSWITCH), anyString()))
+                .thenReturn(null)
+                .thenReturn(null)
+                .thenReturn(PROVIDER_MAPPINGS);
+        String networkNames[] = {PHYSNET1, PHYSNET2};
+        String interfaceNames[] = {ETH1, ETH2};
+
+        verifyNoMoreInteractions(configurationService);
+        when(configurationService.getDefaultProviderMapping()).thenReturn(PROVIDER_MAPPINGS_DEFAULT);
+
+        assertNull("Error, should not have found " + PHYSNET2 + ":" + ETH2,
+                bridgeConfigurationManagerImpl.getPhysicalInterfaceName(node, PHYSNET2));
+        assertEquals("Error, should have found " + PHYSNET1 + ":" + ETH1,
+                ETH1, bridgeConfigurationManagerImpl.getPhysicalInterfaceName(node, PHYSNET1));
+        for (int i = 0; i < networkNames.length; i++) {
+            assertEquals("Error, network: " + networkNames[i]
+                            + ", did not match interface: "+ interfaceNames[i],
+                    interfaceNames[i],
+                    bridgeConfigurationManagerImpl.getPhysicalInterfaceName(node, networkNames[i]));
         }
+        assertNull(PHYSNET1, bridgeConfigurationManagerImpl.getPhysicalInterfaceName(node, PHYSNET3));
+        verify(configurationService, times(5)).getProviderMappingsKey();
+        verify(configurationService, times(2)).getDefaultProviderMapping();
+        verify(southbound, times(5)).getOtherConfig(any(Node.class), eq(OvsdbTables.OPENVSWITCH), anyString());
     }
 
     @Test
     public void testGetAllPhysicalInterfaceNames() throws Exception {
-        String interfaceNames[] = {"interfaceName-0", "interfaceName-1", "interfaceName-2", "interfaceName-3"};
-        List<String> intNameList = new ArrayList<>();
-        for (String name: interfaceNames){
-            intNameList.add(name);
-        }
-        Row row = mock(Row.class);
-        OpenVSwitch ovsRowOVS = mock(OpenVSwitch.class);
-        Column<GenericTableSchema, Map<String, String>> col = mock(Column.class);
-        Map<String, String> colMap = mock(Map.class);
-        ConcurrentHashMap<String, Row> hashMap;
-        hashMap = new ConcurrentHashMap<>();
-        hashMap.put("row1", row);
-
-        when(ovsdbConfigurationService.getRows(any(Node.class), anyString())).thenReturn(hashMap);
-        when(ovsdbConfigurationService.getTypedRow(any(Node.class), same(OpenVSwitch.class),
-                any(Row.class))).thenReturn(ovsRowOVS);
-        when(ovsRowOVS.getOtherConfigColumn()).thenReturn(col);
-        when(col.getData()).thenReturn(colMap);
-        when(colMap.get(anyString())).thenReturn("network-0:interfaceName-0,network-1:interfaceName-1," +
-                "network-2:interfaceName-2,network-3:interfaceName-3");
-
-        assertEquals("Error, did not get all interface names", intNameList,
-                bridgeConfigurationManagerImpl.getAllPhysicalInterfaceNames(nodeMock));
-        verify(ovsdbConfigurationService, times(1)).getRows(any(Node.class), anyString());
-        verify(ovsdbConfigurationService, times(1)).getTableName(any(Node.class), any(Class.class));
-        verify(ovsdbConfigurationService, times(1)).getTypedRow(any(Node.class), any(Class.class), any(Row.class));
-        verify(configurationService, times(1)).getProviderMappingsKey();
-        verify(configurationService, times(0)).getDefaultProviderMapping();
+        when(southbound.getOtherConfig(any(Node.class), eq(OvsdbTables.OPENVSWITCH), anyString()))
+                .thenReturn(null)
+                .thenReturn(PROVIDER_MAPPINGS);
+
+        verifyNoMoreInteractions(configurationService);
+        when(configurationService.getDefaultProviderMapping()).thenReturn(PROVIDER_MAPPINGS_DEFAULT);
+
+        List<String> interfaces = bridgeConfigurationManagerImpl.getAllPhysicalInterfaceNames(node);
+        assertEquals("Error, should have found 1 interface", 1, interfaces.size());
+        assertTrue("Error, should have found " + ETH1, interfaces.contains(ETH1));
+        assertFalse("Error, should not have found " + ETH2, interfaces.contains(ETH2));
+        interfaces = bridgeConfigurationManagerImpl.getAllPhysicalInterfaceNames(node);
+        assertEquals("Error, should have found 2 interfaces", 2, interfaces.size());
+        assertTrue("Error, should have found " + ETH1, interfaces.contains(ETH1));
+        assertTrue("Error, should have found " + ETH1, interfaces.contains(ETH2));
+        assertFalse("Error, should not have found " + ETH3, interfaces.contains(ETH3));
+
+        verify(configurationService, times(2)).getProviderMappingsKey();
+        verify(configurationService, times(1)).getDefaultProviderMapping();
+        verify(southbound, times(2)).getOtherConfig(any(Node.class), eq(OvsdbTables.OPENVSWITCH), anyString());
     }
 
     @Test
-    public void testGetBridge() throws Exception {
-        Row row = mock(Row.class);
-        Bridge bridge = mock(Bridge.class);
-        ConcurrentHashMap<String, Row> hashMap;
-        hashMap = new ConcurrentHashMap<>();
-        hashMap.put("row1", row);
-
-        when(ovsdbConfigurationService.getRows(any(Node.class), anyString())).thenReturn(hashMap);
-        when(ovsdbConfigurationService.getTypedRow(any(Node.class), same(Bridge.class),
-                any(Row.class))).thenReturn(bridge);
-        when(bridge.getName()).thenReturn("test-bridge");
-
-        assertEquals("Error, did not get correct bridge", bridge,
-                bridgeConfigurationManagerImpl.getBridge(nodeMock, "test-bridge"));
-        verify(ovsdbConfigurationService, times(1)).getRows(any(Node.class), anyString());
-        verify(ovsdbConfigurationService, times(1)).getTableName(any(Node.class), any(Class.class));
-        verify(ovsdbConfigurationService, times(1)).getTypedRow(any(Node.class), any(Class.class), any(Row.class));
+    public void testSetDependencies() throws Exception {
+        ConfigurationService configurationService = mock(ConfigurationService.class);
+        NetworkingProviderManager networkingProviderManager = mock(NetworkingProviderManager.class);
+        Southbound southbound = mock(Southbound.class);
+
+        PowerMockito.mockStatic(ServiceHelper.class);
+        PowerMockito.when(ServiceHelper.getGlobalInstance(ConfigurationService.class, bridgeConfigurationManagerImpl)).thenReturn(configurationService);
+        PowerMockito.when(ServiceHelper.getGlobalInstance(NetworkingProviderManager.class, bridgeConfigurationManagerImpl)).thenReturn(networkingProviderManager);
+        PowerMockito.when(ServiceHelper.getGlobalInstance(Southbound.class, bridgeConfigurationManagerImpl)).thenReturn(southbound);
+
+        bridgeConfigurationManagerImpl.setDependencies(mock(ServiceReference.class));
+
+        assertEquals("Error, did not return the correct object", getField("configurationService"), configurationService);
+        assertEquals("Error, did not return the correct object", getField("networkingProviderManager"), networkingProviderManager);
+        assertEquals("Error, did not return the correct object", getField("southbound"), southbound);
+    }
+
+    private Object getField(String fieldName) throws Exception {
+        Field field = BridgeConfigurationManagerImpl.class.getDeclaredField(fieldName);
+        field.setAccessible(true);
+        return field.get(bridgeConfigurationManagerImpl);
     }
 }
\ No newline at end of file