diff --git a/src/main/java/emissary/core/BaseDataObject.java b/src/main/java/emissary/core/BaseDataObject.java index 937959ef7b..763ec98329 100755 --- a/src/main/java/emissary/core/BaseDataObject.java +++ b/src/main/java/emissary/core/BaseDataObject.java @@ -992,7 +992,8 @@ public boolean appendUniqueParameter(final String key, final CharSequence value) public String getParameterAsString(final String key) { final var obj = getParameterAsStrings(key); if (obj.size() > 1) { - logger.warn("Multiple values for parameter, returning the first - parameter:{}, number of values:{}", key, obj.size()); + logger.warn("Multiple values for parameter, parameter:{}, number of values:{}", key, obj.size()); + return getParameterAsConcatString(key); } return obj.stream().findFirst().orElse(null); } diff --git a/src/test/java/emissary/core/BaseDataObjectTest.java b/src/test/java/emissary/core/BaseDataObjectTest.java index 5efdfc5435..623a4d9c64 100755 --- a/src/test/java/emissary/core/BaseDataObjectTest.java +++ b/src/test/java/emissary/core/BaseDataObjectTest.java @@ -852,10 +852,10 @@ void testPutParametersWithPolicy() { assertEquals("uno;uno", this.b.getStringParameter("ONE"), "When specifying KEEP_ALL values must all stay"); assertEquals("uno;uno", this.b.getParameterAsConcatString("ONE"), "When specifying KEEP_ALL values must all stay"); - assertEquals("uno", this.b.getParameterAsString("ONE"), "When specifying KEEP_ALL first value should be retained"); + assertEquals("uno;uno", this.b.getParameterAsString("ONE"), "When specifying KEEP_ALL first value should be retained"); assertEquals("deux;dos", this.b.getStringParameter("TWO"), "When specifying KEEP_ALL values must all stay"); assertEquals("deux;dos", this.b.getParameterAsConcatString("TWO"), "When specifying KEEP_ALL values must all stay"); - assertEquals("deux", this.b.getParameterAsString("TWO"), "When specifying KEEP_ALL first value should be retained"); + assertEquals("deux;dos", this.b.getParameterAsString("TWO"), "When specifying KEEP_ALL first value should be retained"); assertEquals("tres", this.b.getStringParameter("THREE"), "When specifying KEEP_ALL new keys must be stored"); assertEquals("tres", this.b.getParameterAsConcatString("THREE"), "When specifying KEEP_ALL new keys must be stored"); assertEquals("tres", this.b.getParameterAsString("THREE"), "When specifying KEEP_ALL first value should be retained"); @@ -952,7 +952,7 @@ void testAppendDuplicateParameters() { this.b.appendParameter("YO", "GABBA"); assertEquals("GABBA;GABBA", this.b.getStringParameter("YO"), "Appended duplicate parameters should be preserved"); assertEquals("GABBA;GABBA", this.b.getParameterAsConcatString("YO"), "Appended duplicate parameters should be preserved"); - assertEquals("GABBA", this.b.getParameterAsString("YO"), "Appended duplicate parameters first value should be preserved"); + assertEquals("GABBA;GABBA", this.b.getParameterAsString("YO"), "Appended duplicate parameters first value should be preserved"); assertTrue(this.b.hasParameter("YO"), "HasParameter should be true"); } @@ -983,7 +983,7 @@ void testParametersWithMixtureOfSingleValuesAndLists() { assertEquals("FOO1;FOO2;FOO3;FOO4", this.b.getParameterAsConcatString("FOO"), "Returned string should be combination of initial list and added value"); - assertEquals("FOO1", + assertEquals("FOO1;FOO2;FOO3;FOO4", this.b.getParameterAsString("FOO"), "Returned string should be first value from combination of initial list and added value"); } @@ -1002,7 +1002,7 @@ void testParametersWithMixtureOfSingleValuesAndSets() { assertEquals("FOO1;FOO2;FOO3;FOO4", this.b.getStringParameter("FOO"), "Returned string should be combination of initial set and added value"); assertEquals("FOO1;FOO2;FOO3;FOO4", this.b.getParameterAsConcatString("FOO"), "Returned string should be combination of initial set and added value"); - assertEquals("FOO1", this.b.getParameterAsString("FOO"), + assertEquals("FOO1;FOO2;FOO3;FOO4", this.b.getParameterAsString("FOO"), "Returned string should be first value from combination of initial set and added value"); } @@ -1036,7 +1036,7 @@ void testAppendParameter() { this.b.appendParameter("ME", "FOO"); assertEquals("YOU;FOO", this.b.getStringParameter("ME"), "Appended parameter value"); assertEquals("YOU;FOO", this.b.getParameterAsConcatString("ME"), "Appended parameter value"); - assertEquals("YOU", this.b.getParameterAsString("ME"), "Appended parameter value"); + assertEquals("YOU;FOO", this.b.getParameterAsString("ME"), "Appended parameter value"); } @Test @@ -1045,7 +1045,7 @@ void testAppendParameterIterables() { this.b.appendParameter("ME", Arrays.asList("FOO", "BAR", "BAZ")); assertEquals("YOU;FOO;BAR;BAZ", this.b.getStringParameter("ME"), "Appended parameter value"); assertEquals("YOU;FOO;BAR;BAZ", this.b.getParameterAsConcatString("ME"), "Appended parameter value"); - assertEquals("YOU", this.b.getParameterAsString("ME"), "First value from appended parameter value"); + assertEquals("YOU;FOO;BAR;BAZ", this.b.getParameterAsString("ME"), "First value from appended parameter value"); final Set s = new TreeSet<>(); s.add("ZAB"); @@ -1055,7 +1055,7 @@ void testAppendParameterIterables() { assertEquals("YOU;FOO;BAR;BAZ;OOF;RAB;ZAB", this.b.getStringParameter("ME"), "Appended set parameter value"); assertEquals("YOU;FOO;BAR;BAZ;OOF;RAB;ZAB", this.b.getParameterAsConcatString("ME"), "Appended set parameter value"); - assertEquals("YOU", this.b.getParameterAsString("ME"), "First value from appended set parameter value"); + assertEquals("YOU;FOO;BAR;BAZ;OOF;RAB;ZAB", this.b.getParameterAsString("ME"), "First value from appended set parameter value"); } @Test @@ -1422,11 +1422,11 @@ void testGetParameterAsString() throws IOException { this.b.putParameter("A", 1L); this.b.appendParameter("A", "TWO"); this.b.appendParameter("A", "THREE"); - assertEquals("1", this.b.getParameterAsString("A")); + assertEquals("1;TWO;THREE", this.b.getParameterAsString("A")); assertEquals("1;TWO;THREE", this.b.getParameterAsConcatString("A")); assertEquals("1;TWO;THREE", this.b.getStringParameter("A")); LogbackTester.SimplifiedLogEvent logEvent = new LogbackTester.SimplifiedLogEvent(Level.WARN, - "Multiple values for parameter, returning the first - parameter:A, number of values:3", null); + "Multiple values for parameter, parameter:A, number of values:3", null); logbackTester.checkLogList(Collections.singletonList(logEvent)); } @@ -1457,7 +1457,7 @@ void testGetParameterAsString() throws IOException { this.b.putParameter("A", null); this.b.appendParameter("A", "FOUR"); this.b.appendParameter("A", " "); - assertEquals("null", this.b.getParameterAsString("A")); + assertEquals("null;FOUR; ", this.b.getParameterAsString("A")); assertEquals("null;FOUR; ", this.b.getParameterAsConcatString("A")); assertEquals("null;FOUR; ", this.b.getStringParameter("A")); }