-
Notifications
You must be signed in to change notification settings - Fork 2
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 #312 from team-haribo/feature/311_jacoco
🔀 :: 테스트 커버리지 시각화
- Loading branch information
Showing
43 changed files
with
606 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
object PluginVersions { | ||
const val SPRING_BOOT_VERSION = "2.7.5" | ||
const val DEPENDENCY_MANAGER_VERSION = "1.1.0" | ||
const val JVM_VERSION = "1.7.22" | ||
const val JVM_VERSION = "1.9.0" | ||
const val SPRING_PLUGIN_VERSION = "1.7.22" | ||
const val JPA_PLUGIN_VERSION = "1.6.21" | ||
const val ALL_OPEN_VERSION = "1.6.21" | ||
const val KAPT_VERSION = "1.7.10" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -43,4 +43,4 @@ class OutingUseCase( | |
} | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -29,4 +29,4 @@ class QueryAllAccountUseCase( | |
} | ||
} | ||
|
||
} | ||
} |
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
81 changes: 81 additions & 0 deletions
81
goms-application/src/test/kotlin/com/goms/v2/domain/account/ChangePasswordUseCaseTest.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,81 @@ | ||
package com.goms.v2.domain.account | ||
|
||
import com.goms.v2.common.AnyValueObjectGenerator | ||
import com.goms.v2.common.util.AccountUtil | ||
import com.goms.v2.domain.account.data.dto.ChangePasswordDto | ||
import com.goms.v2.domain.account.exception.DuplicatedNewPasswordException | ||
import com.goms.v2.domain.account.exception.PasswordNotMatchException | ||
import com.goms.v2.domain.account.usecase.ChangePasswordUseCase | ||
import com.goms.v2.domain.auth.exception.AccountNotFoundException | ||
import com.goms.v2.domain.auth.spi.PasswordEncoderPort | ||
import com.goms.v2.repository.account.AccountRepository | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.IsolationMode | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.spyk | ||
import io.mockk.verify | ||
import java.util.* | ||
|
||
class ChangePasswordUseCaseTest: BehaviorSpec({ | ||
isolationMode = IsolationMode.InstancePerLeaf | ||
val accountRepository = mockk<AccountRepository>() | ||
val passwordEncoderPort = mockk<PasswordEncoderPort>() | ||
val accountUtil = mockk<AccountUtil>() | ||
val changePasswordUseCase = ChangePasswordUseCase(accountRepository, passwordEncoderPort, accountUtil) | ||
|
||
Given("ChangePasswordDto가 주어지면") { | ||
val accountIdx = UUID.randomUUID() | ||
val newPassword = "123" | ||
val encodedPassword = "encodedPassword" | ||
val account = spyk<Account>(AnyValueObjectGenerator.anyValueObject<Account>("idx" to accountIdx)) | ||
val changePasswordDto = AnyValueObjectGenerator.anyValueObject<ChangePasswordDto>("newPassword" to newPassword) | ||
|
||
every { accountUtil.getCurrentAccountIdx() } returns accountIdx | ||
every { accountRepository.findByIdOrNull(accountIdx) } returns account | ||
every { passwordEncoderPort.isPasswordMatch(changePasswordDto.password, account.password) } returns true | ||
every { passwordEncoderPort.isPasswordMatch(changePasswordDto.newPassword, account.password) } returns false | ||
every { passwordEncoderPort.passwordEncode(changePasswordDto.newPassword) } returns encodedPassword | ||
every { accountRepository.save(account) } returns account | ||
|
||
When("비밀번호 변경 요청을 하면") { | ||
changePasswordUseCase.execute(changePasswordDto) | ||
|
||
Then("비밀번호가 변경된 상태로 Account가 저장되어야 한다.") { | ||
verify(exactly = 1) { account.updatePassword(encodedPassword) } | ||
verify(exactly = 1) { accountRepository.save(account) } | ||
} | ||
} | ||
|
||
When("Account가 존재하지 않는다면") { | ||
every { accountRepository.findByIdOrNull(accountIdx) } returns null | ||
|
||
Then("AccountNotFoundException을 터쳐야 한다.") { | ||
shouldThrow<AccountNotFoundException> { | ||
changePasswordUseCase.execute(changePasswordDto) | ||
} | ||
} | ||
} | ||
|
||
When("기존 비밀번호가 일치하지 않으면") { | ||
every { passwordEncoderPort.isPasswordMatch(changePasswordDto.password, account.password) } returns false | ||
|
||
Then("PasswordNotMatchException이 터져야 한다.") { | ||
shouldThrow<PasswordNotMatchException> { | ||
changePasswordUseCase.execute(changePasswordDto) | ||
} | ||
} | ||
} | ||
|
||
When("새로운 비밀번호와 기존 비밀번호가 동일하면") { | ||
every { passwordEncoderPort.isPasswordMatch(changePasswordDto.newPassword, account.password) } returns true | ||
|
||
Then("DuplicatedNewPasswordException이 터져야 한다.") { | ||
shouldThrow<DuplicatedNewPasswordException> { | ||
changePasswordUseCase.execute(changePasswordDto) | ||
} | ||
} | ||
} | ||
} | ||
}) |
57 changes: 57 additions & 0 deletions
57
goms-application/src/test/kotlin/com/goms/v2/domain/account/DeleteImageUseCaseTest.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,57 @@ | ||
package com.goms.v2.domain.account | ||
|
||
import com.goms.v2.common.AnyValueObjectGenerator | ||
import com.goms.v2.common.util.AccountUtil | ||
import com.goms.v2.domain.account.spi.S3UtilPort | ||
import com.goms.v2.domain.account.usecase.DeleteImageUseCase | ||
import com.goms.v2.domain.auth.exception.AccountNotFoundException | ||
import com.goms.v2.repository.account.AccountRepository | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.IsolationMode | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.spyk | ||
import io.mockk.verify | ||
import java.util.UUID | ||
|
||
class DeleteImageUseCaseTest: BehaviorSpec({ | ||
isolationMode = IsolationMode.InstancePerLeaf | ||
val accountRepository = mockk<AccountRepository>() | ||
val s3UtilPort = mockk<S3UtilPort>() | ||
val accountUtil = mockk<AccountUtil>() | ||
val deleteImageUseCase = DeleteImageUseCase(accountRepository, s3UtilPort, accountUtil) | ||
|
||
|
||
Given("프로필 이미지가 존재할 때") { | ||
val accountIdx = UUID.randomUUID() | ||
val account = spyk<Account>(AnyValueObjectGenerator.anyValueObject<Account>("idx" to accountIdx)) | ||
val profileURL = account.profileUrl | ||
|
||
every { accountUtil.getCurrentAccountIdx() } returns accountIdx | ||
every { accountRepository.findByIdOrNull(accountIdx) } returns account | ||
every { s3UtilPort.deleteImage(account.profileUrl.toString()) } returns Unit | ||
every { accountRepository.save(account) } returns account | ||
|
||
When("프로필 이미지 삭제 요청이 들어오면") { | ||
deleteImageUseCase.execute() | ||
|
||
Then("프로필 이미지를 지운 후에 Account가 저장되어야한다.") { | ||
verify(exactly = 1) { s3UtilPort.deleteImage((profileURL.toString())) } | ||
verify(exactly = 1) { account.resetProfileUrl(null) } | ||
verify(exactly = 1) { accountRepository.save(account) } | ||
} | ||
} | ||
|
||
When("Account가 존재하지 않는다면") { | ||
every { accountRepository.findByIdOrNull(accountIdx) } returns null | ||
|
||
Then("AccountNotFoundException이 터져야 한다.") { | ||
shouldThrow<AccountNotFoundException> { | ||
deleteImageUseCase.execute() | ||
} | ||
} | ||
} | ||
|
||
} | ||
}) |
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
45 changes: 45 additions & 0 deletions
45
goms-application/src/test/kotlin/com/goms/v2/domain/account/UpdateImageUseCaseTest.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,45 @@ | ||
package com.goms.v2.domain.account | ||
|
||
import com.goms.v2.common.AnyValueObjectGenerator | ||
import com.goms.v2.domain.account.spi.S3UtilPort | ||
import com.goms.v2.domain.account.usecase.UpdateImageUseCase | ||
import com.goms.v2.repository.account.AccountRepository | ||
import io.kotest.core.spec.IsolationMode | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.spyk | ||
import io.mockk.verify | ||
import org.springframework.mock.web.MockMultipartFile | ||
import java.nio.charset.StandardCharsets | ||
import java.util.* | ||
|
||
class UpdateImageUseCaseTest: BehaviorSpec({ | ||
isolationMode = IsolationMode.InstancePerLeaf | ||
val accountRepository = mockk<AccountRepository>() | ||
val s3UtilPort = mockk<S3UtilPort>() | ||
val updateImageUseCase = UpdateImageUseCase(accountRepository, s3UtilPort) | ||
|
||
Given("multipart image가 주어질 때") { | ||
val imageBytes = "image content".toByteArray(StandardCharsets.UTF_8) | ||
val image = MockMultipartFile("File", "image.png", "image/png", imageBytes) | ||
|
||
val imageURL = "" | ||
val accountIdx = UUID.randomUUID() | ||
val account = spyk<Account>(AnyValueObjectGenerator.anyValueObject<Account>("idx" to accountIdx)) | ||
|
||
every { s3UtilPort.validImage(image) } returns account | ||
every { s3UtilPort.deleteImage(account.profileUrl.toString()) } returns Unit | ||
every { s3UtilPort.upload(image) } returns imageURL | ||
every { accountRepository.save(account) } returns account | ||
|
||
When("프로필 이미지 수정 요청을 하면") { | ||
updateImageUseCase.execute(image) | ||
|
||
Then("account가 저장되어야 한다.") { | ||
verify(exactly = 1) { account.updateProfileUrl(imageURL) } | ||
verify(exactly = 1) { accountRepository.save(account) } | ||
} | ||
} | ||
} | ||
}) |
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
Oops, something went wrong.