diff --git a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java index 3c3aa27ad95..f4520de8801 100644 --- a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java +++ b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java @@ -24,7 +24,7 @@ import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -92,6 +92,7 @@ public void testNewIpSelector() { @Test public void testNewMetadataSelector() { Instance ins1 = new Instance(); + ins1.setMetadata(new LinkedHashMap<>()); ins1.addMetadata("a", "1"); ins1.addMetadata("b", "2"); Instance ins2 = new Instance(); @@ -102,7 +103,7 @@ public void testNewMetadataSelector() { NamingContext namingContext = mock(NamingContext.class); when(namingContext.getInstances()).thenReturn(Arrays.asList(ins1, ins2, ins3)); - NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new HashMap() { + NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new LinkedHashMap() { { put("a", "1"); put("b", "2"); @@ -117,6 +118,7 @@ public void testNewMetadataSelector() { @Test public void testNewMetadataSelector2() { Instance ins1 = new Instance(); + ins1.setMetadata(new LinkedHashMap<>()); ins1.addMetadata("a", "1"); ins1.addMetadata("c", "3"); Instance ins2 = new Instance(); @@ -127,7 +129,7 @@ public void testNewMetadataSelector2() { NamingContext namingContext = mock(NamingContext.class); when(namingContext.getInstances()).thenReturn(Arrays.asList(ins1, ins2, ins3)); - NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new HashMap() { + NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new LinkedHashMap() { { put("a", "1"); put("b", "2");