15
15
*/
16
16
package picocli ;
17
17
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 ;
34
27
35
28
import java .io .BufferedReader ;
36
29
import java .io .File ;
53
46
import java .util .Scanner ;
54
47
import java .util .concurrent .TimeUnit ;
55
48
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 ;
61
66
62
67
/**
63
68
* Tests the scripts generated by AutoComplete.
@@ -93,7 +98,7 @@ public void run() {
93
98
public void basic () throws Exception {
94
99
String script = AutoComplete .bash ("basicExample" , new CommandLine (new BasicExample ()));
95
100
String expected = format (loadTextFromClasspath ("/basic.bash" ),
96
- CommandLine .VERSION , spaced ( TimeUnit .values ()));
101
+ CommandLine .VERSION , concat ( " \" \" " , TimeUnit .values ()));
97
102
assertEquals (expected , script );
98
103
}
99
104
@@ -188,7 +193,7 @@ public void nestedSubcommands() throws Exception {
188
193
);
189
194
String script = AutoComplete .bash ("picocompletion-demo" , hierarchy );
190
195
String expected = format (loadTextFromClasspath ("/picocompletion-demo_completion.bash" ),
191
- CommandLine .VERSION , spaced ( TimeUnit .values ()));
196
+ CommandLine .VERSION , concat ( " \" \" " , TimeUnit .values ()));
192
197
assertEquals (expected , script );
193
198
}
194
199
@@ -204,16 +209,16 @@ public void helpCommand() {
204
209
.addSubcommand (new CommandLine .HelpCommand ());
205
210
String script = AutoComplete .bash ("picocompletion-demo-help" , hierarchy );
206
211
String expected = format (loadTextFromClasspath ("/picocompletion-demo-help_completion.bash" ),
207
- CommandLine .VERSION , spaced ( TimeUnit .values ()));
212
+ CommandLine .VERSION , concat ( " \" \" " , TimeUnit .values ()));
208
213
assertEquals (expected , script );
209
214
}
210
215
211
- private static String spaced ( Object [] values ) {
216
+ private static String concat ( String infix , Object [] values ) {
212
217
StringBuilder result = new StringBuilder ();
213
218
for (Object value : values ) {
214
- result .append (value ).append (' ' );
219
+ result .append (value ).append (infix );
215
220
}
216
- return result .toString ().substring (0 , result .length () - 1 );
221
+ return result .toString ().substring (0 , result .length () - infix . length () );
217
222
}
218
223
219
224
static String loadTextFromClasspath (String path ) {
0 commit comments