RouterDeploymentDefinition { protected List<DeployDestination> findDestinations() { final List<DeployDestination> destinations = new ArrayList<DeployDestination>(); if (isBasic() && dest.getPod() == null) { final long dcId = dest.getDataCenter().getId(); final List<HostPodVO> pods = listByDataCenterIdVMTypeAndStates(dcId, VirtualMachine.Type.User, VirtualMachine.State.Starting, VirtualMachine.State.Running); for (final HostPodVO pod : pods) { final long podId = pod.getId(); final List<DomainRouterVO> virtualRouters = routerDao.listByPodIdAndStates(podId, VirtualMachine.State.Starting, VirtualMachine.State.Running); if (virtualRouters.size() > 1) { throw new CloudRuntimeException("Pod can have utmost one VR in Basic Zone, please check!"); } routers.addAll(virtualRouters); if (virtualRouters.size() == 1) { logger.debug("Skipping VR deployment: Found a running or starting VR in Pod " + pod.getName() + " id=" + podId); continue; } destinations.add(new DeployDestination(dest.getDataCenter(), pod, null, null)); } } else { destinations.add(dest); } return destinations; } protected  RouterDeploymentDefinition(final Network guestNetwork, final DeployDestination dest,
                                         final Account owner, final Map<Param, Object> params); Long getServiceOfferingId(); Vpc getVpc(); Network getGuestNetwork(); DeployDestination getDest(); Account getOwner(); Map<Param, Object> getParams(); boolean isRedundant(); DeploymentPlan getPlan(); boolean isVpcRouter(); Pod getPod(); Long getPodId(); List<DomainRouterVO> getRouters(); VirtualRouterProvider getVirtualProvider(); boolean isBasic(); boolean isPublicNetwork(); PublicIp getSourceNatIP(); boolean needsPublicNic(); boolean hasSourceNatService(); List<DomainRouterVO> deployVirtualRouter();  }
@Test public void testFindDestinationsNonBasicZone() { when(mockDataCenter.getNetworkType()).thenReturn(NetworkType.Advanced); final List<DeployDestination> destinations = deployment.findDestinations(); assertEquals(ONLY_THE_PROVIDED_AS_DEFAULT_DESTINATION_WAS_EXPECTED, 1, destinations.size()); assertEquals(ONLY_THE_PROVIDED_AS_DEFAULT_DESTINATION_WAS_EXPECTED, mockDestination, destinations.get(0)); }
@Test public void testFindDestinations() { when(mockDataCenter.getNetworkType()).thenReturn(NetworkType.Basic); when(mockDestination.getPod()).thenReturn(null); mockPods.add(mockHostPodVO1); mockPods.add(mockHostPodVO2); mockPods.add(mockHostPodVO3); final RouterDeploymentDefinition deployment = spy(this.deployment); doReturn(mockPods).when(deployment).listByDataCenterIdVMTypeAndStates( DATA_CENTER_ID, VirtualMachine.Type.User, VirtualMachine.State.Starting, VirtualMachine.State.Running); final List<DomainRouterVO> virtualRouters1 = new ArrayList<>(); when(mockRouterDao.listByPodIdAndStates(POD_ID1, VirtualMachine.State.Starting, VirtualMachine.State.Running)).thenReturn(virtualRouters1); final List<DomainRouterVO> virtualRouters2 = new ArrayList<>(); final DomainRouterVO domainRouterVO1 = mock(DomainRouterVO.class); virtualRouters2.add(domainRouterVO1); when(mockRouterDao.listByPodIdAndStates(POD_ID2, VirtualMachine.State.Starting, VirtualMachine.State.Running)).thenReturn(virtualRouters2); final List<DomainRouterVO> virtualRouters3 = new ArrayList<>(); when(mockRouterDao.listByPodIdAndStates(POD_ID3, VirtualMachine.State.Starting, VirtualMachine.State.Running)).thenReturn(virtualRouters3); final List<DeployDestination> destinations = deployment.findDestinations(); assertEquals("", 2, destinations.size()); assertEquals("", mockDataCenter, destinations.get(0).getDataCenter()); assertEquals("", mockHostPodVO1, destinations.get(0).getPod()); assertEquals("", mockDataCenter, destinations.get(1).getDataCenter()); assertEquals("", mockHostPodVO3, destinations.get(1).getPod()); }