Skip to content

Commit ef7ab76

Browse files
committed
Polishing
1 parent 06d9db1 commit ef7ab76

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.test.context.util;
1818

19+
import java.util.ArrayList;
1920
import java.util.Arrays;
2021
import java.util.List;
2122
import java.util.regex.Pattern;
@@ -135,13 +136,13 @@ public static Resource[] convertToResources(ResourceLoader resourceLoader, Strin
135136
* the given {@link ResourceLoader}.
136137
* @param resourceLoader the {@code ResourceLoader} to use to convert the paths
137138
* @param paths the paths to be converted
138-
* @return a new list of resources
139+
* @return a new, mutable list of resources
139140
* @since 4.2
140141
* @see #convertToResources(ResourceLoader, String...)
141142
* @see #convertToClasspathResourcePaths
142143
*/
143144
public static List<Resource> convertToResourceList(ResourceLoader resourceLoader, String... paths) {
144-
return stream(resourceLoader, paths).collect(Collectors.toList());
145+
return stream(resourceLoader, paths).collect(Collectors.toCollection(ArrayList::new));
145146
}
146147

147148
private static Stream<Resource> stream(ResourceLoader resourceLoader, String... paths) {

spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private List<Class<?>> classes(TestContextManager testContextManager) {
200200
}
201201

202202
private List<String> names(List<Class<?>> classes) {
203-
return classes.stream().map(Class::getSimpleName).collect(toList());
203+
return classes.stream().map(Class::getSimpleName).toList();
204204
}
205205

206206
private void assertRegisteredListeners(Class<?> testClass, List<Class<?>> expected) {

spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@
2727
import org.springframework.test.util.ReflectionTestUtils;
2828

2929
import static java.util.Arrays.asList;
30-
import static java.util.stream.Collectors.toList;
3130
import static org.assertj.core.api.Assertions.assertThat;
3231
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
3332
import static org.mockito.Mockito.mock;
@@ -166,7 +165,7 @@ private static void assertCacheContents(DefaultContextCache cache, String... exp
166165
List<String> actualNames = contextMap.keySet().stream()
167166
.map(cfg -> cfg.getClasses()[0])
168167
.map(Class::getSimpleName)
169-
.collect(toList());
168+
.toList();
170169
// @formatter:on
171170

172171
assertThat(actualNames).isEqualTo(asList(expectedNames));

spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/DefaultPublishedEvents.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
2020
import java.util.List;
2121
import java.util.function.Function;
2222
import java.util.function.Predicate;
23-
import java.util.stream.Collectors;
2423
import java.util.stream.Stream;
2524

2625
import org.springframework.test.context.event.ApplicationEventsHolder;
@@ -51,7 +50,7 @@ private SimpleTypedPublishedEvents(List<T> events) {
5150
}
5251

5352
static <T> SimpleTypedPublishedEvents<T> of(Stream<T> stream) {
54-
return new SimpleTypedPublishedEvents<>(stream.collect(Collectors.toList()));
53+
return new SimpleTypedPublishedEvents<>(stream.toList());
5554
}
5655

5756
@Override

spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/PublishedEvents.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.test.context.junit.jupiter.event;
1818

19-
import java.util.Arrays;
2019
import java.util.function.Function;
2120
import java.util.function.Predicate;
2221

@@ -30,16 +29,6 @@
3029
*/
3130
public interface PublishedEvents {
3231

33-
/**
34-
* Creates a new {@link PublishedEvents} instance for the given events.
35-
*
36-
* @param events must not be {@literal null}
37-
* @return will never be {@literal null}
38-
*/
39-
public static PublishedEvents of(Object... events) {
40-
return of(Arrays.asList(events));
41-
}
42-
4332
/**
4433
* Returns all application events of the given type that were fired during the test execution.
4534
*

0 commit comments

Comments
 (0)