Skip to content

Conversation

@jlkim909
Copy link
Member

PULL REQUEST

  • 원격 사용자 정보 조회 기능 구현, 의존성 주입 설정 및 단위 테스트 추가

Description

데이터 전송 객체(DTO) 및 매핑 함수 추가

  • 네트워크 계층에서 사용자 정보를 수신하기 위한 UserDataResponse DTO 정의
    • 서버 응답 스키마에 맞춰 memberId, email, kakaoId, nickname, memberProfile, title, point 등의 필드를 포함
  • UserDataResponseUserData 변환을 위한 toModel() 확장 함수 추가
    • 프로필 이미지, 타이틀 등의 하위 객체를 도메인 모델에 맞춰 변환

원격 데이터 소스 인터페이스 정의

  • UserRemoteDataSource 인터페이스 추가
    • 원격 사용자 정보 조회 기능을 추상화
    • getUserData() 메서드를 선언

Ktor 기반 구현체 추가

  • KtorUserRemoteDataSource 클래스 구현
    • UserRemoteDataSource 인터페이스 구현
    • @AuthorizedClient로 주입받은 HttpClient를 사용
    • UserResource를 통해 서버에 GET 요청을 보내고, 응답(ApiResponse<UserDataResponse>)을 받아 UserData로 매핑 후 반환

의존성 주입 설정

  • NetworkModuleUserRemoteDataSourceKtorUserRemoteDataSource를 바인딩
    • Hilt를 통해 구현체를 의존성으로 주입할 수 있도록 설정

단위 테스트 추가

  • KtorUserRemoteDataSourceTest 작성
    • MockEngine을 사용하여 UserResource API 응답을 시뮬레이션
    • 정상 응답 시 getUserData()가 예상된 UserData를 반환하는지 검증

- `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()`가 예상한 사용자 데이터를 반환하는지 검증
@jlkim909 jlkim909 requested a review from hyunjung-choi August 10, 2025 20:17
@jlkim909 jlkim909 self-assigned this Aug 10, 2025
@jlkim909 jlkim909 added the feat 새로운 기능 label Aug 10, 2025
@jlkim909 jlkim909 linked an issue Aug 10, 2025 that may be closed by this pull request
3 tasks
Copy link
Member

@hyunjung-choi hyunjung-choi left a 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)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MockEngine인데, 실제 API를 호출하는 것 같은데 맞나요? 🤔 . .

@jlkim909 jlkim909 merged commit b11e8f1 into develop Aug 11, 2025
1 check passed
@jlkim909 jlkim909 deleted the feature/userdata-remote-datasource branch August 11, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 새로운 기능

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add UserDataRemoteDataSource with Ktor client

2 participants