Search in sources :

Example 1 with TestBatchFormClassProvider

use of org.activityinfo.model.formTree.TestBatchFormClassProvider in project activityinfo by bedatadriven.

the class FormulaValidatorTest method invalidFormSchema.

@Test
public void invalidFormSchema() {
    FormClass formClass = new FormClass(ResourceId.valueOf("XYZ"));
    formClass.addField(ResourceId.valueOf("F1")).setCode("A").setLabel("Field A1").setType(TextType.SIMPLE);
    formClass.addField(ResourceId.valueOf("F2")).setCode("A").setLabel("Field A2").setType(TextType.SIMPLE);
    TestBatchFormClassProvider formProvider = new TestBatchFormClassProvider();
    formProvider.add(formClass);
    FormTreeBuilder formTreeBuilder = new FormTreeBuilder(formProvider);
    FormTree formTree = formTreeBuilder.queryTree(formClass.getId());
    FormulaValidator validator = new FormulaValidator(formTree);
    assertFalse(validator.validate(FormulaParser.parse("A")));
    assertThat(validator.getErrors(), hasSize(1));
}
Also used : FormulaValidator(org.activityinfo.analysis.FormulaValidator) FormTree(org.activityinfo.model.formTree.FormTree) FormClass(org.activityinfo.model.form.FormClass) TestBatchFormClassProvider(org.activityinfo.model.formTree.TestBatchFormClassProvider) FormTreeBuilder(org.activityinfo.model.formTree.FormTreeBuilder) Test(org.junit.Test)

Example 2 with TestBatchFormClassProvider

use of org.activityinfo.model.formTree.TestBatchFormClassProvider in project activityinfo by bedatadriven.

the class SchemaCsvWriterV3Test method setup.

@Before
public void setup() throws IOException {
    LocaleProxy.initialize();
    database = new UserDatabaseDTO(1, "Survey DB");
    formClassProvider = new TestBatchFormClassProvider();
    setupSurveyForm();
    setupMonthly();
    expectedSurveyExport = readExport("survey.csv");
}
Also used : UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) TestBatchFormClassProvider(org.activityinfo.model.formTree.TestBatchFormClassProvider) Before(org.junit.Before)

Aggregations

TestBatchFormClassProvider (org.activityinfo.model.formTree.TestBatchFormClassProvider)2 FormulaValidator (org.activityinfo.analysis.FormulaValidator)1 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)1 FormClass (org.activityinfo.model.form.FormClass)1 FormTree (org.activityinfo.model.formTree.FormTree)1 FormTreeBuilder (org.activityinfo.model.formTree.FormTreeBuilder)1 Before (org.junit.Before)1 Test (org.junit.Test)1