mirror of https://github.com/apache/cloudstack.git
autounboxing fix in ConfigurationManager
Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>
This commit is contained in:
parent
44ff7fea5f
commit
ecec8d368d
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue