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 @@ -11,7 +11,6 @@ import org.springframework.scheduling.annotation.Async
import org.springframework.stereotype.Component
import org.springframework.transaction.event.TransactionPhase
import org.springframework.transaction.event.TransactionalEventListener
import java.time.LocalDate

private val logger = KotlinLogging.logger {}

Expand Down Expand Up @@ -79,7 +78,7 @@ class NotificationEventListener(
bodyArgs = arrayOf(nickname),
deepLinkParams = mapOf(
"goalId" to event.goalId.toString(),
"date" to LocalDate.now().toString(),
"date" to event.verificationDate.toString(),
),
)
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ data class PokedEvent(
data class PhotologCreatedEvent(
val userId: Long,
val goalId: Long,
val verificationDate: LocalDate,
)

data class GoalEndedEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ class PhotologService(
)
)

notificationEventPublisher.publishEvent(PhotologCreatedEvent(userId = userId, goalId = goalId))
notificationEventPublisher.publishEvent(
PhotologCreatedEvent(userId = userId, goalId = goalId, verificationDate = verificationDate),
)

return saved
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class NotificationEventListenerTest : DescribeSpec({
val userId = 1L
val partnerId = 2L
val goalId = 10L
val verificationDate = LocalDate.of(2026, 1, 15)

val coupleInfo = CoupleInfo(
id = 100L,
Expand Down Expand Up @@ -145,15 +146,17 @@ class NotificationEventListenerTest : DescribeSpec({
UserAdditionInfo(userId = userId, nickname = "철수")
every { goalRepository.findById(goalId) } returns goal

listener.handlePhotologCreated(PhotologCreatedEvent(userId = userId, goalId = goalId))
listener.handlePhotologCreated(
PhotologCreatedEvent(userId = userId, goalId = goalId, verificationDate = verificationDate),
)

verify {
notificationService.sendNotification(
targetUserId = partnerId,
type = NotificationType.GOAL_COMPLETED,
titleArgs = arrayOf("철수", "운동하기"),
bodyArgs = arrayOf("철수"),
deepLinkParams = mapOf("goalId" to "10", "date" to LocalDate.now().toString()),
deepLinkParams = mapOf("goalId" to "10", "date" to verificationDate.toString()),
)
}
}
Expand All @@ -172,15 +175,17 @@ class NotificationEventListenerTest : DescribeSpec({
UserAdditionInfo(userId = userId, nickname = "철수")
every { goalRepository.findById(goalId) } returns goal

listener.handlePhotologCreated(PhotologCreatedEvent(userId = userId, goalId = goalId))
listener.handlePhotologCreated(
PhotologCreatedEvent(userId = userId, goalId = goalId, verificationDate = verificationDate),
)

verify {
notificationService.sendNotification(
targetUserId = partnerId,
type = NotificationType.GOAL_COMPLETED,
titleArgs = arrayOf("철수", "운동하기"),
bodyArgs = arrayOf("철수"),
deepLinkParams = mapOf("goalId" to "10", "date" to LocalDate.now().toString()),
deepLinkParams = mapOf("goalId" to "10", "date" to verificationDate.toString()),
)
}
}
Expand All @@ -192,15 +197,17 @@ class NotificationEventListenerTest : DescribeSpec({
every { userAdditionInfoRepository.findByUserId(userId) } returns null
every { goalRepository.findById(goalId) } returns goal

listener.handlePhotologCreated(PhotologCreatedEvent(userId = userId, goalId = goalId))
listener.handlePhotologCreated(
PhotologCreatedEvent(userId = userId, goalId = goalId, verificationDate = verificationDate),
)

verify {
notificationService.sendNotification(
targetUserId = partnerId,
type = NotificationType.GOAL_COMPLETED,
titleArgs = arrayOf("상대방", "운동하기"),
bodyArgs = arrayOf("상대방"),
deepLinkParams = mapOf("goalId" to "10", "date" to LocalDate.now().toString()),
deepLinkParams = mapOf("goalId" to "10", "date" to verificationDate.toString()),
)
}
}
Expand All @@ -210,7 +217,9 @@ class NotificationEventListenerTest : DescribeSpec({
it("알림을 전송하지 않는다") {
every { coupleInfoRepository.findByUserId(userId) } returns null

listener.handlePhotologCreated(PhotologCreatedEvent(userId = userId, goalId = goalId))
listener.handlePhotologCreated(
PhotologCreatedEvent(userId = userId, goalId = goalId, verificationDate = verificationDate),
)

verify(exactly = 0) { notificationService.sendNotification(any(), any(), any(), any(), any()) }
}
Expand All @@ -223,7 +232,9 @@ class NotificationEventListenerTest : DescribeSpec({
UserAdditionInfo(userId = userId, nickname = "철수")
every { goalRepository.findById(goalId) } returns null

listener.handlePhotologCreated(PhotologCreatedEvent(userId = userId, goalId = goalId))
listener.handlePhotologCreated(
PhotologCreatedEvent(userId = userId, goalId = goalId, verificationDate = verificationDate),
)

verify(exactly = 0) { notificationService.sendNotification(any(), any(), any(), any(), any()) }
}
Expand Down
Loading