-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathConfigurationManagerImplTest.java
More file actions
411 lines (365 loc) · 21.7 KB
/
Copy pathConfigurationManagerImplTest.java
File metadata and controls
411 lines (365 loc) · 21.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.configuration;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.DataCenterIpAddressDao;
import com.cloud.dc.dao.DedicatedResourceDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.host.dao.HostDao;
import com.cloud.network.Network;
import com.cloud.network.NetworkModel;
import com.cloud.network.NetworkService;
import com.cloud.network.Networks;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.NsxProviderDao;
import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.element.NsxProviderVO;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.storage.StorageManager;
import com.cloud.storage.dao.VMTemplateZoneDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.dao.VMInstanceDao;
import org.apache.cloudstack.annotation.dao.AnnotationDao;
import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.framework.config.ConfigDepot;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.test.util.ReflectionTestUtils;
import java.util.Collections;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.nullable;
import static org.mockito.Mockito.anyMap;
import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
@RunWith(MockitoJUnitRunner.class)
public class ConfigurationManagerImplTest {
@Mock
ConfigDepot configDepot;
@Mock
NsxProviderDao nsxProviderDao;
@Mock
DataCenterDao zoneDao;
@Mock
HostDao hostDao;
@Mock
HostPodDao podDao;
@Mock
DataCenterIpAddressDao ipAddressDao;
@Mock
IPAddressDao publicIpAddressDao;
@Mock
VMInstanceDao vmInstanceDao;
@Mock
VolumeDao volumeDao;
@Mock
PhysicalNetworkDao physicalNetworkDao;
@Mock
ImageStoreDao imageStoreDao;
@Mock
VlanDao vlanDao;
@Mock
VMTemplateZoneDao vmTemplateZoneDao;
@Mock
CapacityDao capacityDao;
@Mock
DedicatedResourceDao dedicatedResourceDao;
@Mock
AnnotationDao annotationDao;
@Mock
ConfigurationDao configDao;
@Mock
NetworkOfferingDao networkOfferingDao;
@Mock
NetworkService networkService;
@Mock
NetworkModel networkModel;
ConfigurationManagerImpl configurationManagerImplSpy = Mockito.spy(new ConfigurationManagerImpl());
DeleteZoneCmd deleteZoneCmd;
CreateNetworkOfferingCmd createNetworkOfferingCmd;
@Before
public void setUp() throws Exception {
configurationManagerImplSpy._configDepot = configDepot;
configurationManagerImplSpy.nsxProviderDao = nsxProviderDao;
configurationManagerImplSpy._zoneDao = zoneDao;
configurationManagerImplSpy._hostDao = hostDao;
configurationManagerImplSpy._podDao = podDao;
configurationManagerImplSpy._privateIpAddressDao = ipAddressDao;
configurationManagerImplSpy._publicIpAddressDao = publicIpAddressDao;
configurationManagerImplSpy._vmInstanceDao = vmInstanceDao;
configurationManagerImplSpy._volumeDao = volumeDao;
configurationManagerImplSpy._physicalNetworkDao = physicalNetworkDao;
configurationManagerImplSpy._imageStoreDao = imageStoreDao;
configurationManagerImplSpy._vlanDao = vlanDao;
configurationManagerImplSpy._capacityDao = capacityDao;
configurationManagerImplSpy._dedicatedDao = dedicatedResourceDao;
configurationManagerImplSpy._configDao = configDao;
configurationManagerImplSpy._networkOfferingDao = networkOfferingDao;
configurationManagerImplSpy._networkSvc = networkService;
configurationManagerImplSpy._networkModel = networkModel;
ReflectionTestUtils.setField(configurationManagerImplSpy, "templateZoneDao", vmTemplateZoneDao);
ReflectionTestUtils.setField(configurationManagerImplSpy, "annotationDao", annotationDao);
deleteZoneCmd = Mockito.mock(DeleteZoneCmd.class);
createNetworkOfferingCmd = Mockito.mock(CreateNetworkOfferingCmd.class);
}
@Test
public void validateIfIntValueIsInRangeTestValidValueReturnNull() {
String testVariable = configurationManagerImplSpy.validateIfIntValueIsInRange("String name", "3", "1-5");
Assert.assertNull(testVariable);
}
@Test
public void validateIfIntValueIsInRangeTestInvalidValueReturnString() {
String testVariable = configurationManagerImplSpy.validateIfIntValueIsInRange("String name", "9", "1-5");
Assert.assertNotNull(testVariable);
}
@Test
public void validateIfStringValueIsInRangeTestValidValuesReturnNull() {
String testVariable;
List<String> methods = List.of("privateip", "hypervisorList", "instanceName", "domainName", "default");
Mockito.doReturn(null).when(configurationManagerImplSpy).validateRangePrivateIp(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(null).when(configurationManagerImplSpy).validateRangeHypervisorList(Mockito.anyString());
Mockito.doReturn(null).when(configurationManagerImplSpy).validateRangeInstanceName(Mockito.anyString());
Mockito.doReturn(null).when(configurationManagerImplSpy).validateRangeDomainName(Mockito.anyString());
Mockito.doReturn(null).when(configurationManagerImplSpy).validateRangeOther(Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
for (String method : methods) {
testVariable = configurationManagerImplSpy.validateIfStringValueIsInRange("name", "value", method);
Assert.assertNull(testVariable);
}
}
@Test
public void validateIfStringValueIsInRangeTestInvalidValuesReturnString() {
String testVariable;
List<String> methods = List.of("privateip", "hypervisorList", "instanceName", "domainName", "default");
Mockito.doReturn("returnMsg").when(configurationManagerImplSpy).validateRangePrivateIp(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn("returnMsg").when(configurationManagerImplSpy).validateRangeHypervisorList(Mockito.anyString());
Mockito.doReturn("returnMsg").when(configurationManagerImplSpy).validateRangeInstanceName(Mockito.anyString());
Mockito.doReturn("returnMsg").when(configurationManagerImplSpy).validateRangeDomainName(Mockito.anyString());
Mockito.doReturn("returnMsg").when(configurationManagerImplSpy).validateRangeOther(Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
for (String method : methods) {
testVariable = configurationManagerImplSpy.validateIfStringValueIsInRange("name", "value", method);
Assert.assertEquals("The provided value is not returnMsg.", testVariable);
}
}
@Test
public void validateIfStringValueIsInRangeTestMultipleRangesValidValueReturnNull() {
Mockito.doReturn("returnMsg1").when(configurationManagerImplSpy).validateRangePrivateIp(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(null).when(configurationManagerImplSpy).validateRangeInstanceName(Mockito.anyString());
String testVariable = configurationManagerImplSpy.validateIfStringValueIsInRange("name", "value", "privateip", "instanceName", "default");
Assert.assertNull(testVariable);
}
@Test
public void validateIfStringValueIsInRangeTestMultipleRangesInvalidValueReturnMessages() {
Mockito.doReturn("returnMsg1").when(configurationManagerImplSpy).validateRangePrivateIp(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn("returnMsg2").when(configurationManagerImplSpy).validateRangeInstanceName(Mockito.anyString());
Mockito.doReturn("returnMsg3").when(configurationManagerImplSpy).validateRangeOther(Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
String testVariable = configurationManagerImplSpy.validateIfStringValueIsInRange("name", "value", "privateip", "instanceName", "default");
Assert.assertEquals("The provided value is neither returnMsg1 NOR returnMsg2 NOR returnMsg3.", testVariable);
}
@Test
public void validateRangePrivateIpTestValidValueReturnNull() {
try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) {
Mockito.when(NetUtils.isSiteLocalAddress(Mockito.anyString())).thenReturn(true);
String testVariable = configurationManagerImplSpy.validateRangePrivateIp("name", "value");
Assert.assertNull(testVariable);
}
}
@Test
public void validateRangePrivateIpTestInvalidValueReturnString() {
try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) {
Mockito.when(NetUtils.isSiteLocalAddress(Mockito.anyString())).thenReturn(false);
String testVariable = configurationManagerImplSpy.validateRangePrivateIp("name", "value");
Assert.assertEquals("a valid site local IP address", testVariable);
}
}
@Test
public void validateRangeHypervisorListTestValidValueReturnNull() {
String testVariable = configurationManagerImplSpy.validateRangeHypervisorList("Ovm3,VirtualBox,KVM,VMware");
Assert.assertNull(testVariable);
}
@Test
public void validateRangeHypervisorListTestInvalidValueReturnString() {
String testVariable = configurationManagerImplSpy.validateRangeHypervisorList("Ovm3,VirtualBox,KVM,VMware,Any,InvalidHypervisorName");
Assert.assertEquals("a valid hypervisor type", testVariable);
}
@Test
public void validateRangeInstanceNameTestValidValueReturnNull() {
try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) {
Mockito.when(NetUtils.verifyInstanceName(Mockito.anyString())).thenReturn(true);
String testVariable = configurationManagerImplSpy.validateRangeInstanceName("ThisStringShouldBeValid");
Assert.assertNull(testVariable);
}
}
@Test
public void validateRangeInstanceNameTestInvalidValueReturnString() {
try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) {
Mockito.when(NetUtils.verifyInstanceName(Mockito.anyString())).thenReturn(false);
String testVariable = configurationManagerImplSpy.validateRangeInstanceName("This string should not be valid.");
Assert.assertEquals("a valid instance name (instance names cannot contain hyphens, spaces or plus signs)", testVariable);
}
}
@Test
public void validateRangeDomainNameTestValueDoesNotStartWithStarAndIsAValidValueReturnNull() {
String testVariable = configurationManagerImplSpy.validateRangeDomainName("ThisStringShould.Work");
Assert.assertNull(testVariable);
}
@Test
public void validateRangeDomainNameTestValueDoesNotStartWithStarAndIsAValidValueButIsOver238charactersLongReturnString() {
String testVariable = configurationManagerImplSpy.validateRangeDomainName("ThisStringDoesNotStartWithStarAndIsOverTwoHundredAndForty.CharactersLongWithAtLeast" +
"OnePeriodEverySixtyFourLetters.ThisShouldCauseAnErrorBecauseItIsTooLong.TheRestOfThisAreRandomlyGeneratedCharacters.gNXhNOBNTNAoMCQqJMzcvFSBwHUhmWHftjfTNUaHR");
Assert.assertEquals("a valid domain name", testVariable);
}
@Test
public void validateRangeDomainNameTestValueDoesNotStartWithStarAndIsNotAValidValueReturnString() {
String testVariable = configurationManagerImplSpy.validateRangeDomainName("ThisStringDoesNotMatchThePatternFor.DomainNamesSinceItHas1NumberInTheLastPartOfTheString");
Assert.assertEquals("a valid domain name", testVariable);
}
@Test
public void validateRangeDomainNameTestValueStartsWithStarAndIsAValidValueReturnNull() {
String testVariable = configurationManagerImplSpy.validateRangeDomainName("*.ThisStringStartsWithAStarAndAPeriod.ThisShouldWorkEvenThoughItIsOverTwoHundredAnd" +
"ThirtyEight.CharactersLong.BecauseTheFirstTwoCharactersAreIgnored.TheRestOfThisStringWasRandomlyGenerated.MgTUerXPlLyMaUpKTjAhxasFYRCfNCXmtWDwqSDOcTjASWlAXS");
Assert.assertNull(testVariable);
}
@Test
public void validateRangeDomainNameTestValueStartsWithStarAndIsAValidValueButIsOver238charactersLongReturnString() {
String testVariable = configurationManagerImplSpy.validateRangeDomainName("*.ThisStringStartsWithStarAndIsOverTwoHundredAndForty.CharactersLongWithAtLeastOnePeriod" +
"EverySixtyFourLetters.ThisShouldCauseAnErrorBecauseItIsTooLong.TheRestOfThisAreRandomlyGeneratedCharacters.gNXNOBNTNAoMChQqJMzcvFSBwHUhmWHftjfTNUaHRKVyXm");
Assert.assertEquals("a valid domain name", testVariable);
}
@Test
public void validateRangeDomainNameTestValueStartsWithStarAndIsNotAValidValueReturnString() {
String testVariable = configurationManagerImplSpy.validateRangeDomainName("*.ThisStringDoesNotMatchThePatternFor.DomainNamesSinceItHas1NumberInTheLastPartOfTheString");
Assert.assertEquals("a valid domain name", testVariable);
}
@Test
public void validateRangeOtherTestValidValueReturnNull() {
String testVariable = configurationManagerImplSpy.validateRangeOther("NameTest1", "SoShouldThis", "ThisShouldWork,ThisShouldAlsoWork,SoShouldThis");
Assert.assertNull(testVariable);
}
@Test
public void validateRangeOtherTestInvalidValueReturnString() {
String testVariable = configurationManagerImplSpy.validateRangeOther("NameTest1", "ThisShouldNotWork", "ThisShouldWork,ThisShouldAlsoWork,SoShouldThis");
Assert.assertNotNull(testVariable);
}
@Test
public void testValidateIpAddressRelatedConfigValuesUnrelated() {
configurationManagerImplSpy.validateIpAddressRelatedConfigValues(StorageManager.PreferredStoragePool.key(), "something");
configurationManagerImplSpy.validateIpAddressRelatedConfigValues("config.ip", "");
Mockito.when(configurationManagerImplSpy._configDepot.get("config.ip")).thenReturn(null);
configurationManagerImplSpy.validateIpAddressRelatedConfigValues("config.ip", "something");
configurationManagerImplSpy.validateIpAddressRelatedConfigValues(StorageManager.MountDisabledStoragePool.key(), "false");
}
@Test(expected = InvalidParameterValueException.class)
public void testValidateIpAddressRelatedConfigValuesInvalidIp() {
ConfigKey<String> key = StorageManager.PreferredStoragePool; // Any ConfigKey of String type
Mockito.doReturn(key).when(configurationManagerImplSpy._configDepot).get("config.ip");
configurationManagerImplSpy.validateIpAddressRelatedConfigValues("config.ip", "abcdefg");
}
@Test
public void testValidateIpAddressRelatedConfigValuesValidIp() {
ConfigKey<String> key = StorageManager.PreferredStoragePool; // Any ConfigKey of String type
Mockito.doReturn(key).when(configurationManagerImplSpy._configDepot).get("config.ip");
configurationManagerImplSpy.validateIpAddressRelatedConfigValues("config.ip", "192.168.1.1");
}
@Test(expected = InvalidParameterValueException.class)
public void testValidateIpAddressRelatedConfigValuesInvalidIpRange() {
ConfigKey<String> key = StorageManager.PreferredStoragePool; // Any ConfigKey of String type. RemoteAccessVpnManagerImpl.RemoteAccessVpnClientIpRange not accessible here
Mockito.doReturn(key).when(configurationManagerImplSpy._configDepot).get("config.iprange");
configurationManagerImplSpy.validateIpAddressRelatedConfigValues("config.iprange", "xyz-192.168.1.20");
}
@Test(expected = InvalidParameterValueException.class)
public void testValidateIpAddressRelatedConfigValuesInvalidIpRange1() {
ConfigKey<String> key = StorageManager.PreferredStoragePool; // Any ConfigKey of String type. RemoteAccessVpnManagerImpl.RemoteAccessVpnClientIpRange not accessible here
Mockito.doReturn(key).when(configurationManagerImplSpy._configDepot).get("config.iprange");
configurationManagerImplSpy.validateIpAddressRelatedConfigValues("config.iprange", "192.168.1.20");
}
@Test
public void testValidateIpAddressRelatedConfigValuesValidIpRange() {
ConfigKey<String> key = StorageManager.PreferredStoragePool; // Any ConfigKey of String type. RemoteAccessVpnManagerImpl.RemoteAccessVpnClientIpRange not accessible here
Mockito.doReturn(key).when(configurationManagerImplSpy._configDepot).get("config.iprange");
configurationManagerImplSpy.validateIpAddressRelatedConfigValues("config.iprange", "192.168.1.1-192.168.1.100");
}
@Test
public void testDeleteZoneInvokesDeleteNsxProviderWhenNSXIsEnabled() {
NsxProviderVO nsxProviderVO = Mockito.mock(NsxProviderVO.class);
DataCenterVO dataCenterVO = Mockito.mock(DataCenterVO.class);
when(nsxProviderDao.findByZoneId(anyLong())).thenReturn(nsxProviderVO);
when(zoneDao.findById(anyLong())).thenReturn(dataCenterVO);
lenient().when(hostDao.findByDataCenterId(anyLong())).thenReturn(Collections.emptyList());
when(podDao.listByDataCenterId(anyLong())).thenReturn(Collections.emptyList());
when(ipAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
when(publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
when(vmInstanceDao.listByZoneId(anyLong())).thenReturn(Collections.emptyList());
when(volumeDao.findByDc(anyLong())).thenReturn(Collections.emptyList());
when(physicalNetworkDao.listByZone(anyLong())).thenReturn(Collections.emptyList());
when(imageStoreDao.findByZone(any(ZoneScope.class), nullable(Boolean.class))).thenReturn(Collections.emptyList());
when(vlanDao.listByZone(anyLong())).thenReturn(List.of(Mockito.mock(VlanVO.class)));
when(nsxProviderVO.getId()).thenReturn(1L);
when(zoneDao.remove(anyLong())).thenReturn(true);
when(capacityDao.removeBy(nullable(Short.class), anyLong(), nullable(Long.class), nullable(Long.class), nullable(Long.class))).thenReturn(true);
when(dedicatedResourceDao.findByZoneId(anyLong())).thenReturn(null);
lenient().when(annotationDao.removeByEntityType(anyString(), anyString())).thenReturn(true);
configurationManagerImplSpy.deleteZone(deleteZoneCmd);
verify(nsxProviderDao, times(1)).remove(anyLong());
}
@Test
public void testCreateNetworkOfferingForNsx() {
NetworkOfferingVO offeringVO = Mockito.mock(NetworkOfferingVO.class);
when(createNetworkOfferingCmd.isForNsx()).thenReturn(true);
when(createNetworkOfferingCmd.getNsxMode()).thenReturn(NetworkOffering.NsxMode.NATTED.name());
when(createNetworkOfferingCmd.getTraffictype()).thenReturn(Networks.TrafficType.Guest.name());
when(createNetworkOfferingCmd.getGuestIpType()).thenReturn(Network.GuestType.Isolated.name());
when(createNetworkOfferingCmd.getAvailability()).thenReturn(NetworkOffering.Availability.Optional.name());
lenient().when(configurationManagerImplSpy.createNetworkOffering(anyString(), anyString(), any(Networks.TrafficType.class), anyString(),
anyBoolean(), any(NetworkOffering.Availability.class), anyInt(), anyMap(), anyBoolean(), any(Network.GuestType.class),
anyBoolean(), anyLong(), anyBoolean(), anyMap(), anyBoolean(), anyBoolean(), anyMap(), anyBoolean(), anyInt(),
anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyString(), anyList(), anyList(), anyBoolean(), any(NetUtils.InternetProtocol.class)))
.thenReturn(offeringVO);
when(configDao.getValue(anyString())).thenReturn("1000");
lenient().when(networkOfferingDao.persist(any(NetworkOfferingVO.class), anyMap())).thenReturn(offeringVO);
doNothing().when(networkService).validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouter(anyLong());
doNothing().when(networkModel).canProviderSupportServices(anyMap());
NetworkOffering offering = configurationManagerImplSpy.createNetworkOffering(createNetworkOfferingCmd);
Assert.assertNotNull(offering);
}
}