diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ApiCallSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ApiCallSection.java index 5d097f872b4..45538454585 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ApiCallSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ApiCallSection.java @@ -61,10 +61,6 @@ public class ApiCallSection { this.headers.putAll(otherHeaders); } - public void addHeader(String key, String value) { - this.headers.put(key, value); - } - public Map getHeaders() { return unmodifiableMap(headers); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index 482525c46b5..744b52303b5 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -38,6 +38,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import static java.util.Collections.emptyList; import static java.util.Collections.unmodifiableList; @@ -77,7 +78,7 @@ public class DoSection implements ExecutableSection { DoSection doSection = new DoSection(parser.getTokenLocation()); ApiCallSection apiCallSection = null; - Map headers = new HashMap<>(); + Map headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); List expectedWarnings = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -138,9 +139,7 @@ public class DoSection implements ExecutableSection { if (apiCallSection == null) { throw new IllegalArgumentException("client call section is mandatory within a do section"); } - if (headers.isEmpty() == false) { - apiCallSection.addHeaders(headers); - } + apiCallSection.addHeaders(headers); doSection.setApiCallSection(apiCallSection); doSection.setExpectedWarningHeaders(unmodifiableList(expectedWarnings)); } finally {