From 30d27609b0e0e0f17090caa9c7c99a3b233f9a69 Mon Sep 17 00:00:00 2001 From: Richard Ogin Date: Tue, 10 Sep 2024 15:57:14 -0500 Subject: [PATCH] #6276 add unit test --- .../com/mirth/connect/util/HttpUtilTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core-util/test/com/mirth/connect/util/HttpUtilTest.java b/core-util/test/com/mirth/connect/util/HttpUtilTest.java index f138119023..6e591391c8 100644 --- a/core-util/test/com/mirth/connect/util/HttpUtilTest.java +++ b/core-util/test/com/mirth/connect/util/HttpUtilTest.java @@ -9,10 +9,13 @@ package com.mirth.connect.util; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.security.KeyStore; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.UUID; import javax.net.ssl.SSLContext; @@ -22,6 +25,9 @@ import org.apache.http.ssl.SSLContexts; import org.junit.Test; +import com.mirth.connect.donkey.model.message.ConnectorMessage; +import com.mirth.connect.donkey.util.MessageMaps; + public class HttpUtilTest { @Test @@ -40,4 +46,20 @@ public void testExecuteGetRequest() throws Exception { } catch (Exception e) { } } + + @Test + public void testMapOrderPreserved() { + final String MAP_KEY = "MyMap"; + + Map initial = new LinkedHashMap<>(); + initial.put("First", 1); + initial.put("Second", 2); + initial.put("Third", 3); + + ConnectorMessage cm = new ConnectorMessage(); + cm.getSourceMap().put(MAP_KEY, initial); + + Map copied = HttpUtil.getTableMap(MAP_KEY, new MessageMaps(), cm); + assertArrayEquals("Failed to preserve key order", initial.keySet().toArray(), copied.keySet().toArray()); + } }