RouterDeploymentDefinition { protected void setupAccountOwner() { if (networkModel.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) { owner = accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM); } } 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 testSetupAccountOwner() { when(mockNetworkModel.isNetworkSystem(mockNw)).thenReturn(true); final Account newAccountOwner = mock(Account.class); when(mockAccountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM)).thenReturn(newAccountOwner); deployment.setupAccountOwner(); assertEquals("New account owner not properly set", newAccountOwner, deployment.owner); }
@Test public void testSetupAccountOwnerNotNetworkSystem() { when(mockNetworkModel.isNetworkSystem(mockNw)).thenReturn(false); when(mockNw.getGuestType()).thenReturn(Network.GuestType.Shared); final Account newAccountOwner = mock(Account.class); when(mockAccountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM)).thenReturn(newAccountOwner); deployment.setupAccountOwner(); assertEquals("New account owner not properly set", newAccountOwner, deployment.owner); }
@Test public void testSetupAccountOwnerNotSharedNeitherNetworkSystem() { when(mockNetworkModel.isNetworkSystem(mockNw)).thenReturn(false); when(mockNw.getGuestType()).thenReturn(Network.GuestType.Isolated); when(mockAccountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM)).thenReturn(null); deployment.setupAccountOwner(); assertEquals("New account shouldn't have been updated", mockOwner, deployment.owner); }