-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/userdata remote datasource #107
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
Merged
Merged
Conversation
This file contains hidden or 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
- `UserDataResponse` 데이터 전송 객체(DTO)를 정의 - `UserDataResponse`를 `UserData` 도메인 모델로 변환하는 `toModel()` 확장 함수를 추가
- 원격 사용자 정보 조회를 담당하는 `UserRemoteDataSource` 인터페이스 추가 - 사용자 정보 조회를 위한 추상 메서드 `getUserData()` 선언
- Ktor를 사용해 원격 사용자 데이터를 조회하는 `KtorUserRemoteDataSource` 클래스 구현 - `UserRemoteDataSource` 인터페이스를 구현하며, `@AuthorizedClient`로 주입받은 `HttpClient` 사용 - `getUserData()`에서 `UserResource` 요청 후 `ApiResponse<UserDataResponse>`를 받아 `UserData` 도메인 모델로 변환해 반환
- `UserRemoteDataSource` 인터페이스와 구현체 `KtorUserRemoteDataSource`를 `NetworkModule`에 바인딩 - Hilt를 통해 `UserRemoteDataSource` 의존성을 주입 가능하도록 설정
- `UserRemoteDataSource`에 대한 단위 테스트 추가 - `MockEngine`으로 `UserResource` API 응답을 시뮬레이션 - `getUserData()`가 예상한 사용자 데이터를 반환하는지 검증
3 tasks
hyunjung-choi
approved these changes
Aug 11, 2025
Member
hyunjung-choi
left a comment
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.
늦은 시간까지 고생 많으셨습니다.!
Comment on lines
+21
to
+33
| val userMockEngine = MockEngine { request -> | ||
| val userPath = href(ResourcesFormat(), UserResource()) | ||
|
|
||
| when { | ||
| request.method == HttpMethod.Get && request.url.fullPath == userPath -> respond( | ||
| content = userJson, // 아래 상수의 JSON 반환 | ||
| status = HttpStatusCode.OK, | ||
| headers = headersOf(HttpHeaders.ContentType, "application/json") | ||
| ) | ||
|
|
||
| else -> respondError(HttpStatusCode.NotFound) | ||
| } | ||
| } |
Member
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.
MockEngine인데, 실제 API를 호출하는 것 같은데 맞나요? 🤔 . .
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.
PULL REQUEST
Description
데이터 전송 객체(DTO) 및 매핑 함수 추가
UserDataResponseDTO 정의memberId,email,kakaoId,nickname,memberProfile,title,point등의 필드를 포함UserDataResponse→UserData변환을 위한toModel()확장 함수 추가원격 데이터 소스 인터페이스 정의
UserRemoteDataSource인터페이스 추가getUserData()메서드를 선언Ktor 기반 구현체 추가
KtorUserRemoteDataSource클래스 구현UserRemoteDataSource인터페이스 구현@AuthorizedClient로 주입받은HttpClient를 사용UserResource를 통해 서버에 GET 요청을 보내고, 응답(ApiResponse<UserDataResponse>)을 받아UserData로 매핑 후 반환의존성 주입 설정
NetworkModule에UserRemoteDataSource와KtorUserRemoteDataSource를 바인딩단위 테스트 추가
KtorUserRemoteDataSourceTest작성MockEngine을 사용하여UserResourceAPI 응답을 시뮬레이션getUserData()가 예상된UserData를 반환하는지 검증