Skip to content

Commit

Permalink
Add test for non entityList media files
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Jul 10, 2024
1 parent ca95d84 commit dc6edec
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,29 @@ class OpenRosaResponseParserImplTest {
assertThat(mediaFiles.size, equalTo(1))
assertThat(mediaFiles[0].isEntityList, equalTo(true))
}

@Test
fun `parseManifest() when media file does not have type returns isEntityList as false`() {
val response = StringBuilder()
.appendLine("<?xml version='1.0' encoding='UTF-8' ?>")
.appendLine("<manifest xmlns=\"http://openrosa.org/xforms/xformsManifest\">")
.appendLine("<mediaFile>")
.appendLine("<filename>badgers.csv</filename>")
.appendLine("<hash>blah</hash>")
.appendLine("<downloadUrl>http://funk.appspot.com/binaryData?blobKey=%3A477e3</downloadUrl>")
.appendLine("</mediaFile>")
.appendLine("</manifest>")
.toString()

val doc = StringReader(response).use { reader ->
val parser = KXmlParser()
parser.setInput(reader)
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true)
Document().also { it.parse(parser) }
}

val mediaFiles = OpenRosaResponseParserImpl().parseManifest(doc)!!
assertThat(mediaFiles.size, equalTo(1))
assertThat(mediaFiles[0].isEntityList, equalTo(false))
}
}

0 comments on commit dc6edec

Please sign in to comment.