Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ public boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String
PhysicalNetworkServiceProviderVO ntwkSvcProvider = _pNSPDao.findByServiceProvider(physicalNetowrkId, providerName);
if (ntwkSvcProvider == null) {
logger.warn("Unable to find provider {} in physical network {}",
providerName::toString, () -> _physicalNetworkDao.findById(physicalNetowrkId));
() -> providerName, () -> _physicalNetworkDao.findById(physicalNetowrkId));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix.
I noticed a similar case in isServiceEnabledInNetwork that may benefit from the same approach.

return false;
}
return isProviderEnabled(ntwkSvcProvider);
Expand Down
12 changes: 12 additions & 0 deletions server/src/test/java/com/cloud/network/NetworkModelImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.cloud.network.dao.NetworkServiceMapDao;
import com.cloud.network.dao.NetworkServiceMapVO;
import com.cloud.network.dao.NetworkVO;
import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
import com.cloud.network.element.NetworkElement;
import com.cloud.network.element.VpcVirtualRouterElement;
import com.cloud.offerings.NetworkOfferingVO;
Expand Down Expand Up @@ -232,4 +234,14 @@ public void testGetProviderToIpList() {
Map<Network.Provider, ArrayList<PublicIpAddress>> result = networkModel.getProviderToIpList(network, ipToServices);
Assert.assertNotNull(result);
}

@Test
public void testIsProviderEnabledInPhysicalNetworkNullProvider() {
PhysicalNetworkServiceProviderDao pNSPDao = Mockito.mock(PhysicalNetworkServiceProviderDao.class);
networkModel._pNSPDao = pNSPDao;
networkModel._physicalNetworkDao = Mockito.mock(PhysicalNetworkDao.class);
Mockito.when(pNSPDao.findByServiceProvider(1L, null)).thenReturn(null);

Assert.assertFalse(networkModel.isProviderEnabledInPhysicalNetwork(1L, null));
}
}
Loading