Shell implements CommandRegistry { @PostConstruct public void gatherMethodTargets() throws Exception { ConfigurableCommandRegistry registry = new ConfigurableCommandRegistry(); for (MethodTargetRegistrar resolver : applicationContext.getBeansOfType(MethodTargetRegistrar.class).values()) { resolver.register(registry); } methodTargets = registry.listCommands(); methodTargets.values() .forEach(this::validateParameterResolvers); } Shell(ResultHandler resultHandler); @Autowired(required = false) void setValidatorFactory(ValidatorFactory validatorFactory); @Override Map<String, MethodTarget> listCommands(); @PostConstruct void gatherMethodTargets(); @Autowired void setParameterResolvers(List<ParameterResolver> resolvers); void run(InputProvider inputProvider); Object evaluate(Input input); List<CompletionProposal> complete(CompletionContext context); static final Object NO_INPUT; }
@Test public void parametersSupported() throws Exception { when(parameterResolver.supports(any())).thenReturn(false); shell.applicationContext = mock(ApplicationContext.class); when(shell.applicationContext.getBeansOfType(MethodTargetRegistrar.class)) .thenReturn(Collections.singletonMap("foo", r -> { r.register("hw", MethodTarget.of("helloWorld", this, new Command.Help("hellow world"))); })); thrown.expect(ParameterResolverMissingException.class); shell.gatherMethodTargets(); }