cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/master to 8a1eed2
Date Fri, 23 May 2014 05:33:53 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master faa379b6c -> 8a1eed24b


Fix AccountManager unit testcase.

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8a1eed24
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8a1eed24
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8a1eed24

Branch: refs/heads/master
Commit: 8a1eed24b9971934545b49b65e84b0b1e15c9266
Parents: faa379b
Author: Min Chen <min.chen@citrix.com>
Authored: Thu May 22 22:33:25 2014 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Thu May 22 22:33:25 2014 -0700

----------------------------------------------------------------------
 .../com/cloud/user/AccountManagerImplTest.java  | 33 +++++++++++++++-----
 1 file changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8a1eed24/server/test/com/cloud/user/AccountManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/user/AccountManagerImplTest.java b/server/test/com/cloud/user/AccountManagerImplTest.java
index 44bb954..176cf1d 100644
--- a/server/test/com/cloud/user/AccountManagerImplTest.java
+++ b/server/test/com/cloud/user/AccountManagerImplTest.java
@@ -21,6 +21,15 @@ import java.util.Arrays;
 
 import javax.inject.Inject;
 
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@@ -30,14 +39,6 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.framework.messagebus.MessageBus;
 import org.apache.cloudstack.region.gslb.GlobalLoadBalancerRuleDao;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
 
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.dao.ResourceCountDao;
@@ -45,6 +46,8 @@ import com.cloud.configuration.dao.ResourceLimitDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.DataCenterVnetDao;
 import com.cloud.dc.dao.DedicatedResourceDao;
+import com.cloud.domain.Domain;
+import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.ResourceUnavailableException;
@@ -246,6 +249,7 @@ public class AccountManagerImplTest {
     public void deleteUserAccount() {
         AccountVO account = new AccountVO();
         account.setId(42l);
+        DomainVO domain = new DomainVO();
         Mockito.when(_accountDao.findById(42l)).thenReturn(account);
         Mockito.when(
                 securityChecker.checkAccess(Mockito.any(Account.class),
@@ -255,6 +259,12 @@ public class AccountManagerImplTest {
         Mockito.when(_accountDao.remove(42l)).thenReturn(true);
         Mockito.when(_configMgr.releaseAccountSpecificVirtualRanges(42l))
                 .thenReturn(true);
+        Mockito.when(_domainMgr.getDomain(Mockito.anyLong())).thenReturn(domain);
+        Mockito.when(
+                securityChecker.checkAccess(Mockito.any(Account.class),
+                        Mockito.any(Domain.class)))
+                .thenReturn(true);
+
         Assert.assertTrue(accountManager.deleteUserAccount(42));
         // assert that this was a clean delete
         Mockito.verify(_accountDao, Mockito.never()).markForCleanup(
@@ -265,6 +275,7 @@ public class AccountManagerImplTest {
     public void deleteUserAccountCleanup() {
         AccountVO account = new AccountVO();
         account.setId(42l);
+        DomainVO domain = new DomainVO();
         Mockito.when(_accountDao.findById(42l)).thenReturn(account);
         Mockito.when(
                 securityChecker.checkAccess(Mockito.any(Account.class),
@@ -279,6 +290,12 @@ public class AccountManagerImplTest {
         Mockito.when(
                 _vmMgr.expunge(Mockito.any(UserVmVO.class), Mockito.anyLong(),
                         Mockito.any(Account.class))).thenReturn(false);
+        Mockito.when(_domainMgr.getDomain(Mockito.anyLong())).thenReturn(domain);
+        Mockito.when(
+                securityChecker.checkAccess(Mockito.any(Account.class),
+                        Mockito.any(Domain.class)))
+                .thenReturn(true);
+
         Assert.assertTrue(accountManager.deleteUserAccount(42));
         // assert that this was NOT a clean delete
         Mockito.verify(_accountDao, Mockito.atLeastOnce()).markForCleanup(


Mime
View raw message