-
Notifications
You must be signed in to change notification settings - Fork 1
PolicyRepository의 반환값을 Flow에서 Result<Data>로 변경 #314
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f0bd8f5
#313 - refactor : PolicyRepository의 getPolicyDetail 함수의 반환값을 변경
hegunhee d4fd1cd
#313 - refactor : PolicyDetail을 받는 ViewModel에서 Result 데이터를 개별로 처리
hegunhee 19b2219
#313 - refactor : PolicyRepository의 최근에 본 정책 함수의 반환값을 flow에서 Result로 처리
hegunhee e520dd6
#313 - feat : 최근에 본 정책값을 받는 ViewModel, UseCase를 Result로 개별 처리
hegunhee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
68 changes: 68 additions & 0 deletions
68
core/data/src/test/java/com/youthtalk/repository/PolicyRepositoryTest.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package com.youthtalk.repository | ||
|
|
||
| import com.core.dataapi.repository.PolicyRepository | ||
| import com.youthtalk.data.PolicyService | ||
| import com.youthtalk.dto.CommonResponse | ||
| import com.youthtalk.dto.PolicyDetailResponse | ||
| import com.youthtalk.mapper.toData | ||
| import com.youthtalk.model.policy.Policy | ||
| import kotlinx.coroutines.test.runTest | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Before | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import org.mockito.Mock | ||
| import org.mockito.junit.MockitoJUnitRunner | ||
| import org.mockito.kotlin.verify | ||
| import org.mockito.kotlin.whenever | ||
|
|
||
| @RunWith(MockitoJUnitRunner::class) | ||
| class PolicyRepositoryTest { | ||
|
|
||
| private lateinit var sut: PolicyRepository | ||
|
|
||
| @Mock | ||
| private lateinit var policyService: PolicyService | ||
|
|
||
| @Before | ||
| fun setUp() { | ||
| sut = PolicyRepositoryImpl(policyService) | ||
| } | ||
|
|
||
| @Test | ||
| fun givenPolicyId_whenGetPolicyDetail_thenReturnsPolicy() { | ||
| runTest { | ||
| // given | ||
| val policyId = 3L | ||
| val policyDetailResponse = createPolicyDetailResponse() | ||
|
|
||
| whenever(policyService.getPolicyDetail(policyId)).thenReturn(CommonResponse(200, "정책 조회에 성공하였습니다.", "S04", policyDetailResponse)) | ||
|
|
||
| // when | ||
| val result = sut.getPolicyDetail(policyId).getOrThrow() | ||
|
|
||
| // then | ||
| assertEquals(policyDetailResponse.toData(), result) | ||
| verify(policyService).getPolicyDetail(policyId) | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun given_whenGetRecentViewPolicy_thenReturnsPolicy() { | ||
| runTest { | ||
| // given | ||
| whenever(policyService.getRecentlyViewPolicies()).thenReturn(CommonResponse(200, "요청에 성공하였습니다.", "S01", listOf())) | ||
|
|
||
| // when | ||
| val result = sut.getRecentlyViewPolicies().getOrThrow() | ||
|
|
||
| // then | ||
| assertEquals(listOf<Policy>(), result) | ||
| verify(policyService).getRecentlyViewPolicies() | ||
| } | ||
| } | ||
|
|
||
| private fun createPolicyDetailResponse(): PolicyDetailResponse { | ||
| return PolicyDetailResponse("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", true, "", "") | ||
| } | ||
| } | ||
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
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
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
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
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
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
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
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
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.
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.
🚫 [ktlint] standard:function-expression-body reported by reviewdog 🐶
Function body should be replaced with body expression