-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: CallAdapter 적용 및 검증 테스트 작성 #558 #574
Merged
Merged
Conversation
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
- ResponseResult Exception의 message 파라미터에 기본 인자 설정
- 이전: handleApiResponse2 - 이후: handleApiResponse
- 이전: ApiResponseHandler - 이후: ApiResultHandler
- 이전: NetworkResultCall - 이후: ApiResultCall
- 이전: NetworkResultCallAdapter - 이후: ApiResultCallAdapter
- 이전: NetworkResultCallAdapterFactory - 이후: ApiResultCallAdapterFactory
- 서버의 이미지 제한 용량 변경과 관계 없도록 수정
- Call<T>의 파라미터 클래스 T의 타입을 획득하여 저장하는 변수라는 것을 명시적으로 나타내기 위해 변수명 변경
- delegate 패턴을 사용하고 있다는 것을 좀 더 명시적으로 나타내도록 변수명 수정
- 네트워크 중심으로 테스트가 이루어지도록 FakeApiService를 활용해 CallAdapter 동작 테스트 수정
- 생성 성공(201), 실패(400, 401, 500), 예외 - 네트워크 중심으로 테스트가 이루어지도록 FakeApiService를 활용해 CallAdapter 동작 테스트 수정
- 네트워크 중심으로 테스트가 이루어지도록 FakeApiService를 활용해 CallAdapter 동작 테스트 수정
안드의 꼼꼼함에 놀라고,,,,배워갑니다.....👍👍👍👍 |
- 이전: LoginViewModel에서 SharedPreferences에 사용자 토큰 저장 - 이후: LoginRepository에서 SharedPreferences에 사용자 토큰 저장
- 이전: executable - 이후: action
Junyoung-WON
approved these changes
Jan 20, 2025
Comment on lines
+3
to
+13
private const val REQUIRED_VALUES_ERROR_MESSAGE = "필수 값을 모두 입력해 주세요." | ||
private const val NETWORK_ERROR_MESSAGE = "네트워크 연결이 불안정합니다.\n연결을 재설정한 후 다시 시도해 주세요." | ||
private const val UNKNOWN_ERROR_MESSAGE = "예기치 못한 오류가 발생했습니다.\n잠시 후 다시 시도해 주세요." | ||
private const val IMAGE_UPLOAD_ERROR_MESSAGE = "이미지 업로드에 실패했습니다." | ||
|
||
enum class ExceptionState(val message: String) { | ||
NetworkError(NETWORK_ERROR_MESSAGE), | ||
RequiredValuesMissing(REQUIRED_VALUES_ERROR_MESSAGE), | ||
ImageUploadError(IMAGE_UPLOAD_ERROR_MESSAGE), | ||
UnknownError(UNKNOWN_ERROR_MESSAGE), | ||
} |
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.
ExceptionState
를 만들고, handler 메서드가 ExceptionState
를 반환해주도록 구현했네요!
data 레이어에서 사용자에게 보여줄 에러 메시지를 결정하는 로직을 잘 제거한 것 같습니다!! 완전 짱짱!! 😁
- 이전: RecoveryViewModel에서 SharedPreferences에 사용자 토큰 저장 - 이후: RecoveryRepository에서 SharedPreferences에 사용자 토큰 저장
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
⭐️ Issue Number
🚩 Summary
CallAdapter 적용
CallAdapter 적용을 위해
Call
,CallAdapter
,CallAdapterFactory
객체를 구현했습니다.CallAdapter 테스트 작성
MockWebServer
를 활용해 CallAdapter가 정상 동작하는 지 검증했습니다.ApiResult 처리 확장 함수 구현 및 Repository에 적용
Repository의 네트워크 응답 중복 로직을 최소화했습니다.
🛠️ Technical Concerns
CallAdapter
아래 4가지 클래스는 CallAdapter 구현을 위한 클래스입니다.
ApiResult(전 ResponseResult)
Success
,ServerError
,Exception
)ApiResultCall
ApiResultCallAdapter
CallAdapter<R, T>
는Call<R>
을 T로 반환해주는 interfaceApiResultCallAdapterFactory
ApiResult 처리 확장 함수 구현 및 Repository에 적용
테스트
JUnit5
,AssertJ
,MockWebServer
,kotlinx coroutines test
를 활용했습니다.🙂 To Reviewer
이해가 되지 않는 부분이 있으시다면 언제든 질문 주세요!
CI가 터지는 데 리뷰 주시는 동안 해결해보겠습니다..!➡️ 해결완료!📋 To Do