@@ -69,7 +69,7 @@ else if ("last".equals(option.longName()) || 'l' == option.shortName()) {
6969 };
7070
7171 @ BeforeEach
72- public void before () {
72+ void before () {
7373 command = mock (Command .class );
7474 when (command .getName ()).thenReturn ("hello" );
7575 when (command .getDescription ()).thenReturn ("Says Hello." );
@@ -88,7 +88,7 @@ private List<String> toCandidateDisplayText(List<Candidate> candidates) {
8888
8989 @ ParameterizedTest
9090 @ MethodSource ("completeData" )
91- public void testComplete (List <String > words , List <String > expectedValues ) {
91+ void testComplete (List <String > words , List <String > expectedValues ) {
9292 // given
9393 when (command .getOptions ())
9494 .thenReturn (List .of (new CommandOption .Builder ().longName ("first" ).shortName ('f' ).build (),
@@ -176,7 +176,7 @@ static Stream<Arguments> completeData() {
176176
177177 @ ParameterizedTest
178178 @ MethodSource ("completeCommandWithLongNamesData" )
179- public void testCompleteCommandWithLongNames (List <String > words , List <String > expectedValues ) {
179+ void testCompleteCommandWithLongNames (List <String > words , List <String > expectedValues ) {
180180 // given
181181 when (command .getOptions ()).thenReturn (List .of (new CommandOption .Builder ().longName ("first" ).build (),
182182 new CommandOption .Builder ().longName ("last" ).build ()));
@@ -230,7 +230,7 @@ static Stream<Arguments> completeCommandWithLongNamesData() {
230230
231231 @ ParameterizedTest
232232 @ MethodSource ("completeCommandWithShortNamesData" )
233- public void testCompleteCommandWithShortNames (List <String > words , List <String > expectedValues ) {
233+ void testCompleteCommandWithShortNames (List <String > words , List <String > expectedValues ) {
234234 // given
235235 when (command .getOptions ()).thenReturn (List .of (new CommandOption .Builder ().shortName ('f' ).build (),
236236 new CommandOption .Builder ().shortName ('l' ).build ()));
@@ -282,7 +282,7 @@ static Stream<Arguments> completeCommandWithShortNamesData() {
282282
283283 @ ParameterizedTest
284284 @ MethodSource ("completeWithSubCommandsData" )
285- public void testCompleteWithSubCommands (List <String > words , List <String > expectedValues ) {
285+ void testCompleteWithSubCommands (List <String > words , List <String > expectedValues ) {
286286 // given
287287 when (command .getName ()).thenReturn ("hello world" );
288288 when (command .getOptions ())
@@ -331,7 +331,7 @@ static Stream<Arguments> completeWithSubCommandsData() {
331331
332332 @ ParameterizedTest
333333 @ MethodSource ("completeWithTwoOptionsWhereOneIsSubsetOfOtherData" )
334- public void testCompleteWithTwoOptionsWhereOneIsSubsetOfOther (List <String > words , List <String > expectedValues ) {
334+ void testCompleteWithTwoOptionsWhereOneIsSubsetOfOther (List <String > words , List <String > expectedValues ) {
335335 // given
336336 when (command .getOptions ()).thenReturn (List .of (new CommandOption .Builder ().longName ("first" ).build (),
337337 new CommandOption .Builder ().longName ("firstname" ).build ()));
@@ -376,7 +376,7 @@ static Stream<Arguments> completeWithTwoOptionsWhereOneIsSubsetOfOtherData() {
376376
377377 @ ParameterizedTest
378378 @ MethodSource ("completeWithHiddenCommandsData" )
379- public void testCompleteWithHiddenCommands (List <String > words , List <String > expectedValues ) {
379+ void testCompleteWithHiddenCommands (List <String > words , List <String > expectedValues ) {
380380 // given
381381 when (command .getName ()).thenReturn ("hello visible" );
382382 when (command .getOptions ()).thenReturn (List .of ());
@@ -416,7 +416,7 @@ static Stream<Arguments> completeWithHiddenCommandsData() {
416416
417417 @ ParameterizedTest
418418 @ MethodSource ("completeForProposalDisplayText" )
419- public void testCompleteForProposalDisplayText (List <String > words , List <String > expectedValues ) {
419+ void testCompleteForProposalDisplayText (List <String > words , List <String > expectedValues ) {
420420 // given
421421 when (command .getOptions ())
422422 .thenReturn (List .of (new CommandOption .Builder ().longName ("first" ).shortName ('f' ).build (),
@@ -452,4 +452,38 @@ static Stream<Arguments> completeForProposalDisplayText() {
452452 Arguments .of (List .of ("hello" , "--last" , "" ), List .of ("Chan" , "Noris" )));
453453 }
454454
455+ @ ParameterizedTest
456+ @ MethodSource ("completeForCommandAlias" )
457+ void testCompleteForCommandAlias (List <String > words , List <String > expectedValues ) {
458+ // given
459+ when (command .getAliases ()).thenReturn (List .of ("hi" , "bye" ));
460+
461+ List <Candidate > candidates = new ArrayList <>();
462+ ParsedLine line = mock (ParsedLine .class );
463+ when (line .words ()).thenReturn (words );
464+ when (line .word ()).thenReturn (words .get (words .size () - 1 ));
465+ when (line .line ()).thenReturn (String .join (" " , words ));
466+
467+ // when
468+ completer .complete (mock (LineReader .class ), line , candidates );
469+
470+ // then
471+ assertEquals (expectedValues , toCandidateDisplayText (candidates ));
472+ }
473+
474+ static Stream <Arguments > completeForCommandAlias () {
475+ return Stream .of (
476+ Arguments .of (List .of ("" ), List .of ("bye: Says Hello." , "hello: Says Hello." , "hi: Says Hello." )),
477+
478+ Arguments .of (List .of ("h" ), List .of ("hello: Says Hello." , "hi: Says Hello." )),
479+ Arguments .of (List .of ("he" ), List .of ("hello: Says Hello." )),
480+ Arguments .of (List .of ("hello" ), List .of ("hello: Says Hello." )),
481+ Arguments .of (List .of ("hi" ), List .of ("hi: Says Hello." )),
482+ Arguments .of (List .of ("b" ), List .of ("bye: Says Hello." )),
483+ Arguments .of (List .of ("bye" ), List .of ("bye: Says Hello." )),
484+
485+ Arguments .of (List .of ("hello" , "" ), List .of ()), Arguments .of (List .of ("hi" , "" ), List .of ()),
486+ Arguments .of (List .of ("bye" , "" ), List .of ()));
487+ }
488+
455489}
0 commit comments