Polishing
This commit is contained in:
parent
06d9db154e
commit
ef7ab768e7
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.test.context.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -135,13 +136,13 @@ public abstract class TestContextResourceUtils {
|
|||
* the given {@link ResourceLoader}.
|
||||
* @param resourceLoader the {@code ResourceLoader} to use to convert the paths
|
||||
* @param paths the paths to be converted
|
||||
* @return a new list of resources
|
||||
* @return a new, mutable list of resources
|
||||
* @since 4.2
|
||||
* @see #convertToResources(ResourceLoader, String...)
|
||||
* @see #convertToClasspathResourcePaths
|
||||
*/
|
||||
public static List<Resource> convertToResourceList(ResourceLoader resourceLoader, String... paths) {
|
||||
return stream(resourceLoader, paths).collect(Collectors.toList());
|
||||
return stream(resourceLoader, paths).collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
private static Stream<Resource> stream(ResourceLoader resourceLoader, String... paths) {
|
||||
|
|
|
@ -200,7 +200,7 @@ class TestExecutionListenersTests {
|
|||
}
|
||||
|
||||
private List<String> names(List<Class<?>> classes) {
|
||||
return classes.stream().map(Class::getSimpleName).collect(toList());
|
||||
return classes.stream().map(Class::getSimpleName).toList();
|
||||
}
|
||||
|
||||
private void assertRegisteredListeners(Class<?> testClass, List<Class<?>> expected) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,7 +27,6 @@ import org.springframework.test.context.MergedContextConfiguration;
|
|||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -166,7 +165,7 @@ class LruContextCacheTests {
|
|||
List<String> actualNames = contextMap.keySet().stream()
|
||||
.map(cfg -> cfg.getClasses()[0])
|
||||
.map(Class::getSimpleName)
|
||||
.collect(toList());
|
||||
.toList();
|
||||
// @formatter:on
|
||||
|
||||
assertThat(actualNames).isEqualTo(asList(expectedNames));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.test.context.event.ApplicationEventsHolder;
|
||||
|
@ -51,7 +50,7 @@ class DefaultPublishedEvents implements PublishedEvents {
|
|||
}
|
||||
|
||||
static <T> SimpleTypedPublishedEvents<T> of(Stream<T> stream) {
|
||||
return new SimpleTypedPublishedEvents<>(stream.collect(Collectors.toList()));
|
||||
return new SimpleTypedPublishedEvents<>(stream.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.test.context.junit.jupiter.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
@ -30,16 +29,6 @@ import java.util.function.Predicate;
|
|||
*/
|
||||
public interface PublishedEvents {
|
||||
|
||||
/**
|
||||
* Creates a new {@link PublishedEvents} instance for the given events.
|
||||
*
|
||||
* @param events must not be {@literal null}
|
||||
* @return will never be {@literal null}
|
||||
*/
|
||||
public static PublishedEvents of(Object... events) {
|
||||
return of(Arrays.asList(events));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all application events of the given type that were fired during the test execution.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue