-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OING-320] refactor: 가족 중 몇명이 더 올리면 미션 참여 가능한지 반환하는 API 로직 리팩터링 (#242)
* refactor: refact calculateRemainingSurvivalPostCountUntilMissuonUnlocked logic * feature: add isActiveMember method and refact code * test: refact test code due to seperated logic * test: add calculateRemainingSurvivalPostCountUntilMissionUnlocked test code
- Loading branch information
Showing
6 changed files
with
84 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.oing.service; | ||
|
||
import com.oing.domain.Emoji; | ||
import com.oing.domain.Post; | ||
import com.oing.domain.PostType; | ||
import com.oing.domain.Reaction; | ||
import com.oing.dto.request.PostReactionRequest; | ||
import com.oing.repository.PostRepository; | ||
import com.oing.repository.ReactionRepository; | ||
import com.oing.util.IdentityGenerator; | ||
import com.oing.util.PreSignedUrlGenerator; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class PostServiceTest { | ||
|
||
@InjectMocks | ||
private PostService postService; | ||
|
||
@Mock | ||
private PostRepository postRepository; | ||
@Mock | ||
private ApplicationEventPublisher applicationEventPublisher; | ||
@Mock | ||
private PreSignedUrlGenerator preSignedUrlGenerator; | ||
@Mock | ||
private MissionBridge missionBridge; | ||
@Mock | ||
private IdentityGenerator identityGenerator; | ||
|
||
@Test | ||
void 미션_키_획득까지_남은_생존신고_게시글_업로드_수_조회_테스트() { | ||
//given | ||
String familyId = "1"; | ||
|
||
//when | ||
when(postRepository.countFamilyMembersByFamilyId(familyId)).thenReturn(1); | ||
when(postRepository.countTodaySurvivalPostsByFamilyId(familyId)).thenReturn(0); | ||
|
||
//then | ||
assertEquals(0, postService.calculateRemainingSurvivalPostCountUntilMissionUnlocked(familyId)); | ||
} | ||
} |