1818import static com .google .common .truth .Truth .assertThat ;
1919
2020import com .google .common .collect .ImmutableList ;
21+ import java .util .Arrays ;
22+ import java .util .Collection ;
2123import org .junit .Before ;
2224import org .junit .Test ;
2325import org .junit .runner .RunWith ;
24- import org .junit .runners .JUnit4 ;
26+ import org .junit .runners .Parameterized ;
2527import org .mobilitydata .gtfsvalidator .notice .MixedCaseRecommendedFieldNotice ;
2628import org .mobilitydata .gtfsvalidator .table .MixedCaseTest ;
2729import org .mobilitydata .gtfsvalidator .table .MixedCaseTestTableDescriptor ;
3032import org .mobilitydata .gtfsvalidator .validator .ValidatorLoader ;
3133import org .mobilitydata .gtfsvalidator .validator .ValidatorLoaderException ;
3234
33- @ RunWith (JUnit4 .class )
35+ @ RunWith (Parameterized .class )
3436public class MixedCaseSchemaTest {
37+ private final String value ;
38+ private final boolean isValid ;
39+
40+ public MixedCaseSchemaTest (String value , boolean isValid ) {
41+ this .value = value ;
42+ this .isValid = isValid ;
43+ }
3544
3645 private MixedCaseTestTableDescriptor tableDescriptor ;
3746 private LoadingHelper helper ;
@@ -44,29 +53,54 @@ public void setup() throws ValidatorLoaderException {
4453 ValidatorLoader .createForClasses (ImmutableList .of (MixedCaseTestMixedCaseValidator .class )));
4554 }
4655
47- @ Test
48- public void testValidMixedCase () throws ValidatorLoaderException {
49-
50- String [] validValues = {
51- "MixedCase" , "Mixed-Case" , "Mixed_Case" , "Mixed Case" , "Another good value"
52- };
53-
54- for (String value : validValues ) {
55- helper .load (tableDescriptor , MixedCaseTest .SOME_FIELD_FIELD_NAME , value );
56-
57- assertThat (helper .getValidationNotices ()).isEmpty ();
58- }
56+ @ Parameterized .Parameters
57+ public static Collection <Object []> data () {
58+ return Arrays .asList (
59+ new Object [][] {
60+ // valid values
61+ {"Mixed-Case" , true },
62+ {"Mixed_Case" , true },
63+ {"Mixed Case" , true },
64+ {"22222" , true },
65+ {"A1" , true },
66+ {"ZA112" , true },
67+ {"301" , true },
68+ {"RTE 30" , true },
69+ {"급 행 12" , true },
70+ {"급행12" , true },
71+ {"東西線" , true },
72+ {"101B" , true },
73+ {"A14C" , true },
74+ {"A14c" , true },
75+ {"A14-C" , true },
76+ {"A14_C" , true },
77+ {"A14 C" , true },
78+ {"Route 1" , true },
79+ {"Route 1 Boulevard" , true },
80+ {"ZA12" , true },
81+ {"Avenue des Champs-Élysées" , true },
82+ {"UPPERCASE" , true },
83+ {"ROUTE 22" , true },
84+ {"ROUTE 1" , true },
85+ {"route 1 Boulevard" , true },
86+ {"Sentences are ok with one mixed case word" , true },
87+ {"MixedCaseButSingleWord" , true },
88+ // invalid values
89+ {"lowercase" , false },
90+ {"snake_case" , false },
91+ {"kebab-case" , false },
92+ {"UPPER-CASE" , false },
93+ {"lower case space" , false },
94+ {"34broadst" , false },
95+ });
5996 }
6097
6198 @ Test
62- public void testInvalidMixedCases () throws ValidatorLoaderException {
63- String [] invalidValues = {
64- "lowercase" , "UPPERCASE" , "snake_case" , "kebab-case" , "UPPER-CASE" , "lower case space"
65- };
66-
67- for (String value : invalidValues ) {
68- helper .load (tableDescriptor , MixedCaseTest .SOME_FIELD_FIELD_NAME , value );
69-
99+ public void testMixedCase () throws ValidatorLoaderException {
100+ helper .load (tableDescriptor , MixedCaseTest .SOME_FIELD_FIELD_NAME , value );
101+ if (isValid ) {
102+ assertThat (helper .getValidationNotices ()).isEmpty ();
103+ } else {
70104 assertThat (helper .getValidationNotices ())
71105 .containsExactly (
72106 new MixedCaseRecommendedFieldNotice (
0 commit comments