fix(can): 회원 2의 강제 통화 예외를 제거한다
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package kr.co.vividnext.sodalive.can
|
||||
|
||||
import kr.co.vividnext.sodalive.common.CountryContext
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.support.EmbeddedRedisInitializer
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.CsvSource
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.test.annotation.DirtiesContext
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.math.BigDecimal
|
||||
import javax.persistence.EntityManager
|
||||
|
||||
@SpringBootTest(properties = ["spring.cache.type=none"])
|
||||
@ContextConfiguration(initializers = [EmbeddedRedisInitializer::class])
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
@Transactional
|
||||
class CanControllerIntegrationTest @Autowired constructor(
|
||||
private val controller: CanController,
|
||||
private val countryContext: CountryContext,
|
||||
private val entityManager: EntityManager
|
||||
) {
|
||||
@BeforeEach
|
||||
fun setUp() {
|
||||
listOf("KRW", "USD", "JPY").forEach { currency ->
|
||||
entityManager.persist(
|
||||
Can(
|
||||
title = "test-$currency",
|
||||
can = 100,
|
||||
rewardCan = 0,
|
||||
price = BigDecimal("100"),
|
||||
currency = currency,
|
||||
status = CanStatus.SALE
|
||||
)
|
||||
)
|
||||
}
|
||||
entityManager.flush()
|
||||
entityManager.clear()
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource(
|
||||
"2, KR, KRW",
|
||||
"2, US, USD",
|
||||
"2, JP, USD",
|
||||
"2, , USD",
|
||||
"4, KR, JPY",
|
||||
"4, US, JPY",
|
||||
"44144, KR, JPY",
|
||||
"44144, US, JPY",
|
||||
"3, KR, KRW",
|
||||
"3, US, USD",
|
||||
", KR, KRW",
|
||||
", US, USD",
|
||||
", , USD"
|
||||
)
|
||||
@DisplayName("회원 2는 국가별 통화를 사용하고 기존 JPY 예외와 일반·비로그인 조회는 유지한다")
|
||||
fun shouldSelectCurrencyByCountryExceptRemainingForcedMembers(
|
||||
memberId: Long?,
|
||||
countryCode: String?,
|
||||
expectedCurrency: String
|
||||
) {
|
||||
val member = memberId?.let { id ->
|
||||
Member(nickname = "test-$id", password = "").apply { this.id = id }
|
||||
}
|
||||
countryContext.setCountryCode(countryCode)
|
||||
|
||||
val response = controller.getCans(member)
|
||||
|
||||
assertEquals(true, response.success)
|
||||
assertEquals(listOf(expectedCurrency), response.data?.map { it.currency })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user