|
6 | 6 | import org.json.JSONArray; |
7 | 7 | import org.junit.Assert; |
8 | 8 | import org.junit.Test; |
9 | | -import org.labkey.api.collections.CaseInsensitiveHashSet; |
10 | 9 | import org.labkey.api.exp.property.IPropertyValidator; |
11 | 10 | import org.labkey.api.exp.property.PropertyService; |
12 | 11 | import org.labkey.api.gwt.client.model.PropertyValidatorType; |
|
21 | 20 | import java.sql.ResultSet; |
22 | 21 | import java.sql.SQLException; |
23 | 22 | import java.sql.Types; |
24 | | -import java.text.Format; |
25 | 23 | import java.util.ArrayList; |
26 | 24 | import java.util.Arrays; |
27 | 25 | import java.util.Collection; |
|
32 | 30 | import java.util.Map; |
33 | 31 | import java.util.Objects; |
34 | 32 | import java.util.Set; |
| 33 | +import java.util.TreeSet; |
35 | 34 | import java.util.function.BiConsumer; |
36 | 35 | import java.util.function.BinaryOperator; |
37 | 36 | import java.util.function.Function; |
@@ -216,12 +215,12 @@ public static class Array implements List<String>, java.sql.Array |
216 | 215 |
|
217 | 216 | protected Array(Stream<Object> str) |
218 | 217 | { |
219 | | - CaseInsensitiveHashSet set = new CaseInsensitiveHashSet(); |
220 | | - array = str.filter(Objects::nonNull) |
| 218 | + TreeSet<String> setCaseSensitive = new TreeSet<>(); |
| 219 | + str.filter(Objects::nonNull) |
221 | 220 | .map(s -> StringUtils.trimToNull(s.toString())) |
222 | 221 | .filter(Objects::nonNull) |
223 | | - .filter(set::add) |
224 | | - .toArray(String[]::new); |
| 222 | + .forEach(setCaseSensitive::add); |
| 223 | + array = setCaseSensitive.toArray(new String[0]); |
225 | 224 | } |
226 | 225 |
|
227 | 226 | protected Array(Object[] array) |
@@ -575,6 +574,8 @@ public void testConvert() throws Exception |
575 | 574 | assertEquals(expected, _converter.convert(Array.class, new String[]{"a,","b\"","c "})); |
576 | 575 | assertEquals(expected, _converter.convert(Array.class, List.of("a,","b\"","c "))); |
577 | 576 | assertEquals(expected, _converter.convert(Array.class, new JSONArray(List.of("a,","b\"","c ")))); |
| 577 | + // test that result is ordered |
| 578 | + assertEquals(expected, _converter.convert(Array.class, "\"c \",\"b\"\"\",\"a,\"")); |
578 | 579 | } |
579 | 580 |
|
580 | 581 | @Test |
|
0 commit comments