diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java index a990ba4ed0..45fe14b925 100644 --- a/spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java @@ -31,7 +31,6 @@ import org.junit.platform.engine.discovery.ClassNameFilter; import org.junit.platform.engine.support.descriptor.ClassSource; import org.junit.platform.engine.support.descriptor.MethodSource; import org.junit.platform.launcher.LauncherDiscoveryRequest; -import org.junit.platform.launcher.TestIdentifier; import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; import org.junit.platform.launcher.core.LauncherFactory; import org.junit.platform.launcher.listeners.SummaryGeneratingListener; @@ -196,45 +195,28 @@ class AotIntegrationTests extends AbstractAotTests { private static void printFailingTestClasses(TestExecutionSummary summary) { System.err.println("Failing Test Classes:"); summary.getFailures().stream() - .map(Failure::getTestIdentifier) - .map(TestIdentifier::getSource) + .map(failure -> failure.getTestIdentifier().getSource()) .flatMap(Optional::stream) - .map(TestSource.class::cast) - .map(source -> { - if (source instanceof ClassSource classSource) { - return getJavaClass(classSource); - } - else if (source instanceof MethodSource methodSource) { - return getJavaClass(methodSource); - } - return Optional.> empty(); - }) - .flatMap(Optional::stream) - .map(Class::getName) + .map(AotIntegrationTests::getJavaClassName) .distinct() .sorted() .forEach(System.err::println); System.err.println(); } - private static Optional> getJavaClass(ClassSource classSource) { - try { - return Optional.of(classSource.getJavaClass()); - } - catch (Exception ex) { - // ignore exception - return Optional.empty(); - } - } - - private static Optional> getJavaClass(MethodSource methodSource) { + private static String getJavaClassName(TestSource source) { try { - return Optional.of(methodSource.getJavaClass()); + if (source instanceof ClassSource classSource) { + return classSource.getJavaClass().getName(); + } + else if (source instanceof MethodSource methodSource) { + return methodSource.getJavaClass().getName(); + } } catch (Exception ex) { - // ignore exception - return Optional.empty(); + // ignore } + return ""; } private static TestClassScanner createTestClassScanner() {