11package com .scalar .db .dataloader .cli .command .dataexport ;
22
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
34import static org .junit .jupiter .api .Assertions .assertThrows ;
5+ import static org .junit .jupiter .api .Assertions .assertTrue ;
46
57import com .scalar .db .dataloader .core .DataLoaderError ;
68import com .scalar .db .dataloader .core .FileFormat ;
79import java .io .File ;
810import java .nio .file .Paths ;
911import org .junit .jupiter .api .AfterEach ;
10- import org .junit .jupiter .api .Assertions ;
1112import org .junit .jupiter .api .BeforeEach ;
1213import org .junit .jupiter .api .Test ;
1314import picocli .CommandLine ;
@@ -54,8 +55,7 @@ void call_withBlankScalarDBConfigurationFile_shouldThrowException() {
5455 IllegalArgumentException .class ,
5556 exportCommand ::call ,
5657 "Expected to throw FileNotFound exception as configuration path is invalid" );
57- Assertions .assertEquals (
58- DataLoaderError .CONFIG_FILE_PATH_BLANK .buildMessage (), thrown .getMessage ());
58+ assertEquals (DataLoaderError .CONFIG_FILE_PATH_BLANK .buildMessage (), thrown .getMessage ());
5959 }
6060
6161 @ Test
@@ -68,7 +68,7 @@ void call_withInvalidScalarDBConfigurationFile_shouldReturnOne() throws Exceptio
6868 exportCommand .outputDirectory = "" ;
6969 exportCommand .outputFileName = "sample.json" ;
7070 exportCommand .outputFormat = FileFormat .JSON ;
71- Assertions . assertEquals (1 , exportCommand .call ());
71+ assertEquals (1 , exportCommand .call ());
7272 }
7373
7474 @ Test
@@ -97,7 +97,7 @@ void call_withBothStartExclusiveAndStartInclusive_shouldThrowException() {
9797 CommandLine .ParameterException .class ,
9898 command ::call ,
9999 "Expected to throw ParameterException when both deprecated and new options are specified" );
100- Assertions . assertTrue (
100+ assertTrue (
101101 thrown
102102 .getMessage ()
103103 .contains (
@@ -130,10 +130,68 @@ void call_withBothEndExclusiveAndEndInclusive_shouldThrowException() {
130130 CommandLine .ParameterException .class ,
131131 command ::call ,
132132 "Expected to throw ParameterException when both deprecated and new options are specified" );
133- Assertions . assertTrue (
133+ assertTrue (
134134 thrown
135135 .getMessage ()
136136 .contains (
137137 "Cannot specify both deprecated option '--end-exclusive' and new option '--end-inclusive'" ));
138138 }
139+
140+ @ Test
141+ void call_withOnlyDeprecatedStartExclusive_shouldApplyInvertedValue () {
142+ // Simulate command line parsing with only deprecated option
143+ String [] args = {
144+ "--config" ,
145+ "scalardb.properties" ,
146+ "--namespace" ,
147+ "scalar" ,
148+ "--table" ,
149+ "asset" ,
150+ "--format" ,
151+ "JSON" ,
152+ "--start-exclusive=true"
153+ };
154+ ExportCommand command = new ExportCommand ();
155+ CommandLine cmd = new CommandLine (command );
156+ cmd .parseArgs (args );
157+
158+ // Verify the deprecated value was parsed
159+ assertEquals (true , command .startExclusiveDeprecated );
160+
161+ // Apply deprecated options (this is what the command does after validation)
162+ command .applyDeprecatedOptions ();
163+
164+ // Verify the value was applied with inverted logic
165+ // start-exclusive=true should become start-inclusive=false
166+ assertEquals (false , command .scanStartInclusive );
167+ }
168+
169+ @ Test
170+ void call_withOnlyDeprecatedEndExclusive_shouldApplyInvertedValue () {
171+ // Simulate command line parsing with only deprecated option
172+ String [] args = {
173+ "--config" ,
174+ "scalardb.properties" ,
175+ "--namespace" ,
176+ "scalar" ,
177+ "--table" ,
178+ "asset" ,
179+ "--format" ,
180+ "JSON" ,
181+ "--end-exclusive=false"
182+ };
183+ ExportCommand command = new ExportCommand ();
184+ CommandLine cmd = new CommandLine (command );
185+ cmd .parseArgs (args );
186+
187+ // Verify the deprecated value was parsed
188+ assertEquals (false , command .endExclusiveDeprecated );
189+
190+ // Apply deprecated options (this is what the command does after validation)
191+ command .applyDeprecatedOptions ();
192+
193+ // Verify the value was applied with inverted logic
194+ // end-exclusive=false should become end-inclusive=true
195+ assertEquals (true , command .scanEndInclusive );
196+ }
139197}
0 commit comments