-
Notifications
You must be signed in to change notification settings - Fork 1
온보딩 api 연결 #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "feat/#34-\uC628\uBCF4\uB529-api-\uC5F0\uACB0"
온보딩 api 연결 #36
Changes from all commits
c9c0b34
cb5b1a7
e350946
676a4df
25e6b1a
7ef9ef0
bb85f91
5cc9c95
69a9a30
cec976e
cb09872
1c3873e
e97f63b
00dd422
b7d00ce
3216d74
88d2c44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,9 @@ import io.ktor.client.HttpClientConfig | |
| import io.ktor.client.plugins.HttpTimeout | ||
| import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
| import io.ktor.client.plugins.defaultRequest | ||
| import io.ktor.client.plugins.logging.ANDROID | ||
| import io.ktor.client.plugins.logging.LogLevel | ||
| import io.ktor.client.plugins.logging.Logger | ||
| import io.ktor.client.plugins.logging.Logging | ||
| import io.ktor.http.ContentType | ||
| import io.ktor.http.contentType | ||
|
|
@@ -24,6 +26,18 @@ internal object HttpClientProvider { | |
| configureLogging(isDebug) | ||
| configureTimeout() | ||
| configureDefaultRequest(baseUrl) | ||
|
|
||
| // TODO : 토큰 관련 기능 구현 후 적용 | ||
| // install(Auth) { | ||
| // bearer { | ||
| // loadTokens { | ||
| // BearerTokens( | ||
| // accessToken = "", | ||
| // refreshToken = "", | ||
| // ) | ||
| // } | ||
| // } | ||
| // } | ||
| } | ||
|
|
||
| private fun HttpClientConfig<*>.configureContentNegotiation(isDebug: Boolean) { | ||
|
|
@@ -46,6 +60,7 @@ internal object HttpClientProvider { | |
| } else { | ||
| LogLevel.NONE | ||
| } | ||
| logger = Logger.ANDROID | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logger.ANDROID 그대로 쓰면 될 것 같아요! |
||
|
|
||
| sanitizeHeader { header -> header == SANITIZE_HEADER } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| package com.twix.network.di | ||
|
|
||
| import com.twix.network.service.OnboardingService | ||
| import com.twix.network.service.createOnboardingService | ||
| import de.jensklingenberg.ktorfit.Ktorfit | ||
| import org.koin.dsl.module | ||
|
|
||
| internal val apiServiceModule = | ||
| module { | ||
| single<OnboardingService> { | ||
| get<Ktorfit>().createOnboardingService() | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ package com.twix.network.di | |
| val networkModule = | ||
| listOf( | ||
| httpClientModule, | ||
| apiServiceModule, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.twix.network.model.request | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class AnniversaryRequest( | ||
| val anniversaryDate: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.twix.network.model.request | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class CoupleConnectionRequest( | ||
| val inviteCode: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.twix.network.model.request | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class ProfileRequest( | ||
| val nickname: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.twix.network.model.response.onboarding | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class InviteCodeResponse( | ||
| val inviteCode: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.twix.network.model.response.onboarding | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class OnBoardingStatusResponse( | ||
| val status: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.twix.network.service | ||
|
|
||
| import com.twix.network.model.request.AnniversaryRequest | ||
| import com.twix.network.model.request.CoupleConnectionRequest | ||
| import com.twix.network.model.request.ProfileRequest | ||
| import com.twix.network.model.response.onboarding.InviteCodeResponse | ||
| import com.twix.network.model.response.onboarding.OnBoardingStatusResponse | ||
| import de.jensklingenberg.ktorfit.http.Body | ||
| import de.jensklingenberg.ktorfit.http.GET | ||
| import de.jensklingenberg.ktorfit.http.POST | ||
|
|
||
| interface OnboardingService { | ||
| @POST("onboarding/anniversary") | ||
| suspend fun anniversarySetup( | ||
| @Body request: AnniversaryRequest, | ||
| ) | ||
|
Comment on lines
13
to
16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: rg -n "Anniversary" --type=kotlin -g '!**/build/**'Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: cat core/network/src/main/java/com/twix/network/service/OnboardingService.ktRepository: YAPP-Github/Twix-Android Length of output: 1057 🏁 Script executed: # Search for request/response models in the same directory as OnboardingService
fd -e "kt" core/network/src/main/java/com/twix/network/ | head -20Repository: YAPP-Github/Twix-Android Length of output: 549 🏁 Script executed: # List all request models to see the pattern
fd -e "Request.kt" core/network/src/main/java/com/twix/network/model/request/Repository: YAPP-Github/Twix-Android Length of output: 605 🏁 Script executed: # Check if there's an AnniversarySetupRequest or similar already defined
rg "AnniversarySetup|AnniversaryRequest" --type=kotlinRepository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Look at some example request DTOs to understand the pattern
cat core/network/src/main/java/com/twix/network/model/request/CoupleConnectionRequest.ktRepository: YAPP-Github/Twix-Android Length of output: 230 🏁 Script executed: fd . 'core/network/src/main/java/com/twix/network/model/request/' --extension ktRepository: YAPP-Github/Twix-Android Length of output: 228 🏁 Script executed: cat core/network/src/main/java/com/twix/network/model/request/ProfileRequest.ktRepository: YAPP-Github/Twix-Android Length of output: 219 🏁 Script executed: # Search for other `@Body` request: String patterns in the codebase
rg "@Body.*String" --type=kotlinRepository: YAPP-Github/Twix-Android Length of output: 171
왜 문제가 되나요?
개선 방법: // com.twix.network.model.request 패키지에 추가
`@Serializable`
data class AnniversarySetupRequest(
val month: Int,
val day: Int,
// 실제 필요한 필드들...
)
// OnboardingService에서
suspend fun anniversarySetup(
`@Body` request: AnniversarySetupRequest,
)API 문서나 백엔드 스펙을 확인해서 anniversary 엔드포인트가 어떤 필드를 요구하는지 알려주실 수 있나요? 🤖 Prompt for AI Agents
Comment on lines
14
to
16
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분도 요청 DTO 만들어서 수정해주세요!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 에고... 꼼꼼하게 봐줘서 고마워 ! 리뷰 반영 커밋 : 3216d74 |
||
|
|
||
| @POST("onboarding/couple-connection") | ||
| suspend fun coupleConnection( | ||
| @Body request: CoupleConnectionRequest, | ||
| ) | ||
|
|
||
| @POST("onboarding/profile") | ||
| suspend fun profileSetup( | ||
| @Body request: ProfileRequest, | ||
| ) | ||
|
Comment on lines
13
to
26
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swagger상 request body가 JSON인데 지금은 문자열 그대로 보내고 있어서 통신이 안될 가능성이 높아 보여요. Request DTO 만들어서 @Body로 보내는 형태로 수정해주세요!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 리뷰 반영 완료 ! 리뷰 반영 커밋 e97f63b |
||
|
|
||
| @GET("onboarding/invite-code") | ||
| suspend fun fetchInviteCode(): InviteCodeResponse | ||
|
|
||
| @GET("onboarding/status") | ||
| suspend fun fetchOnBoardingStatus(): OnBoardingStatusResponse | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.twix.data.di | ||
|
|
||
| val dataModule = | ||
| listOf( | ||
| repositoryModule, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.twix.data.di | ||
|
|
||
| import com.twix.data.repository.DefaultOnboardingRepository | ||
| import com.twix.domain.repository.OnBoardingRepository | ||
| import org.koin.dsl.module | ||
|
|
||
| internal val repositoryModule = | ||
| module { | ||
| single<OnBoardingRepository> { | ||
| DefaultOnboardingRepository(get()) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.twix.data.repository | ||
|
|
||
| import com.twix.domain.model.InviteCode | ||
| import com.twix.domain.model.OnboardingStatus | ||
| import com.twix.domain.repository.OnBoardingRepository | ||
| import com.twix.network.model.request.AnniversaryRequest | ||
| import com.twix.network.model.request.CoupleConnectionRequest | ||
| import com.twix.network.model.request.ProfileRequest | ||
| import com.twix.network.service.OnboardingService | ||
|
|
||
| class DefaultOnboardingRepository( | ||
| private val service: OnboardingService, | ||
| ) : OnBoardingRepository { | ||
| override suspend fun fetchInviteCode(): InviteCode { | ||
| val response = service.fetchInviteCode() | ||
| return InviteCode(response.inviteCode) | ||
| } | ||
|
Comment on lines
+11
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Find other Repository implementations to check error handling patterns
fd -e kt -path '*repository*' -type f | head -20Repository: YAPP-Github/Twix-Android Length of output: 236 🏁 Script executed: # Search for error handling patterns in repository classes
rg -n "runCatching|try\s*\{|Result<|catch\s*\(" --type=kotlin -g '*Repository*' -A 2Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Look for domain error model definitions
fd -e kt -type f | xargs grep -l "sealed.*Error\|sealed.*class.*Error\|object.*Error" | head -20Repository: YAPP-Github/Twix-Android Length of output: 238 🏁 Script executed: # Check the full DefaultOnboardingRepository implementation
fd -e kt -path '*DefaultOnboardingRepository*' -type fRepository: YAPP-Github/Twix-Android Length of output: 236 🏁 Script executed: # Find repository files
find . -name "*Repository.kt" | head -20Repository: YAPP-Github/Twix-Android Length of output: 218 🏁 Script executed: # Search for error handling patterns in kotlin files
rg "runCatching|try\s*\{|Result<|catch\s*\(" -A 2 | head -100Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Look for domain error model definitions
rg "sealed.*class|object.*Error|sealed.*Error" --type kotlin | head -30Repository: YAPP-Github/Twix-Android Length of output: 276 🏁 Script executed: # Get the full DefaultOnboardingRepository implementation
cat data/src/main/java/com/twix/data/repository/DefaultOnboardingRepository.ktRepository: YAPP-Github/Twix-Android Length of output: 1067 🏁 Script executed: # Find all Repository implementations to check patterns
find . -name "*Repository.kt" -not -path "*/build/*" | xargs grep -l "class.*Repository"Repository: YAPP-Github/Twix-Android Length of output: 144 🏁 Script executed: # Check the domain repository interface
cat domain/src/main/java/com/twix/domain/repository/OnBoardingRepository.ktRepository: YAPP-Github/Twix-Android Length of output: 479 🏁 Script executed: # Search for Result types and error handling utilities
find . -name "*.kt" -not -path "*/build/*" | xargs grep -l "sealed class Result\|Result<" | head -10Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Look for any error/exception models
find . -name "*Error.kt" -o -name "*Exception.kt" | head -20Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Search for OnboardingService implementation
find . -name "*OnboardingService*" -o -name "*Service.kt" | head -20Repository: YAPP-Github/Twix-Android Length of output: 142 🏁 Script executed: # Check ViewModel or UseCase error handling
find . -name "*ViewModel.kt" -o -name "*UseCase.kt" | xargs grep -l "try\|catch\|error\|Error" | head -10Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Look at network layer for error handling
find . -path "*network*" -name "*.kt" | xargs grep -l "Exception\|error\|catch" | head -10Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Check if there are any other data layer operations with error handling
find . -path "*data*" -name "*.kt" | xargs grep -n "try\s*\{" | head -30Repository: YAPP-Github/Twix-Android Length of output: 86 🏁 Script executed: # Check OnboardingService implementation
cat core/network/src/main/java/com/twix/network/service/OnboardingService.ktRepository: YAPP-Github/Twix-Android Length of output: 917 🏁 Script executed: # Search for error handling in data layer more broadly
find . -path "*data*" -name "*.kt" | xargs grep -n "try" | head -30Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Check for error handling in all layers
find . -name "*.kt" -not -path "*/build/*" | xargs grep -n "catch" | head -30Repository: YAPP-Github/Twix-Android Length of output: 50 🏁 Script executed: # Look for network error handling or exception handling
find . -path "*network*" -name "*.kt" | xargs cat | head -100Repository: YAPP-Github/Twix-Android Length of output: 2898 네트워크 예외 처리가 필요합니다. 현재 구현에서 코딩 가이드라인에서 "에러가 도메인 레벨로 적절히 변환되는가?"를 확인하도록 되어 있는데, 현재는 기술 계층의 예외가 도메인 계층으로 올라가고 있습니다. 프로젝트에서 사용 중인 에러 처리 패턴이 있다면 그에 맞춰 적용하면 됩니다. 예를 들어:
UI 레이어에서 일관되게 에러를 처리하려면 어디서 예외를 캐치하고 도메인 계층으로 변환할 계획인지 논의해 주세요. 🤖 Prompt for AI Agents |
||
|
|
||
| override suspend fun fetchOnboardingStatus(): OnboardingStatus { | ||
| val response = service.fetchOnBoardingStatus() | ||
| return OnboardingStatus.from(response.status) | ||
| } | ||
|
Comment on lines
+19
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: fd -type f -name "*.kt" | xargs rg "class OnboardingStatus|sealed class OnboardingStatus|enum class OnboardingStatus" -lRepository: YAPP-Github/Twix-Android Length of output: 385 🏁 Script executed: fd -type f -name "*OnboardingStatus*"Repository: YAPP-Github/Twix-Android Length of output: 238 🏁 Script executed: rg -n "OnboardingStatus" data/ --type kt -l | head -20Repository: YAPP-Github/Twix-Android Length of output: 94 🏁 Script executed: cat -n domain/src/main/java/com/twix/domain/model/OnboardingStatus.ktRepository: YAPP-Github/Twix-Android Length of output: 699 🏁 Script executed: cat -n domain/src/main/java/com/twix/domain/model/OnboardingStatusTest.ktRepository: YAPP-Github/Twix-Android Length of output: 166 🏁 Script executed: cat -n data/src/main/java/com/twix/data/repository/DefaultOnboardingRepository.ktRepository: YAPP-Github/Twix-Android Length of output: 1545
왜 문제가 되나: 어떻게 개선하나:
어느 방식이 더 적절할까요? 서버로부터 예상치 못한 상태값이 올 수 있는 상황에서는 Unknown 상태를 명시적으로 처리하는 것이 권장됩니다. 🤖 Prompt for AI Agents |
||
|
|
||
| override suspend fun anniversarySetup(request: String) { | ||
| service.anniversarySetup(AnniversaryRequest(request)) | ||
| } | ||
|
|
||
| override suspend fun coupleConnection(request: String) { | ||
| service.coupleConnection(CoupleConnectionRequest(request)) | ||
| } | ||
|
|
||
| override suspend fun profileSetup(request: String) { | ||
| service.profileSetup(ProfileRequest(request)) | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.twix.domain.model | ||
|
|
||
| @JvmInline | ||
| value class InviteCode( | ||
| val value: String, | ||
| ) { | ||
| init { | ||
| require(value.length == INVITE_CODE_LENGTH) { INVALID_INVITE_CODE_EXCEPTION } | ||
| require(INVITE_CODE_REGEX.matches(value)) { INVALID_INVITE_CODE_EXCEPTION } | ||
| } | ||
|
|
||
| companion object { | ||
| private val INVITE_CODE_REGEX = Regex("^[A-Z0-9]+$") | ||
| private const val INVITE_CODE_LENGTH = 8 | ||
| private const val INVALID_INVITE_CODE_EXCEPTION = | ||
| "InviteCode must be 8 characters of uppercase letters and digits" | ||
| } | ||
| } | ||
|
Comment on lines
+3
to
+18
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 커플을 연결할 때 유저가 입력하는 UI 값을 이 클래스로 변환해서 서버로 전송한다고 하면, 잘못된 값을 입력했을 때 require로 인해서 앱이 죽어버릴 수도 있을 거 같거든요. 그래서 유효성 체크하는 부분을 보완하면 좋을 거 같아요. 예를 들면 유효성 검사에 실패했을 때 Result로 래핑해서 BaseViewModel에서 처리하고 경고 메시지를 보여주거나 이런식으로 개선하는 것도 괜찮지 않을까 싶습니다! 다른 방법을 생각하고 계신 게 있으면 말씀해주세요
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 앗 이 부분을 미리 말을 못했구나 에러처리 관련한 부분은 우리가 아직 논의가 안돼서 임시로 구현해놨어 ! 😅 나도 현수가 말한 것 처럼 InvalidInviteCodeException같은 특정 에러 상태를 나타내는 클래스를 만들고 요건 우리가 추후 에러 처리를 논의할 때 딥하게 논의해보면 좋을 것 같아 ! |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.twix.domain.model | ||
|
|
||
| enum class OnboardingStatus { | ||
| COUPLE_CONNECTION, | ||
| PROFILE_SETUP, | ||
| ANNIVERSARY_SETUP, | ||
| COMPLETED, | ||
| ; | ||
|
|
||
| companion object { | ||
| fun from(status: String): OnboardingStatus = | ||
| runCatching { | ||
| valueOf(status.trim().uppercase()) | ||
| }.getOrElse { | ||
| throw IllegalArgumentException(UNKNOWN_STATUS.format(status)) | ||
| } | ||
|
|
||
| private const val UNKNOWN_STATUS = "UNKNOWN_STATUS: %s" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.twix.domain.repository | ||
|
|
||
| import com.twix.domain.model.InviteCode | ||
| import com.twix.domain.model.OnboardingStatus | ||
|
|
||
| interface OnBoardingRepository { | ||
| suspend fun anniversarySetup(request: String) | ||
|
|
||
| suspend fun coupleConnection(request: String) | ||
|
|
||
| suspend fun profileSetup(request: String) | ||
|
|
||
| suspend fun fetchInviteCode(): InviteCode | ||
|
|
||
| suspend fun fetchOnboardingStatus(): OnboardingStatus | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.twix.domain.model | ||
|
|
||
| import org.assertj.core.api.Assertions.assertThat | ||
| import org.assertj.core.api.Assertions.assertThatThrownBy | ||
| import org.junit.jupiter.api.Test | ||
| import org.junit.jupiter.params.ParameterizedTest | ||
| import org.junit.jupiter.params.provider.ValueSource | ||
|
|
||
| class InviteCodeTest { | ||
| @Test | ||
| fun `유효한 초대 코드는 정상적으로 생성된다`() { | ||
| val inviteCode = InviteCode("AB12CD34") | ||
|
|
||
| assertThat(inviteCode.value).isEqualTo("AB12CD34") | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @ValueSource( | ||
| strings = [ | ||
| "ab12CD34", | ||
| "AB12CD3!", | ||
| " ", | ||
| ], | ||
| ) | ||
| fun `규칙에 맞지 않는 초대 코드는 예외가 발생한다`(invalidCode: String) { | ||
| assertThatThrownBy { InviteCode(invalidCode) } | ||
| .isInstanceOf(IllegalArgumentException::class.java) | ||
| .hasMessage("InviteCode must be 8 characters of uppercase letters and digits") | ||
|
Comment on lines
+27
to
+28
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분을 InvalidInviteCodeException이라는 걸 만들어서 관리하는 건 어떠신가요? |
||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @ValueSource( | ||
| strings = [ | ||
| "ABC123", | ||
| "AB12CD345", | ||
| ], | ||
| ) | ||
| fun `8자리가 아닌 초대 코드는 예외가 발생한다`(invalidLengthCode: String) { | ||
| assertThatThrownBy { InviteCode(invalidLengthCode) } | ||
| .isInstanceOf(IllegalArgumentException::class.java) | ||
| .hasMessage("InviteCode must be 8 characters of uppercase letters and digits") | ||
| } | ||
|
Comment on lines
+31
to
+42
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InvalidInviteCodeException를 따로 만들면 규칙에 맞지 않는 초대 코드는 예외가 발생한다, 8자리가 아닌 초대 코드는 예외가 발생한다 이 두 테스트를 하나로 묶는 것도 가능할 것 같아요 |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.twix.domain.model | ||
|
|
||
| import org.assertj.core.api.Assertions.assertThatThrownBy | ||
| import org.junit.jupiter.api.DisplayName | ||
| import org.junit.jupiter.api.Test | ||
| import org.junit.jupiter.params.ParameterizedTest | ||
| import org.junit.jupiter.params.provider.CsvSource | ||
| import kotlin.test.assertEquals | ||
|
|
||
| class OnboardingStatusTest { | ||
| @ParameterizedTest | ||
| @CsvSource( | ||
| "COUPLE_CONNECTION,COUPLE_CONNECTION", | ||
| "PROFILE_SETUP,PROFILE_SETUP", | ||
| "ANNIVERSARY_SETUP,ANNIVERSARY_SETUP", | ||
| "COMPLETED,COMPLETED", | ||
| ) | ||
| @DisplayName("올바른 OnboardingStatus enum을 반환한다") | ||
| fun `유효한 상태 문자열이 주어지면 올바른 OnboardingStatus enum을 반환한다`( | ||
| input: String, | ||
| expected: OnboardingStatus, | ||
| ) { | ||
| // when | ||
| val result = OnboardingStatus.from(input) | ||
|
|
||
| // then | ||
| assertEquals(result, expected) | ||
| } | ||
|
|
||
| @Test | ||
| fun `유효하지 않은 상태 문자열이 주어지면 IllegalArgumentException을 던진다`() { | ||
| // given | ||
| val invalidStatus = "UNKNOWN" | ||
|
|
||
| // when | ||
| assertThatThrownBy { OnboardingStatus.from(invalidStatus) } | ||
| // then | ||
| .isInstanceOf(IllegalArgumentException::class.java) | ||
| .hasMessage("UNKNOWN_STATUS: $invalidStatus") | ||
| } | ||
| } |

Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 설정이 있어야
createOnboardingService처럼 Ktrofit이 서비스 인터페이스 프록시를 만들기 때문에 추가했어 !