@Test(expected = ArgumentParseException.class) public void testInitOptionsAndArgsWithMissingArgumentShouldThrowError() throws AbstractPublishingPluginException { final Publication publication = createPublication(); publication.setUsername(null); publication.setHost(null); axwayPublishingAdapter.initOptionsAndArgs(publication); }
public void initOptionsAndArgs(final Publication publication) throws AbstractPublishingPluginException { final List<String> args = new ArrayList<>(); Options options = new Options(); options.addOption(Option.builder("s").longOpt("stage").hasArg(true).argName("preprod").build()); getArgValue(args, "--stage", () -> publication.getStage()); options.addOption(Option.builder("h").longOpt("host").hasArg(true).argName("api-host").build()); getArgValue(args, "--host", () -> publication.getHost()); options.addOption(Option.builder("port").longOpt("port").hasArg(true).argName("8181").build()); getArgValue(args, "--port", () -> String.valueOf(publication.getPort())); options.addOption(Option.builder("u").longOpt("username").hasArg(true).argName("apiadmin").build()); getArgValue(args, "--username", () -> publication.getUsername()); options.addOption(Option.builder("p").longOpt("password").hasArg(true).build()); getArgValue(args, "--password", () -> publication.getPassword() ); options.addOption(Option.builder("f").longOpt("force").hasArg(true).build()); getArgValue(args, "--force", () -> String.valueOf(publication.getForce())); options.addOption(Option.builder("iq").longOpt("ignoreQuotas").hasArg(true).build()); getArgValue(args, "--ignoreQuotas", () -> String.valueOf(publication.getIgnoreQuotas())); options.addOption(Option.builder("clientOrgsMode").longOpt("clientOrgsMode").hasArg(true).build()); getArgValue(args, "--clientOrgsMode", () -> String.valueOf(publication.getClientOrgsMode())); options.addOption(Option.builder("clientAppsMode").longOpt("clientAppsMode").hasArg(true).build()); getArgValue(args, "--clientAppsMode", () -> String.valueOf(publication.getClientAppsMode())); Options internalOptions = new Options(); internalOptions .addOption(Option.builder("ignoreAdminAccount").longOpt("ignoreAdminAccount").hasArg(true).build()); getArgValue(args, "--ignoreAdminAccount", () -> String.valueOf(publication.getIgnoreAdminAccount())); try { CommandLineParser parser = new RelaxedParser(); final String[] argsValue = args.toArray(new String[args.size()]); final CommandLine cmd = parser.parse(options, argsValue); final CommandLine internalCmd = parser.parse(internalOptions, argsValue); CommandParameters params = new CommandParameters(cmd, internalCmd, new EnvironmentProperties(cmd.getOptionValue("stage"))); } catch (AppException e) { logger.error(e); throw AppExceptionMapper.map(e); } catch (ParseException e) { throw new ArgumentParseException(e.getMessage(), e); } }
AxwayPublishingAdapter { public void initOptionsAndArgs(final Publication publication) throws AbstractPublishingPluginException { final List<String> args = new ArrayList<>(); Options options = new Options(); options.addOption(Option.builder("s").longOpt("stage").hasArg(true).argName("preprod").build()); getArgValue(args, "--stage", () -> publication.getStage()); options.addOption(Option.builder("h").longOpt("host").hasArg(true).argName("api-host").build()); getArgValue(args, "--host", () -> publication.getHost()); options.addOption(Option.builder("port").longOpt("port").hasArg(true).argName("8181").build()); getArgValue(args, "--port", () -> String.valueOf(publication.getPort())); options.addOption(Option.builder("u").longOpt("username").hasArg(true).argName("apiadmin").build()); getArgValue(args, "--username", () -> publication.getUsername()); options.addOption(Option.builder("p").longOpt("password").hasArg(true).build()); getArgValue(args, "--password", () -> publication.getPassword() ); options.addOption(Option.builder("f").longOpt("force").hasArg(true).build()); getArgValue(args, "--force", () -> String.valueOf(publication.getForce())); options.addOption(Option.builder("iq").longOpt("ignoreQuotas").hasArg(true).build()); getArgValue(args, "--ignoreQuotas", () -> String.valueOf(publication.getIgnoreQuotas())); options.addOption(Option.builder("clientOrgsMode").longOpt("clientOrgsMode").hasArg(true).build()); getArgValue(args, "--clientOrgsMode", () -> String.valueOf(publication.getClientOrgsMode())); options.addOption(Option.builder("clientAppsMode").longOpt("clientAppsMode").hasArg(true).build()); getArgValue(args, "--clientAppsMode", () -> String.valueOf(publication.getClientAppsMode())); Options internalOptions = new Options(); internalOptions .addOption(Option.builder("ignoreAdminAccount").longOpt("ignoreAdminAccount").hasArg(true).build()); getArgValue(args, "--ignoreAdminAccount", () -> String.valueOf(publication.getIgnoreAdminAccount())); try { CommandLineParser parser = new RelaxedParser(); final String[] argsValue = args.toArray(new String[args.size()]); final CommandLine cmd = parser.parse(options, argsValue); final CommandLine internalCmd = parser.parse(internalOptions, argsValue); CommandParameters params = new CommandParameters(cmd, internalCmd, new EnvironmentProperties(cmd.getOptionValue("stage"))); } catch (AppException e) { logger.error(e); throw AppExceptionMapper.map(e); } catch (ParseException e) { throw new ArgumentParseException(e.getMessage(), e); } } }
AxwayPublishingAdapter { public void initOptionsAndArgs(final Publication publication) throws AbstractPublishingPluginException { final List<String> args = new ArrayList<>(); Options options = new Options(); options.addOption(Option.builder("s").longOpt("stage").hasArg(true).argName("preprod").build()); getArgValue(args, "--stage", () -> publication.getStage()); options.addOption(Option.builder("h").longOpt("host").hasArg(true).argName("api-host").build()); getArgValue(args, "--host", () -> publication.getHost()); options.addOption(Option.builder("port").longOpt("port").hasArg(true).argName("8181").build()); getArgValue(args, "--port", () -> String.valueOf(publication.getPort())); options.addOption(Option.builder("u").longOpt("username").hasArg(true).argName("apiadmin").build()); getArgValue(args, "--username", () -> publication.getUsername()); options.addOption(Option.builder("p").longOpt("password").hasArg(true).build()); getArgValue(args, "--password", () -> publication.getPassword() ); options.addOption(Option.builder("f").longOpt("force").hasArg(true).build()); getArgValue(args, "--force", () -> String.valueOf(publication.getForce())); options.addOption(Option.builder("iq").longOpt("ignoreQuotas").hasArg(true).build()); getArgValue(args, "--ignoreQuotas", () -> String.valueOf(publication.getIgnoreQuotas())); options.addOption(Option.builder("clientOrgsMode").longOpt("clientOrgsMode").hasArg(true).build()); getArgValue(args, "--clientOrgsMode", () -> String.valueOf(publication.getClientOrgsMode())); options.addOption(Option.builder("clientAppsMode").longOpt("clientAppsMode").hasArg(true).build()); getArgValue(args, "--clientAppsMode", () -> String.valueOf(publication.getClientAppsMode())); Options internalOptions = new Options(); internalOptions .addOption(Option.builder("ignoreAdminAccount").longOpt("ignoreAdminAccount").hasArg(true).build()); getArgValue(args, "--ignoreAdminAccount", () -> String.valueOf(publication.getIgnoreAdminAccount())); try { CommandLineParser parser = new RelaxedParser(); final String[] argsValue = args.toArray(new String[args.size()]); final CommandLine cmd = parser.parse(options, argsValue); final CommandLine internalCmd = parser.parse(internalOptions, argsValue); CommandParameters params = new CommandParameters(cmd, internalCmd, new EnvironmentProperties(cmd.getOptionValue("stage"))); } catch (AppException e) { logger.error(e); throw AppExceptionMapper.map(e); } catch (ParseException e) { throw new ArgumentParseException(e.getMessage(), e); } } private  AxwayPublishingAdapter(); }
AxwayPublishingAdapter { public void initOptionsAndArgs(final Publication publication) throws AbstractPublishingPluginException { final List<String> args = new ArrayList<>(); Options options = new Options(); options.addOption(Option.builder("s").longOpt("stage").hasArg(true).argName("preprod").build()); getArgValue(args, "--stage", () -> publication.getStage()); options.addOption(Option.builder("h").longOpt("host").hasArg(true).argName("api-host").build()); getArgValue(args, "--host", () -> publication.getHost()); options.addOption(Option.builder("port").longOpt("port").hasArg(true).argName("8181").build()); getArgValue(args, "--port", () -> String.valueOf(publication.getPort())); options.addOption(Option.builder("u").longOpt("username").hasArg(true).argName("apiadmin").build()); getArgValue(args, "--username", () -> publication.getUsername()); options.addOption(Option.builder("p").longOpt("password").hasArg(true).build()); getArgValue(args, "--password", () -> publication.getPassword() ); options.addOption(Option.builder("f").longOpt("force").hasArg(true).build()); getArgValue(args, "--force", () -> String.valueOf(publication.getForce())); options.addOption(Option.builder("iq").longOpt("ignoreQuotas").hasArg(true).build()); getArgValue(args, "--ignoreQuotas", () -> String.valueOf(publication.getIgnoreQuotas())); options.addOption(Option.builder("clientOrgsMode").longOpt("clientOrgsMode").hasArg(true).build()); getArgValue(args, "--clientOrgsMode", () -> String.valueOf(publication.getClientOrgsMode())); options.addOption(Option.builder("clientAppsMode").longOpt("clientAppsMode").hasArg(true).build()); getArgValue(args, "--clientAppsMode", () -> String.valueOf(publication.getClientAppsMode())); Options internalOptions = new Options(); internalOptions .addOption(Option.builder("ignoreAdminAccount").longOpt("ignoreAdminAccount").hasArg(true).build()); getArgValue(args, "--ignoreAdminAccount", () -> String.valueOf(publication.getIgnoreAdminAccount())); try { CommandLineParser parser = new RelaxedParser(); final String[] argsValue = args.toArray(new String[args.size()]); final CommandLine cmd = parser.parse(options, argsValue); final CommandLine internalCmd = parser.parse(internalOptions, argsValue); CommandParameters params = new CommandParameters(cmd, internalCmd, new EnvironmentProperties(cmd.getOptionValue("stage"))); } catch (AppException e) { logger.error(e); throw AppExceptionMapper.map(e); } catch (ParseException e) { throw new ArgumentParseException(e.getMessage(), e); } } private  AxwayPublishingAdapter(); static synchronized AxwayPublishingAdapter instance(); static synchronized void cleanInstance(); void initOptionsAndArgs(final Publication publication); void processApi(final Api e, final String stage); }
AxwayPublishingAdapter { public void initOptionsAndArgs(final Publication publication) throws AbstractPublishingPluginException { final List<String> args = new ArrayList<>(); Options options = new Options(); options.addOption(Option.builder("s").longOpt("stage").hasArg(true).argName("preprod").build()); getArgValue(args, "--stage", () -> publication.getStage()); options.addOption(Option.builder("h").longOpt("host").hasArg(true).argName("api-host").build()); getArgValue(args, "--host", () -> publication.getHost()); options.addOption(Option.builder("port").longOpt("port").hasArg(true).argName("8181").build()); getArgValue(args, "--port", () -> String.valueOf(publication.getPort())); options.addOption(Option.builder("u").longOpt("username").hasArg(true).argName("apiadmin").build()); getArgValue(args, "--username", () -> publication.getUsername()); options.addOption(Option.builder("p").longOpt("password").hasArg(true).build()); getArgValue(args, "--password", () -> publication.getPassword() ); options.addOption(Option.builder("f").longOpt("force").hasArg(true).build()); getArgValue(args, "--force", () -> String.valueOf(publication.getForce())); options.addOption(Option.builder("iq").longOpt("ignoreQuotas").hasArg(true).build()); getArgValue(args, "--ignoreQuotas", () -> String.valueOf(publication.getIgnoreQuotas())); options.addOption(Option.builder("clientOrgsMode").longOpt("clientOrgsMode").hasArg(true).build()); getArgValue(args, "--clientOrgsMode", () -> String.valueOf(publication.getClientOrgsMode())); options.addOption(Option.builder("clientAppsMode").longOpt("clientAppsMode").hasArg(true).build()); getArgValue(args, "--clientAppsMode", () -> String.valueOf(publication.getClientAppsMode())); Options internalOptions = new Options(); internalOptions .addOption(Option.builder("ignoreAdminAccount").longOpt("ignoreAdminAccount").hasArg(true).build()); getArgValue(args, "--ignoreAdminAccount", () -> String.valueOf(publication.getIgnoreAdminAccount())); try { CommandLineParser parser = new RelaxedParser(); final String[] argsValue = args.toArray(new String[args.size()]); final CommandLine cmd = parser.parse(options, argsValue); final CommandLine internalCmd = parser.parse(internalOptions, argsValue); CommandParameters params = new CommandParameters(cmd, internalCmd, new EnvironmentProperties(cmd.getOptionValue("stage"))); } catch (AppException e) { logger.error(e); throw AppExceptionMapper.map(e); } catch (ParseException e) { throw new ArgumentParseException(e.getMessage(), e); } } private  AxwayPublishingAdapter(); static synchronized AxwayPublishingAdapter instance(); static synchronized void cleanInstance(); void initOptionsAndArgs(final Publication publication); void processApi(final Api e, final String stage);  }