printHelp(printStream); if (exit) { System.exit(0); throw new ClassNotFoundException("PipelineOptions of type " + klass + " not found."); printHelp(printStream, (Class<? extends PipelineOptions>) klass); } catch (ClassNotFoundException e) { .collect(Collectors.toList()); try { printHelp(printStream, Iterables.getOnlyElement(matches)); } catch (NoSuchElementException exception) { printStream.format("Unable to find option %s.%n", helpOption); printHelp(printStream); } catch (IllegalArgumentException exception) { printStream.format( .map(ReflectHelpers.CLASS_NAME::apply) .collect(Collectors.toList())); printHelp(printStream);
@Test public void testProgrammaticPrintHelp() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PipelineOptionsFactory.printHelp(new PrintStream(baos)); String output = new String(baos.toByteArray(), Charsets.UTF_8); assertThat(output, containsString("The set of registered options are:")); assertThat(output, containsString("org.apache.beam.sdk.options.PipelineOptions")); }
@Test public void testProgrammaticPrintHelpForSpecificType() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PipelineOptionsFactory.printHelp(new PrintStream(baos), PipelineOptions.class); String output = new String(baos.toByteArray(), Charsets.UTF_8); assertThat(output, containsString("org.apache.beam.sdk.options.PipelineOptions")); assertThat(output, containsString("--runner")); assertThat(output, containsString("Default: " + DEFAULT_RUNNER_NAME)); assertThat( output, containsString("The pipeline runner that will be used to execute the pipeline.")); }