AlterQueryServiceCommand extends SingleGfshCommand { void populateMethodAuthorizer(String methodAuthorizerName, Set<String> parameterSet, QueryConfigService queryConfigService) { QueryConfigService.MethodAuthorizer methodAuthorizer = new QueryConfigService.MethodAuthorizer(); methodAuthorizer.setClassName(methodAuthorizerName); if (!parameterSet.isEmpty()) { List<QueryConfigService.MethodAuthorizer.Parameter> parameterList = new ArrayList<>(); for (String value : parameterSet) { QueryConfigService.MethodAuthorizer.Parameter parameter = new QueryConfigService.MethodAuthorizer.Parameter(); parameter.setParameterValue(value); parameterList.add(parameter); } methodAuthorizer.setParameters(parameterList); } queryConfigService.setMethodAuthorizer(methodAuthorizer); }  @CliCommand(value = COMMAND_NAME, help = COMMAND_HELP) @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER, operation = ResourcePermission.Operation.MANAGE) ResultModel execute(
      @CliOption(key = AUTHORIZER_NAME, help = METHOD_AUTHORIZER_NAME_HELP,
          mandatory = true) String methodAuthorizerName,
      @CliOption(key = AUTHORIZER_PARAMETERS, help = AUTHORIZER_PARAMETERS_HELP,
          optionContext = "splittingRegex=" + SPLITTING_REGEX) String[] authorizerParameters,
      @CliOption(key = FORCE_UPDATE, help = FORCE_UPDATE_HELP, specifiedDefaultValue = "true",
          unspecifiedDefaultValue = "false") boolean forceUpdate); @Override boolean updateConfigForGroup(String group, CacheConfig config, Object configObject); static final String PARTIAL_FAILURE_MESSAGE; }
@Test public void populateMethodAuthorizerSetsAuthorizerNameAndParameters() { String authorizerName = "authorizerName"; QueryConfigService queryConfigService = new QueryConfigService(); Set<String> parameters = new HashSet<>(Arrays.asList("param1", "param2")); command.populateMethodAuthorizer(authorizerName, parameters, queryConfigService); QueryConfigService.MethodAuthorizer methodAuthorizer = queryConfigService.getMethodAuthorizer(); assertThat(methodAuthorizer.getClassName()).isEqualTo(authorizerName); assertThat(methodAuthorizer.getParameters().size()).isEqualTo(parameters.size()); assertThat(methodAuthorizer.getParameters().stream() .map(QueryConfigService.MethodAuthorizer.Parameter::getParameterValue) .collect(Collectors.toSet())).isEqualTo(parameters); }