From f4fa3c2f56abdca1ef99272c0f925a7096abea99 Mon Sep 17 00:00:00 2001 From: leeeryboy Date: Mon, 11 Sep 2023 18:18:17 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seminar/service/SeminarServiceTest.kt | 113 +++++++++--------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/src/test/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarServiceTest.kt b/src/test/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarServiceTest.kt index 0ff9573a..64359c52 100644 --- a/src/test/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarServiceTest.kt +++ b/src/test/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarServiceTest.kt @@ -9,13 +9,14 @@ import io.kotest.matchers.shouldNotBe import jakarta.transaction.Transactional import org.springframework.boot.test.context.SpringBootTest import org.springframework.data.repository.findByIdOrNull +import java.time.LocalDateTime @SpringBootTest @Transactional -class SeminarServiceTest ( +class SeminarServiceTest( private val seminarService: SeminarService, private val seminarRepository: SeminarRepository, -): BehaviorSpec() { +) : BehaviorSpec() { init { beforeContainer { @@ -27,42 +28,42 @@ class SeminarServiceTest ( Given("세미나를 생성하려고 할 때") { val seminarDTO = SeminarDto( - id = -1, - title = "title", - description = """ + id = -1, + title = "title", + description = """

Hello, World!

This is seminar description.

Goodbye, World!

""".trimIndent(), - introduction = """ + introduction = """

Hello, World!

This is seminar introduction.

Goodbye, World!

""".trimIndent(), - name = "name", - speakerURL = "speakerURL", - speakerTitle = "speakerTitle", - affiliation = "affiliation", - affiliationURL = "affiliationURL", - startDate = "startDate", - endDate = "endDate", - location = "location", - host = "host", - additionalNote = """ + name = "name", + speakerURL = "speakerURL", + speakerTitle = "speakerTitle", + affiliation = "affiliation", + affiliationURL = "affiliationURL", + startDate = LocalDateTime.now(), + endDate = LocalDateTime.now(), + location = "location", + host = "host", + additionalNote = """

Hello, World!

This is seminar additionalNote.

Goodbye, World!

""".trimIndent(), - createdAt = null, - modifiedAt = null, - isPrivate = false, - isImportant = false, - prevId = null, - prevTitle = null, - nextId = null, - nextTitle = null, - imageURL = null, - attachments = null + createdAt = null, + modifiedAt = null, + isPrivate = false, + isImportant = false, + prevId = null, + prevTitle = null, + nextId = null, + nextTitle = null, + imageURL = null, + attachments = null ) When("간단한 세미나 DTO가 주어지면") { val resultSeminarDTO = seminarService.createSeminar(seminarDTO, null, null) @@ -83,58 +84,58 @@ class SeminarServiceTest ( Given("기존 간단한 세미나의 Description을 수정하려고 할 때") { val originalSeminar = seminarRepository.save( - SeminarEntity( - title = "title", - description = """ + SeminarEntity( + title = "title", + description = """

Hello, World!

This is seminar description.

Goodbye, World!

""".trimIndent(), - plainTextDescription = "Hello, World! This is seminar description. Goodbye, World!", - introduction = """ + plainTextDescription = "Hello, World! This is seminar description. Goodbye, World!", + introduction = """

Hello, World!

This is seminar introduction.

Goodbye, World!

""".trimIndent(), - plainTextIntroduction = "Hello, World! This is seminar introduction. Goodbye, World!", - name = "name", - speakerURL = "speakerURL", - speakerTitle = "speakerTitle", - affiliation = "affiliation", - affiliationURL = "affiliationURL", - startDate = "startDate", - endDate = "endDate", - location = "location", - host = "host", - additionalNote = """ + plainTextIntroduction = "Hello, World! This is seminar introduction. Goodbye, World!", + name = "name", + speakerURL = "speakerURL", + speakerTitle = "speakerTitle", + affiliation = "affiliation", + affiliationURL = "affiliationURL", + startDate = LocalDateTime.now(), + endDate = LocalDateTime.now(), + location = "location", + host = "host", + additionalNote = """

Hello, World!

This is seminar additionalNote.

Goodbye, World!

""".trimIndent(), - plainTextAdditionalNote = "Hello, World! This is seminar additionalNote. Goodbye, World!", - isPrivate = false, - isImportant = false, - ) + plainTextAdditionalNote = "Hello, World! This is seminar additionalNote. Goodbye, World!", + isPrivate = false, + isImportant = false, + ) ) val originalId = originalSeminar.id When("수정된 DTO를 이용하여 수정하면") { val modifiedSeminarDTO = SeminarDto.of( - originalSeminar, null, emptyList(), null + originalSeminar, null, emptyList(), null ).copy( - description = """ + description = """

Hello, World!

This is modified seminar description.

Goodbye, World!

And this is a new line.

""".trimIndent(), - introduction = """ + introduction = """

Hello, World!

This is modified seminar introduction.

Goodbye, World!

And this is a new line.

""".trimIndent(), - additionalNote = """ + additionalNote = """

Hello, World!

This is modified seminar additionalNote.

Goodbye, World!

@@ -143,11 +144,11 @@ class SeminarServiceTest ( ) val modifiedSeminarDto = seminarService.updateSeminar( - originalSeminar.id, - modifiedSeminarDTO, - null, - null, - emptyList() + originalSeminar.id, + modifiedSeminarDTO, + null, + null, + emptyList() ) Then("같은 Entity가 수정되어야 한다.") { @@ -165,4 +166,4 @@ class SeminarServiceTest ( } } } -} \ No newline at end of file +}