SwaggerConfluence { public void runCLI(final String[] args){ final Options options = buildOptions(); final CommandLine commandLine = parseCommandLineOptions(options, args); if(commandLine.hasOption("h") || args.length == 0){ final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("swagger-confluence-cli", options); } else { final SwaggerConfluenceConfig swaggerConfluenceConfig = buildSwaggerConfluenceConfig(commandLine); swaggerToConfluenceService.convertSwaggerToConfluence(swaggerConfluenceConfig); } } SwaggerConfluence(final SwaggerToConfluenceService swaggerToConfluenceService); static void main(final String[] args); void runCLI(final String[] args);  }
@Test public void testRunCLI(){ final String[] args = new String[]{ "-b", "c3RhcmxpZ2h0a25pZ2h0OnRyb2wsb2NrNw==", "-g", "false", "-p", "[CLI]", "-i", "false", "-k", "DOC", "-s", "swagger-petstore-example.yaml", "-t", "Swagger Pet Store", "-m", "single" }; final ArgumentCaptor<SwaggerConfluenceConfig> swaggerConfluenceConfigArgumentCaptor = ArgumentCaptor.forClass(SwaggerConfluenceConfig.class); swaggerConfluence.runCLI(args); verify(swaggerToConfluenceService).convertSwaggerToConfluence( swaggerConfluenceConfigArgumentCaptor.capture()); final SwaggerConfluenceConfig swaggerConfluenceConfig = swaggerConfluenceConfigArgumentCaptor.getValue(); assertEquals("Authentication Parsed Incorrectly!", args[1], swaggerConfluenceConfig.getAuthentication()); assertEquals("Generate Numeric Prefixes Parsed Incorrectly!", Boolean.valueOf(args[3]), swaggerConfluenceConfig.isGenerateNumericPrefixes()); assertEquals("Prefix Parsed Incorrectly!", args[5]+" ", swaggerConfluenceConfig.getPrefix()); assertEquals("Include ToC for Single Parsed Incorrectly!", Boolean.valueOf(args[7]), swaggerConfluenceConfig.isIncludeTableOfContentsOnSinglePage()); assertEquals("Space Key Parsed Incorrectly!", args[9], swaggerConfluenceConfig.getSpaceKey()); assertEquals("Schema Location Parsed Incorrectly!", args[11], swaggerConfluenceConfig.getSwaggerSchema()); assertEquals("Title Parsed Incorrectly!", args[13], swaggerConfluenceConfig.getTitle()); assertEquals("Pagination Mode Parsed Incorrectly!", PaginationMode.SINGLE_PAGE, swaggerConfluenceConfig.getPaginationMode()); }