use of org.javarosa.xform.parse.FormParserHelper.ParseResult in project javarosa by opendatakit.
the class XFormParserTest method parseFormWithSubmissionElement.
@Test
public void parseFormWithSubmissionElement() throws IOException {
// Given & When
ParseResult parseResult = parse(r("submission-element.xml"));
// Then
assertEquals(parseResult.formDef.getTitle(), "Single Submission Element");
assertNoParseErrors(parseResult);
SubmissionProfile submissionProfile = parseResult.formDef.getSubmissionProfile();
assertEquals("http://some.destination.com", submissionProfile.getAction());
assertEquals("form-data-post", submissionProfile.getMethod());
assertNull(submissionProfile.getMediaType());
assertEquals("/data/text", submissionProfile.getRef().getReference().toString());
}
use of org.javarosa.xform.parse.FormParserHelper.ParseResult in project javarosa by opendatakit.
the class XFormParserTest method parseFormWithTemplateRepeat.
@Test
public void parseFormWithTemplateRepeat() throws IOException {
// Given & When
ParseResult parseResult = parse(r("template-repeat.xml"));
// Then
assertEquals(parseResult.formDef.getTitle(), "Repeat with template");
assertNoParseErrors(parseResult);
}
use of org.javarosa.xform.parse.FormParserHelper.ParseResult 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));
}
use of org.javarosa.xform.parse.FormParserHelper.ParseResult in project javarosa by opendatakit.
the class XFormParserTest method parseFormWithTwoModels.
@Test
public void parseFormWithTwoModels() throws IOException {
// Given & When
ParseResult parseResult = parse(r("two-models.xml"));
// Then
FormDef formDef = parseResult.formDef;
assertEquals(formDef.getTitle(), "Two Models");
assertEquals("Number of error messages", 1, parseResult.errorMessages.size());
assertEquals("Multiple models not supported. Ignoring subsequent models.", parseResult.errorMessages.get(0));
String firstModelInstanceId = (String) formDef.getMainInstance().getRoot().getAttribute(null, "id").getValue().getValue();
assertEquals("first-model", firstModelInstanceId);
}
Aggregations