mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed Hashmap Key value comparision (#8238)
Co-authored-by: kavvya97 <kavvya.ramarathnam@gmail.com>
This commit is contained in:
parent
6001772335
commit
6eb04a86a6
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user