assertEquals(Result.Grade.FAIL, new AllowedArgsCmdLineOptionValidator()
.validate(instance).getGrade());
}
public void testValidate() {
ArgRegExpCmdLineOptionValidator validator = new ArgRegExpCmdLineOptionValidator();
validator.setAllowedArgs(Lists.newArrayList("v.*?1", "v.*?2"));
// Test no null option instance allowed.
try {
validator.validate(null);
fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException ignore) { /* expect throw */
}
// Test should fail case.
CmdLineOptionInstance instance = createOptionInstance(
createSimpleOption("test", false), "value");
assertEquals(Result.Grade.FAIL, validator.validate(instance).getGrade());
// Test should pass case.
instance = createOptionInstance(createSimpleOption("test", false),
"value1");
assertEquals(Result.Grade.PASS, validator.validate(instance).getGrade());
}