suryag1201 commented on code in PR #14767:
URL: https://github.com/apache/cloudstack/pull/14767#discussion_r4710607941


##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -840,7 +840,7 @@ public static DataStoreRole getDataStoreRole(Snapshot 
snapshot, SnapshotDataStor
 
         if (mapCapabilities != null) {

Review Comment:
   mapCapabilities can be empty, in this case get() and parseBoolean() calls do 
not add much value. While the performance impact is negligible, using a utility 
method such as isNotEmpty() would avoid executing the block when the map is 
either null or empty.



##########
server/src/test/java/com/cloud/api/ApiResponseHelperTest.java:
##########
@@ -850,4 +858,31 @@ public void 
showVmInfoForSharedNetworksTestRouterPlaceholderOnly() {
             verify(ipResponse, 
Mockito.never()).setVirtualMachineId(Mockito.anyString());
         }
     }
+
+    private DataStoreRole 
getDataStoreRoleForStorageSystemSnapshotCapability(String capability) {
+        Snapshot snapshot = Mockito.mock(Snapshot.class);
+        when(snapshot.getId()).thenReturn(1L);
+        SnapshotDataStoreVO snapshotStore = 
Mockito.mock(SnapshotDataStoreVO.class);
+        when(snapshotStore.getDataStoreId()).thenReturn(2L);
+        SnapshotDataStoreDao snapshotStoreDao = 
Mockito.mock(SnapshotDataStoreDao.class);
+        when(snapshotStoreDao.findOneBySnapshotAndDatastoreRole(1L, 
DataStoreRole.Primary)).thenReturn(snapshotStore);
+        DataStoreDriver driver = Mockito.mock(DataStoreDriver.class);
+        
when(driver.getCapabilities()).thenReturn(Map.of(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString(),
 capability));
+        DataStore dataStore = Mockito.mock(DataStore.class);
+        when(dataStore.getDriver()).thenReturn(driver);
+        DataStoreManager dataStoreMgr = Mockito.mock(DataStoreManager.class);
+        when(dataStoreMgr.getDataStore(2L, 
DataStoreRole.Primary)).thenReturn(dataStore);
+
+        return ApiResponseHelper.getDataStoreRole(snapshot, snapshotStoreDao, 
dataStoreMgr);
+    }
+
+    @Test
+    public void getDataStoreRoleTestStorageSystemSnapshotSupported() {

Review Comment:
   Add more unit test cases:
   1- case-insensitive values like "TRUE", "True" and odd values like "yes", ""
   2- when getCapabilities is empty or null



##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -531,7 +531,7 @@ public GetUploadParamsResponse 
doInTransaction(TransactionStatus status) throws
                     GetUploadParamsResponse response = new 
GetUploadParamsResponse();
 
                     String ssvmUrlDomain = 
_configDao.getValue(Config.SecStorageSecureCopyCert.key());
-                    String protocol = UseHttpsToUpload.value() ? "https" : 
"http";
+                    String protocol = UseHttpsToUpload.valueIn(zoneId) ? 
"https" : "http";

Review Comment:
   Please consider using the constants for "https" and "http" instead of 
hardcoded string literals.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to