1515 */
1616package picocli ;
1717
18- import org .hamcrest .MatcherAssert ;
19- import org .junit .Rule ;
20- import org .junit .Test ;
21- import org .junit .contrib .java .lang .system .Assertion ;
22- import org .junit .contrib .java .lang .system .ExpectedSystemExit ;
23- import org .junit .contrib .java .lang .system .ProvideSystemProperty ;
24- import org .junit .contrib .java .lang .system .RestoreSystemProperties ;
25- import org .junit .contrib .java .lang .system .SystemErrRule ;
26- import org .junit .contrib .java .lang .system .SystemOutRule ;
27- import org .junit .rules .TestRule ;
28- import picocli .CommandLine .Command ;
29- import picocli .CommandLine .Model .CommandSpec ;
30- import picocli .CommandLine .Model .OptionSpec ;
31- import picocli .CommandLine .Model .PositionalParamSpec ;
32- import picocli .CommandLine .Option ;
33- import picocli .CommandLine .Parameters ;
18+ import static java .lang .String .format ;
19+ import static org .hamcrest .CoreMatchers .containsString ;
20+ import static org .hamcrest .CoreMatchers .not ;
21+ import static org .hamcrest .MatcherAssert .assertThat ;
22+ import static org .junit .Assert .assertEquals ;
23+ import static org .junit .Assert .assertFalse ;
24+ import static org .junit .Assert .assertNotEquals ;
25+ import static org .junit .Assert .assertTrue ;
26+ import static org .junit .Assert .fail ;
3427
3528import java .io .BufferedReader ;
3629import java .io .File ;
5346import java .util .Scanner ;
5447import java .util .concurrent .TimeUnit ;
5548
56- import static java .lang .String .format ;
57- import static org .hamcrest .CoreMatchers .containsString ;
58- import static org .hamcrest .CoreMatchers .not ;
59- import static org .hamcrest .MatcherAssert .assertThat ;
60- import static org .junit .Assert .*;
49+ import org .hamcrest .MatcherAssert ;
50+ import org .junit .Rule ;
51+ import org .junit .Test ;
52+ import org .junit .contrib .java .lang .system .Assertion ;
53+ import org .junit .contrib .java .lang .system .ExpectedSystemExit ;
54+ import org .junit .contrib .java .lang .system .ProvideSystemProperty ;
55+ import org .junit .contrib .java .lang .system .RestoreSystemProperties ;
56+ import org .junit .contrib .java .lang .system .SystemErrRule ;
57+ import org .junit .contrib .java .lang .system .SystemOutRule ;
58+ import org .junit .rules .TestRule ;
59+
60+ import picocli .CommandLine .Command ;
61+ import picocli .CommandLine .Model .CommandSpec ;
62+ import picocli .CommandLine .Model .OptionSpec ;
63+ import picocli .CommandLine .Model .PositionalParamSpec ;
64+ import picocli .CommandLine .Option ;
65+ import picocli .CommandLine .Parameters ;
6166
6267/**
6368 * Tests the scripts generated by AutoComplete.
@@ -93,7 +98,7 @@ public void run() {
9398 public void basic () throws Exception {
9499 String script = AutoComplete .bash ("basicExample" , new CommandLine (new BasicExample ()));
95100 String expected = format (loadTextFromClasspath ("/basic.bash" ),
96- CommandLine .VERSION , spaced ( TimeUnit .values ()));
101+ CommandLine .VERSION , concat ( " \" \" " , TimeUnit .values ()));
97102 assertEquals (expected , script );
98103 }
99104
@@ -188,7 +193,7 @@ public void nestedSubcommands() throws Exception {
188193 );
189194 String script = AutoComplete .bash ("picocompletion-demo" , hierarchy );
190195 String expected = format (loadTextFromClasspath ("/picocompletion-demo_completion.bash" ),
191- CommandLine .VERSION , spaced ( TimeUnit .values ()));
196+ CommandLine .VERSION , concat ( " \" \" " , TimeUnit .values ()));
192197 assertEquals (expected , script );
193198 }
194199
@@ -204,16 +209,16 @@ public void helpCommand() {
204209 .addSubcommand (new CommandLine .HelpCommand ());
205210 String script = AutoComplete .bash ("picocompletion-demo-help" , hierarchy );
206211 String expected = format (loadTextFromClasspath ("/picocompletion-demo-help_completion.bash" ),
207- CommandLine .VERSION , spaced ( TimeUnit .values ()));
212+ CommandLine .VERSION , concat ( " \" \" " , TimeUnit .values ()));
208213 assertEquals (expected , script );
209214 }
210215
211- private static String spaced ( Object [] values ) {
216+ private static String concat ( String infix , Object [] values ) {
212217 StringBuilder result = new StringBuilder ();
213218 for (Object value : values ) {
214- result .append (value ).append (' ' );
219+ result .append (value ).append (infix );
215220 }
216- return result .toString ().substring (0 , result .length () - 1 );
221+ return result .toString ().substring (0 , result .length () - infix . length () );
217222 }
218223
219224 static String loadTextFromClasspath (String path ) {
0 commit comments