-
Notifications
You must be signed in to change notification settings - Fork 683
/
GfshParserAutoCompletionIntegrationTest.java
604 lines (534 loc) · 25 KB
/
GfshParserAutoCompletionIntegrationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package org.apache.geode.management.internal.cli;
import static java.lang.System.lineSeparator;
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.stream.Collectors;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.shell.core.Completion;
import org.springframework.shell.core.annotation.CliOption;
import org.apache.geode.management.internal.cli.commands.StartServerCommand;
import org.apache.geode.management.internal.i18n.CliStrings;
import org.apache.geode.test.junit.categories.GfshTest;
import org.apache.geode.test.junit.rules.GfshParserRule;
import org.apache.geode.test.junit.rules.GfshParserRule.CommandCandidate;
@Category(GfshTest.class)
public class GfshParserAutoCompletionIntegrationTest {
private static int startServerCommandCliOptions = 0;
@BeforeClass
public static void calculateStartServerCommandParameters() {
Object o = new StartServerCommand();
for (Method method : o.getClass().getDeclaredMethods()) {
if (method.getName().equals("startServer")) {
for (Parameter param : method.getParameters()) {
CliOption annotation = param.getAnnotation(CliOption.class);
startServerCommandCliOptions += annotation.key().length;
}
break;
}
}
assertThat(startServerCommandCliOptions).isNotZero();
}
@AfterClass
public static void cleanup() {
startServerCommandCliOptions = 0;
}
@Rule
public GfshParserRule gfshParserRule = new GfshParserRule();
@Test
public void testCompletionDescribe() {
String buffer = "describe";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(9);
assertThat(candidate.getFirstCandidate()).isEqualTo("describe client");
}
@Test
public void testCompletionDescribeWithSpace() {
String buffer = "describe ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(9);
assertThat(candidate.getFirstCandidate()).isEqualTo("describe client");
}
@Test
public void testCompletionDeploy() {
String buffer = "deploy";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()
.stream().map(completion -> completion.getValue().trim()).collect(Collectors.toList()))
.containsExactlyInAnyOrder("--dir", "--jar", "--jars", "--group", "--groups",
"--dependencies");
}
@Test
public void testCompletionDeployWithSpace() {
String buffer = "deploy ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()
.stream().map(completion -> completion.getValue().trim()).collect(Collectors.toList()))
.containsExactlyInAnyOrder("--dir", "--jar", "--jars", "--group", "--groups",
"--dependencies");
}
@Test
public void testCompleteWithRequiredOption() {
String buffer = "describe config";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --member");
}
@Test
public void testCompleteWithRequiredOptionWithSpace() {
String buffer = "describe config ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--member");
}
@Test
public void testCompletionStart() {
String buffer = "start";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates().size()).isEqualTo(8);
assertThat(candidate.getCandidates().stream()
.anyMatch(completion -> completion.getFormattedValue().contains("gateway-receiver")))
.isTrue();
assertThat(candidate.getCandidates().stream()
.anyMatch(completion -> completion.getFormattedValue().contains("vsd")))
.isTrue();
}
@Test
public void testCompletionStartWithSpace() {
String buffer = "start ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates().size()).isEqualTo(8);
assertThat(candidate.getCandidates().stream()
.anyMatch(completion -> completion.getFormattedValue().contains("gateway-receiver")))
.isTrue();
assertThat(candidate.getCandidates().stream()
.anyMatch(completion -> completion.getFormattedValue().contains("vsd")))
.isTrue();
}
@Test
public void testCompleteCommand() {
String buffer = "start ser";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat("start server").isEqualTo(candidate.getFirstCandidate());
}
@Test
public void testCompleteOptionWithOnlyOneCandidate() {
String buffer = "start server --nam";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "e");
}
@Test
public void testCompleteOptionWithMultipleCandidates() {
String buffer = "start server --name=jinmei --loc";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(3);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "ator-wait-time");
assertThat(candidate.getCandidate(1)).isEqualTo(buffer + "ators");
assertThat(candidate.getCandidate(2)).isEqualTo(buffer + "k-memory");
}
@Test
public void testCompleteWithExtraSpace() {
String buffer = "start server --name=name1 --se";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo("start server --name=name1 ".length());
assertThat(candidate.getCandidates()).hasSize(3);
assertThat(candidate.getCandidates()).contains(new Completion("--server-port"));
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "curity-properties-file");
}
@Test
public void testCompleteWithDashInTheEnd() {
String buffer = "start server --name=name1 --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 2);
assertThat(candidate.getCandidates()).hasSize(startServerCommandCliOptions - 1);
assertThat(candidate.getCandidates()).contains(new Completion("--properties-file"));
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "J");
}
@Test
public void testCompleteWithSpace() {
String buffer = "start server --name=name1 ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 1);
assertThat(candidate.getCandidates()).hasSize(startServerCommandCliOptions - 1);
assertThat(candidate.getCandidates()).contains(new Completion(" --properties-file"));
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--J");
}
@Test
public void testCompleteWithOutSpace() {
String buffer = "start server --name=name1";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length());
assertThat(candidate.getCandidates()).hasSize(startServerCommandCliOptions - 1);
assertThat(candidate.getCandidates()).contains(new Completion(" --properties-file"));
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --J");
}
@Test
public void testCompleteJ() {
String buffer = "start server --name=name1 --J=";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 3);
assertThat(candidate.getCandidates()).hasSize(1);
}
@Test
public void testCompleteWithValue() {
String buffer = "start server --name=name1 --J";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 3);
assertThat(candidate.getCandidates()).hasSize(1);
}
@Test
public void testCompleteWithDash() {
String buffer = "start server --name=name1 --J=-Dfoo.bar --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(startServerCommandCliOptions - 2);
}
@Test
public void testCompleteWithMultipleJ() {
String buffer = "start server --name=name1 --J=-Dme=her --J=-Dfoo=bar --l";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor())
.isEqualTo("start server --name=name1 --J=-Dme=her --J=-Dfoo=bar ".length());
assertThat(candidate.getCandidates()).hasSize(4);
assertThat(candidate.getCandidates()).contains(new Completion("--locators"));
}
@Test
public void testMultiJComplete() {
String buffer = "start server --name=name1 --J=-Dtest=test1 --J=-Dfoo=bar";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length());
assertThat(candidate.getCandidates()).hasSize(startServerCommandCliOptions - 2);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --assign-buckets");
}
@Test
public void testMultiJCompleteWithDifferentOrder() {
String buffer = "start server --J=-Dtest=test1 --J=-Dfoo=bar --name=name1";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length());
assertThat(candidate.getCandidates()).hasSize(startServerCommandCliOptions - 2);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --assign-buckets");
}
@Test
public void testJComplete3() {
String buffer = "start server --name=name1 --locators=localhost --J=-Dfoo=bar";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length());
assertThat(candidate.getCandidates()).hasSize(startServerCommandCliOptions - 3);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --assign-buckets");
}
@Test
public void testJComplete4() {
String buffer = "start server --name=name1 --locators=localhost --J=-Dfoo=bar --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 2);
assertThat(candidate.getCandidates()).hasSize(startServerCommandCliOptions - 3);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "assign-buckets");
}
@Test
public void testCompleteRegionType() {
String buffer = "create region --name=test --type";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(23);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "=LOCAL");
}
@Test
public void testCompletePartialRegionType() {
String buffer = "create region --name=test --type=LO";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(5);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "CAL");
}
@Test
public void testCompleteWithRegionTypeWithNoSpace() {
String buffer = "create region --name=test --type=REPLICATE";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(5);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "_HEAP_LRU");
}
@Test
public void testCompleteWithRegionTypeWithSpace() {
String buffer = "create region --name=test --type=REPLICATE ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(45);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--async-event-queue-id");
}
@Test
public void testCompleteLogLevel() {
String buffer = "change loglevel --loglevel";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(8);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "=ALL");
}
@Test
public void testCompleteLogLevelWithEqualSign() {
String buffer = "change loglevel --loglevel=";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(8);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "ALL");
}
@Test
public void testCompleteHintNonexistemt() {
String buffer = "hint notfound";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(0);
}
@Test
public void testCompleteHintNada() {
String buffer = "hint";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates().size()).isGreaterThan(10);
assertThat(candidate.getFirstCandidate()).isEqualToIgnoringCase("hint client");
}
@Test
public void testCompleteHintSpace() {
String buffer = "hint ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates().size()).isGreaterThan(10);
assertThat(candidate.getFirstCandidate()).isEqualToIgnoringCase("hint client");
}
@Test
public void testCompleteHintPartial() {
String buffer = "hint d";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(3);
assertThat(candidate.getFirstCandidate()).isEqualToIgnoringCase("hint data");
}
@Test
public void testCompleteHintAlreadyComplete() {
String buffer = "hint data";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualToIgnoringCase(buffer);
}
@Test
public void testCompleteHelpFirstWord() {
String buffer = "help start";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(8);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " gateway-receiver");
}
@Test
public void testCompleteHelpPartialFirstWord() {
String buffer = "help st";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(18);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "art gateway-receiver");
}
@Test
public void testObtainHelp() {
String command = CliStrings.START_PULSE;
String helpString = "NAME" + lineSeparator() + "start pulse" + lineSeparator() + "IS AVAILABLE"
+ lineSeparator() + "true" + lineSeparator() + "SYNOPSIS" + lineSeparator()
+ "Open a new window in the default Web browser with the URL for the Pulse application."
+ lineSeparator()
+ "SYNTAX" + lineSeparator() + "start pulse [--url=value]" + lineSeparator() + "PARAMETERS"
+ lineSeparator() + "url" + lineSeparator()
+ "URL of the Pulse Web application." + lineSeparator() + "Required: false"
+ lineSeparator()
+ "Default (if the parameter is not specified): http://localhost:7070/pulse"
+ lineSeparator();
assertThat(gfshParserRule.getCommandManager().obtainHelp(command)).isEqualTo(helpString);
}
@Test
public void testObtainHelpForStart() {
String command = "start";
String helpProvided = gfshParserRule.getCommandManager().getHelper().getHelp(command, 1000);
String[] helpProvidedArray = helpProvided.split(lineSeparator());
assertThat(helpProvidedArray.length).isEqualTo(8 * 2 + 3);
for (int i = 0; i < helpProvidedArray.length - 3; i++) {
if (i % 2 != 0) {
assertThat(helpProvidedArray[i]).startsWith(" ");
} else {
assertThat(helpProvidedArray[i]).startsWith(command);
}
}
}
@Test
public void testObtainHintForData() {
String hintArgument = "data";
String hintsProvided = gfshParserRule.getCommandManager().obtainHint(hintArgument);
String[] hintsProvidedArray = hintsProvided.split(lineSeparator());
assertThat(hintsProvidedArray.length).isEqualTo(17);
assertThat(hintsProvidedArray[0])
.isEqualTo("User data as stored in regions of the Geode distributed system.");
}
@Test
public void testObtainHintWithoutArgument() {
String hintArgument = "";
String hintsProvided = gfshParserRule.getCommandManager().obtainHint(hintArgument);
String[] hintsProvidedArray = hintsProvided.split(lineSeparator());
assertThat(hintsProvidedArray.length).isEqualTo(21);
assertThat(hintsProvidedArray[0]).isEqualTo(
"Hints are available for the following topics. Use \"hint <topic-name>\" for a specific hint.");
}
@Test
public void testObtainHintWithNonExistingCommand() {
String hintArgument = "fortytwo";
String hintsProvided = gfshParserRule.getCommandManager().obtainHint(hintArgument);
String[] hintsProvidedArray = hintsProvided.split(lineSeparator());
assertThat(hintsProvidedArray.length).isEqualTo(1);
assertThat(hintsProvidedArray[0]).isEqualTo(
"Unknown topic: " + hintArgument + ". Use hint to view the list of available topics.");
}
@Test
public void testObtainHintWithPartialCommand() {
String hintArgument = "d";
String hintsProvided = gfshParserRule.getCommandManager().obtainHint(hintArgument);
System.out.println(hintsProvided);
String[] hintsProvidedArray = hintsProvided.split(lineSeparator());
assertThat(hintsProvidedArray.length).isEqualTo(5);
assertThat(hintsProvidedArray[0]).isEqualTo(
"Hints are available for the following topics. Use \"hint <topic-name>\" for a specific hint.");
assertThat(hintsProvidedArray).contains("Data");
assertThat(hintsProvidedArray).contains("Debug-Utility");
assertThat(hintsProvidedArray).contains("Disk Store");
}
@Test
@SuppressWarnings("deprecation")
public void testIndexType() {
String buffer = "create index --type=";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates())
.hasSize(org.apache.geode.cache.query.IndexType.values().length);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "hash");
}
@Test
public void testCompletionOffersMandatoryOptionsInAlphabeticalOrderForCreateGatewaySenderWithSpace() {
String buffer = "create gateway-sender ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(2);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--id");
assertThat(candidate.getCandidates().get(1).getValue())
.isEqualTo(buffer + "--remote-distributed-system-id");
}
@Test
public void testCompletionOffersTheFirstMandatoryOptionInAlphabeticalOrderForCreateGatewaySenderWithDash() {
String buffer = "create gateway-sender --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "id");
}
@Test
public void testCompletionOffersMandatoryOptionsInAlphabeticalOrderForChangeLogLevelWithSpace() {
String buffer = "change loglevel ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--loglevel");
}
@Test
public void testCompletionOffersTheFirstMandatoryOptionInAlphabeticalOrderForChangeLogLevelWithDash() {
String buffer = "change loglevel --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "loglevel");
}
@Test
public void testCompletionOffersMandatoryOptionsInAlphabeticalOrderForCreateDiskStoreWithSpace() {
String buffer = "create disk-store ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(2);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--dir");
assertThat(candidate.getCandidate(1)).isEqualTo(buffer + "--name");
}
@Test
public void testCompletionOffersTheFirstMandatoryOptionInAlphabeticalOrderForCreateDiskStoreWithDash() {
String buffer = "create disk-store --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "dir");
}
@Test
public void testCompletionOffersMandatoryOptionsInAlphabeticalOrderForCreateJndiBindingWithSpace() {
String buffer = "create jndi-binding ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(3);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--connection-url");
assertThat(candidate.getCandidate(1)).isEqualTo(buffer + "--name");
assertThat(candidate.getCandidate(2)).isEqualTo(buffer + "--url");
}
@Test
public void testCompletionOffersTheFirstMandatoryOptionInAlphabeticalOrderForCreateJndiBindingWithDash() {
String buffer = "create jndi-binding --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(2);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "connection-url");
assertThat(candidate.getCandidate(1)).isEqualTo(buffer + "url");
}
@Test
public void testCompletionOffersMandatoryOptionsInAlphabeticalOrderForDestroyGwSenderWithSpace() {
String buffer = "destroy gateway-sender ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--id");
}
@Test
public void testCompletionOffersTheFirstMandatoryOptionInAlphabeticalOrderForDestroyGwSenderWithDash() {
String buffer = "destroy gateway-sender --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "id");
}
@Test
public void testCompletionOffersMandatoryOptionsInAlphabeticalOrderForExportDataWithSpace() {
String buffer = "export data ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(2);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--member");
assertThat(candidate.getCandidate(1)).isEqualTo(buffer + "--region");
}
@Test
public void testCompletionOffersTheFirstMandatoryOptionInAlphabeticalOrderForExportDataWithDash() {
String buffer = "export data --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "member");
}
@Test
public void testCompletionOffersMandatoryOptionsInAlphabeticalOrderForImportDataWithSpace() {
String buffer = "import data ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(2);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--member");
assertThat(candidate.getCandidate(1)).isEqualTo(buffer + "--region");
}
@Test
public void testCompletionOffersTheFirstMandatoryOptionInAlphabeticalOrderForImportDataWithDash() {
String buffer = "import data --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "member");
}
@Test
public void testCompletionOffersMandatoryOptionsInAlphabeticalOrderForRemoveWithSpace() {
String buffer = "remove ";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--region");
}
@Test
public void testCompletionOffersTheFirstMandatoryOptionInAlphabeticalOrderForRemoveWithDash() {
String buffer = "remove --";
CommandCandidate candidate = gfshParserRule.complete(buffer);
assertThat(candidate.getCandidates()).hasSize(1);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "region");
}
}