fix(recommendation): native Boolean 매핑을 보정한다

This commit is contained in:
2026-06-27 10:56:05 +09:00
parent 9c458d0ae1
commit b3cf26119b
2 changed files with 54 additions and 3 deletions
@@ -44,11 +44,15 @@ import kr.co.vividnext.sodalive.v2.recommendation.port.out.HomePopularCommunityR
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers.any
import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mockito
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
import org.springframework.context.annotation.Import
import java.time.LocalDateTime
import javax.persistence.EntityManager
import javax.persistence.Query
@DataJpaTest(
properties = [
@@ -1183,6 +1187,45 @@ class DefaultHomeRecommendationQueryRepositoryTest @Autowired constructor(
assertEquals(true, contents.single().isOriginalSeries)
}
@Test
@DisplayName("첫 오디오 콘텐츠 native query의 숫자 Boolean 값을 매핑한다")
fun shouldMapNumericNativeBooleanFromFirstAudioContentRows() {
val mockEntityManager = Mockito.mock(EntityManager::class.java)
val mockQuery = Mockito.mock(Query::class.java)
val repository = DefaultHomeRecommendationQueryRepository(
JPAQueryFactory(mockEntityManager),
mockEntityManager
)
Mockito.`when`(mockEntityManager.createNativeQuery(anyString())).thenReturn(mockQuery)
Mockito.`when`(mockQuery.setParameter(anyString(), any())).thenReturn(mockQuery)
Mockito.`when`(mockQuery.resultList).thenReturn(
listOf(
arrayOf(
1L,
2L,
"creator",
null,
"title",
0,
null,
true,
false,
1
)
)
)
val contents = repository.findFirstAudioContents(
now = LocalDateTime.of(2026, 6, 27, 10, 0),
offset = 0L,
limit = 1,
memberId = null,
includeAdultContents = false
)
assertEquals(true, contents.single().isOriginalSeries)
}
@Test
@DisplayName("첫 오디오 콘텐츠는 회원과 크리에이터의 양방향 차단 관계를 제외한다")
fun shouldExcludeBidirectionalBlockedCreatorsFromFirstAudioContents() {