-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from KUSITMS-29th-TEAM-B/test/flight-169
test: 경험 도메인 테스트 코드 작성(#169)
- Loading branch information
Showing
8 changed files
with
423 additions
and
3 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
60 changes: 60 additions & 0 deletions
60
...t/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceAppenderTest.kt
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.bamyanggang.domainmodule.domain.experience.service | ||
|
||
import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceContent | ||
import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceStrongPoint | ||
import com.bamyanggang.domainmodule.domain.experience.repository.ExperienceRepository | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
class ExperienceAppenderTest : BehaviorSpec({ | ||
val experienceRepository = mockk<ExperienceRepository>(relaxed = true) | ||
val experienceAppender = ExperienceAppender(experienceRepository) | ||
|
||
Given("경험 등록 데이터들이 주어졌을 때") { | ||
val title = "경험 제목" | ||
val parentTagId: UUID = UUID.randomUUID() | ||
val childTagId: UUID = UUID.randomUUID() | ||
val contents = arrayListOf( | ||
ExperienceContent( | ||
question = "질문 1", | ||
answer = "대답 1" | ||
), | ||
ExperienceContent( | ||
question = "질문 2", | ||
answer = "대답 2" | ||
) | ||
) | ||
|
||
val experienceStrongPoints: List<ExperienceStrongPoint> = arrayListOf( | ||
ExperienceStrongPoint.create( | ||
UUID.randomUUID() | ||
), | ||
ExperienceStrongPoint.create( | ||
UUID.randomUUID() | ||
) | ||
) | ||
val startedAt: LocalDateTime = LocalDateTime.now() | ||
val endedAt: LocalDateTime = startedAt.plusDays(1) | ||
val userId = UUID.randomUUID() | ||
|
||
When("ExperienceAppender.appendExperience를 호출하면") { | ||
val newExperience = experienceAppender.appendExperience( | ||
title = title, | ||
parentTagId = parentTagId, | ||
childTagId = childTagId, | ||
contents = contents, | ||
experienceStrongPoints = experienceStrongPoints, | ||
userId = userId, | ||
startedAt = startedAt, | ||
endedAt = endedAt | ||
) | ||
|
||
Then("experienceRepository.save가 호출된다.") { | ||
verify { experienceRepository.save(newExperience) } | ||
} | ||
} | ||
} | ||
}) |
62 changes: 62 additions & 0 deletions
62
...t/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceModifierTest.kt
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.bamyanggang.domainmodule.domain.experience.service | ||
|
||
import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceContent | ||
import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceStrongPoint | ||
import com.bamyanggang.domainmodule.domain.experience.repository.ExperienceRepository | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
class ExperienceModifierTest : BehaviorSpec({ | ||
val experienceRepository = mockk<ExperienceRepository>(relaxed = true) | ||
val experienceModifier = ExperienceModifier(experienceRepository) | ||
|
||
Given("수정할 경험 등록 데이터들이 주어졌을 때") { | ||
val experienceId = UUID.randomUUID() | ||
val title = "수정한 경험 제목" | ||
val parentTagId: UUID = UUID.randomUUID() | ||
val childTagId: UUID = UUID.randomUUID() | ||
val contents = arrayListOf( | ||
ExperienceContent( | ||
question = "수정한 질문 1", | ||
answer = "수정한 대답 1" | ||
), | ||
ExperienceContent( | ||
question = "수정한 질문 2", | ||
answer = "수정한 대답 2" | ||
) | ||
) | ||
|
||
val experienceStrongPoints: List<ExperienceStrongPoint> = arrayListOf( | ||
ExperienceStrongPoint.create( | ||
UUID.randomUUID() | ||
), | ||
ExperienceStrongPoint.create( | ||
UUID.randomUUID() | ||
) | ||
) | ||
val startedAt: LocalDateTime = LocalDateTime.now() | ||
val endedAt: LocalDateTime = startedAt.plusDays(1) | ||
val userId = UUID.randomUUID() | ||
|
||
When("ExperienceModifier.modifyExperience 호출하면") { | ||
val editExperience = experienceModifier.modifyExperience( | ||
experienceId = experienceId, | ||
title = title, | ||
parentTagId = parentTagId, | ||
childTagId = childTagId, | ||
contents = contents, | ||
experienceStrongPoints = experienceStrongPoints, | ||
userId = userId, | ||
startedAt = startedAt, | ||
endedAt = endedAt | ||
) | ||
|
||
Then("experienceRepository.save가 호출된다.") { | ||
verify { experienceRepository.save(editExperience) } | ||
} | ||
} | ||
} | ||
}) |
Oops, something went wrong.