Search in sources :

Example 26 with IFormElement

use of org.javarosa.core.model.IFormElement in project javarosa by opendatakit.

the class XFormParserTest method parseGroupWithNodesetAttrForm.

@Test
public void parseGroupWithNodesetAttrForm() throws IOException {
    // Given & When
    ParseResult parseResult = parse(r("group-with-nodeset-attr.xml"));
    // Then
    assertEquals(parseResult.formDef.getTitle(), "group with nodeset attribute");
    assertEquals("Number of error messages", 0, parseResult.errorMessages.size());
    final TreeReference expectedTreeReference = new TreeReference();
    // absolute reference
    expectedTreeReference.setRefLevel(-1);
    // the instance root
    expectedTreeReference.add("data", -1);
    // the outer repeat
    expectedTreeReference.add("R1", -1);
    // the inner group
    expectedTreeReference.add("G2", -1);
    final IDataReference expectedXPathReference = new XPathReference(expectedTreeReference);
    IFormElement groupElement = parseResult.formDef.getChild(0).getChild(0);
    assertThat(groupElement, instanceOf(GroupDef.class));
    assertThat(((GroupDef) groupElement).getRepeat(), is(false));
    assertThat(groupElement.getBind(), is(expectedXPathReference));
}
Also used : IFormElement(org.javarosa.core.model.IFormElement) ParseResult(org.javarosa.xform.parse.FormParserHelper.ParseResult) TreeReference(org.javarosa.core.model.instance.TreeReference) IDataReference(org.javarosa.core.model.IDataReference) XPathReference(org.javarosa.model.xform.XPathReference) GroupDef(org.javarosa.core.model.GroupDef) Test(org.junit.Test)

Aggregations

IFormElement (org.javarosa.core.model.IFormElement)26 GroupDef (org.javarosa.core.model.GroupDef)19 QuestionDef (org.javarosa.core.model.QuestionDef)10 ArrayList (java.util.ArrayList)9 TreeReference (org.javarosa.core.model.instance.TreeReference)8 FormIndex (org.javarosa.core.model.FormIndex)6 TreeElement (org.javarosa.core.model.instance.TreeElement)6 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)5 IDataReference (org.javarosa.core.model.IDataReference)4 AbstractTreeElement (org.javarosa.core.model.instance.AbstractTreeElement)3 XPathReference (org.javarosa.model.xform.XPathReference)3 Element (org.kxml2.kdom.Element)3 DataBinding (org.javarosa.core.model.DataBinding)2 Constraint (org.javarosa.core.model.condition.Constraint)2 IAnswerData (org.javarosa.core.model.data.IAnswerData)2 FormEntryModel (org.javarosa.form.api.FormEntryModel)2 Test (org.junit.Test)2 QuestionDetails (org.odk.collect.android.formentry.questions.QuestionDetails)2 MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)2 Activity (android.app.Activity)1