1818 */
1919package org .apache .cloudstack .storage .lifecycle ;
2020
21+ import org .apache .cloudstack .storage .utils .Constants ;
2122import org .junit .jupiter .api .BeforeEach ;
2223import org .junit .jupiter .api .Test ;
2324import org .junit .jupiter .api .extension .ExtendWith ;
@@ -151,41 +152,20 @@ void setUp() {
151152 poolDetails .put ("password" , "password" );
152153 poolDetails .put ("svmName" , "svm1" );
153154 poolDetails .put ("protocol" , "NFS3" );
154- poolDetails .put ("managementLIF" , "192.168.1.100" );
155- poolDetails .put ("isDisaggregated" , "false" );
155+ poolDetails .put ("storageIP" , "192.168.1.100" );
156156 }
157157
158158 @ Test
159159 public void testInitialize_positive () {
160160
161- Map <String , Object > dsInfos = new HashMap <>();
162- dsInfos .put ("username" , "testUser" );
163- dsInfos .put ("password" , "testPassword" );
164- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1" );
165- dsInfos .put ("zoneId" ,1L );
166- dsInfos .put ("podId" ,1L );
167- dsInfos .put ("clusterId" , 1L );
168- dsInfos .put ("name" , "testStoragePool" );
169- dsInfos .put ("providerName" , "testProvider" );
170- dsInfos .put ("capacityBytes" ,200000L );
171- dsInfos .put ("managed" ,true );
172- dsInfos .put ("tags" , "testTag" );
173- dsInfos .put ("isTagARule" , false );
174- dsInfos .put ("details" , new HashMap <String , String >());
175-
176- try (MockedStatic <StorageProviderFactory > storageProviderFactory = Mockito .mockStatic (StorageProviderFactory .class )) {
177- storageProviderFactory .when (() -> StorageProviderFactory .getStrategy (any ())).thenReturn (storageStrategy );
178- ontapPrimaryDatastoreLifecycle .initialize (dsInfos );
179- }
180- }
181-
182- @ Test
183- public void testInitialize_positiveWithIsDisaggregated () {
161+ HashMap <String , String > detailsMap = new HashMap <String , String >();
162+ detailsMap .put (Constants .USERNAME , "testUser" );
163+ detailsMap .put (Constants .PASSWORD , "testPassword" );
164+ detailsMap .put (Constants .STORAGE_IP , "10.10.10.10" );
165+ detailsMap .put (Constants .SVM_NAME , "vs0" );
166+ detailsMap .put (Constants .PROTOCOL , "NFS3" );
184167
185168 Map <String , Object > dsInfos = new HashMap <>();
186- dsInfos .put ("username" , "testUser" );
187- dsInfos .put ("password" , "testPassword" );
188- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1;isDisaggregated=false" );
189169 dsInfos .put ("zoneId" ,1L );
190170 dsInfos .put ("podId" ,1L );
191171 dsInfos .put ("clusterId" , 1L );
@@ -195,7 +175,7 @@ public void testInitialize_positiveWithIsDisaggregated() {
195175 dsInfos .put ("managed" ,true );
196176 dsInfos .put ("tags" , "testTag" );
197177 dsInfos .put ("isTagARule" , false );
198- dsInfos .put ("details" , new HashMap < String , String >() );
178+ dsInfos .put ("details" , detailsMap );
199179
200180 try (MockedStatic <StorageProviderFactory > storageProviderFactory = Mockito .mockStatic (StorageProviderFactory .class )) {
201181 storageProviderFactory .when (() -> StorageProviderFactory .getStrategy (any ())).thenReturn (storageStrategy );
@@ -212,8 +192,14 @@ public void testInitialize_null_Arg() {
212192
213193 @ Test
214194 public void testInitialize_missingRequiredDetailKey () {
195+
196+ HashMap <String , String > detailsMap = new HashMap <String , String >();
197+ detailsMap .put (Constants .USERNAME , "testUser" );
198+ detailsMap .put (Constants .PASSWORD , "testPassword" );
199+ detailsMap .put (Constants .STORAGE_IP , "10.10.10.10" );
200+ detailsMap .put (Constants .SVM_NAME , "vs0" );
201+
215202 Map <String , Object > dsInfos = new HashMap <>();
216- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3" );
217203 dsInfos .put ("zoneId" ,1L );
218204 dsInfos .put ("podId" ,1L );
219205 dsInfos .put ("clusterId" , 1L );
@@ -223,7 +209,7 @@ public void testInitialize_missingRequiredDetailKey() {
223209 dsInfos .put ("managed" ,true );
224210 dsInfos .put ("tags" , "testTag" );
225211 dsInfos .put ("isTagARule" , false );
226- dsInfos .put ("details" , new HashMap < String , String >() );
212+ dsInfos .put ("details" , detailsMap );
227213
228214 try (MockedStatic <StorageProviderFactory > storageProviderFactory = Mockito .mockStatic (StorageProviderFactory .class )) {
229215 storageProviderFactory .when (() -> StorageProviderFactory .getStrategy (any ())).thenReturn (storageStrategy );
@@ -234,8 +220,15 @@ public void testInitialize_missingRequiredDetailKey() {
234220
235221 @ Test
236222 public void testInitialize_invalidCapacityBytes () {
223+
224+ HashMap <String , String > detailsMap = new HashMap <String , String >();
225+ detailsMap .put (Constants .USERNAME , "testUser" );
226+ detailsMap .put (Constants .PASSWORD , "testPassword" );
227+ detailsMap .put (Constants .STORAGE_IP , "10.10.10.10" );
228+ detailsMap .put (Constants .SVM_NAME , "vs0" );
229+ detailsMap .put (Constants .PROTOCOL , "NFS3" );
230+
237231 Map <String , Object > dsInfos = new HashMap <>();
238- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1" );
239232 dsInfos .put ("zoneId" ,1L );
240233 dsInfos .put ("podId" ,1L );
241234 dsInfos .put ("clusterId" , 1L );
@@ -245,7 +238,7 @@ public void testInitialize_invalidCapacityBytes() {
245238 dsInfos .put ("managed" ,true );
246239 dsInfos .put ("tags" , "testTag" );
247240 dsInfos .put ("isTagARule" , false );
248- dsInfos .put ("details" , new HashMap < String , String >() );
241+ dsInfos .put ("details" , detailsMap );
249242
250243 try (MockedStatic <StorageProviderFactory > storageProviderFactory = Mockito .mockStatic (StorageProviderFactory .class )) {
251244 storageProviderFactory .when (() -> StorageProviderFactory .getStrategy (any ())).thenReturn (storageStrategy );
@@ -256,7 +249,6 @@ public void testInitialize_invalidCapacityBytes() {
256249 @ Test
257250 public void testInitialize_unmanagedStorage () {
258251 Map <String , Object > dsInfos = new HashMap <>();
259- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1" );
260252 dsInfos .put ("zoneId" ,1L );
261253 dsInfos .put ("podId" ,1L );
262254 dsInfos .put ("clusterId" , 1L );
@@ -280,7 +272,6 @@ public void testInitialize_unmanagedStorage() {
280272 @ Test
281273 public void testInitialize_nullStoragePoolName () {
282274 Map <String , Object > dsInfos = new HashMap <>();
283- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1" );
284275 dsInfos .put ("zoneId" ,1L );
285276 dsInfos .put ("podId" ,1L );
286277 dsInfos .put ("clusterId" , 1L );
@@ -304,7 +295,6 @@ public void testInitialize_nullStoragePoolName() {
304295 @ Test
305296 public void testInitialize_nullProviderName () {
306297 Map <String , Object > dsInfos = new HashMap <>();
307- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1" );
308298 dsInfos .put ("zoneId" ,1L );
309299 dsInfos .put ("podId" ,1L );
310300 dsInfos .put ("clusterId" , 1L );
@@ -328,7 +318,6 @@ public void testInitialize_nullProviderName() {
328318 @ Test
329319 public void testInitialize_nullPodAndClusterAndZone () {
330320 Map <String , Object > dsInfos = new HashMap <>();
331- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1" );
332321 dsInfos .put ("zoneId" ,null );
333322 dsInfos .put ("podId" ,null );
334323 dsInfos .put ("clusterId" , null );
@@ -356,7 +345,6 @@ public void testInitialize_clusterNotKVM() {
356345 when (_clusterDao .findById (2L )).thenReturn (clusterVO );
357346
358347 Map <String , Object > dsInfos = new HashMap <>();
359- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1" );
360348 dsInfos .put ("zoneId" ,1L );
361349 dsInfos .put ("podId" ,1L );
362350 dsInfos .put ("clusterId" , 2L );
@@ -379,8 +367,16 @@ public void testInitialize_clusterNotKVM() {
379367
380368 @ Test
381369 public void testInitialize_unexpectedDetailKey () {
370+
371+ HashMap <String , String > detailsMap = new HashMap <String , String >();
372+ detailsMap .put (Constants .USERNAME , "testUser" );
373+ detailsMap .put (Constants .PASSWORD , "testPassword" );
374+ detailsMap .put (Constants .STORAGE_IP , "10.10.10.10" );
375+ detailsMap .put (Constants .SVM_NAME , "vs0" );
376+ detailsMap .put (Constants .PROTOCOL , "NFS3" );
377+ detailsMap .put ("unexpectedKey" , "unexpectedValue" );
378+
382379 Map <String , Object > dsInfos = new HashMap <>();
383- dsInfos .put ("url" , "username=testUser;password=testPassword;svmName=testSVM;protocol=NFS3;managementLIF=192.168.1.1;unexpectedKey=unexpectedValue" );
384380 dsInfos .put ("zoneId" ,1L );
385381 dsInfos .put ("podId" ,1L );
386382 dsInfos .put ("clusterId" , 1L );
@@ -390,7 +386,7 @@ public void testInitialize_unexpectedDetailKey() {
390386 dsInfos .put ("managed" ,true );
391387 dsInfos .put ("tags" , "testTag" );
392388 dsInfos .put ("isTagARule" , false );
393- dsInfos .put ("details" , new HashMap < String , String >() );
389+ dsInfos .put ("details" , detailsMap );
394390
395391 Exception ex = assertThrows (CloudRuntimeException .class , () -> {
396392 try (MockedStatic <StorageProviderFactory > storageProviderFactory = Mockito .mockStatic (StorageProviderFactory .class )) {
0 commit comments