31
31
import static io .streamthoughts .kafka .connect .filepulse .fs .filter .DateInFilenameFileListFilterTest .Fixture .invalidCutoffDate ;
32
32
import static io .streamthoughts .kafka .connect .filepulse .fs .filter .DateInFilenameFileListFilterTest .Fixture .maxCutoffDate ;
33
33
import static io .streamthoughts .kafka .connect .filepulse .fs .filter .DateInFilenameFileListFilterTest .Fixture .minCutoffDate ;
34
- import static org .assertj .core .api .Assertions .assertThat ;
35
- import static org .assertj .core .api .Assertions .assertThatThrownBy ;
34
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
35
+ import static org .junit .jupiter .api .Assertions .assertNull ;
36
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
37
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
36
38
import static org .junit .jupiter .params .provider .Arguments .arguments ;
37
39
38
40
import io .streamthoughts .kafka .connect .filepulse .source .FileObjectMeta ;
@@ -52,10 +54,9 @@ class DateInFilenameFileListFilterTest {
52
54
@ Test
53
55
void when_pattern_empty_configure_should_throw_exception () {
54
56
DateInFilenameFileListFilter filter = new DateInFilenameFileListFilter ();
55
- assertThatThrownBy (() -> filter .configure (Map .of ()))
56
- .isInstanceOf (ConfigException .class )
57
- .hasMessageContaining (FILE_FILTER_DATE_REGEX_EXTRACTOR_PATTERN_CONFIG )
58
- .hasNoCause ();
57
+ ConfigException configException = assertThrows (ConfigException .class , () -> filter .configure (Map .of ()));
58
+ assertNull (configException .getCause ());
59
+ assertTrue (configException .getMessage ().contains (FILE_FILTER_DATE_REGEX_EXTRACTOR_PATTERN_CONFIG ));
59
60
}
60
61
61
62
@ Test
@@ -65,10 +66,9 @@ void when_date_min_invalid_configure_should_throw_exception() {
65
66
FILE_FILTER_DATE_MIN_DATE_CONFIG , invalidCutoffDate );
66
67
67
68
DateInFilenameFileListFilter filter = new DateInFilenameFileListFilter ();
68
- assertThatThrownBy (() -> filter .configure (configs ))
69
- .isInstanceOf (ConfigException .class )
70
- .hasMessageContaining (FILE_FILTER_DATE_MIN_DATE_CONFIG )
71
- .hasNoCause ();
69
+ ConfigException configException = assertThrows (ConfigException .class , () -> filter .configure (configs ));
70
+ assertNull (configException .getCause ());
71
+ assertTrue (configException .getMessage ().contains (FILE_FILTER_DATE_MIN_DATE_CONFIG ));
72
72
}
73
73
74
74
@ Test
@@ -78,10 +78,9 @@ void when_date_max_invalid_configure_should_throw_exception() {
78
78
FILE_FILTER_DATE_MAX_DATE_CONFIG , invalidCutoffDate );
79
79
80
80
DateInFilenameFileListFilter filter = new DateInFilenameFileListFilter ();
81
- assertThatThrownBy (() -> filter .configure (configs ))
82
- .isInstanceOf (ConfigException .class )
83
- .hasMessageContaining (FILE_FILTER_DATE_MAX_DATE_CONFIG )
84
- .hasNoCause ();
81
+ ConfigException configException = assertThrows (ConfigException .class , () -> filter .configure (configs ));
82
+ assertNull (configException .getCause ());
83
+ assertTrue (configException .getMessage ().contains (FILE_FILTER_DATE_MAX_DATE_CONFIG ));
85
84
}
86
85
87
86
@ Test
@@ -90,10 +89,9 @@ void when_neither_max_date_nor_min_date_provided_configure_should_throw_exceptio
90
89
Map .of (FILE_FILTER_DATE_REGEX_EXTRACTOR_PATTERN_CONFIG , dateExtractorRegex );
91
90
92
91
DateInFilenameFileListFilter filter = new DateInFilenameFileListFilter ();
93
- assertThatThrownBy (() -> filter .configure (configs ))
94
- .isInstanceOf (ConfigException .class )
95
- .hasMessageContaining ("At least one of" )
96
- .hasNoCause ();
92
+ ConfigException configException = assertThrows (ConfigException .class , () -> filter .configure (configs ));
93
+ assertNull (configException .getCause ());
94
+ assertTrue (configException .getMessage ().contains ("At least one of" ));
97
95
}
98
96
99
97
private DateInFilenameFileListFilter prepareFilter (String minCutoffDate , String maxCutoffDate ) {
@@ -122,7 +120,7 @@ void when_called_test_should_return_expected_value(Boolean expected,
122
120
String maxCutoffDate ) {
123
121
124
122
DateInFilenameFileListFilter filter = prepareFilter (minCutoffDate , maxCutoffDate );
125
- assertThat ( filter .test (meta )). isEqualTo ( expected );
123
+ assertEquals ( expected , filter .test (meta ));
126
124
}
127
125
128
126
public static Stream <Arguments > when_called_test_should_return_expected_value () {
0 commit comments