You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2023/11/17 08:06:05 UTC

(cloudstack) branch main updated: Fixed Hashmap Key value comparision (#8238)

This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 6eb04a86a6b Fixed Hashmap Key value comparision (#8238)
6eb04a86a6b is described below

commit 6eb04a86a6b63ea54eb983e47bee11e7ae22e036
Author: Kavvya Ramarathnam <56...@users.noreply.github.com>
AuthorDate: Fri Nov 17 02:05:58 2023 -0600

    Fixed Hashmap Key value comparision (#8238)
    
    Co-authored-by: kavvya97 <ka...@gmail.com>
---
 .../cloud/network/as/AutoScaleVmProfileVOTest.java | 24 ++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/engine/schema/src/test/java/com/cloud/network/as/AutoScaleVmProfileVOTest.java b/engine/schema/src/test/java/com/cloud/network/as/AutoScaleVmProfileVOTest.java
index 7e9658e1dd3..6813a209157 100755
--- a/engine/schema/src/test/java/com/cloud/network/as/AutoScaleVmProfileVOTest.java
+++ b/engine/schema/src/test/java/com/cloud/network/as/AutoScaleVmProfileVOTest.java
@@ -17,6 +17,7 @@
 package com.cloud.network.as;
 
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -42,14 +43,14 @@ public class AutoScaleVmProfileVOTest {
     public void testCounterParamsForUpdate() {
         AutoScaleVmProfileVO profile = new AutoScaleVmProfileVO();
 
-        Map<String, HashMap<String, String>> counterParamList = new HashMap<>();
-        counterParamList.put("0", new HashMap<>() {{ put("name", "snmpcommunity"); put("value", "public"); }});
-        counterParamList.put("1", new HashMap<>() {{ put("name", "snmpport"); put("value", "161"); }});
+        Map<String, LinkedHashMap<String, String>> counterParamList = new LinkedHashMap<>();
+        counterParamList.put("0", new LinkedHashMap<>() {{ put("name", "snmpcommunity"); put("value", "public"); }});
+        counterParamList.put("1", new LinkedHashMap<>() {{ put("name", "snmpport"); put("value", "161"); }});
 
         profile.setCounterParamsForUpdate(counterParamList);
         Assert.assertEquals("snmpcommunity=public&snmpport=161", profile.getCounterParamsString());
+        List<Pair<String, String>> counterParams = profile.getCounterParams();
 
-        List<Pair<String, String>>  counterParams = profile.getCounterParams();
         Assert.assertEquals(2, counterParams.size());
         Assert.assertEquals("snmpcommunity", counterParams.get(0).first());
         Assert.assertEquals("public", counterParams.get(0).second());
@@ -69,10 +70,17 @@ public class AutoScaleVmProfileVOTest {
 
         List<Pair<String, String>> otherDeployParamsList = profile.getOtherDeployParamsList();
         Assert.assertEquals(2, otherDeployParamsList.size());
-        Assert.assertEquals("serviceofferingid", otherDeployParamsList.get(0).first());
-        Assert.assertEquals("a7fb50f6-01d9-11ed-8bc1-77f8f0228926", otherDeployParamsList.get(0).second());
-        Assert.assertEquals("rootdisksize", otherDeployParamsList.get(1).first());
-        Assert.assertEquals("10", otherDeployParamsList.get(1).second());
+        Assert.assertTrue(containsPair(otherDeployParamsList, "serviceofferingid", "a7fb50f6-01d9-11ed-8bc1-77f8f0228926"));
+        Assert.assertTrue(containsPair(otherDeployParamsList, "rootdisksize", "10"));
+    }
+
+    private boolean containsPair(List<Pair<String, String>> list, String key, String value) {
+        for (Pair<String, String> pair : list) {
+            if (key.equals(pair.first()) && value.equals(pair.second())) {
+                return true;
+            }
+        }
+        return false;
     }
 
     @Test