Skip to content

Commit

Permalink
#764 Change XmlPreprocessor more functional and
Browse files Browse the repository at this point in the history
remove should_exists
  • Loading branch information
adamfilipow92 committed May 8, 2020
1 parent 5350fc3 commit df19d79
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
3 changes: 2 additions & 1 deletion test_runner/buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ object Versions {
// https://github.com/mockk/mockk
const val MOCKK = "1.9.3"

const val COMMON_TEXT = "1.7"
//https://commons.apache.org/proper/commons-text/
const val COMMON_TEXT = "1.8"
}

object Libs {
Expand Down
Empty file removed test_runner/should_exists.txt
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ package ftl.reports.xml.preprocesor

import org.apache.commons.text.StringEscapeUtils

fun fixHtmlCodes(data: String): String {
val isoHtmlCodesToReplace =
listOf(UtfControlCharRanges.CONTROL_TOP_START.charValue..UtfControlCharRanges.CONTROL_TOP_END.charValue).union(
listOf(UtfControlCharRanges.CONTROL_BOTTOM_START.charValue..UtfControlCharRanges.CONTROL_BOTTOM_END.charValue)
).flatten()
.map { StringEscapeUtils.escapeXml11(it.toChar().toString()) }.filter { it.startsWith("&#") }

var fixedStr = data
for (isoControlCode in isoHtmlCodesToReplace) {
fixedStr = fixedStr.replace(isoControlCode, "")
}
return fixedStr
}
fun fixHtmlCodes(data: String): String = listOf(
UtfControlCharRanges.CONTROL_TOP_START.charValue..UtfControlCharRanges.CONTROL_TOP_END.charValue,
UtfControlCharRanges.CONTROL_BOTTOM_START.charValue..UtfControlCharRanges.CONTROL_BOTTOM_END.charValue
).flatten()
.map { StringEscapeUtils.escapeXml11(it.toChar().toString()) }
.filter { it.startsWith("&#") }
.fold(data) { fixedStr: String, isoControlCode: String -> fixedStr.replace(isoControlCode, "") }
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,5 @@ junit.framework.Assert.fail(Assert.java:50)</failure>
""".trimIndent()
val oneSuiteXml = parseOneSuiteXml(crashingOneSuiteMessage).xmlToString().trimIndent()
Assert.assertEquals("One Suite Messages should be the same!", expectedOneSuiteMessage, oneSuiteXml)

}
}

0 comments on commit df19d79

Please sign in to comment.