-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix/reward response] - 보상 응답 수정 #94
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
6 commits
Select commit
Hold shift + click to select a range
b68b76b
:sparkles: feat : update reward-response
ekgns33 6c53e3f
:bug: fix : `LoveGrantService` return acquired amount for reward
ekgns33 843ded3
:recycle: refactor : use factory method
ekgns33 1aa5f8a
:white_check_mark: test : add validation for acquired_love_point, img…
ekgns33 d8be18e
:white_check_mark: test : add unit test for LoveGrantService
ekgns33 802260f
:bug: fix : fix parameter
ekgns33 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
13 changes: 13 additions & 0 deletions
13
src/main/java/org/runimo/runimo/rewards/service/dto/RewardResponse.java
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 |
|---|---|---|
| @@ -1,11 +1,24 @@ | ||
| package org.runimo.runimo.rewards.service.dto; | ||
|
|
||
|
|
||
| import org.runimo.runimo.item.domain.Egg; | ||
|
|
||
| public record RewardResponse( | ||
| Boolean isRewarded, | ||
| String eggCode, | ||
| String eggType, | ||
| String eggImgUrl, | ||
| Long lovePointAmount | ||
| ) { | ||
|
|
||
| public static RewardResponse of(Egg egg, Long lovePointAmount) { | ||
| return new RewardResponse( | ||
| egg != Egg.EMPTY, | ||
| egg.getItemCode(), | ||
| egg.getEggType().getName(), | ||
| egg.getImgUrl(), | ||
ekgns33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| lovePointAmount | ||
| ); | ||
| } | ||
|
|
||
| } | ||
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
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -219,7 +219,9 @@ void tearDown() { | |||
| .log().all() | ||||
| .statusCode(HttpStatus.OK.value()) | ||||
| .body("payload.love_point_amount", notNullValue()) | ||||
| .body("payload.love_point_amount", greaterThan(0)); | ||||
| .body("payload.love_point_amount", greaterThan(0)) | ||||
|
||||
| .body("payload.love_point_amount", greaterThan(0)) |
68 changes: 68 additions & 0 deletions
68
src/test/java/org/runimo/runimo/rewards/service/lovepoint/LoveGrantServiceTest.java
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 org.runimo.runimo.rewards.service.lovepoint; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.when; | ||
| import static org.mockito.MockitoAnnotations.initMocks; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.Optional; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.InjectMocks; | ||
| import org.mockito.Mock; | ||
| import org.runimo.runimo.common.scale.Distance; | ||
| import org.runimo.runimo.records.domain.RunningRecord; | ||
| import org.runimo.runimo.user.UserFixtures; | ||
| import org.runimo.runimo.user.service.LovePointProcessor; | ||
| import org.runimo.runimo.user.service.UserFinder; | ||
|
|
||
| class LoveGrantServiceTest { | ||
|
|
||
|
|
||
| @InjectMocks | ||
| private LoveGrantService loveGrantService; | ||
| @Mock | ||
| private UserFinder userFinder; | ||
| @Mock | ||
| private LovePointProcessor lovePointProcessor; | ||
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| initMocks(this); | ||
| } | ||
|
|
||
| @Test | ||
| void km_당_1포인트를_지급한다() { | ||
|
|
||
| RunningRecord record = RunningRecord.builder() | ||
| .isRewarded(false) | ||
| .startedAt(LocalDateTime.of(2020, 1, 1, 12, 0, 0)) | ||
| .endAt(LocalDateTime.of(2020, 1, 1, 12, 30, 0)) | ||
| .totalDistance(new Distance(7800L)) | ||
| .build(); | ||
|
|
||
| when(userFinder.findUserById(any())).thenReturn( | ||
| Optional.ofNullable(UserFixtures.getUserWithId(1L))); | ||
| Long amount = loveGrantService.grantLoveToUserWithDistance(record); | ||
|
|
||
| assertEquals(7L, amount); | ||
| } | ||
|
|
||
| @Test | ||
| void 달린거리_1km보다_작으면_지급하지_않는다() { | ||
| RunningRecord record = RunningRecord.builder() | ||
| .isRewarded(false) | ||
| .startedAt(LocalDateTime.of(2020, 1, 1, 12, 0, 0)) | ||
| .endAt(LocalDateTime.of(2020, 1, 1, 12, 30, 0)) | ||
| .totalDistance(new Distance(900L)) | ||
| .build(); | ||
|
|
||
| when(userFinder.findUserById(any())).thenReturn( | ||
| Optional.ofNullable(UserFixtures.getUserWithId(1L))); | ||
| Long amount = loveGrantService.grantLoveToUserWithDistance(record); | ||
|
|
||
| assertEquals(0L, amount); | ||
| } | ||
|
|
||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.