1919import static feast .core .validators .Matchers .checkLowerSnakeCase ;
2020import static feast .core .validators .Matchers .checkUpperSnakeCase ;
2121import static feast .core .validators .Matchers .checkValidClassPath ;
22+ import static org .junit .jupiter .api .Assertions .assertThrows ;
2223
2324import com .google .common .base .Strings ;
24- import org .junit .Rule ;
2525import org .junit .Test ;
26- import org .junit .rules .ExpectedException ;
2726
2827public class MatchersTest {
29- @ Rule public final ExpectedException exception = ExpectedException .none ();
3028
3129 @ Test
3230 public void checkUpperSnakeCaseShouldPassForLegitUpperSnakeCase () {
@@ -42,15 +40,15 @@ public void checkUpperSnakeCaseShouldPassForLegitUpperSnakeCaseWithNumbers() {
4240
4341 @ Test
4442 public void checkUpperSnakeCaseShouldThrowIllegalArgumentExceptionWithFieldForInvalidString () {
45- exception .expect (IllegalArgumentException .class );
46- exception .expectMessage (
43+ String in = "redis" ;
44+ assertThrows (
45+ IllegalArgumentException .class ,
46+ () -> checkUpperSnakeCase (in , "featuretable" ),
4747 Strings .lenientFormat (
4848 "invalid value for %s resource, %s: %s" ,
4949 "featuretable" ,
5050 "redis" ,
5151 "argument must be in upper snake case, and cannot include any special characters." ));
52- String in = "redis" ;
53- checkUpperSnakeCase (in , "featuretable" );
5452 }
5553
5654 @ Test
@@ -61,15 +59,15 @@ public void checkLowerSnakeCaseShouldPassForLegitLowerSnakeCase() {
6159
6260 @ Test
6361 public void checkLowerSnakeCaseShouldThrowIllegalArgumentExceptionWithFieldForInvalidString () {
64- exception .expect (IllegalArgumentException .class );
65- exception .expectMessage (
62+ String in = "Invalid_feature name" ;
63+ assertThrows (
64+ IllegalArgumentException .class ,
65+ () -> checkLowerSnakeCase (in , "feature" ),
6666 Strings .lenientFormat (
6767 "invalid value for %s resource, %s: %s" ,
6868 "feature" ,
6969 "Invalid_feature name" ,
7070 "argument must be in lower snake case, and cannot include any special characters." ));
71- String in = "Invalid_feature name" ;
72- checkLowerSnakeCase (in , "feature" );
7371 }
7472
7573 @ Test
@@ -80,13 +78,11 @@ public void checkValidClassPathSuccess() {
8078
8179 @ Test
8280 public void checkValidClassPathEmpty () {
83- exception .expect (IllegalArgumentException .class );
84- checkValidClassPath ("" , "FeatureTable" );
81+ assertThrows (IllegalArgumentException .class , () -> checkValidClassPath ("" , "FeatureTable" ));
8582 }
8683
8784 @ Test
8885 public void checkValidClassPathDigits () {
89- exception .expect (IllegalArgumentException .class );
90- checkValidClassPath ("123" , "FeatureTable" );
86+ assertThrows (IllegalArgumentException .class , () -> checkValidClassPath ("123" , "FeatureTable" ));
9187 }
9288}
0 commit comments