Yair Zaslavsky has uploaded a new change for review.

Change subject: utils: Adding addToMapOfSets to MultiValueMapUtils
......................................................................

utils: Adding addToMapOfSets to MultiValueMapUtils

Change-Id: I6523181542291f70d854a8c32fc51ceea32a71eb
Topic: AAA
Signed-off-by: Yair Zaslavsky <yzasl...@redhat.com>
---
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtils.java
M 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtilsTest.java
2 files changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/29907/1

diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtils.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtils.java
index 8f4c18a..e2d2b0a 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtils.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtils.java
@@ -49,6 +49,10 @@
         addToMap(key, value, map, new ListCreator<V>());
     }
 
+    public static <K, V> void addToMapOfSets(K key, V value, Map<K, Set<V>> 
map) {
+        addToMap(key, value, map, new SetCreator<V>());
+    }
+
     public static interface CollectionCreator<V, C extends Collection<V>> {
         C create();
     }
diff --git 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtilsTest.java
 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtilsTest.java
index d895ddd..7ffbc39 100644
--- 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtilsTest.java
+++ 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/collections/MultiValueMapUtilsTest.java
@@ -9,6 +9,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.junit.Before;
 import org.junit.Rule;
@@ -30,12 +31,14 @@
 
     /** The map used for testing */
     private Map<Integer, List<Integer>> map;
+    private Map<Integer, Set<Integer>> mapOfSets;
 
     @Before
     public void setUp() {
         key = RandomUtils.instance().nextInt();
         value = RandomUtils.instance().nextInt();
         map = new HashMap<Integer, List<Integer>>();
+        mapOfSets = new HashMap<Integer, Set<Integer>>();
     }
 
     /** Tests adding a value to map that does not contain the testing key */
@@ -108,5 +111,15 @@
         assertEquals(value, val);
     }
 
+    @Test
+    public void testMultiValueMapOfSets() {
+        MultiValueMapUtils.addToMapOfSets(key, value, mapOfSets);
+        assertEquals(mapOfSets.get(key).size(), 1);
+        MultiValueMapUtils.addToMapOfSets(key, value, mapOfSets);
+        assertEquals(mapOfSets.get(key).size(), 1);
+        MultiValueMapUtils.addToMapOfSets(key, 
RandomUtils.instance().nextInt() + value, mapOfSets);
+        assertEquals(mapOfSets.get(key).size(), 2);
+    }
+
 
 }


-- 
To view, visit http://gerrit.ovirt.org/29907
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6523181542291f70d854a8c32fc51ceea32a71eb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Yair Zaslavsky <yzasl...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to