@Test public void testComplete() { Session session = Mockito.mock( Session.class ); CommandLine commandLine = Mockito.mock( CommandLine.class ); Mockito.when( commandLine.getCursorArgument()).thenReturn( "" ); Mockito.when( commandLine.getArgumentPosition()).thenReturn( 0 ); PluginCompleter completer = new PluginCompleter(); List<String> candidates = new ArrayList<> (); Assert.assertEquals( 0, candidates.size()); Assert.assertEquals( 0, completer.complete( session, commandLine, candidates )); Assert.assertEquals( SupportedPlugin.allString().size(), candidates.size()); candidates = new ArrayList<> (); Mockito.when( commandLine.getCursorArgument()).thenReturn( "f" ); Mockito.when( commandLine.getArgumentPosition()).thenReturn( 1 ); Assert.assertEquals( 0, candidates.size()); Assert.assertEquals( -1, completer.complete( session, commandLine, candidates )); Assert.assertEquals( 1, candidates.size()); Assert.assertEquals( SupportedPlugin.FILE.toString().toLowerCase(), candidates.get( 0 ).trim()); candidates = new ArrayList<> (); Mockito.when( commandLine.getCursorArgument()).thenReturn( "FI" ); Mockito.when( commandLine.getArgumentPosition()).thenReturn( 2 ); Assert.assertEquals( 0, candidates.size()); Assert.assertEquals( -2, completer.complete( session, commandLine, candidates )); Assert.assertEquals( 1, candidates.size()); Assert.assertEquals( SupportedPlugin.FILE.toString().toLowerCase(), candidates.get( 0 ).trim()); candidates = new ArrayList<> (); Mockito.when( commandLine.getCursorArgument()).thenReturn( "unknown" ); Mockito.when( commandLine.getArgumentPosition()).thenReturn( "unknown".length()); Assert.assertEquals( 0, candidates.size()); Assert.assertEquals( -1, completer.complete( session, commandLine, candidates )); }
@Override public int complete( Session session, CommandLine commandLine, List<String> candidates ) { StringsCompleter delegate = new StringsCompleter( false ); delegate.getStrings().addAll( SupportedPlugin.allString()); return delegate.complete( session, commandLine, candidates ); }
PluginCompleter implements Completer { @Override public int complete( Session session, CommandLine commandLine, List<String> candidates ) { StringsCompleter delegate = new StringsCompleter( false ); delegate.getStrings().addAll( SupportedPlugin.allString()); return delegate.complete( session, commandLine, candidates ); } }
PluginCompleter implements Completer { @Override public int complete( Session session, CommandLine commandLine, List<String> candidates ) { StringsCompleter delegate = new StringsCompleter( false ); delegate.getStrings().addAll( SupportedPlugin.allString()); return delegate.complete( session, commandLine, candidates ); }  }
PluginCompleter implements Completer { @Override public int complete( Session session, CommandLine commandLine, List<String> candidates ) { StringsCompleter delegate = new StringsCompleter( false ); delegate.getStrings().addAll( SupportedPlugin.allString()); return delegate.complete( session, commandLine, candidates ); }  @Override int complete( Session session, CommandLine commandLine, List<String> candidates ); }
PluginCompleter implements Completer { @Override public int complete( Session session, CommandLine commandLine, List<String> candidates ) { StringsCompleter delegate = new StringsCompleter( false ); delegate.getStrings().addAll( SupportedPlugin.allString()); return delegate.complete( session, commandLine, candidates ); }  @Override int complete( Session session, CommandLine commandLine, List<String> candidates );  }