feat(ranking): 랭킹 내부 모델을 추가한다
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package kr.co.vividnext.sodalive.v2.ranking.domain
|
||||
|
||||
data class CreatorRankingItem(
|
||||
val rank: Int,
|
||||
val rankChange: Int?,
|
||||
val isNew: Boolean,
|
||||
val creatorId: Long,
|
||||
val nickname: String,
|
||||
val profileImageUrl: String?
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
package kr.co.vividnext.sodalive.v2.ranking.domain
|
||||
|
||||
data class CreatorRankingSnapshotCandidate(
|
||||
val creatorId: Long,
|
||||
val nickname: String,
|
||||
val profileImageUrl: String?,
|
||||
val finalScore: Double,
|
||||
val contentLiveScore: Double,
|
||||
val engagementScore: Double,
|
||||
val supportScore: Double,
|
||||
val fanLoyaltyScore: Double,
|
||||
val liveCanAmount: Long,
|
||||
val contentPurchaseCanAmount: Long,
|
||||
val contentLikeCount: Long,
|
||||
val contentCommentCount: Long,
|
||||
val channelDonationCanAmount: Long,
|
||||
val channelDonationCount: Long,
|
||||
val fanTalkCount: Long,
|
||||
val finalFollowerCount: Long,
|
||||
val followIncrease: Long
|
||||
)
|
||||
@@ -0,0 +1,52 @@
|
||||
package kr.co.vividnext.sodalive.v2.ranking.application
|
||||
|
||||
import kr.co.vividnext.sodalive.v2.ranking.domain.CreatorRankingItem
|
||||
import kr.co.vividnext.sodalive.v2.ranking.domain.CreatorRankingSnapshotCandidate
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class CreatorRankingQueryServiceTest {
|
||||
@Test
|
||||
@DisplayName("스냅샷 후보와 조회 item 내부 모델은 순위 변화와 신규 진입 값을 담을 수 있다")
|
||||
fun shouldCreateRankingDomainModelsForLaterQueryService() {
|
||||
val candidate = CreatorRankingSnapshotCandidate(
|
||||
creatorId = 1L,
|
||||
nickname = "creator",
|
||||
profileImageUrl = "profile.png",
|
||||
finalScore = 100.0,
|
||||
contentLiveScore = 10.0,
|
||||
engagementScore = 20.0,
|
||||
supportScore = 30.0,
|
||||
fanLoyaltyScore = 40.0,
|
||||
liveCanAmount = 100,
|
||||
contentPurchaseCanAmount = 200,
|
||||
contentLikeCount = 3,
|
||||
contentCommentCount = 4,
|
||||
channelDonationCanAmount = 500,
|
||||
channelDonationCount = 6,
|
||||
fanTalkCount = 7,
|
||||
finalFollowerCount = 8,
|
||||
followIncrease = -1
|
||||
)
|
||||
val item = CreatorRankingItem(
|
||||
rank = 1,
|
||||
rankChange = null,
|
||||
isNew = true,
|
||||
creatorId = candidate.creatorId,
|
||||
nickname = candidate.nickname,
|
||||
profileImageUrl = candidate.profileImageUrl
|
||||
)
|
||||
val fallenItem = item.copy(rank = 2, rankChange = -1, isNew = false)
|
||||
|
||||
assertEquals(1L, candidate.creatorId)
|
||||
assertEquals(100.0, candidate.finalScore, 0.0001)
|
||||
assertNull(item.rankChange)
|
||||
assertTrue(item.isNew)
|
||||
assertEquals(-1, fallenItem.rankChange)
|
||||
assertFalse(fallenItem.isNew)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user