assertEquals(Result.Grade.FAIL, new AllowedArgsCmdLineOptionValidator()
.validate(instance).getGrade());
}
public void testValidate() {
AllowedArgsCmdLineOptionValidator validator = new AllowedArgsCmdLineOptionValidator();
validator.setAllowedArgs(Lists.newArrayList("value1", "value2"));
// 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());
}