From 8639940b56e4824b75613cac43fc412c3de4729e Mon Sep 17 00:00:00 2001 From: jyx-07 Date: Mon, 3 Aug 2026 15:06:20 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EC=95=88=EB=A7=88=EC=9D=98=EC=9E=90?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20Redis=20=EB=8C=80=EA=B8=B0?= =?UTF-8?q?=EC=97=B4=20=EC=A4=91=EB=B3=B5=20=EC=A1=B0=ED=9A=8C=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/GetMassageServiceImpl.kt | 4 ++-- .../massage/service/GetMassageServiceTest.kt | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) 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() } + } + } + } })