@@ -73,39 +73,32 @@ void call_withInvalidScalarDBConfigurationFile_shouldReturnOne() throws Exceptio
7373
7474 @ Test
7575 void call_withBothStartExclusiveAndStartInclusive_shouldThrowException () {
76- // Simulate command line parsing with both deprecated and new options
77- String [] args = {
78- "--config" ,
79- "scalardb.properties" ,
80- "--namespace" ,
81- "scalar" ,
82- "--table" ,
83- "asset" ,
84- "--format" ,
85- "JSON" ,
86- "--start-exclusive=false" ,
87- "--start-inclusive=false"
88- };
89- ExportCommand command = new ExportCommand ();
90- CommandLine cmd = new CommandLine (command );
91- // Parse args - this will trigger our validation
92- cmd .parseArgs (args );
93-
94- // Now call the command, which should throw the validation error
95- CommandLine .ParameterException thrown =
96- assertThrows (
97- CommandLine .ParameterException .class ,
98- command ::call ,
99- "Expected to throw ParameterException when both deprecated and new options are specified" );
100- assertTrue (
101- thrown
102- .getMessage ()
103- .contains (
104- "Cannot specify both deprecated option '--start-exclusive' and new option '--start-inclusive'" ));
76+ assertBothDeprecatedAndNewOptionsThrowException (
77+ "--start-exclusive=false" ,
78+ "--start-inclusive=false" ,
79+ "--start-exclusive" ,
80+ "--start-inclusive" );
10581 }
10682
10783 @ Test
10884 void call_withBothEndExclusiveAndEndInclusive_shouldThrowException () {
85+ assertBothDeprecatedAndNewOptionsThrowException (
86+ "--end-exclusive=false" , "--end-inclusive=false" , "--end-exclusive" , "--end-inclusive" );
87+ }
88+
89+ /**
90+ * Helper method to test that using both deprecated and new options together throws an exception.
91+ *
92+ * @param deprecatedOptionArg the deprecated option with value (e.g., "--start-exclusive=false")
93+ * @param newOptionArg the new option with value (e.g., "--start-inclusive=false")
94+ * @param deprecatedOptionName the deprecated option name for error message verification
95+ * @param newOptionName the new option name for error message verification
96+ */
97+ private void assertBothDeprecatedAndNewOptionsThrowException (
98+ String deprecatedOptionArg ,
99+ String newOptionArg ,
100+ String deprecatedOptionName ,
101+ String newOptionName ) {
109102 // Simulate command line parsing with both deprecated and new options
110103 String [] args = {
111104 "--config" ,
@@ -116,12 +109,11 @@ void call_withBothEndExclusiveAndEndInclusive_shouldThrowException() {
116109 "asset" ,
117110 "--format" ,
118111 "JSON" ,
119- "--end-exclusive=false" ,
120- "--end-inclusive=false"
112+ deprecatedOptionArg ,
113+ newOptionArg
121114 };
122115 ExportCommand command = new ExportCommand ();
123116 CommandLine cmd = new CommandLine (command );
124- // Parse args - this will trigger our validation
125117 cmd .parseArgs (args );
126118
127119 // Now call the command, which should throw the validation error
@@ -134,7 +126,11 @@ void call_withBothEndExclusiveAndEndInclusive_shouldThrowException() {
134126 thrown
135127 .getMessage ()
136128 .contains (
137- "Cannot specify both deprecated option '--end-exclusive' and new option '--end-inclusive'" ));
129+ "Cannot specify both deprecated option '"
130+ + deprecatedOptionName
131+ + "' and new option '"
132+ + newOptionName
133+ + "'" ));
138134 }
139135
140136 @ Test
0 commit comments