test #426
@@ -0,0 +1,17 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.home.live.dto
|
||||
|
||||
data class HomeOnAirLivePageResponse(
|
||||
val items: List<HomeOnAirLiveResponse>,
|
||||
val page: Int,
|
||||
val size: Int,
|
||||
val hasNext: Boolean
|
||||
)
|
||||
|
||||
data class HomeOnAirLiveResponse(
|
||||
val roomId: Long,
|
||||
val creatorNickname: String,
|
||||
val creatorProfileImage: String,
|
||||
val title: String,
|
||||
val price: Int,
|
||||
val beginDateTimeUtc: String
|
||||
)
|
||||
@@ -0,0 +1,40 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.home.live.dto
|
||||
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class HomeOnAirLiveResponseTest {
|
||||
private val objectMapper = jacksonObjectMapper()
|
||||
|
||||
@Test
|
||||
fun shouldSerializeOnAirLivePageResponse() {
|
||||
val response = HomeOnAirLivePageResponse(
|
||||
items = listOf(
|
||||
HomeOnAirLiveResponse(
|
||||
roomId = 1L,
|
||||
creatorNickname = "creator",
|
||||
creatorProfileImage = "https://cdn.test/profile.png",
|
||||
title = "paid live",
|
||||
price = 30,
|
||||
beginDateTimeUtc = "2026-06-26T12:30:00Z"
|
||||
)
|
||||
),
|
||||
page = 0,
|
||||
size = 20,
|
||||
hasNext = true
|
||||
)
|
||||
|
||||
val json = objectMapper.readTree(objectMapper.writeValueAsString(response))
|
||||
|
||||
assertEquals(1L, json["items"][0]["roomId"].asLong())
|
||||
assertEquals("creator", json["items"][0]["creatorNickname"].asText())
|
||||
assertEquals("https://cdn.test/profile.png", json["items"][0]["creatorProfileImage"].asText())
|
||||
assertEquals("paid live", json["items"][0]["title"].asText())
|
||||
assertEquals(30, json["items"][0]["price"].asInt())
|
||||
assertEquals("2026-06-26T12:30:00Z", json["items"][0]["beginDateTimeUtc"].asText())
|
||||
assertEquals(0, json["page"].asInt())
|
||||
assertEquals(20, json["size"].asInt())
|
||||
assertEquals(true, json["hasNext"].asBoolean())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user