You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ko...@apache.org on 2014/04/28 20:59:13 UTC
git commit: updated refs/heads/master to ecec8d3
Repository: cloudstack
Updated Branches:
refs/heads/master 44ff7fea5 -> ecec8d368
autounboxing fix in ConfigurationManager
Signed-off-by: Laszlo Hornyak <la...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ecec8d36
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ecec8d36
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ecec8d36
Branch: refs/heads/master
Commit: ecec8d368d8572c8f788443eb257ad574eb0fcbf
Parents: 44ff7fe
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Wed Apr 23 22:48:48 2014 +0200
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Mon Apr 28 20:56:45 2014 +0200
----------------------------------------------------------------------
.../configuration/ConfigurationManagerImpl.java | 6 ++---
.../configuration/ConfigurationManagerTest.java | 25 +++++++++++++++++---
2 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ecec8d36/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 9844bb7..7211638 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -4665,7 +4665,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Override
public Account getVlanAccount(long vlanId) {
Vlan vlan = _vlanDao.findById(vlanId);
- Long accountId = null;
// if vlan is Virtual Account specific, get vlan information from the
// accountVlanMap; otherwise get account information
@@ -4681,11 +4680,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if (networkId != null) {
Network network = _networkModel.getNetwork(networkId);
if (network != null) {
- accountId = network.getAccountId();
+ return _accountMgr.getAccount(network.getAccountId());
}
}
-
- return _accountMgr.getAccount(accountId);
+ return null;
}
@Override
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ecec8d36/server/test/com/cloud/configuration/ConfigurationManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/configuration/ConfigurationManagerTest.java b/server/test/com/cloud/configuration/ConfigurationManagerTest.java
index f1bb30a..ac30aa2 100755
--- a/server/test/com/cloud/configuration/ConfigurationManagerTest.java
+++ b/server/test/com/cloud/configuration/ConfigurationManagerTest.java
@@ -32,15 +32,14 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
-import junit.framework.Assert;
-
import org.apache.log4j.Logger;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-
import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd;
import org.apache.cloudstack.api.command.admin.vlan.ReleasePublicIpRangeCmd;
import org.apache.cloudstack.context.CallContext;
@@ -57,6 +56,8 @@ import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.IpAddressManager;
+import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
import com.cloud.network.Network.Capability;
import com.cloud.network.dao.FirewallRulesDao;
import com.cloud.network.dao.IPAddressDao;
@@ -105,9 +106,17 @@ public class ConfigurationManagerTest {
FirewallRulesDao _firewallDao;
@Mock
IpAddressManager _ipAddrMgr;
+ @Mock
+ NetworkModel _networkModel;
VlanVO vlan = new VlanVO(Vlan.VlanType.VirtualNetwork, "vlantag", "vlangateway", "vlannetmask", 1L, "iprange", 1L, 1L, null, null, null);
+ @Mock
+ Network network;
+
+ @Mock
+ Account account;
+
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -122,6 +131,7 @@ public class ConfigurationManagerTest {
configurationMgr._zoneDao = _zoneDao;
configurationMgr._firewallDao = _firewallDao;
configurationMgr._ipAddrMgr = _ipAddrMgr;
+ configurationMgr._networkModel = _networkModel;
Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
when(configurationMgr._accountMgr.getAccount(anyLong())).thenReturn(account);
@@ -513,4 +523,13 @@ public class ConfigurationManagerTest {
return 1;
}
}
+
+ @Test
+ public void getVlanAccount() {
+ Mockito.when(_vlanDao.findById(42l)).thenReturn(vlan);
+ Mockito.when(_networkModel.getNetwork(1l)).thenReturn(network);
+ Mockito.when(network.getAccountId()).thenReturn(1l);
+ Mockito.when(_accountMgr.getAccount(1l)).thenReturn(account);
+ Assert.assertNotNull(configurationMgr.getVlanAccount(42l));
+ }
}