-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make relationships with MailHistory and MailMessage by id r…
…eference
- Loading branch information
Showing
7 changed files
with
38 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import java.time.LocalDateTime | |
private const val SUBJECT: String = "메일제목" | ||
private const val BODY: String = "메일 본문 입니다." | ||
private const val SENDER: String = "[email protected]" | ||
private const val MAIL_MESSAGE_ID: Long = 1L | ||
private val RECIPIENTS: List<String> = listOf("[email protected]", "[email protected]") | ||
private val SENT_TIME: LocalDateTime = LocalDateTime.now() | ||
private val RESERVATION_TIME: LocalDateTime = LocalDateTime.now().plusHours(3).withMinute(0) | ||
|
@@ -44,10 +45,8 @@ fun createMailReservation( | |
} | ||
|
||
fun createSuccessMailHistory( | ||
subject: String = SUBJECT, | ||
body: String = BODY, | ||
sender: String = SENDER, | ||
mailMessageId: Long = MAIL_MESSAGE_ID, | ||
recipients: List<String> = RECIPIENTS | ||
): MailHistory { | ||
return MailHistory(createMailMessage(subject, body, sender, recipients), recipients, true) | ||
return MailHistory(mailMessageId, recipients, true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package apply.application | ||
|
||
import apply.application.mail.MailHistoryService | ||
import apply.createMailMessage | ||
import apply.createSuccessMailHistory | ||
import apply.domain.mail.MailHistoryRepository | ||
import apply.domain.mail.MailMessageRepository | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.collections.shouldContain | ||
import io.mockk.clearAllMocks | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
|
@@ -18,17 +19,21 @@ class MailHistoryServiceTest : BehaviorSpec({ | |
val mailHistoryService = MailHistoryService(mailHistoryRepository, mailMessageRepository) | ||
|
||
Given("메일 이력이 있는 경우") { | ||
val mailMessage = createMailMessage(id = 1L) | ||
|
||
every { mailHistoryRepository.findAll() } returns listOf( | ||
createSuccessMailHistory(subject = "제목1"), | ||
createSuccessMailHistory(subject = "제목2") | ||
createSuccessMailHistory(mailMessage.id, listOf("[email protected]")), | ||
createSuccessMailHistory(mailMessage.id, listOf("[email protected]")) | ||
) | ||
|
||
every { mailMessageRepository.findAllById(any()) } returns listOf(mailMessage) | ||
|
||
When("모든 메일 이력을 조회하면") { | ||
val actual = mailHistoryService.findAll() | ||
|
||
Then("모든 메일 이력을 확인할 수 있다") { | ||
actual[0].subject shouldBe "제목1" | ||
actual[1].subject shouldBe "제목2" | ||
actual[0].recipients shouldContain "[email protected]" | ||
actual[1].recipients shouldContain "[email protected]" | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters