GabrielBrascher commented on a change in pull request #4140:
URL: https://github.com/apache/cloudstack/pull/4140#discussion_r440835059



##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -3423,12 +3432,22 @@ else if (!template.isPublicTemplate() && 
caller.getType() != Account.ACCOUNT_TYP
             return uniqueTmplPair;
         }
         List<TemplateJoinVO> uniqueTmpls = uniqueTmplPair.first();
-        String[] tzIds = new String[uniqueTmpls.size()];
         int i = 0;
-        for (TemplateJoinVO v : uniqueTmpls) {
-            tzIds[i++] = v.getTempZonePair();
+        List<TemplateJoinVO> vrs = null;
+        if (showUnique) {
+            Long[] tzIds = new Long[uniqueTmpls.size()];
+            for (TemplateJoinVO v : uniqueTmpls) {
+                tzIds[i++] = v.getId();
+            }
+            vrs = _templateJoinDao.findByDistinctIds(tzIds);
+        } else {
+            String[] tzIds = new String[uniqueTmpls.size()];
+            for (TemplateJoinVO v : uniqueTmpls) {
+                tzIds[i++] = v.getTempZonePair();
+            }
+            vrs = _templateJoinDao.searchByTemplateZonePair(showRemovedTmpl, 
tzIds);

Review comment:
       Unit testing for such a huge/complex method is not easy. However, it 
would be great to address small pieces.
   
   With that said, lines 3436 - 3448 could be extracted into a method that 
would allow testing this specific piece of code.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to