Use predictable-order sets 19/78219/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 27 Nov 2018 16:38:16 +0000 (17:38 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 27 Nov 2018 16:39:08 +0000 (17:39 +0100)
MapServerTest requires MapServer to respond with specific order
of items. Use LinkedHashMap/ImmutableSet to achieve that
consistently.

Change-Id: Ia96ac31e434f8fee5095802de446f0b1dc1eeeb7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java

index cba7fc1b798e1168be9f701a5616f858e71987e9..5dd1c36f66252057384666b5376c7304847fd96e 100644 (file)
@@ -17,8 +17,8 @@ import java.net.SocketException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Enumeration;
-import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -145,7 +145,7 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener, IS
             MapNotifyBuilder builder = new MapNotifyBuilder();
             List<TransportAddress> rlocs = null;
             if (merge) {
-                Set<IpAddressBinary> notifyRlocs = new HashSet<IpAddressBinary>();
+                Set<IpAddressBinary> notifyRlocs = new LinkedHashSet<IpAddressBinary>();
                 List<MappingRecordItem> mergedMappings = new ArrayList<MappingRecordItem>();
                 for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
                     MappingRecord mapping = record.getMappingRecord();
index 1593a82da58342003eea5f91686f3a3771fe64df..c3812323401aea79a50752be67b8ae4d8db4f8da 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.lispflowmapping.implementation.lisp;
 
 import static org.junit.Assert.assertEquals;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import java.lang.reflect.Field;
@@ -409,9 +410,7 @@ public class MapServerTest {
     }
 
     private static Set<IpAddressBinary> getDefaultIpAddressSet() {
-        final Set<IpAddressBinary> addressSet = Sets.newHashSet(IPV4_BINARY_1, IPV4_BINARY_2);
-
-        return addressSet;
+        return ImmutableSet.of(IPV4_BINARY_1, IPV4_BINARY_2);
     }
 
     private static List<TransportAddress> getTransportAddressList() {