Skip to content

Commit 8a05661

Browse files
committed
Polishing
1 parent f72bf0c commit 8a05661

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed

spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.junit.platform.engine.support.descriptor.ClassSource;
3232
import org.junit.platform.engine.support.descriptor.MethodSource;
3333
import org.junit.platform.launcher.LauncherDiscoveryRequest;
34-
import org.junit.platform.launcher.TestIdentifier;
3534
import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
3635
import org.junit.platform.launcher.core.LauncherFactory;
3736
import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
@@ -196,45 +195,28 @@ private static void runTestsInAotMode(long expectedNumTests, List<Class<?>> test
196195
private static void printFailingTestClasses(TestExecutionSummary summary) {
197196
System.err.println("Failing Test Classes:");
198197
summary.getFailures().stream()
199-
.map(Failure::getTestIdentifier)
200-
.map(TestIdentifier::getSource)
198+
.map(failure -> failure.getTestIdentifier().getSource())
201199
.flatMap(Optional::stream)
202-
.map(TestSource.class::cast)
203-
.map(source -> {
204-
if (source instanceof ClassSource classSource) {
205-
return getJavaClass(classSource);
206-
}
207-
else if (source instanceof MethodSource methodSource) {
208-
return getJavaClass(methodSource);
209-
}
210-
return Optional.<Class<?>> empty();
211-
})
212-
.flatMap(Optional::stream)
213-
.map(Class::getName)
200+
.map(AotIntegrationTests::getJavaClassName)
214201
.distinct()
215202
.sorted()
216203
.forEach(System.err::println);
217204
System.err.println();
218205
}
219206

220-
private static Optional<Class<?>> getJavaClass(ClassSource classSource) {
221-
try {
222-
return Optional.of(classSource.getJavaClass());
223-
}
224-
catch (Exception ex) {
225-
// ignore exception
226-
return Optional.empty();
227-
}
228-
}
229-
230-
private static Optional<Class<?>> getJavaClass(MethodSource methodSource) {
207+
private static String getJavaClassName(TestSource source) {
231208
try {
232-
return Optional.of(methodSource.getJavaClass());
209+
if (source instanceof ClassSource classSource) {
210+
return classSource.getJavaClass().getName();
211+
}
212+
else if (source instanceof MethodSource methodSource) {
213+
return methodSource.getJavaClass().getName();
214+
}
233215
}
234216
catch (Exception ex) {
235-
// ignore exception
236-
return Optional.empty();
217+
// ignore
237218
}
219+
return "<unknown>";
238220
}
239221

240222
private static TestClassScanner createTestClassScanner() {

0 commit comments

Comments
 (0)