fix(can): 캔 서비스 조회 트랜잭션을 적용한다
This commit is contained in:
@@ -6,10 +6,12 @@ import kr.co.vividnext.sodalive.common.CountryContext
|
|||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import org.springframework.data.domain.Pageable
|
import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
import org.springframework.transaction.annotation.Transactional
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@Transactional(readOnly = true)
|
||||||
class CanService(
|
class CanService(
|
||||||
private val repository: CanRepository,
|
private val repository: CanRepository,
|
||||||
private val countryContext: CountryContext
|
private val countryContext: CountryContext
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test
|
|||||||
import org.mockito.Mockito.mock
|
import org.mockito.Mockito.mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.springframework.data.domain.PageRequest
|
import org.springframework.data.domain.PageRequest
|
||||||
|
import org.springframework.transaction.annotation.Transactional
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
class CanServiceTest {
|
class CanServiceTest {
|
||||||
@@ -134,6 +135,14 @@ class CanServiceTest {
|
|||||||
assertEquals("캐릭터 톡 이용권 구매", result[5].title)
|
assertEquals("캐릭터 톡 이용권 구매", result[5].title)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("캔 서비스 조회 로직은 read-only 트랜잭션 경계에서 실행된다")
|
||||||
|
fun `should run can service queries in read only transaction`() {
|
||||||
|
val transactional = CanService::class.java.getAnnotation(Transactional::class.java)
|
||||||
|
|
||||||
|
assertEquals(true, transactional.readOnly)
|
||||||
|
}
|
||||||
|
|
||||||
private fun createUseCanDto(
|
private fun createUseCanDto(
|
||||||
usage: CanUsage,
|
usage: CanUsage,
|
||||||
can: Int,
|
can: Int,
|
||||||
|
|||||||
Reference in New Issue
Block a user