Skip to content

Commit

Permalink
Use simpler parsing code
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Sep 30, 2022
1 parent 43fff8d commit eb6568e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/test/java/org/javarosa/entities/EntityDatasetParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import org.javarosa.core.model.instance.FormInstance;
import org.javarosa.core.util.XFormsElement;
import org.javarosa.entities.internal.EntityDatasetParser;
import org.javarosa.xform.parse.XFormParser;
import org.javarosa.xform.util.XFormUtils;
import org.junit.Test;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -25,7 +28,7 @@
public class EntityDatasetParserTest {

@Test
public void parseFirstDatasetToCreate_ignoresDatasetWithCreateActionWithIncorrectNamespace() {
public void parseFirstDatasetToCreate_ignoresDatasetWithCreateActionWithIncorrectNamespace() throws IOException {
XFormsElement form = XFormsElement.html(
asList(
new Pair<>("correct", "http://www.opendatakit.org/xforms/entities"),
Expand All @@ -52,10 +55,10 @@ public void parseFirstDatasetToCreate_ignoresDatasetWithCreateActionWithIncorrec
)
);

FormDef formDef = XFormUtils.getFormFromInputStream(new ByteArrayInputStream(form.asXml().getBytes()));
FormInstance mainInstance = formDef.getMainInstance();
XFormParser parser = new XFormParser(new InputStreamReader(new ByteArrayInputStream(form.asXml().getBytes())));
FormDef formDef = parser.parse(null);

String dataset = EntityDatasetParser.parseFirstDatasetToCreate(mainInstance);
String dataset = EntityDatasetParser.parseFirstDatasetToCreate(formDef.getMainInstance());
assertThat(dataset, equalTo(null));
}
}

0 comments on commit eb6568e

Please sign in to comment.