test_class.declarator: ROUTER_ID = 1L
test_class.modifier: protected static final
test_class.original_string: protected static final long ROUTER_ID = 1L;
test_class.type: long
test_class.var_name: ROUTER_ID
test_class.declarator: NW_ID_1 = 11L
test_class.modifier: protected static final
test_class.original_string: protected static final long NW_ID_1 = 11L;
test_class.type: long
test_class.var_name: NW_ID_1
test_class.declarator: NW_ID_2 = 12L
test_class.modifier: protected static final
test_class.original_string: protected static final long NW_ID_2 = 12L;
test_class.type: long
test_class.var_name: NW_ID_2
test_class.declarator: NW_ID_3 = 13L
test_class.modifier: protected static final
test_class.original_string: protected static final long NW_ID_3 = 13L;
test_class.type: long
test_class.var_name: NW_ID_3
test_class.declarator: DIDN_T_GET_THE_EXPECTED_IP4_ADDRESS = "Didn't get the expected IP4 address"
test_class.modifier: private static final
test_class.original_string: private static final String DIDN_T_GET_THE_EXPECTED_IP4_ADDRESS = "Didn't get the expected IP4 address";
test_class.type: String
test_class.var_name: DIDN_T_GET_THE_EXPECTED_IP4_ADDRESS
test_class.declarator: IP4_ADDRES1 = "IP4Addres1"
test_class.modifier: private static final
test_class.original_string: private static final String IP4_ADDRES1 = "IP4Addres1";
test_class.type: String
test_class.var_name: IP4_ADDRES1
test_class.declarator: IP4_ADDRES2 = "IP4Addres2"
test_class.modifier: private static final
test_class.original_string: private static final String IP4_ADDRES2 = "IP4Addres2";
test_class.type: String
test_class.var_name: IP4_ADDRES2
test_class.declarator: nicDao
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected NicDao nicDao;
test_class.type: NicDao
test_class.var_name: nicDao
test_class.declarator: nwDao
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected NetworkDao nwDao;
test_class.type: NetworkDao
test_class.var_name: nwDao
test_class.declarator: routerDao
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected DomainRouterDao routerDao;
test_class.type: DomainRouterDao
test_class.var_name: routerDao
test_class.declarator: routerControlHelper = new RouterControlHelper()
test_class.modifier: @InjectMocks
      protected
test_class.original_string: @InjectMocks
      protected RouterControlHelper routerControlHelper = new RouterControlHelper();
test_class.type: RouterControlHelper
test_class.var_name: routerControlHelper
test_class.file: cosmic-core/server/src/test/java/com/cloud/network/router/RouterControlHelperTest.java
test_class.identifier: RouterControlHelperTest
test_case.body: @Test
      public void testGetRouterControlIp() {
          // Prepare
          final List<NicVO> nics = new ArrayList<>();
          final NicVO nic1 = mock(NicVO.class);
          final NicVO nic2 = mock(NicVO.class);
          // Actually the third one will never be used, but we must assert that is not
          final NicVO nic3 = mock(NicVO.class);
          when(nic1.getNetworkId()).thenReturn(NW_ID_1);
          when(nic2.getNetworkId()).thenReturn(NW_ID_2);
          when(nic2.getIPv4Address()).thenReturn(IP4_ADDRES1);
          when(nic3.getNetworkId()).thenReturn(NW_ID_3);
          when(nic3.getIPv4Address()).thenReturn(IP4_ADDRES2);
          nics.add(nic1);
          nics.add(nic2);
          nics.add(nic3);
          when(this.nicDao.listByVmId(ROUTER_ID)).thenReturn(nics);
  
          final NetworkVO nw1 = mock(NetworkVO.class);
          when(nw1.getTrafficType()).thenReturn(TrafficType.Public);
          final NetworkVO nw2 = mock(NetworkVO.class);
          when(nw2.getTrafficType()).thenReturn(TrafficType.Control);
          final NetworkVO nw3 = mock(NetworkVO.class);
          when(nw3.getTrafficType()).thenReturn(TrafficType.Control);
          when(this.nwDao.findById(NW_ID_1)).thenReturn(nw1);
          when(this.nwDao.findById(NW_ID_2)).thenReturn(nw2);
          when(this.nwDao.findById(NW_ID_3)).thenReturn(nw3);
  
          // Execute
          final String ip4address = this.routerControlHelper.getRouterControlIp(ROUTER_ID);
  
          // Assert
          assertEquals(DIDN_T_GET_THE_EXPECTED_IP4_ADDRESS, IP4_ADDRES1, ip4address);
      }
test_case.class_method_signature: RouterControlHelperTest.testGetRouterControlIp()
test_case.full_signature: @Test public void testGetRouterControlIp()
test_case.identifier: testGetRouterControlIp
test_case.invocations: mock mock mock thenReturn when getNetworkId thenReturn when getNetworkId thenReturn when getIPv4Address thenReturn when getNetworkId thenReturn when getIPv4Address add add add thenReturn when listByVmId mock thenReturn when getTrafficType mock thenReturn when getTrafficType mock thenReturn when getTrafficType thenReturn when findById thenReturn when findById thenReturn when findById getRouterControlIp assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetRouterControlIp()
focal_class.declarator: logger = LoggerFactory.getLogger(RouterControlHelper.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(RouterControlHelper.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: routerDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private DomainRouterDao routerDao;
focal_class.type: DomainRouterDao
focal_class.var_name: routerDao
focal_class.declarator: networkDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private NetworkDao networkDao;
focal_class.type: NetworkDao
focal_class.var_name: networkDao
focal_class.declarator: nicDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private NicDao nicDao;
focal_class.type: NicDao
focal_class.var_name: nicDao
focal_class.file: cosmic-core/server/src/main/java/com/cloud/network/router/RouterControlHelper.java
focal_class.identifier: RouterControlHelper
focal_class.class_method_signature: RouterControlHelper.getRouterControlIp(final long routerId)
focal_class.full_signature: public String getRouterControlIp(final long routerId)
focal_class.identifier: getRouterControlIp
focal_class.modifiers: public
focal_class.parameters: (final long routerId)
focal_class.return: String
focal_class.signature: String getRouterControlIp(final long routerId)
focal_class.class_method_signature: RouterControlHelper.getRouterIpInNetwork(final long networkId, final long instanceId)
focal_class.full_signature: public String getRouterIpInNetwork(final long networkId, final long instanceId)
focal_class.identifier: getRouterIpInNetwork
focal_class.modifiers: public
focal_class.parameters: (final long networkId, final long instanceId)
focal_class.return: String
focal_class.signature: String getRouterIpInNetwork(final long networkId, final long instanceId)
focal_method.body: public String getRouterControlIp(final long routerId) {
          String routerControlIpAddress = null;
          final List<NicVO> nics = nicDao.listByVmId(routerId);
          for (final NicVO n : nics) {
              final NetworkVO nc = networkDao.findById(n.getNetworkId());
              if (nc != null && nc.getTrafficType() == TrafficType.Control) {
                  routerControlIpAddress = n.getIPv4Address();
                  // router will have only one control ip
                  break;
              }
          }
  
          if (routerControlIpAddress == null) {
              logger.warn("Unable to find router's control ip in its attached NICs!. routerId: " + routerId);
              final DomainRouterVO router = routerDao.findById(routerId);
              return router.getPrivateIpAddress();
          }
  
          return routerControlIpAddress;
      }
focal_method.class_method_signature: RouterControlHelper.getRouterControlIp(final long routerId)
focal_method.full_signature: public String getRouterControlIp(final long routerId)
focal_method.identifier: getRouterControlIp
focal_method.invocations: listByVmId findById getNetworkId getTrafficType getIPv4Address warn findById getPrivateIpAddress
focal_method.modifiers: public
focal_method.parameters: (final long routerId)
focal_method.return: String
focal_method.signature: String getRouterControlIp(final long routerId)