RouterDeploymentDefinition { public List<DomainRouterVO> deployVirtualRouter() throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { findOrDeployVirtualRouter(); return nwHelper.startRouters(this); } 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(expected = ConcurrentOperationException.class) public void testDeployVirtualRouter() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { final List<DeployDestination> mockDestinations = new ArrayList<>(); mockDestinations.add(mock(DeployDestination.class)); mockDestinations.add(mock(DeployDestination.class)); final RouterDeploymentDefinition deploymentUT = spy(deployment); doNothing().when(deploymentUT).lock(); doNothing().when(deploymentUT).checkPreconditions(); doReturn(mockDestinations).when(deploymentUT).findDestinations(); doNothing().when(deploymentUT).planDeploymentRouters(); doNothing().when(deploymentUT).generateDeploymentPlan(); final ConcurrentOperationException exception = new ConcurrentOperationException(null); doNothing().doThrow(exception).when(deploymentUT).executeDeployment(); doNothing().when(deploymentUT).unlock(); try { deploymentUT.findOrDeployVirtualRouter(); } finally { verify(deploymentUT, times(1)).lock(); verify(deploymentUT, times(2)).checkPreconditions(); verify(deploymentUT, times(2)).findDestinations(); verify(deploymentUT, times(3)).generateDeploymentPlan(); verify(deploymentUT, times(2)).executeDeployment(); verify(deploymentUT, times(1)).unlock(); } fail(); }