use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.
the class VirtualRouterElementTest method testGetRouters3.
@Test
public void testGetRouters3() {
Network network = new NetworkVO(3l, null, null, null, 1l, 1l, 1l, 1l, "d", "d", "d", null, 1l, 1l, null, true, null, true);
mockDAOs((NetworkVO) network, testOffering);
//alwyas return backup routers first when both master and backup need update.
List<DomainRouterVO> routers = virtualRouterElement.getRouters(network);
assertTrue(routers.size() == 4);
}
use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.
the class VirtualRouterElementTest method getResourceCountTest.
@Test
public void getResourceCountTest() {
Network network = new NetworkVO(3l, null, null, null, 1l, 1l, 1l, 1l, "d", "d", "d", null, 1l, 1l, null, true, null, true);
mockDAOs((NetworkVO) network, testOffering);
int routers = virtualRouterElement.getResourceCount(network);
assertTrue(routers == 4);
}
use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.
the class CreatePrivateNetworkTest method setup.
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
networkService._accountMgr = _accountMgr;
networkService._networkOfferingDao = _networkOfferingDao;
networkService._physicalNetworkDao = _physicalNetworkDao;
networkService._dcDao = _dcDao;
networkService._networksDao = _networkDao;
networkService._networkMgr = _networkMgr;
networkService._privateIpDao = _privateIpDao;
Account account = new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(networkService._accountMgr.getAccount(anyLong())).thenReturn(account);
NetworkOfferingVO ntwkOff = new NetworkOfferingVO("offer", "fakeOffer", TrafficType.Guest, true, true, null, null, false, null, null, GuestType.Isolated, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
when(networkService._networkOfferingDao.findById(anyLong())).thenReturn(ntwkOff);
List<NetworkOfferingVO> netofferlist = new ArrayList<NetworkOfferingVO>();
netofferlist.add(ntwkOff);
when(networkService._networkOfferingDao.listSystemNetworkOfferings()).thenReturn(netofferlist);
PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork");
when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork);
DataCenterVO dc = new DataCenterVO(1L, "hut", "op de hei", null, null, null, null, "10.1.1.0/24", "unreal.net", 1L, NetworkType.Advanced, null, null);
when(networkService._dcDao.lockRow(anyLong(), anyBoolean())).thenReturn(dc);
when(networkService._networksDao.getPrivateNetwork(anyString(), anyString(), eq(1L), eq(1L), anyLong())).thenReturn(null);
Network net = new NetworkVO(1L, TrafficType.Guest, Mode.None, BroadcastDomainType.Vlan, 1L, 1L, 1L, 1L, "bla", "fake", "eet.net", GuestType.Isolated, 1L, 1L, ACLType.Account, false, 1L, false);
when(networkService._networkMgr.createGuestNetwork(eq(ntwkOff.getId()), eq("bla"), eq("fake"), eq("10.1.1.1"), eq("10.1.1.0/24"), anyString(), anyString(), eq(account), anyLong(), eq(physicalNetwork), eq(physicalNetwork.getDataCenterId()), eq(ACLType.Account), anyBoolean(), eq(1L), anyString(), anyString(), anyBoolean(), anyString())).thenReturn(net);
when(networkService._privateIpDao.findByIpAndSourceNetworkId(net.getId(), "10.1.1.2")).thenReturn(null);
when(networkService._privateIpDao.findByIpAndSourceNetworkIdAndVpcId(eq(1L), anyString(), eq(1L))).thenReturn(null);
}
use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.
the class ConsoleProxyManagerTest method getDefaultNetworkForBasicSG.
@Test
public void getDefaultNetworkForBasicSG() {
DataCenterVO dc = Mockito.mock(DataCenterVO.class);
when(dc.getNetworkType()).thenReturn(NetworkType.Basic);
when(dc.isSecurityGroupEnabled()).thenReturn(true);
when(_dcDao.findById(Mockito.anyLong())).thenReturn(dc);
NetworkVO network = Mockito.mock(NetworkVO.class);
NetworkVO badNetwork = Mockito.mock(NetworkVO.class);
when(_networkDao.listByZoneAndTrafficType(anyLong(), eq(TrafficType.Guest))).thenReturn(Collections.singletonList(network));
when(_networkDao.listByZoneAndTrafficType(anyLong(), not(eq(TrafficType.Guest)))).thenReturn(Collections.singletonList(badNetwork));
NetworkVO returnedNetwork = cpvmManager.getDefaultNetworkForBasicZone(dc);
Assert.assertNotNull(returnedNetwork);
Assert.assertEquals(network, returnedNetwork);
Assert.assertNotEquals(badNetwork, returnedNetwork);
}
use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.
the class ConsoleProxyManagerTest method getDefaultNetworkForBasicSGWrongZoneType.
//also test invalid input
@Test(expected = CloudRuntimeException.class)
public void getDefaultNetworkForBasicSGWrongZoneType() {
DataCenterVO dc = Mockito.mock(DataCenterVO.class);
when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
when(dc.isSecurityGroupEnabled()).thenReturn(true);
when(_dcDao.findById(Mockito.anyLong())).thenReturn(dc);
NetworkVO network = Mockito.mock(NetworkVO.class);
NetworkVO badNetwork = Mockito.mock(NetworkVO.class);
when(_networkDao.listByZoneAndTrafficType(anyLong(), eq(TrafficType.Guest))).thenReturn(Collections.singletonList(network));
when(_networkDao.listByZoneAndTrafficType(anyLong(), not(eq(TrafficType.Guest)))).thenReturn(Collections.singletonList(badNetwork));
cpvmManager.getDefaultNetworkForBasicZone(dc);
}
Aggregations