Github user koushik-das commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1360#discussion_r58875609 --- Diff: server/test/com/cloud/consoleproxy/ConsoleProxyManagerTest.java --- @@ -87,4 +114,136 @@ public void testExisingCPVMStartFailure() throws Exception { cpvmManager.expandPool(new Long(1), new Object()); } + + @Test + public void getDefaultNetworkForAdvancedNonSG() { + DataCenterVO dc = mock(DataCenterVO.class); + when(dc.getNetworkType()).thenReturn(NetworkType.Advanced); + when(dc.isSecurityGroupEnabled()).thenReturn(false); + + when(_dcDao.findById(Mockito.anyLong())).thenReturn(dc); + + NetworkVO network = Mockito.mock(NetworkVO.class); + NetworkVO badNetwork = Mockito.mock(NetworkVO.class); + when(_networkDao.listByZoneAndTrafficType(anyLong(), eq(TrafficType.Public))) + .thenReturn(Collections.singletonList(network)); + + when(_networkDao.listByZoneAndTrafficType(anyLong(), not(eq(TrafficType.Public)))) + .thenReturn(Collections.singletonList(badNetwork)); + + when(_networkDao.listByZoneSecurityGroup(anyLong())) + .thenReturn(Collections.singletonList(badNetwork)); + + NetworkVO returnedNetwork = cpvmManager.getDefaultNetworkForAdvancedZone(dc); + + Assert.assertNotNull(returnedNetwork); + Assert.assertEquals(network, returnedNetwork); + Assert.assertNotEquals(badNetwork, returnedNetwork); + } + + @Test + public void getDefaultNetworkForAdvancedSG() { --- End diff -- @ProjectMoon The unit tests getDefaultNetworkForBasicNonSG() and getDefaultNetworkForBasicSG() are same since SG has no impact on the method being tested. The line "when(dc.isSecurityGroupEnabled()).thenReturn(true or false);" doesn't impact test outcome. Thats what I mentioned in my initial comment.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---