|
17 | 17 | package com.cloud.api;
|
18 | 18 |
|
19 | 19 | import com.cloud.domain.DomainVO;
|
| 20 | +import com.cloud.network.Networks; |
| 21 | +import com.cloud.network.PhysicalNetworkTrafficType; |
20 | 22 | import com.cloud.network.as.AutoScaleVmGroup;
|
21 | 23 | import com.cloud.network.as.AutoScaleVmGroupVO;
|
22 | 24 | import com.cloud.network.as.AutoScaleVmProfileVO;
|
|
25 | 27 | import com.cloud.network.dao.LoadBalancerVO;
|
26 | 28 | import com.cloud.network.dao.NetworkServiceMapDao;
|
27 | 29 | import com.cloud.network.dao.NetworkVO;
|
| 30 | +import com.cloud.network.dao.PhysicalNetworkVO; |
| 31 | +import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; |
| 32 | + |
28 | 33 | import com.cloud.storage.VMTemplateVO;
|
29 | 34 | import com.cloud.usage.UsageVO;
|
30 | 35 | import com.cloud.user.Account;
|
|
43 | 48 | import org.apache.cloudstack.api.response.DirectDownloadCertificateResponse;
|
44 | 49 | import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
|
45 | 50 | import org.apache.cloudstack.api.response.UsageRecordResponse;
|
| 51 | +import org.apache.cloudstack.api.response.TrafficTypeResponse; |
| 52 | + |
46 | 53 | import org.apache.cloudstack.context.CallContext;
|
47 | 54 | import org.apache.cloudstack.usage.UsageService;
|
48 | 55 | import org.junit.After;
|
|
66 | 73 | import static org.junit.Assert.assertEquals;
|
67 | 74 | import static org.junit.Assert.assertNull;
|
68 | 75 | import static org.junit.Assert.assertTrue;
|
| 76 | +import static org.junit.Assert.assertFalse; |
| 77 | + |
69 | 78 | import static org.mockito.ArgumentMatchers.any;
|
70 | 79 | import static org.mockito.ArgumentMatchers.anyLong;
|
71 | 80 | import static org.mockito.Mockito.when;
|
@@ -367,4 +376,36 @@ public void testAutoScaleVmProfileResponseWithoutUserData() {
|
367 | 376 | assertNull(response.getUserDataDetails());
|
368 | 377 | }
|
369 | 378 | }
|
| 379 | + |
| 380 | + @Test |
| 381 | + public void testCreateTrafficTypeResponse() { |
| 382 | + PhysicalNetworkVO pnet = new PhysicalNetworkVO(); |
| 383 | + pnet.addIsolationMethod("VXLAN"); |
| 384 | + pnet.addIsolationMethod("STT"); |
| 385 | + |
| 386 | + try (MockedStatic<ApiDBUtils> ignored = Mockito.mockStatic(ApiDBUtils.class)) { |
| 387 | + when(ApiDBUtils.findPhysicalNetworkById(anyLong())).thenReturn(pnet); |
| 388 | + String xenLabel = "xen"; |
| 389 | + String kvmLabel = "kvm"; |
| 390 | + String vmwareLabel = "vmware"; |
| 391 | + String simulatorLabel = "simulator"; |
| 392 | + String hypervLabel = "hyperv"; |
| 393 | + String ovmLabel = "ovm"; |
| 394 | + String vlan = "vlan"; |
| 395 | + String trafficType = "Public"; |
| 396 | + PhysicalNetworkTrafficType pnetTrafficType = new PhysicalNetworkTrafficTypeVO(pnet.getId(), Networks.TrafficType.getTrafficType(trafficType), xenLabel, kvmLabel, vmwareLabel, simulatorLabel, vlan, hypervLabel, ovmLabel); |
| 397 | + |
| 398 | + TrafficTypeResponse response = apiResponseHelper.createTrafficTypeResponse(pnetTrafficType); |
| 399 | + assertFalse(UUID.fromString(response.getId()).toString().isEmpty()); |
| 400 | + assertEquals(response.getphysicalNetworkId(), pnet.getUuid()); |
| 401 | + assertEquals(response.getTrafficType(), trafficType); |
| 402 | + assertEquals(response.getXenLabel(), xenLabel); |
| 403 | + assertEquals(response.getKvmLabel(), kvmLabel); |
| 404 | + assertEquals(response.getVmwareLabel(), vmwareLabel); |
| 405 | + assertEquals(response.getHypervLabel(), hypervLabel); |
| 406 | + assertEquals(response.getOvm3Label(), ovmLabel); |
| 407 | + assertEquals(response.getVlan(), vlan); |
| 408 | + assertEquals(response.getIsolationMethods(), "VXLAN,STT"); |
| 409 | + } |
| 410 | + } |
370 | 411 | }
|
0 commit comments