@Test(description = "Test openapi gen client command with help flag", enabled = false) public void testOpenAPIGenClientCmdHelp() throws IOException { String[] args = {"-h"}; OpenApiGenClientCmd openApiGenClientCmd = new OpenApiGenClientCmd(printStream, this.tmpDir.toString()); new CommandLine(openApiGenClientCmd).parseArgs(args); openApiGenClientCmd.execute(); String output = readOutput(true); Assert.assertTrue(output.contains("ballerina-openapi-gen-client - Generate a mock Ballerina client\n" + " for a given OpenAPI contract")); }
@Override public void execute() { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); tag.add("pet"); operation.add("operation"); Filter filter = new Filter(tag, operation); outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); CodeGenerator generator = new CodeGenerator(); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (moduleArgs == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.CLIENT_MANDATORY); } if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_FILE_MANDATORY); } if (moduleArgs.size() >= 2) { generator.setSrcPackage(moduleArgs.get(0)); } try { generator.generateClient(executionPath, argList.get(0), moduleArgs.get(1), output, filter); } catch (IOException | BallerinaOpenApiException e) { if (e.getLocalizedMessage() != null) { throw LauncherUtils.createLauncherException(e.getLocalizedMessage()); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_CLIENT_EXCEPTION); } } }
OpenApiGenClientCmd implements BLauncherCmd { @Override public void execute() { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); tag.add("pet"); operation.add("operation"); Filter filter = new Filter(tag, operation); outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); CodeGenerator generator = new CodeGenerator(); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (moduleArgs == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.CLIENT_MANDATORY); } if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_FILE_MANDATORY); } if (moduleArgs.size() >= 2) { generator.setSrcPackage(moduleArgs.get(0)); } try { generator.generateClient(executionPath, argList.get(0), moduleArgs.get(1), output, filter); } catch (IOException | BallerinaOpenApiException e) { if (e.getLocalizedMessage() != null) { throw LauncherUtils.createLauncherException(e.getLocalizedMessage()); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_CLIENT_EXCEPTION); } } } }
OpenApiGenClientCmd implements BLauncherCmd { @Override public void execute() { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); tag.add("pet"); operation.add("operation"); Filter filter = new Filter(tag, operation); outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); CodeGenerator generator = new CodeGenerator(); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (moduleArgs == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.CLIENT_MANDATORY); } if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_FILE_MANDATORY); } if (moduleArgs.size() >= 2) { generator.setSrcPackage(moduleArgs.get(0)); } try { generator.generateClient(executionPath, argList.get(0), moduleArgs.get(1), output, filter); } catch (IOException | BallerinaOpenApiException e) { if (e.getLocalizedMessage() != null) { throw LauncherUtils.createLauncherException(e.getLocalizedMessage()); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_CLIENT_EXCEPTION); } } } OpenApiGenClientCmd();  OpenApiGenClientCmd(PrintStream outStream, String executionPath); }
OpenApiGenClientCmd implements BLauncherCmd { @Override public void execute() { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); tag.add("pet"); operation.add("operation"); Filter filter = new Filter(tag, operation); outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); CodeGenerator generator = new CodeGenerator(); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (moduleArgs == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.CLIENT_MANDATORY); } if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_FILE_MANDATORY); } if (moduleArgs.size() >= 2) { generator.setSrcPackage(moduleArgs.get(0)); } try { generator.generateClient(executionPath, argList.get(0), moduleArgs.get(1), output, filter); } catch (IOException | BallerinaOpenApiException e) { if (e.getLocalizedMessage() != null) { throw LauncherUtils.createLauncherException(e.getLocalizedMessage()); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_CLIENT_EXCEPTION); } } } OpenApiGenClientCmd();  OpenApiGenClientCmd(PrintStream outStream, String executionPath); @Override void execute(); @Override String getName(); @Override void printLongDesc(StringBuilder out); @Override void printUsage(StringBuilder out); @Override void setParentCmdParser(CommandLine parentCmdParser); }
OpenApiGenClientCmd implements BLauncherCmd { @Override public void execute() { List<String> tag = new ArrayList<>(); List<String> operation = new ArrayList<>(); tag.add("pet"); operation.add("operation"); Filter filter = new Filter(tag, operation); outStream.println(OpenApiMesseges.EXPERIMENTAL_FEATURE); CodeGenerator generator = new CodeGenerator(); if (helpFlag) { String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(getName()); outStream.println(commandUsageInfo); return; } if (moduleArgs == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.CLIENT_MANDATORY); } if (argList == null) { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_FILE_MANDATORY); } if (moduleArgs.size() >= 2) { generator.setSrcPackage(moduleArgs.get(0)); } try { generator.generateClient(executionPath, argList.get(0), moduleArgs.get(1), output, filter); } catch (IOException | BallerinaOpenApiException e) { if (e.getLocalizedMessage() != null) { throw LauncherUtils.createLauncherException(e.getLocalizedMessage()); } else { throw LauncherUtils.createLauncherException(OpenApiMesseges.OPENAPI_CLIENT_EXCEPTION); } } } OpenApiGenClientCmd();  OpenApiGenClientCmd(PrintStream outStream, String executionPath); @Override void execute(); @Override String getName(); @Override void printLongDesc(StringBuilder out); @Override void printUsage(StringBuilder out); @Override void setParentCmdParser(CommandLine parentCmdParser);  }