-
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 #168 from KUSITMS-29th-TEAM-B/test/flight-165
test: 역량 키워드 도메인 테스트 코드 작성(#165)
- Loading branch information
Showing
5 changed files
with
126 additions
and
6 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
28 changes: 28 additions & 0 deletions
28
.../test/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/KeywordReaderTest.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,28 @@ | ||
package com.bamyanggang.domainmodule.domain.strongpoint.service | ||
|
||
import com.bamyanggang.domainmodule.domain.strongpoint.repository.KeywordRepository | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import java.util.* | ||
|
||
class KeywordReaderTest : BehaviorSpec({ | ||
val keywordRepository = mockk<KeywordRepository>(relaxed = true) | ||
val keywordReader = KeywordReader(keywordRepository) | ||
|
||
Given("기본 역량 키워드 id 배열이 주어졌을 때") { | ||
val defaultStrongPoints = arrayListOf( | ||
UUID.randomUUID(), | ||
UUID.randomUUID(), | ||
UUID.randomUUID() | ||
) | ||
|
||
When("KeywordReader.readByIds 함수가 호출되면") { | ||
keywordReader.readByIds(defaultStrongPoints) | ||
|
||
Then("keywordRepository.findByIds 함수가 호출된다.") { | ||
verify { keywordRepository.findByIds(defaultStrongPoints) } | ||
} | ||
} | ||
} | ||
}) |
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
43 changes: 43 additions & 0 deletions
43
.../kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointRemoverTest.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,43 @@ | ||
package com.bamyanggang.domainmodule.domain.strongpoint.service | ||
|
||
import com.bamyanggang.domainmodule.domain.strongpoint.exception.StrongPointExceptionMessage | ||
import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import java.util.* | ||
|
||
class StrongPointRemoverTest : BehaviorSpec({ | ||
val strongPointRepository = mockk<StrongPointRepository>(relaxed = true) | ||
val strongPointRemover = StrongPointRemover(strongPointRepository) | ||
|
||
Given("삭제할 역량 키워드 id가 주어졌을 때") { | ||
val deleteStrongPointId = UUID.randomUUID() | ||
|
||
When("StrongPointReader.removeStrongPoint 함수가 호출되면") { | ||
every { strongPointRepository.isExistByStrongPointId(deleteStrongPointId) } returns true | ||
strongPointRemover.removeStrongPoint(deleteStrongPointId) | ||
|
||
Then("strongPointRepository.deleteByStrongPointId 함수가 호출된다.") { | ||
verify { strongPointRepository.deleteByStrongPointId(deleteStrongPointId) } | ||
} | ||
} | ||
} | ||
|
||
Given("존재하지 않는 역량 키워드 id가 주어졌을 때") { | ||
val deleteStrongPointId = UUID.randomUUID() | ||
|
||
When("StrongPointReader.removeStrongPoint 함수가 호출되면") { | ||
every { strongPointRepository.isExistByStrongPointId(deleteStrongPointId) } returns false | ||
val exception = shouldThrow<IllegalArgumentException> { | ||
strongPointRemover.removeStrongPoint(deleteStrongPointId) | ||
} | ||
|
||
Then("IllegalAgumentException이 발생한다.") { | ||
assert(exception.message == StrongPointExceptionMessage.NOT_FOUND_STRONG_POINT.message) | ||
} | ||
} | ||
} | ||
}) |