@@ -149,4 +149,84 @@ void call_withOnlyDeprecatedThreads_shouldApplyValue() throws Exception {
149149 // Verify the value was applied to maxThreads
150150 assertEquals (12 , command .maxThreads );
151151 }
152+
153+ @ Test
154+ void call_withBothLogSuccessAndEnableLogSuccess_shouldThrowException () throws Exception {
155+ Path configFile = tempDir .resolve ("config.properties" );
156+ Files .createFile (configFile );
157+ Path importFile = tempDir .resolve ("import.json" );
158+ Files .createFile (importFile );
159+
160+ // Simulate command line parsing with both deprecated and new options
161+ String [] args = {"--file" , importFile .toString (), "--log-success" , "--enable-log-success" };
162+ ImportCommand command = new ImportCommand ();
163+ CommandLine cmd = new CommandLine (command );
164+ // Parse args - this will trigger our validation
165+ cmd .parseArgs (args );
166+
167+ // Now call the command, which should throw the validation error
168+ CommandLine .ParameterException thrown =
169+ assertThrows (
170+ CommandLine .ParameterException .class ,
171+ command ::call ,
172+ "Expected to throw ParameterException when both deprecated and new options are specified" );
173+ assertTrue (
174+ thrown
175+ .getMessage ()
176+ .contains (
177+ "Cannot specify both deprecated option '--log-success' and new option '--enable-log-success'" ));
178+ }
179+
180+ @ Test
181+ void call_withOnlyDeprecatedLogSuccess_shouldApplyValue () throws Exception {
182+ Path configFile = tempDir .resolve ("config.properties" );
183+ Files .createFile (configFile );
184+ Path importFile = tempDir .resolve ("import.json" );
185+ Files .createFile (importFile );
186+
187+ // Simulate command line parsing with only deprecated option
188+ String [] args = {"--file" , importFile .toString (), "--log-success" };
189+ ImportCommand command = new ImportCommand ();
190+ CommandLine cmd = new CommandLine (command );
191+ cmd .parseArgs (args );
192+
193+ // Verify the deprecated value was parsed
194+ assertTrue (command .logSuccessRecordsDeprecated );
195+
196+ // Apply deprecated options (this is what the command does after validation)
197+ command .applyDeprecatedOptions ();
198+
199+ // Verify the value was applied to enable-log-success
200+ assertTrue (command .enableLogSuccessRecords );
201+ }
202+
203+ @ Test
204+ void call_withEnableLogSuccess_shouldSetToTrueWithoutValue () throws Exception {
205+ Path importFile = tempDir .resolve ("import.json" );
206+ Files .createFile (importFile );
207+
208+ // Simulate command line parsing with the new flag without providing true/false value
209+ String [] args = {"--file" , importFile .toString (), "--enable-log-success" };
210+ ImportCommand command = new ImportCommand ();
211+ CommandLine cmd = new CommandLine (command );
212+ cmd .parseArgs (args );
213+
214+ // Verify the flag was parsed correctly without requiring a value
215+ assertTrue (command .enableLogSuccessRecords );
216+ }
217+
218+ @ Test
219+ void call_withEnableLogSuccessShortForm_shouldSetToTrueWithoutValue () throws Exception {
220+ Path importFile = tempDir .resolve ("import.json" );
221+ Files .createFile (importFile );
222+
223+ // Simulate command line parsing with the short form flag without providing true/false value
224+ String [] args = {"--file" , importFile .toString (), "-ls" };
225+ ImportCommand command = new ImportCommand ();
226+ CommandLine cmd = new CommandLine (command );
227+ cmd .parseArgs (args );
228+
229+ // Verify the short form flag was parsed correctly without requiring a value
230+ assertTrue (command .enableLogSuccessRecords );
231+ }
152232}
0 commit comments