PipelineOptionsValidator { public static <T extends PipelineOptions> T validateCli(Class<T> klass, PipelineOptions options) { return validate(klass, options, true); }  static T validate(Class<T> klass, PipelineOptions options); static T validateCli(Class<T> klass, PipelineOptions options);  }
@Test public void testWhenRequiredOptionIsSetAndClearedCli() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Missing required value for " + "[--object, \"Fake Description\"]."); Required required = PipelineOptionsFactory.fromArgs(new String[] {"--object=blah"}).as(Required.class); required.setObject(null); PipelineOptionsValidator.validateCli(Required.class, required); }
@Test public void testWhenRequiredOptionIsNeverSetCli() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Missing required value for " + "[--object, \"Fake Description\"]."); Required required = PipelineOptionsFactory.fromArgs(new String[] {}).as(Required.class); PipelineOptionsValidator.validateCli(Required.class, required); }
@Test public void testWhenRequiredOptionIsNeverSetOnSuperInterfaceCli() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Missing required value for " + "[--object, \"Fake Description\"]."); PipelineOptions options = PipelineOptionsFactory.fromArgs(new String[] {}).create(); PipelineOptionsValidator.validateCli(Required.class, options); }
@Test public void testValidationOnOverriddenMethodsCli() throws Exception { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Missing required value for " + "[--object, \"Fake Description\"]."); SubClassValidation required = PipelineOptionsFactory.fromArgs(new String[] {}).as(SubClassValidation.class); PipelineOptionsValidator.validateCli(Required.class, required); }