txn.close("runDedicatePublicIpRangeInvalidRange");
}
}
void runDedicatePublicIpRangeDedicatedRange() throws Exception {
TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangeDedicatedRange");
when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
// public ip range is already dedicated
List<AccountVlanMapVO> accountVlanMaps = new ArrayList<AccountVlanMapVO>();
AccountVlanMapVO accountVlanMap = new AccountVlanMapVO(1, 1);
accountVlanMaps.add(accountVlanMap);
when(configurationMgr._accountVlanMapDao.listAccountVlanMapsByVlan(anyLong())).thenReturn(accountVlanMaps);
DataCenterVO dc =
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Advanced, null, null, true,
true, null, null);
when(configurationMgr._zoneDao.findById(anyLong())).thenReturn(dc);
List<IPAddressVO> ipAddressList = new ArrayList<IPAddressVO>();
IPAddressVO ipAddress = new IPAddressVO(new Ip("75.75.75.75"), 1, 0xaabbccddeeffL, 10, false);
ipAddressList.add(ipAddress);
when(configurationMgr._publicIpAddressDao.listByVlanId(anyLong())).thenReturn(ipAddressList);
try {
configurationMgr.dedicatePublicIpRange(dedicatePublicIpRangesCmd);
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("Public IP range has already been dedicated"));
} finally {
txn.close("runDedicatePublicIpRangePublicIpRangeDedicated");
}
}