File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
jupiter-tests/src/test/java/org/junit/jupiter/params/provider Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 1717
1818import java .util .stream .Stream ;
1919
20+ import org .assertj .core .api .ThrowingConsumer ;
2021import org .jspecify .annotations .Nullable ;
2122import org .junit .jupiter .api .Test ;
2223import org .junit .jupiter .api .extension .ExtensionContext ;
@@ -287,8 +288,7 @@ void throwsExceptionIfSourceExceedsMaxCharsPerColumnConfig() {
287288 assertThatExceptionOfType (CsvParsingException .class )//
288289 .isThrownBy (() -> provideArguments (annotation ).findAny ())//
289290 .withMessageStartingWith ("Failed to parse CSV input configured via Mock for CsvSource" )//
290- .havingRootCause ()//
291- .satisfies (ex -> ex .getClass ().getName ().contains ("de.siegmar.fastcsv.reader.CsvParseException" ));
291+ .havingRootCause ().satisfies (isCsvParseException ());
292292 }
293293
294294 @ Test
@@ -307,8 +307,7 @@ void throwsExceptionWhenSourceExceedsDefaultMaxCharsPerColumnConfig() {
307307 assertThatExceptionOfType (CsvParsingException .class )//
308308 .isThrownBy (() -> provideArguments (annotation ).findAny ())//
309309 .withMessageStartingWith ("Failed to parse CSV input configured via Mock for CsvSource" )//
310- .havingRootCause ()//
311- .satisfies (ex -> ex .getClass ().getName ().contains ("de.siegmar.fastcsv.reader.CsvParseException" ));
310+ .havingRootCause ().satisfies (isCsvParseException ());
312311 }
313312
314313 @ Test
@@ -413,4 +412,8 @@ private Stream<Object[]> provideArguments(CsvSource annotation) {
413412 return elements ;
414413 }
415414
415+ static ThrowingConsumer <Throwable > isCsvParseException () {
416+ return ex -> ex .getClass ().getName ().contains ("de.siegmar.fastcsv.reader.CsvParseException" );
417+ }
418+
416419}
Original file line number Diff line number Diff line change 1313import static java .nio .charset .StandardCharsets .UTF_8 ;
1414import static org .assertj .core .api .Assertions .assertThat ;
1515import static org .junit .jupiter .api .Assertions .assertThrows ;
16+ import static org .junit .jupiter .params .provider .CsvArgumentsProviderTests .isCsvParseException ;
1617import static org .junit .jupiter .params .provider .MockCsvAnnotationBuilder .csvFileSource ;
1718import static org .mockito .Mockito .doCallRealMethod ;
1819import static org .mockito .Mockito .mock ;
@@ -393,8 +394,7 @@ void throwsExceptionForInvalidCsvFormat() {
393394
394395 assertThat (exception )//
395396 .hasMessageStartingWith ("Failed to parse CSV input configured via Mock for CsvFileSource" )//
396- .rootCause ()//
397- .satisfies (ex -> ex .getClass ().getName ().contains ("de.siegmar.fastcsv.reader.CsvParseException" ));
397+ .rootCause ().satisfies (isCsvParseException ());
398398 }
399399
400400 @ Test
@@ -497,8 +497,7 @@ void throwsExceptionForExceedsMaxCharsFileWithDefaultConfig(@TempDir Path tempDi
497497
498498 assertThat (exception )//
499499 .hasMessageStartingWith ("Failed to parse CSV input configured via Mock for CsvFileSource" )//
500- .rootCause ()//
501- .satisfies (ex -> ex .getClass ().getName ().contains ("de.siegmar.fastcsv.reader.CsvParseException" ));
500+ .rootCause ().satisfies (isCsvParseException ());
502501 }
503502
504503 @ Test
You can’t perform that action at this time.
0 commit comments