mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-10-07 22:28:09 +03:00
[O] Add tests for other games
This commit is contained in:
@@ -3,12 +3,21 @@ package test
|
||||
import com.fasterxml.jackson.databind.JsonNode
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import ext.JACKSON
|
||||
import icu.samnyan.aqua.net.games.chu3.Chu3DataExport
|
||||
import icu.samnyan.aqua.net.games.mai2.Maimai2DataExport
|
||||
import icu.samnyan.aqua.net.games.ongeki.OngekiDataExport
|
||||
import icu.samnyan.aqua.net.games.wacca.WaccaDataExport
|
||||
import icu.samnyan.aqua.sega.chusan.model.userdata.Chu3UserData
|
||||
import icu.samnyan.aqua.sega.chusan.model.userdata.UserPlaylog as Chu3UserPlaylog
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserDetail
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserMap
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserPlaylog
|
||||
import icu.samnyan.aqua.sega.ongeki.model.UserData as OngekiUserData
|
||||
import icu.samnyan.aqua.sega.ongeki.model.UserPlaylog as OngekiUserPlaylog
|
||||
import icu.samnyan.aqua.sega.util.BASIC_MAPPER
|
||||
import icu.samnyan.aqua.sega.util.STRING_MAPPER
|
||||
import icu.samnyan.aqua.sega.wacca.model.db.WcUserPlayLog
|
||||
import icu.samnyan.aqua.sega.wacca.model.db.WaccaUser
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
@@ -23,25 +32,6 @@ class ReproduceIssueTest {
|
||||
?: error("Test resource $path not found")
|
||||
}
|
||||
|
||||
private fun samplePlaylog() = Mai2UserPlaylog().apply {
|
||||
musicId = 11479
|
||||
level = 2
|
||||
achievement = 1000000
|
||||
isClear = true
|
||||
}
|
||||
|
||||
private fun sampleMap() = Mai2UserMap().apply {
|
||||
mapId = 1
|
||||
distance = 100
|
||||
isClear = true
|
||||
}
|
||||
|
||||
private fun sampleExport() = Maimai2DataExport().apply {
|
||||
userData = Mai2UserDetail().apply { userName = "TestUser" }
|
||||
userPlaylogList = listOf(samplePlaylog())
|
||||
userMapList = listOf(sampleMap())
|
||||
}
|
||||
|
||||
private fun checkFieldNamesAndValuesMatchRecursive(baselineNode: JsonNode, currentNode: JsonNode, path: String = "$") {
|
||||
assertEquals(baselineNode.nodeType, currentNode.nodeType, "Node type mismatch at path '$path'")
|
||||
|
||||
@@ -73,10 +63,15 @@ class ReproduceIssueTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testObjectMapperWithoutKotlinModule() {
|
||||
fun testObjectMapperWithoutKotlinModuleStripsIsGetters() {
|
||||
val mai2Export = Maimai2DataExport().apply {
|
||||
userData = Mai2UserDetail().apply { userName = "TestUser" }
|
||||
userPlaylogList = listOf(Mai2UserPlaylog().apply { isClear = true })
|
||||
}
|
||||
|
||||
// Standard Jackson 2 ObjectMapper() without KotlinModule strips 'is' getters:
|
||||
val plainObjectMapper = ObjectMapper()
|
||||
val plainJson = plainObjectMapper.writeValueAsString(sampleExport())
|
||||
val plainJson = plainObjectMapper.writeValueAsString(mai2Export)
|
||||
val plainTree = plainObjectMapper.readTree(plainJson)
|
||||
val plainPlaylogNode = plainTree.at("/userPlaylogList/0")
|
||||
|
||||
@@ -87,33 +82,134 @@ class ReproduceIssueTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMai2ExportEntityFieldNamesAndValuesMatchBaselineRecursively() {
|
||||
val currentTree = JACKSON.readTree(JACKSON.writeValueAsString(sampleExport()))
|
||||
val baselineTree = JACKSON.readTree(loadResourceJson("/json/mai2_export_web.json"))
|
||||
fun testMai2ExportAndPlaylogSerialization() {
|
||||
val mai2Playlog = Mai2UserPlaylog().apply {
|
||||
musicId = 11479
|
||||
level = 2
|
||||
achievement = 1000000
|
||||
isClear = true
|
||||
}
|
||||
|
||||
val mai2Map = Mai2UserMap().apply {
|
||||
mapId = 1
|
||||
distance = 100
|
||||
isClear = true
|
||||
}
|
||||
|
||||
val mai2Export = Maimai2DataExport().apply {
|
||||
userData = Mai2UserDetail().apply { userName = "TestUser" }
|
||||
userPlaylogList = listOf(mai2Playlog)
|
||||
userMapList = listOf(mai2Map)
|
||||
}
|
||||
|
||||
val currentTree = JACKSON.readTree(JACKSON.writeValueAsString(mai2Export))
|
||||
val baselineTree = JACKSON.readTree(loadResourceJson("/json/mai2_export_web.json"))
|
||||
checkFieldNamesAndValuesMatchRecursive(baselineTree, currentTree)
|
||||
|
||||
val basicTree = BASIC_MAPPER.readTree(BASIC_MAPPER.writeValueAsString(mai2Playlog))
|
||||
val baselineBasicTree = BASIC_MAPPER.readTree(loadResourceJson("/json/mai2_playlog_basic.json"))
|
||||
checkFieldNamesAndValuesMatchRecursive(baselineBasicTree, basicTree, "Mai2UserPlaylog (BASIC_MAPPER)")
|
||||
|
||||
val stringTree = STRING_MAPPER.readTree(STRING_MAPPER.writeValueAsString(mai2Playlog))
|
||||
val baselineStringTree = STRING_MAPPER.readTree(loadResourceJson("/json/mai2_playlog_string.json"))
|
||||
checkFieldNamesAndValuesMatchRecursive(baselineStringTree, stringTree, "Mai2UserPlaylog (STRING_MAPPER)")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGameFacingMaimai2PlaylogFieldNamesAndValuesMatchBaselineRecursively() {
|
||||
val mai2Playlog = samplePlaylog()
|
||||
fun testChu3ExportAndPlaylogSerialization() {
|
||||
val chu3Playlog = Chu3UserPlaylog().apply {
|
||||
musicId = 100
|
||||
level = 1
|
||||
score = 1000000
|
||||
isClear = true
|
||||
isFullCombo = true
|
||||
isAllJustice = true
|
||||
}
|
||||
|
||||
val currentBasicTree = BASIC_MAPPER.readTree(BASIC_MAPPER.writeValueAsString(mai2Playlog))
|
||||
val baselineBasicTree = BASIC_MAPPER.readTree(loadResourceJson("/json/mai2_playlog_basic.json"))
|
||||
checkFieldNamesAndValuesMatchRecursive(baselineBasicTree, currentBasicTree, "Mai2UserPlaylog (BASIC_MAPPER)")
|
||||
val chu3Export = Chu3DataExport().apply {
|
||||
userData = Chu3UserData().apply { userName = "ChuUser" }
|
||||
userPlaylogList = listOf(chu3Playlog)
|
||||
}
|
||||
|
||||
val currentStringTree = STRING_MAPPER.readTree(STRING_MAPPER.writeValueAsString(mai2Playlog))
|
||||
val baselineStringTree = STRING_MAPPER.readTree(loadResourceJson("/json/mai2_playlog_string.json"))
|
||||
checkFieldNamesAndValuesMatchRecursive(baselineStringTree, currentStringTree, "Mai2UserPlaylog (STRING_MAPPER)")
|
||||
val currentTree = JACKSON.readTree(JACKSON.writeValueAsString(chu3Export))
|
||||
val playlogNode = currentTree.at("/userPlaylogList/0")
|
||||
|
||||
assertTrue(playlogNode.has("isClear"), "Chu3 playlog must have 'isClear'")
|
||||
assertTrue(playlogNode.has("isFullCombo"), "Chu3 playlog must have 'isFullCombo'")
|
||||
assertTrue(playlogNode.has("isAllJustice"), "Chu3 playlog must have 'isAllJustice'")
|
||||
assertTrue(playlogNode.has("isAllPerfect"), "Chu3 playlog must have 'isAllPerfect'")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOngekiExportAndPlaylogSerialization() {
|
||||
val ongekiPlaylog = OngekiUserPlaylog().apply {
|
||||
musicId = 200
|
||||
level = 1
|
||||
techScore = 1000000
|
||||
isFullBell = true
|
||||
isFullCombo = true
|
||||
isAllBreak = true
|
||||
}
|
||||
|
||||
val ongekiExport = OngekiDataExport().apply {
|
||||
userData = OngekiUserData().apply { userName = "OngekiUser" }
|
||||
userPlaylogList = listOf(ongekiPlaylog)
|
||||
}
|
||||
|
||||
val currentTree = JACKSON.readTree(JACKSON.writeValueAsString(ongekiExport))
|
||||
val playlogNode = currentTree.at("/userPlaylogList/0")
|
||||
|
||||
assertTrue(playlogNode.has("isFullBell"), "Ongeki playlog must have 'isFullBell'")
|
||||
assertTrue(playlogNode.has("isFullCombo"), "Ongeki playlog must have 'isFullCombo'")
|
||||
assertTrue(playlogNode.has("isAllBreak"), "Ongeki playlog must have 'isAllBreak'")
|
||||
assertTrue(playlogNode.has("isAllPerfect"), "Ongeki playlog must have 'isAllPerfect'")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWaccaExportAndPlaylogSerialization() {
|
||||
val waccaPlaylog = WcUserPlayLog().apply {
|
||||
musicId = 300
|
||||
level = 1
|
||||
achievement = 990000
|
||||
isClear = true
|
||||
isMissless = true
|
||||
isFullCombo = true
|
||||
isAllPerfect = true
|
||||
}
|
||||
|
||||
val waccaExport = WaccaDataExport(
|
||||
userData = WaccaUser().apply { userName = "WaccaUser" },
|
||||
userOptionList = emptyList(),
|
||||
userBingoList = emptyList(),
|
||||
userFriendList = emptyList(),
|
||||
userGateList = emptyList(),
|
||||
userItemList = emptyList(),
|
||||
userBestScoreList = emptyList(),
|
||||
userPlaylogList = listOf(waccaPlaylog),
|
||||
userStageUpList = emptyList()
|
||||
)
|
||||
|
||||
val currentTree = JACKSON.readTree(JACKSON.writeValueAsString(waccaExport))
|
||||
val playlogNode = currentTree.at("/userPlaylogList/0")
|
||||
|
||||
assertTrue(playlogNode.has("isClear"), "Wacca playlog must have 'isClear'")
|
||||
assertTrue(playlogNode.has("isMissless"), "Wacca playlog must have 'isMissless'")
|
||||
assertTrue(playlogNode.has("isFullCombo"), "Wacca playlog must have 'isFullCombo'")
|
||||
assertTrue(playlogNode.has("isAllPerfect"), "Wacca playlog must have 'isAllPerfect'")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJackson3JsonMapperWithKotlinModule() {
|
||||
val mai2Export = Maimai2DataExport().apply {
|
||||
userData = Mai2UserDetail().apply { userName = "TestUser" }
|
||||
userPlaylogList = listOf(Mai2UserPlaylog().apply { isClear = true })
|
||||
}
|
||||
|
||||
val j3Mapper = JsonMapper.builder()
|
||||
.addModule(KotlinModule.Builder().build())
|
||||
.build()
|
||||
|
||||
val j3Json = j3Mapper.writeValueAsString(sampleExport())
|
||||
val j3Json = j3Mapper.writeValueAsString(mai2Export)
|
||||
val j3Tree = j3Mapper.readTree(j3Json)
|
||||
val j3PlaylogNode = j3Tree.at("/userPlaylogList/0")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user