/** * Create a new validator with the required and optional job parameter keys * provided. * * @see DefaultJobParametersValidator#setOptionalKeys(String[]) * @see DefaultJobParametersValidator#setRequiredKeys(String[]) * * @param requiredKeys the required keys * @param optionalKeys the optional keys */ public DefaultJobParametersValidator(String[] requiredKeys, String[] optionalKeys) { super(); setRequiredKeys(requiredKeys); setOptionalKeys(optionalKeys); }
@Test public void testValidateOptionalValues() throws Exception { validator.setOptionalKeys(new String[] { "name", "value" }); validator.validate(new JobParameters()); }
@Test(expected = IllegalStateException.class) public void testOptionalValuesAlsoRequired() throws Exception { validator.setOptionalKeys(new String[] { "name", "value" }); validator.setRequiredKeys(new String[] { "foo", "value" }); validator.afterPropertiesSet(); }
@Test(expected = JobParametersInvalidException.class) public void testValidateOptionalWithImplicitRequiredKey() throws Exception { validator.setOptionalKeys(new String[] { "name", "value" }); validator.validate(new JobParametersBuilder().addString("foo", "bar").toJobParameters()); }
@Test public void testValidateOptionalWithExplicitRequiredKey() throws Exception { validator.setOptionalKeys(new String[] { "name", "value" }); validator.setRequiredKeys(new String[] { "foo" }); validator.validate(new JobParametersBuilder().addString("foo", "bar").toJobParameters()); }
/** * Create a new validator with the required and optional job parameter keys * provided. * * @see DefaultJobParametersValidator#setOptionalKeys(String[]) * @see DefaultJobParametersValidator#setRequiredKeys(String[]) * * @param requiredKeys the required keys * @param optionalKeys the optional keys */ public DefaultJobParametersValidator(String[] requiredKeys, String[] optionalKeys) { super(); setRequiredKeys(requiredKeys); setOptionalKeys(optionalKeys); }
/** * Create a new validator with the required and optional job parameter keys * provided. * * @see DefaultJobParametersValidator#setOptionalKeys(String[]) * @see DefaultJobParametersValidator#setRequiredKeys(String[]) * * @param requiredKeys the required keys * @param optionalKeys the optional keys */ public DefaultJobParametersValidator(String[] requiredKeys, String[] optionalKeys) { super(); setRequiredKeys(requiredKeys); setOptionalKeys(optionalKeys); }
/** * Create a new validator with the required and optional job parameter keys * provided. * * @see DefaultJobParametersValidator#setOptionalKeys(String[]) * @see DefaultJobParametersValidator#setRequiredKeys(String[]) * * @param requiredKeys the required keys * @param optionalKeys the optional keys */ public DefaultJobParametersValidator(String[] requiredKeys, String[] optionalKeys) { super(); setRequiredKeys(requiredKeys); setOptionalKeys(optionalKeys); }
/** * Create a new validator with the required and optional job parameter keys * provided. * * @see DefaultJobParametersValidator#setOptionalKeys(String[]) * @see DefaultJobParametersValidator#setRequiredKeys(String[]) * * @param requiredKeys the required keys * @param optionalKeys the optional keys */ public DefaultJobParametersValidator(String[] requiredKeys, String[] optionalKeys) { super(); setRequiredKeys(requiredKeys); setOptionalKeys(optionalKeys); }