RouterDeploymentDefinition { protected void deployAllVirtualRouters() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { final int routersToDeploy = getNumberOfRoutersToDeploy(); for (int i = 0; i < routersToDeploy; i++) { final DomainRouterVO router = nwHelper.deployRouter(this, false); if (router != null) { routerDao.addRouterToGuestNetwork(router, guestNetwork); routers.add(router); } } } 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 testDeployAllVirtualRouters() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { deployment.routers = new ArrayList<>(); when(mockNw.isRedundant()).thenReturn(true); final RouterDeploymentDefinition deploymentUT = spy(deployment); doReturn(2).when(deploymentUT).getNumberOfRoutersToDeploy(); final DomainRouterVO routerVO1 = mock(DomainRouterVO.class); final DomainRouterVO routerVO2 = mock(DomainRouterVO.class); when(mockNetworkHelper.deployRouter(deploymentUT, false)) .thenReturn(routerVO1).thenReturn(routerVO2); deploymentUT.deployAllVirtualRouters(); verify(mockRouterDao, times(1)).addRouterToGuestNetwork(routerVO1, mockNw); verify(mockRouterDao, times(1)).addRouterToGuestNetwork(routerVO2, mockNw); assertEquals("First router to deploy was not added to list of available routers", routerVO1, deployment.routers.get(0)); assertEquals("Second router to deploy was not added to list of available routers", routerVO2, deployment.routers.get(1)); }