@@ -15,14 +15,14 @@ import java.nio.file.Files
1515class ConfigFileCreationPassTests extends AnyFunSpec with Matchers {
1616
1717 private class TestDiffGraphBuilder extends io.shiftleft.codepropertygraph.generated.DiffGraphBuilder (GraphSchema ) {
18- val nodes = scala.collection.mutable.Buffer [Any ]()
18+ val nodes = scala.collection.mutable.Buffer [DNode ]()
1919 override def addNode (newNode : DNode ): this .type = {
2020 this .nodes.append(newNode)
2121 this
2222 }
2323 }
2424
25- private val xml : String =
25+ private val Xml : String =
2626 """ <?xml version="1.0" encoding="UTF-8"?>
2727 |<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2828 |<plist version="1.0">
@@ -31,44 +31,43 @@ class ConfigFileCreationPassTests extends AnyFunSpec with Matchers {
3131 | <string>value</string>
3232 |</dict>
3333 |</plist>""" .stripMargin
34+ // com.dd.plist.NSObject#toXMLPropertyList uses line separator when converting
3435 .replace(" \n " , System .lineSeparator())
35- .replace(" " , " \t " ) // com.dd.plist.NSObject#toXMLPropertyList uses tabs when converting
36+ // com.dd.plist.NSObject#toXMLPropertyList uses tabs when converting
37+ .replace(" " , " \t " )
3638
3739 describe(" ConfigFileCreationPass" ) {
3840 it(" creates config node for an XML plist" ) {
3941 FileUtil .usingTemporaryFile(" test" , " .plist" ) { xmlFile =>
40- Files .write(xmlFile, xml .getBytes(" UTF-8" ))
42+ Files .write(xmlFile, Xml .getBytes(" UTF-8" ))
4143
42- val config = Config ()
43- val pass = new ConfigFileCreationPass (null /* cpg not used in here */ , config)
44- val diff = new TestDiffGraphBuilder
44+ val pass = new ConfigFileCreationPass (null /* cpg not used in here */ , Config ())
45+ val diff = new TestDiffGraphBuilder
4546
46- // run the pass on the XML file
4747 pass.runOnPart(diff, xmlFile)
4848 diff.nodes.nonEmpty shouldBe true
4949 val node = diff.nodes.collectFirst { case n : NewConfigFile => n }.get
5050 node.name should (startWith(" test" ) and endWith(" .plist" ))
51- node.content should (startWith( " <!--This has been generated from " ) and endWith(xml))
51+ node.content shouldBe Xml
5252 }
5353 }
5454
5555 it(" creates config node for a binary plist" ) {
5656 FileUtil .usingTemporaryFile(" testbin-src" , " .plist" ) { xmlFile =>
5757 FileUtil .usingTemporaryFile(" testbin" , " .plist" ) { binFile =>
58- Files .write(xmlFile, xml .getBytes(" UTF-8" ))
58+ Files .write(xmlFile, Xml .getBytes(" UTF-8" ))
5959 PropertyListConverter .convertToBinary(xmlFile, binFile)
6060
61- val config = Config ()
62- val pass = new ConfigFileCreationPass (null /* cpg not used in here */ , config)
63- val diff = new TestDiffGraphBuilder
61+ val pass = new ConfigFileCreationPass (null /* cpg not used in here */ , Config ())
62+ val diff = new TestDiffGraphBuilder
6463
6564 pass.runOnPart(diff, binFile)
6665
6766 diff.nodes.nonEmpty shouldBe true
6867 val node = diff.nodes.collectFirst { case n : NewConfigFile => n }.get
6968 node.name should (startWith(" testbin" ) and endWith(" .plist" ))
7069 // binary should have been converted to XML content:
71- node.content should (startWith(" <!--This has been generated from" ) and endWith(xml ))
70+ node.content should (startWith(" <!--This has been generated from" ) and endWith(Xml ))
7271 }
7372 }
7473 }
0 commit comments