use of com.cloud.user.AccountVO in project cloudstack by apache.
the class GlobalLoadBalancingRulesServiceImplTest method runAssignToGlobalLoadBalancerRuleTestSameZoneLb.
void runAssignToGlobalLoadBalancerRuleTestSameZoneLb() throws Exception {
TransactionLegacy txn = TransactionLegacy.open("runAssignToGlobalLoadBalancerRuleTestSameZoneLb");
GlobalLoadBalancingRulesServiceImpl gslbServiceImpl = new GlobalLoadBalancingRulesServiceImpl();
gslbServiceImpl._accountMgr = Mockito.mock(AccountManager.class);
gslbServiceImpl._gslbRuleDao = Mockito.mock(GlobalLoadBalancerRuleDao.class);
gslbServiceImpl._gslbLbMapDao = Mockito.mock(GlobalLoadBalancerLbRuleMapDao.class);
gslbServiceImpl._regionDao = Mockito.mock(RegionDao.class);
gslbServiceImpl._rulesMgr = Mockito.mock(RulesManager.class);
gslbServiceImpl._lbDao = Mockito.mock(LoadBalancerDao.class);
gslbServiceImpl._networkDao = Mockito.mock(NetworkDao.class);
gslbServiceImpl._globalConfigDao = Mockito.mock(ConfigurationDao.class);
gslbServiceImpl._ipAddressDao = Mockito.mock(IPAddressDao.class);
gslbServiceImpl._agentMgr = Mockito.mock(AgentManager.class);
AssignToGlobalLoadBalancerRuleCmd assignCmd = new AssignToGlobalLoadBalancerRuleCmdExtn();
Class<?> _class = assignCmd.getClass().getSuperclass();
Account account = new AccountVO("testaccount", 3, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
gslbRuleId.set(assignCmd, new Long(1));
GlobalLoadBalancerRuleVO gslbRule = new GlobalLoadBalancerRuleVO("test-gslb-rule", "test-gslb-rule", "test-domain", "roundrobin", "sourceip", "tcp", 1, 3, 1, GlobalLoadBalancerRule.State.Active);
when(gslbServiceImpl._gslbRuleDao.findById(new Long(1))).thenReturn(gslbRule);
LoadBalancerVO lbRule1 = new LoadBalancerVO();
lbRule1.setState(FirewallRule.State.Active);
Field networkIdField1 = LoadBalancerVO.class.getSuperclass().getDeclaredField("networkId");
Field accountIdField1 = LoadBalancerVO.class.getSuperclass().getDeclaredField("accountId");
Field domainIdField1 = LoadBalancerVO.class.getSuperclass().getDeclaredField("domainId");
networkIdField1.setAccessible(true);
accountIdField1.setAccessible(true);
domainIdField1.setAccessible(true);
networkIdField1.set(lbRule1, new Long(1));
accountIdField1.set(lbRule1, new Long(3));
domainIdField1.set(lbRule1, new Long(1));
Field idField1 = LoadBalancerVO.class.getSuperclass().getDeclaredField("id");
idField1.setAccessible(true);
idField1.set(lbRule1, new Long(1));
LoadBalancerVO lbRule2 = new LoadBalancerVO();
lbRule2.setState(FirewallRule.State.Active);
Field networkIdField2 = LoadBalancerVO.class.getSuperclass().getDeclaredField("networkId");
Field accountIdField2 = LoadBalancerVO.class.getSuperclass().getDeclaredField("accountId");
Field domainIdField2 = LoadBalancerVO.class.getSuperclass().getDeclaredField("domainId");
networkIdField2.setAccessible(true);
accountIdField2.setAccessible(true);
domainIdField2.setAccessible(true);
networkIdField2.set(lbRule2, new Long(1));
accountIdField2.set(lbRule2, new Long(3));
domainIdField2.set(lbRule2, new Long(1));
Field idField2 = LoadBalancerVO.class.getSuperclass().getDeclaredField("id");
idField2.setAccessible(true);
idField2.set(lbRule2, new Long(2));
when(gslbServiceImpl._lbDao.findById(new Long(1))).thenReturn(lbRule1);
when(gslbServiceImpl._lbDao.findById(new Long(2))).thenReturn(lbRule2);
Field lbRules = _class.getDeclaredField("loadBalancerRulesIds");
lbRules.setAccessible(true);
List<Long> lbRuleIds = new ArrayList<Long>();
lbRuleIds.add(new Long(1));
lbRuleIds.add(new Long(2));
lbRules.set(assignCmd, lbRuleIds);
NetworkVO networkVo = new NetworkVO();
Field dcID = NetworkVO.class.getDeclaredField("dataCenterId");
dcID.setAccessible(true);
dcID.set(networkVo, new Long(1));
when(gslbServiceImpl._networkDao.findById(new Long(1))).thenReturn(networkVo);
try {
gslbServiceImpl.assignToGlobalLoadBalancerRule(assignCmd);
} catch (InvalidParameterValueException e) {
s_logger.info(e.getMessage());
Assert.assertTrue(e.getMessage().contains("Load balancer rule specified should be in unique zone"));
}
}
use of com.cloud.user.AccountVO in project cloudstack by apache.
the class UpdateLoadBalancerTest method setUp.
@Before
public void setUp() {
_lbMgr._accountMgr = new MockAccountManagerImpl();
_lbMgr._autoScaleVmGroupDao = Mockito.mock(AutoScaleVmGroupDao.class);
_lbMgr._networkDao = netDao;
_lbMgr._networkModel = netModel;
_lbMgr._lb2healthcheckDao = Mockito.mock(LBHealthCheckPolicyDao.class);
_lbMgr._lb2stickinesspoliciesDao = Mockito.mock(LBStickinessPolicyDao.class);
_lbMgr._lb2VmMapDao = Mockito.mock(LoadBalancerVMMapDao.class);
_lbMgr._lbCertMapDao = Mockito.mock(LoadBalancerCertMapDao.class);
_lbMgr._lbDao = lbDao;
_lbMgr._lbProviders = new ArrayList<LoadBalancingServiceProvider>();
_lbMgr._lbProviders.add(lbServiceProvider);
updateLbRuleCmd = new UpdateLoadBalancerRuleCmd();
AccountVO account = new AccountVO(accountName, domainId, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account);
}
use of com.cloud.user.AccountVO in project cloudstack by apache.
the class CreatePrivateNetworkTest method setup.
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
networkService._accountMgr = _accountMgr;
networkService._networkOfferingDao = _networkOfferingDao;
networkService._physicalNetworkDao = _physicalNetworkDao;
networkService._dcDao = _dcDao;
networkService._networksDao = _networkDao;
networkService._networkMgr = _networkMgr;
networkService._privateIpDao = _privateIpDao;
Account account = new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(networkService._accountMgr.getAccount(anyLong())).thenReturn(account);
NetworkOfferingVO ntwkOff = new NetworkOfferingVO("offer", "fakeOffer", TrafficType.Guest, true, true, null, null, false, null, null, GuestType.Isolated, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
when(networkService._networkOfferingDao.findById(anyLong())).thenReturn(ntwkOff);
List<NetworkOfferingVO> netofferlist = new ArrayList<NetworkOfferingVO>();
netofferlist.add(ntwkOff);
when(networkService._networkOfferingDao.listSystemNetworkOfferings()).thenReturn(netofferlist);
PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork");
when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork);
DataCenterVO dc = new DataCenterVO(1L, "hut", "op de hei", null, null, null, null, "10.1.1.0/24", "unreal.net", 1L, NetworkType.Advanced, null, null);
when(networkService._dcDao.lockRow(anyLong(), anyBoolean())).thenReturn(dc);
when(networkService._networksDao.getPrivateNetwork(anyString(), anyString(), eq(1L), eq(1L), anyLong())).thenReturn(null);
Network net = new NetworkVO(1L, TrafficType.Guest, Mode.None, BroadcastDomainType.Vlan, 1L, 1L, 1L, 1L, "bla", "fake", "eet.net", GuestType.Isolated, 1L, 1L, ACLType.Account, false, 1L, false);
when(networkService._networkMgr.createGuestNetwork(eq(ntwkOff.getId()), eq("bla"), eq("fake"), eq("10.1.1.1"), eq("10.1.1.0/24"), anyString(), anyString(), eq(account), anyLong(), eq(physicalNetwork), eq(physicalNetwork.getDataCenterId()), eq(ACLType.Account), anyBoolean(), eq(1L), anyString(), anyString(), anyBoolean(), anyString())).thenReturn(net);
when(networkService._privateIpDao.findByIpAndSourceNetworkId(net.getId(), "10.1.1.2")).thenReturn(null);
when(networkService._privateIpDao.findByIpAndSourceNetworkIdAndVpcId(eq(1L), anyString(), eq(1L))).thenReturn(null);
}
use of com.cloud.user.AccountVO in project cloudstack by apache.
the class DedicateGuestVlanRangesTest method setup.
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
networkService._accountMgr = _accountMgr;
networkService._accountDao = _accountDao;
networkService._projectMgr = _projectMgr;
networkService._physicalNetworkDao = _physicalNetworkDao;
networkService._datacneterVnet = _dataCenterVnetDao;
networkService._accountGuestVlanMapDao = _accountGuestVlanMapDao;
Account account = new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(networkService._accountMgr.getAccount(anyLong())).thenReturn(account);
when(networkService._accountDao.findActiveAccount(anyString(), anyLong())).thenReturn(account);
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account);
Field accountNameField = _dedicateGuestVlanRangeClass.getDeclaredField("accountName");
accountNameField.setAccessible(true);
accountNameField.set(dedicateGuestVlanRangesCmd, "accountname");
Field projectIdField = _dedicateGuestVlanRangeClass.getDeclaredField("projectId");
projectIdField.setAccessible(true);
projectIdField.set(dedicateGuestVlanRangesCmd, null);
Field domainIdField = _dedicateGuestVlanRangeClass.getDeclaredField("domainId");
domainIdField.setAccessible(true);
domainIdField.set(dedicateGuestVlanRangesCmd, 1L);
Field physicalNetworkIdField = _dedicateGuestVlanRangeClass.getDeclaredField("physicalNetworkId");
physicalNetworkIdField.setAccessible(true);
physicalNetworkIdField.set(dedicateGuestVlanRangesCmd, 1L);
Field releaseIdField = _releaseGuestVlanRangeClass.getDeclaredField("id");
releaseIdField.setAccessible(true);
releaseIdField.set(releaseDedicatedGuestVlanRangesCmd, 1L);
}
use of com.cloud.user.AccountVO in project cloudstack by apache.
the class AssignLoadBalancerTest method setUp.
@Before
public void setUp() {
assignToLbRuleCmd = new AssignToLoadBalancerRuleCmd() {
};
// ComponentContext.initComponentsLifeCycle();
AccountVO account = new AccountVO(accountName, domainId, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid");
DomainVO domain = new DomainVO("rootDomain", 5L, 5L, "networkDomain");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account);
}
Aggregations