diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertLinesMatch.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertLinesMatch.java index 08314ed5e05e..a6a4811c307a 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertLinesMatch.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertLinesMatch.java @@ -11,6 +11,7 @@ package org.junit.jupiter.api; import static java.lang.String.format; +import static java.lang.String.join; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.platform.commons.util.Preconditions.condition; import static org.junit.platform.commons.util.Preconditions.notNull; @@ -19,6 +20,7 @@ import java.util.Deque; import java.util.List; import java.util.regex.PatternSyntaxException; +import java.util.stream.IntStream; /** * {@code AssertLinesMatch} is a collection of utility methods that support asserting @@ -55,15 +57,7 @@ static void assertLinesMatch(List expectedLines, List actualLine // simple case: both list are equally sized, compare them line-by-line if (expectedSize == actualSize) { - boolean allOk = true; - for (int i = 0; i < expectedSize; i++) { - if (matches(expectedLines.get(i), actualLines.get(i))) { - continue; - } - allOk = false; - break; - } - if (allOk) { + if (IntStream.range(0, expectedSize).allMatch(i -> matches(expectedLines.get(i), actualLines.get(i)))) { return; } } @@ -148,8 +142,8 @@ private static void fail(List expectedLines, List actualLines, S actualLines.subList(0, MAX_SNIPPET_LENGTH); } // use standard assertEquals(Object, Object, message) to let IDEs present the textual difference - String expected = String.join(System.lineSeparator(), expectedLines); - String actual = String.join(System.lineSeparator(), actualLines); + String expected = join(System.lineSeparator(), expectedLines); + String actual = join(System.lineSeparator(), actualLines); assertEquals(expected, actual, format(format, args)); } diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertionUtils.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertionUtils.java index 966a7781943e..b336608f0768 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertionUtils.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertionUtils.java @@ -81,9 +81,7 @@ static String formatValues(Object expected, Object actual) { return String.format("expected: %s but was: %s", formatClassAndValue(expected, expectedString), formatClassAndValue(actual, actualString)); } - else { - return String.format("expected: <%s> but was: <%s>", expectedString, actualString); - } + return String.format("expected: <%s> but was: <%s>", expectedString, actualString); } private static String formatClassAndValue(Object value, String valueString) { @@ -147,9 +145,7 @@ static boolean objectsAreEqual(Object obj1, Object obj2) { if (obj1 == null) { return (obj2 == null); } - else { - return obj1.equals(obj2); - } + return obj1.equals(obj2); } private static void failIllegalDelta(String delta) { diff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/ExtensionRegistry.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/ExtensionRegistry.java index b97df163a8f7..76f74224707f 100644 --- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/ExtensionRegistry.java +++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/ExtensionRegistry.java @@ -142,9 +142,7 @@ public Stream stream(Class extensionType) { if (this.parent == null) { return streamLocal(extensionType); } - else { - return concat(this.parent.stream(extensionType), streamLocal(extensionType)); - } + return concat(this.parent.stream(extensionType), streamLocal(extensionType)); } /** diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/TestInstanceLifecycleTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/TestInstanceLifecycleTests.java index bc430c81b997..bbb88882d1f5 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/TestInstanceLifecycleTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/TestInstanceLifecycleTests.java @@ -10,7 +10,7 @@ package org.junit.jupiter.engine; -import static java.util.stream.Collectors.joining; +import static java.lang.String.join; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -27,7 +27,6 @@ import java.lang.annotation.Target; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -617,7 +616,7 @@ private static String concat(Class c1, Class c2) { } private static String concat(String... args) { - return Arrays.stream(args).collect(joining(".")); + return join(".", args); } // ------------------------------------------------------------------------- diff --git a/junit-jupiter-engine/src/test/kotlin/org/junit/jupiter/engine/kotlin/InstancePerMethodKotlinTestCase.kt b/junit-jupiter-engine/src/test/kotlin/org/junit/jupiter/engine/kotlin/InstancePerMethodKotlinTestCase.kt index f6bb729cd1b1..bbcc6e5e61d5 100644 --- a/junit-jupiter-engine/src/test/kotlin/org/junit/jupiter/engine/kotlin/InstancePerMethodKotlinTestCase.kt +++ b/junit-jupiter-engine/src/test/kotlin/org/junit/jupiter/engine/kotlin/InstancePerMethodKotlinTestCase.kt @@ -1,7 +1,6 @@ package org.junit.jupiter.engine.kotlin import org.junit.jupiter.api.* -import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS class InstancePerMethodKotlinTestCase { diff --git a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestNameFormatter.java b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestNameFormatter.java index 2c9694a6abb6..2527dd22e313 100644 --- a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestNameFormatter.java +++ b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestNameFormatter.java @@ -13,6 +13,7 @@ import static java.util.stream.Collectors.joining; import java.text.MessageFormat; +import java.util.Arrays; import java.util.stream.IntStream; import org.junit.platform.commons.JUnitException; @@ -51,10 +52,8 @@ private String prepareMessageFormatPattern(int invocationIndex, Object[] argumen private Object[] makeReadable(Object[] arguments) { // Note: humanReadableArguments must be an Object[] in order to // avoid varargs issues with non-Eclipse compilers. - Object[] humanReadableArguments = new String[arguments.length]; - for (int i = 0; i < arguments.length; i++) { - humanReadableArguments[i] = StringUtils.nullSafeToString(arguments[i]); - } + Object[] humanReadableArguments = // + Arrays.stream(arguments).map(StringUtils::nullSafeToString).toArray(String[]::new); return humanReadableArguments; } diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/AnnotationUtils.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/AnnotationUtils.java index 8924af032457..c0e8422f03bd 100644 --- a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/AnnotationUtils.java +++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/AnnotationUtils.java @@ -205,12 +205,7 @@ private static Optional findAnnotation(AnnotatedElemen } // Meta-present on indirectly present annotations? - Optional indirectMetaAnnotation = findMetaAnnotation(annotationType, element.getAnnotations(), key, visited); - if (indirectMetaAnnotation.isPresent()) { - return indirectMetaAnnotation; - } - - return Optional.empty(); + return findMetaAnnotation(annotationType, element.getAnnotations(), key, visited); } private static Optional findMetaAnnotation(Class annotationType, diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java index ffedde4ade14..9b684972e1ba 100644 --- a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java +++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java @@ -107,8 +107,7 @@ public enum HierarchyTraversalMode { * * @see Class#getName() */ - private static final Pattern VM_INTERNAL_PRIMITIVE_ARRAY_PATTERN = // - Pattern.compile("^(\\[+)(\\[[Z,B,C,D,F,I,J,S])$"); + private static final Pattern VM_INTERNAL_PRIMITIVE_ARRAY_PATTERN = Pattern.compile("^(\\[+)(\\[[ZBCDFIJS])$"); // Pattern: "java.lang.String[]", "int[]", "int[][][][]", etc. private static final Pattern SOURCE_CODE_SYNTAX_ARRAY_PATTERN = Pattern.compile("^([^\\[\\]]+)((\\[\\])+)+$"); @@ -915,26 +914,21 @@ private static List getDeclaredMethods(Class clazz, HierarchyTraversa * in the Java Language Specification */ private static List getDefaultMethods(Class clazz) { + // @formatter:off // Visible default methods are interface default methods that have not // been overridden. - List visibleDefaultMethods = new ArrayList<>(); - for (Method candidate : clazz.getMethods()) { - if (candidate.isDefault()) { - visibleDefaultMethods.add(candidate); - } - } + List visibleDefaultMethods = Arrays.stream(clazz.getMethods()) + .filter(Method::isDefault) + .collect(toCollection(ArrayList::new)); if (visibleDefaultMethods.isEmpty()) { return visibleDefaultMethods; } - List defaultMethods = new ArrayList<>(); - for (Class ifc : clazz.getInterfaces()) { - for (Method method : getMethods(ifc)) { - if (visibleDefaultMethods.contains(method)) { - defaultMethods.add(method); - } - } - } - return defaultMethods; + return Arrays.stream(clazz.getInterfaces()) + .map(ReflectionUtils::getMethods) + .flatMap(List::stream) + .filter(visibleDefaultMethods::contains) + .collect(toCollection(ArrayList::new)); + // @formatter:on } private static List toSortedMutableList(Method[] methods) { @@ -1038,15 +1032,8 @@ private static boolean hasCompatibleSignature(Method candidate, String methodNam } static boolean isGeneric(Method method) { - if (isGeneric(method.getGenericReturnType())) { - return true; - } - for (Type type : method.getGenericParameterTypes()) { - if (isGeneric(type)) { - return true; - } - } - return false; + return isGeneric(method.getGenericReturnType()) + || Arrays.stream(method.getGenericParameterTypes()).anyMatch(ReflectionUtils::isGeneric); } private static boolean isGeneric(Type type) { diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/StringUtils.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/StringUtils.java index 772e6762fbeb..3d559eca64cb 100644 --- a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/StringUtils.java +++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/StringUtils.java @@ -70,17 +70,7 @@ public static boolean isNotBlank(String str) { * @see Character#isWhitespace(int) */ public static boolean containsWhitespace(String str) { - if (str == null) { - return false; - } - - for (int i = 0; i < str.length(); i++) { - if (Character.isWhitespace(str.codePointAt(i))) { - return true; - } - } - - return false; + return str != null && str.codePoints().anyMatch(Character::isWhitespace); } /** @@ -106,17 +96,7 @@ public static boolean doesNotContainWhitespace(String str) { * @see Character#isISOControl(int) */ public static boolean containsIsoControlCharacter(String str) { - if (str == null) { - return false; - } - - for (int i = 0; i < str.length(); i++) { - if (Character.isISOControl(str.codePointAt(i))) { - return true; - } - } - - return false; + return str != null && str.codePoints().anyMatch(Character::isISOControl); } /** diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ToStringBuilder.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ToStringBuilder.java index 466a8a368048..ec88101bdb65 100644 --- a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ToStringBuilder.java +++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ToStringBuilder.java @@ -10,6 +10,7 @@ package org.junit.platform.commons.util; +import static java.lang.String.join; import static org.junit.platform.commons.meta.API.Usage.Internal; import java.util.ArrayList; @@ -51,15 +52,12 @@ public ToStringBuilder append(String name, Object value) { } private String toString(Object obj) { - if (obj instanceof CharSequence) { - return "'" + obj + "'"; - } - return StringUtils.nullSafeToString(obj); + return (obj instanceof CharSequence) ? ("'" + obj + "'") : StringUtils.nullSafeToString(obj); } @Override public String toString() { - return this.type.getSimpleName() + " [" + String.join(", ", this.values) + "]"; + return this.type.getSimpleName() + " [" + join(", ", this.values) + "]"; } } diff --git a/junit-platform-console/src/main/java/org/junit/platform/console/options/Theme.java b/junit-platform-console/src/main/java/org/junit/platform/console/options/Theme.java index 2fa64d8ced59..63c3a63bd31c 100644 --- a/junit-platform-console/src/main/java/org/junit/platform/console/options/Theme.java +++ b/junit-platform-console/src/main/java/org/junit/platform/console/options/Theme.java @@ -79,43 +79,43 @@ public static Theme valueOf(Charset charset) { this.blank = new String(new char[vertical().length()]).replace('\0', ' '); } - public String root() { + public final String root() { return tiles[0]; } - public String vertical() { + public final String vertical() { return tiles[1]; } - public String blank() { + public final String blank() { return blank; } - public String entry() { + public final String entry() { return tiles[2]; } - public String end() { + public final String end() { return tiles[3]; } - public String successful() { + public final String successful() { return tiles[4]; } - public String aborted() { + public final String aborted() { return tiles[5]; } - public String failed() { + public final String failed() { return tiles[6]; } - public String skipped() { + public final String skipped() { return tiles[7]; } - public String status(TestExecutionResult result) { + public final String status(TestExecutionResult result) { switch (result.getStatus()) { case SUCCESSFUL: return successful(); @@ -133,7 +133,7 @@ public String status(TestExecutionResult result) { * available options. */ @Override - public String toString() { + public final String toString() { return name().toLowerCase(); } diff --git a/junit-platform-console/src/main/java/org/junit/platform/console/tasks/ConsoleTestExecutor.java b/junit-platform-console/src/main/java/org/junit/platform/console/tasks/ConsoleTestExecutor.java index 39672253da07..403c916fddea 100644 --- a/junit-platform-console/src/main/java/org/junit/platform/console/tasks/ConsoleTestExecutor.java +++ b/junit-platform-console/src/main/java/org/junit/platform/console/tasks/ConsoleTestExecutor.java @@ -117,10 +117,7 @@ private Optional createDetailsPrintingListener(PrintWrite } private Optional createXmlWritingListener(PrintWriter out) { - if (options.getReportsDir().isPresent()) { - return Optional.of(new XmlReportsWritingListener(options.getReportsDir().get(), out)); - } - return Optional.empty(); + return options.getReportsDir().map(reportsDir -> new XmlReportsWritingListener(reportsDir, out)); } private void printSummary(TestExecutionSummary summary, PrintWriter out) { diff --git a/junit-platform-engine/src/main/java/org/junit/platform/engine/discovery/DiscoverySelectors.java b/junit-platform-engine/src/main/java/org/junit/platform/engine/discovery/DiscoverySelectors.java index 12bae24a10cb..aec8f12b562c 100644 --- a/junit-platform-engine/src/main/java/org/junit/platform/engine/discovery/DiscoverySelectors.java +++ b/junit-platform-engine/src/main/java/org/junit/platform/engine/discovery/DiscoverySelectors.java @@ -335,9 +335,7 @@ public static MethodSelector selectMethod(String fullyQualifiedMethodName) throw if (StringUtils.isNotBlank(methodParameters)) { return selectMethod(className, methodName, methodParameters); } - else { - return selectMethod(className, methodName); - } + return selectMethod(className, methodName); } /** diff --git a/junit-platform-engine/src/test/java/org/junit/platform/engine/test/event/TestExecutionResultConditions.java b/junit-platform-engine/src/test/java/org/junit/platform/engine/test/event/TestExecutionResultConditions.java index 48906bd94483..74c8dfcac115 100644 --- a/junit-platform-engine/src/test/java/org/junit/platform/engine/test/event/TestExecutionResultConditions.java +++ b/junit-platform-engine/src/test/java/org/junit/platform/engine/test/event/TestExecutionResultConditions.java @@ -51,7 +51,7 @@ public static Condition suppressed(int index, Condition ch } public static Condition cause(Condition condition) { - return new Condition(where(TestExecutionResult::getThrowable, throwable -> { + return new Condition<>(where(TestExecutionResult::getThrowable, throwable -> { return throwable.isPresent() && condition.matches(throwable.get()); }), "cause where %s", condition); } diff --git a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/ServiceLoaderTestEngineRegistry.java b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/ServiceLoaderTestEngineRegistry.java index 997d6759e8f6..9549ebf827a1 100644 --- a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/ServiceLoaderTestEngineRegistry.java +++ b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/ServiceLoaderTestEngineRegistry.java @@ -10,12 +10,17 @@ package org.junit.platform.launcher.core; +import static java.lang.String.join; +import static java.util.stream.Collectors.toList; + import java.util.ArrayList; import java.util.List; import java.util.ServiceLoader; import java.util.logging.Logger; +import java.util.stream.Stream; import org.junit.platform.commons.util.ClassLoaderUtils; +import org.junit.platform.commons.util.CollectionUtils; import org.junit.platform.engine.TestEngine; /** @@ -32,19 +37,20 @@ public Iterable loadTestEngines() { return testEngines; } + @SuppressWarnings("unchecked") private String createDiscoveredTestEnginesMessage(Iterable testEngines) { - List details = new ArrayList<>(); - for (TestEngine engine : testEngines) { - details.add(String.format("%s (%s)", engine.getId(), String.join(", ", computeAttributes(engine)))); - } - if (details.isEmpty()) { - return "No TestEngine implementation discovered."; - } - return "Discovered TestEngines with IDs: [" + String.join(", ", details) + "]"; + // @formatter:off + List details = ((Stream) CollectionUtils.toStream(testEngines)) + .map(engine -> String.format("%s (%s)", engine.getId(), join(", ", computeAttributes(engine)))) + .collect(toList()); + return details.isEmpty() + ? "No TestEngine implementation discovered." + : "Discovered TestEngines with IDs: [" + join(", ", details) + "]"; + // @formatter:on } private List computeAttributes(TestEngine engine) { - List attributes = new ArrayList<>(); + List attributes = new ArrayList<>(4); engine.getGroupId().ifPresent(groupId -> attributes.add("group ID: " + groupId)); engine.getArtifactId().ifPresent(artifactId -> attributes.add("artifact ID: " + artifactId)); engine.getVersion().ifPresent(version -> attributes.add("version: " + version)); diff --git a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/MutableTestExecutionSummary.java b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/MutableTestExecutionSummary.java index 91e8f119d301..1fb366f85c65 100644 --- a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/MutableTestExecutionSummary.java +++ b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/MutableTestExecutionSummary.java @@ -10,6 +10,8 @@ package org.junit.platform.launcher.listeners; +import static java.lang.String.join; + import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; @@ -198,7 +200,7 @@ public List getFailures() { private String describeTest(TestIdentifier testIdentifier) { List descriptionParts = new ArrayList<>(); collectTestDescription(Optional.of(testIdentifier), descriptionParts); - return String.join(":", descriptionParts); + return join(":", descriptionParts); } private void collectTestDescription(Optional optionalIdentifier, List descriptionParts) { diff --git a/junit-platform-runner/src/main/java/org/junit/platform/runner/JUnitPlatformTestTree.java b/junit-platform-runner/src/main/java/org/junit/platform/runner/JUnitPlatformTestTree.java index 3f606f6120a7..d9a5d15b4356 100644 --- a/junit-platform-runner/src/main/java/org/junit/platform/runner/JUnitPlatformTestTree.java +++ b/junit-platform-runner/src/main/java/org/junit/platform/runner/JUnitPlatformTestTree.java @@ -106,9 +106,7 @@ else if (source instanceof MethodSource) { if (StringUtils.isBlank(methodParameterTypes)) { return methodSource.getMethodName(); } - else { - return String.format("%s(%s)", methodSource.getMethodName(), methodParameterTypes); - } + return String.format("%s(%s)", methodSource.getMethodName(), methodParameterTypes); } } diff --git a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java index fcb67939e2e5..d96685ed797b 100644 --- a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java +++ b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java @@ -77,9 +77,9 @@ public void execute(ExecutionRequest request) { private void executeAllChildren(RunnerExecutor runnerExecutor, TestDescriptor engineTestDescriptor) { // @formatter:off engineTestDescriptor.getChildren() - .stream() - .map(RunnerTestDescriptor.class::cast) - .forEach(runnerExecutor::execute); + .stream() + .map(RunnerTestDescriptor.class::cast) + .forEach(runnerExecutor::execute); // @formatter:on } } diff --git a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/discovery/UniqueIdSelectorResolver.java b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/discovery/UniqueIdSelectorResolver.java index a2c557d79d59..53b6328f946e 100644 --- a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/discovery/UniqueIdSelectorResolver.java +++ b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/discovery/UniqueIdSelectorResolver.java @@ -68,9 +68,9 @@ private void resolveIntoFilteredTestClass(UniqueId uniqueId, Predicate> TestClassCollector collector) { // @formatter:off determineTestClassName(uniqueId) - .flatMap(testClassName -> loadTestClass(testClassName, uniqueId)) - .filter(classFilter) - .ifPresent(testClass -> collector.addFiltered(testClass, new UniqueIdFilter(uniqueId))); + .flatMap(testClassName -> loadTestClass(testClassName, uniqueId)) + .filter(classFilter) + .ifPresent(testClass -> collector.addFiltered(testClass, new UniqueIdFilter(uniqueId))); // @formatter:on } diff --git a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/execution/TestRun.java b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/execution/TestRun.java index 8d410fe1c944..6a350f6d8a7d 100644 --- a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/execution/TestRun.java +++ b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/execution/TestRun.java @@ -54,8 +54,9 @@ class TestRun { runnerDescendants = new LinkedHashSet<>(runnerTestDescriptor.getDescendants()); // @formatter:off descriptionToDescriptors = concat(Stream.of(runnerTestDescriptor), runnerDescendants.stream()) - .map(VintageTestDescriptor.class::cast) - .collect(groupingBy(VintageTestDescriptor::getDescription, HashMap::new, toCollection(ArrayList::new))); + .map(VintageTestDescriptor.class::cast) + .collect(groupingBy( + VintageTestDescriptor::getDescription, HashMap::new, toCollection(ArrayList::new))); // @formatter:on } diff --git a/platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsTests.java b/platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsTests.java index 2d5d151f16c4..a61409c30a95 100644 --- a/platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsTests.java +++ b/platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsTests.java @@ -10,6 +10,7 @@ package org.junit.platform.commons.util; +import static java.lang.String.join; import static java.util.Arrays.stream; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; @@ -477,7 +478,7 @@ private static String fqmnWithParamNames(Class clazz, String methodName, Stri Preconditions.notNull(methodName, "methodName must not be null"); Preconditions.notNull(params, "params must not be null"); - return String.format("%s#%s(%s)", clazz.getName(), methodName, String.join(", ", params)); + return String.format("%s#%s(%s)", clazz.getName(), methodName, join(", ", params)); } private static void assertFqmn(String fqmn) { diff --git a/platform-tests/src/test/java/org/junit/platform/engine/discovery/DiscoverySelectorsTests.java b/platform-tests/src/test/java/org/junit/platform/engine/discovery/DiscoverySelectorsTests.java index a991fc2aecfd..abcecc10f938 100644 --- a/platform-tests/src/test/java/org/junit/platform/engine/discovery/DiscoverySelectorsTests.java +++ b/platform-tests/src/test/java/org/junit/platform/engine/discovery/DiscoverySelectorsTests.java @@ -10,6 +10,7 @@ package org.junit.platform.engine.discovery; +import static java.lang.String.join; import static java.util.Collections.singleton; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -484,7 +485,7 @@ private static String fqmn(Class clazz, String methodName, Class... params } private static String fqmnWithParamNames(String... params) { - return String.format("%s#%s(%s)", DiscoverySelectorsTests.class.getName(), "myTest", String.join(", ", params)); + return String.format("%s#%s(%s)", DiscoverySelectorsTests.class.getName(), "myTest", join(", ", params)); } interface TestInterface {