Merge branch 'pairing2' of gitlab.jeudego.org:tournois/pairgoth into pairing2
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
package org.jeudego.pairgoth.test
|
||||
|
||||
import org.jeudego.pairgoth.ext.OpenGotha
|
||||
import org.jeudego.pairgoth.model.toJson
|
||||
import org.jeudego.pairgoth.util.XmlUtils
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.charset.StandardCharsets
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class ImportExportTests: TestBase() {
|
||||
|
||||
companion object {
|
||||
val maskIdRegex = Regex("(?<=\"id\" ?: )\\d+")
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
fun `001 test imports`() {
|
||||
getTestResources("opengotha/tournamentfiles/").forEach { file ->
|
||||
@@ -27,18 +34,23 @@ class ImportExportTests: TestBase() {
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@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 ->
|
||||
getTestResources("opengotha/tournamentfiles").forEach { file ->
|
||||
val resource = file.readText(StandardCharsets.UTF_8)
|
||||
val root_xml = XmlUtils.parse(resource)
|
||||
val tournament = OpenGotha.import(root_xml)
|
||||
val jsonTournament = tournament.toJson().toPrettyString()!!.replace(maskIdRegex, "0")
|
||||
|
||||
val exported = OpenGotha.export(tournament)
|
||||
val tournament2 = OpenGotha.import(XmlUtils.parse(exported))
|
||||
assert(tournament == tournament2)
|
||||
val jsonTournament2 = tournament2.toJson().toPrettyString()!!.replace(maskIdRegex, "0")
|
||||
|
||||
assertEquals(jsonTournament, jsonTournament2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user