fix(recommendation): native Boolean 매핑을 보정한다
This commit is contained in:
@@ -475,9 +475,9 @@ class DefaultHomeRecommendationQueryRepository(
|
||||
title = row[4] as String,
|
||||
price = (row[5] as Number).toInt(),
|
||||
coverImage = row[6] as String?,
|
||||
isPointAvailable = row[7] as Boolean,
|
||||
isAdult = row[8] as Boolean,
|
||||
isOriginalSeries = row[9] as Boolean
|
||||
isPointAvailable = row[7].toNativeBoolean(),
|
||||
isAdult = row[8].toNativeBoolean(),
|
||||
isOriginalSeries = row[9].toNativeBoolean()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1185,6 +1185,14 @@ class DefaultHomeRecommendationQueryRepository(
|
||||
return if (condition == null) this else and(condition)
|
||||
}
|
||||
|
||||
private fun Any?.toNativeBoolean(): Boolean {
|
||||
return when (this) {
|
||||
is Boolean -> this
|
||||
is Number -> this.toInt() != 0
|
||||
else -> this as Boolean
|
||||
}
|
||||
}
|
||||
|
||||
private fun includeAdultCommunityCondition(includeAdultCommunities: Boolean): BooleanExpression? {
|
||||
return if (includeAdultCommunities) null else creatorCommunity.isAdult.isFalse
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user