CommandValueProvider extends ValueProviderSupport { @Override public List<CompletionProposal> complete(MethodParameter parameter, CompletionContext completionContext, String[] hints) { return commandRegistry.listCommands().keySet().stream() .map(CompletionProposal::new) .collect(Collectors.toList()); } CommandValueProvider(CommandRegistry commandRegistry); @Override List<CompletionProposal> complete(MethodParameter parameter, CompletionContext completionContext, String[] hints);  }
@Test public void testValues() { CommandValueProvider valueProvider = new CommandValueProvider(shell); Method help = ReflectionUtils.findMethod(Command.class, "help", String.class); MethodParameter methodParameter = Utils.createMethodParameter(help, 0); CompletionContext completionContext = new CompletionContext(Arrays.asList("help", "m"), 0, 0); boolean supports = valueProvider.supports(methodParameter, completionContext); assertThat(supports).isEqualTo(true); Map<String, MethodTarget> commands = new HashMap<>(); commands.put("me", null); commands.put("meow", null); commands.put("yourself", null); when(shell.listCommands()).thenReturn(commands); List<CompletionProposal> proposals = valueProvider.complete(methodParameter, completionContext, new String[0]); assertThat(proposals).extracting("value", String.class) .contains("me", "meow", "yourself"); }