Assert.assertEquals(networks.size(), 1);
}
@Test(groups = { "res-mgmt" })
public void increaseIPs() {
final NetworkEntity network = new NetworkEntity();
network.setName("staticNetwork");
network.setPortGroup("portGroup1");
network.setAllocType(AllocType.IP_POOL);
network.setNetmask("255.255.255.0");
network.setGateway("192.168.1.1");
network.setDns1("10.1.1.2");
network.setDns2("10.1.1.3");
List<IpBlock> ipBlocks = new ArrayList<IpBlock>();
ipBlocks.add(new IpBlock("192.168.1.11", "192.168.1.12"));
final List<IpBlockEntity> blocks =
new ArrayList<IpBlockEntity>(ipBlocks.size());
for (IpBlock ib : ipBlocks) {
IpBlockEntity blk =
new IpBlockEntity(network, IpBlockEntity.FREE_BLOCK_OWNER_ID,
BlockType.FREE, IpAddressUtil.getAddressAsLong(ib
.getBeginIp()), IpAddressUtil.getAddressAsLong(ib
.getEndIp()));
blocks.add(blk);
}
network.setIpBlocks(blocks);
networkSvc.setNetworkDao(networkDao);
new Expectations() {
{
networkSvc.getNetworkEntityByName(anyString);
result = network;
}
{
networkDao.addIpBlocks(network, network.getIpBlocks());
}
};
networkSvc.increaseIPs("staticNetwork", ipBlocks);
}