Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<List<Long>>()) } returns listOf(currentUser)

val result = service.execute()

result.myApplicationStatus shouldBe MassageApplicationStatus.APPLIED
verify(exactly = 1) { massageRedisAdapter.getQueue() }
}
}
}
})
Loading