added import export test

This commit is contained in:
Theo Barollet
2023-07-08 17:56:25 +02:00
parent ac90b8ee40
commit 5ec283c05e

View File

@@ -1,5 +1,7 @@
package org.jeudego.pairgoth.test package org.jeudego.pairgoth.test
import org.jeudego.pairgoth.ext.OpenGotha
import org.jeudego.pairgoth.util.XmlUtils
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
@@ -24,4 +26,19 @@ class ImportExportTests: TestBase() {
logger.info(xml.slice(0..50)+"...") logger.info(xml.slice(0..50)+"...")
} }
} }
@Test
fun `002 test opengotha import export`() {
// We import a tournament
// Check that after exporting and reimporting we get the same pairgoth tournament object
getTestResources("opengotha").forEach { file ->
val resource = file.readText(StandardCharsets.UTF_8)
val root_xml = XmlUtils.parse(resource)
val tournament = OpenGotha.import(root_xml)
val exported = OpenGotha.export(tournament)
val tournament2 = OpenGotha.import(XmlUtils.parse(exported))
assert(tournament == tournament2)
}
}
} }