diff --git a/src/main/kotlin/team/incube/flooding/domain/dormitory/massage/service/impl/GetMassageServiceImpl.kt b/src/main/kotlin/team/incube/flooding/domain/dormitory/massage/service/impl/GetMassageServiceImpl.kt index 6879c616..1a01f2ab 100644 --- a/src/main/kotlin/team/incube/flooding/domain/dormitory/massage/service/impl/GetMassageServiceImpl.kt +++ b/src/main/kotlin/team/incube/flooding/domain/dormitory/massage/service/impl/GetMassageServiceImpl.kt @@ -26,13 +26,13 @@ class GetMassageServiceImpl( val currentUser = currentUserProvider.getCurrentUser() val now = LocalTime.now(clock) val isApplicationOpen = now >= massageProperties.openTime && now < massageProperties.closeTime + val queue = massageRedisAdapter.getQueue() val myApplicationStatus = when { massageRedisAdapter.isReapplyBlocked(currentUser.id) -> MassageApplicationStatus.CANCELLED - massageRedisAdapter.isApply(currentUser.id) -> MassageApplicationStatus.APPLIED + currentUser.id in queue -> MassageApplicationStatus.APPLIED else -> null } - val queue = massageRedisAdapter.getQueue() val applicants = if (queue.isEmpty()) { emptyList() diff --git a/src/test/kotlin/team/incube/flooding/domain/dormitory/massage/service/GetMassageServiceTest.kt b/src/test/kotlin/team/incube/flooding/domain/dormitory/massage/service/GetMassageServiceTest.kt index 76b4df7d..cc2ee2f9 100644 --- a/src/test/kotlin/team/incube/flooding/domain/dormitory/massage/service/GetMassageServiceTest.kt +++ b/src/test/kotlin/team/incube/flooding/domain/dormitory/massage/service/GetMassageServiceTest.kt @@ -2,10 +2,13 @@ package team.incube.flooding.domain.dormitory.massage.service import io.kotest.core.spec.style.BehaviorSpec import io.kotest.matchers.shouldBe +import io.mockk.clearMocks import io.mockk.every import io.mockk.mockk +import io.mockk.verify import team.incube.flooding.domain.dormitory.massage.adapter.MassageRedisAdapter import team.incube.flooding.domain.dormitory.massage.config.MassageProperties +import team.incube.flooding.domain.dormitory.massage.entity.MassageApplicationStatus import team.incube.flooding.domain.dormitory.massage.service.impl.GetMassageServiceImpl import team.incube.flooding.domain.user.entity.Role import team.incube.flooding.domain.user.entity.Sex @@ -45,7 +48,6 @@ class GetMassageServiceTest : val currentUser = user(999L) every { currentUserProvider.getCurrentUser() } returns currentUser every { massageRedisAdapter.isReapplyBlocked(any()) } returns false - every { massageRedisAdapter.isApply(any()) } returns false val service = GetMassageServiceImpl( @@ -73,4 +75,20 @@ class GetMassageServiceTest : } } } + + given("현재 사용자가 이미 대기열에 포함되어 있을 때") { + `when`("목록을 조회하면") { + then("myApplicationStatus가 APPLIED이다") { + clearMocks(massageRedisAdapter, answers = false) + every { massageRedisAdapter.isReapplyBlocked(any()) } returns false + every { massageRedisAdapter.getQueue() } returns listOf(currentUser.id) + every { userRepository.findAllById(any>()) } returns listOf(currentUser) + + val result = service.execute() + + result.myApplicationStatus shouldBe MassageApplicationStatus.APPLIED + verify(exactly = 1) { massageRedisAdapter.getQueue() } + } + } + } })