Use List.sort instead of Collection.sort in tests
Closes gh-25454
This commit is contained in:
@@ -43,7 +43,7 @@ class OrderSourceProviderTests {
|
||||
C c2 = new C(-5);
|
||||
items.add(c);
|
||||
items.add(c2);
|
||||
Collections.sort(items, comparator);
|
||||
items.sort(comparator);
|
||||
assertOrder(items, c2, c);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class OrderSourceProviderTests {
|
||||
B b = new B();
|
||||
|
||||
List<?> items = Arrays.asList(a, c, b);
|
||||
Collections.sort(items, comparator.withSourceProvider(obj -> null));
|
||||
items.sort(comparator.withSourceProvider(obj -> null));
|
||||
assertOrder(items, c, a, b);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class OrderSourceProviderTests {
|
||||
B b = new B();
|
||||
|
||||
List<?> items = Arrays.asList(a, c, b);
|
||||
Collections.sort(items, comparator.withSourceProvider(obj -> {
|
||||
items.sort(comparator.withSourceProvider(obj -> {
|
||||
if (obj == a) {
|
||||
return new C(4);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class OrderSourceProviderTests {
|
||||
C c2 = new C(-5);
|
||||
|
||||
List<?> items = Arrays.asList(a, c, c2);
|
||||
Collections.sort(items, comparator.withSourceProvider(obj -> {
|
||||
items.sort(comparator.withSourceProvider(obj -> {
|
||||
if (obj == a) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class ConvertingComparatorTests {
|
||||
void shouldGetMapEntryKeys() throws Exception {
|
||||
ArrayList<Entry<String, Integer>> list = createReverseOrderMapEntryList();
|
||||
Comparator<Map.Entry<String, Integer>> comparator = ConvertingComparator.mapEntryKeys(new ComparableComparator<String>());
|
||||
Collections.sort(list, comparator);
|
||||
list.sort(comparator);
|
||||
assertThat(list.get(0).getKey()).isEqualTo("a");
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class ConvertingComparatorTests {
|
||||
void shouldGetMapEntryValues() throws Exception {
|
||||
ArrayList<Entry<String, Integer>> list = createReverseOrderMapEntryList();
|
||||
Comparator<Map.Entry<String, Integer>> comparator = ConvertingComparator.mapEntryValues(new ComparableComparator<Integer>());
|
||||
Collections.sort(list, comparator);
|
||||
list.sort(comparator);
|
||||
assertThat(list.get(0).getValue()).isEqualTo(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -510,56 +510,56 @@ class AntPathMatcherTests {
|
||||
|
||||
paths.add(null);
|
||||
paths.add("/hotels/new");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/new");
|
||||
assertThat(paths.get(1)).isNull();
|
||||
paths.clear();
|
||||
|
||||
paths.add("/hotels/new");
|
||||
paths.add(null);
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/new");
|
||||
assertThat(paths.get(1)).isNull();
|
||||
paths.clear();
|
||||
|
||||
paths.add("/hotels/*");
|
||||
paths.add("/hotels/new");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/new");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/*");
|
||||
paths.clear();
|
||||
|
||||
paths.add("/hotels/new");
|
||||
paths.add("/hotels/*");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/new");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/*");
|
||||
paths.clear();
|
||||
|
||||
paths.add("/hotels/**");
|
||||
paths.add("/hotels/*");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/*");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/**");
|
||||
paths.clear();
|
||||
|
||||
paths.add("/hotels/*");
|
||||
paths.add("/hotels/**");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/*");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/**");
|
||||
paths.clear();
|
||||
|
||||
paths.add("/hotels/{hotel}");
|
||||
paths.add("/hotels/new");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/new");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/{hotel}");
|
||||
paths.clear();
|
||||
|
||||
paths.add("/hotels/new");
|
||||
paths.add("/hotels/{hotel}");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/new");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/{hotel}");
|
||||
paths.clear();
|
||||
@@ -567,7 +567,7 @@ class AntPathMatcherTests {
|
||||
paths.add("/hotels/*");
|
||||
paths.add("/hotels/{hotel}");
|
||||
paths.add("/hotels/new");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/new");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/{hotel}");
|
||||
assertThat(paths.get(2)).isEqualTo("/hotels/*");
|
||||
@@ -576,7 +576,7 @@ class AntPathMatcherTests {
|
||||
paths.add("/hotels/ne*");
|
||||
paths.add("/hotels/n*");
|
||||
Collections.shuffle(paths);
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/ne*");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/n*");
|
||||
paths.clear();
|
||||
@@ -585,7 +585,7 @@ class AntPathMatcherTests {
|
||||
paths.add("/hotels/new.*");
|
||||
paths.add("/hotels/{hotel}");
|
||||
Collections.shuffle(paths);
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/hotels/new.*");
|
||||
assertThat(paths.get(1)).isEqualTo("/hotels/{hotel}");
|
||||
paths.clear();
|
||||
@@ -593,7 +593,7 @@ class AntPathMatcherTests {
|
||||
comparator = pathMatcher.getPatternComparator("/web/endUser/action/login.html");
|
||||
paths.add("/**/login.*");
|
||||
paths.add("/**/endUser/action/login.*");
|
||||
Collections.sort(paths, comparator);
|
||||
paths.sort(comparator);
|
||||
assertThat(paths.get(0)).isEqualTo("/**/endUser/action/login.*");
|
||||
assertThat(paths.get(1)).isEqualTo("/**/login.*");
|
||||
paths.clear();
|
||||
|
||||
Reference in New Issue
Block a user