use of org.activityinfo.analysis.FormulaValidator in project activityinfo by bedatadriven.
the class FormulaValidatorTest method badSymbols.
@Test
public void badSymbols() {
FormulaValidator validator = validate("XX+ZZ");
assertThat(validator.getErrors(), hasSize(2));
}
use of org.activityinfo.analysis.FormulaValidator in project activityinfo by bedatadriven.
the class FormulaValidatorTest method invalidTypeArguments.
@Test
public void invalidTypeArguments() {
FormulaValidator validator = validate("IF('Foo', 1, 0)");
assertThat(validator.getErrors(), hasSize(1));
assertFalse(validator.isValid());
}
use of org.activityinfo.analysis.FormulaValidator in project activityinfo by bedatadriven.
the class FormulaValidatorTest method validate.
private FormulaValidator validate(String formula) {
Survey surveyForm = catalog.getSurvey();
FormulaValidator validator = new FormulaValidator(catalog.getFormTree(surveyForm.getFormId()));
validator.validate(FormulaParser.parse(formula));
for (FormulaError error : validator.getErrors()) {
System.out.println("Error at " + error.getSourceRange() + ": " + error.getMessage());
}
return validator;
}
Aggregations