From 732d6ef32780a528745864b7cd851e075d6a2c2e Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Mon, 12 Aug 2024 15:14:04 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20InstanceDetail=20Facade=20Pattern=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - InstanceDetailFacade & InstanceDetailFacadeService 생성 - InstanceDetailService 기능 상실 -> 제거 - 테스트 코드 DCI 도입 --- .../controller/CertificationController.java | 6 +- .../controller/InstanceDetailController.java | 10 +- .../service/InstanceDetailFacade.java | 14 + ....java => InstanceDetailFacadeService.java} | 68 +- .../instance/service/InstanceProvider.java | 28 - .../challenge/likes/service/LikesService.java | 12 + .../schedule/service/ProgressService.java | 10 +- .../service/InstanceDetailServiceTest.java | 686 ++++++++++-------- .../instance/service/ProgressServiceTest.java | 25 +- 9 files changed, 488 insertions(+), 371 deletions(-) create mode 100644 src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailFacade.java rename src/main/java/com/genius/gitget/challenge/instance/service/{InstanceDetailService.java => InstanceDetailFacadeService.java} (75%) delete mode 100644 src/main/java/com/genius/gitget/challenge/instance/service/InstanceProvider.java diff --git a/src/main/java/com/genius/gitget/challenge/certification/controller/CertificationController.java b/src/main/java/com/genius/gitget/challenge/certification/controller/CertificationController.java index 4c5eff36..07f32680 100644 --- a/src/main/java/com/genius/gitget/challenge/certification/controller/CertificationController.java +++ b/src/main/java/com/genius/gitget/challenge/certification/controller/CertificationController.java @@ -11,7 +11,7 @@ import com.genius.gitget.challenge.certification.facade.CertificationFacade; import com.genius.gitget.challenge.certification.util.DateUtil; import com.genius.gitget.challenge.instance.domain.Instance; -import com.genius.gitget.challenge.instance.service.InstanceProvider; +import com.genius.gitget.challenge.instance.service.InstanceService; import com.genius.gitget.challenge.myChallenge.dto.ActivatedResponse; import com.genius.gitget.challenge.participant.domain.Participant; import com.genius.gitget.challenge.participant.service.ParticipantService; @@ -43,8 +43,8 @@ @RequestMapping("/api/certification") public class CertificationController { private final UserService userService; + private final InstanceService instanceService; private final CertificationFacade certificationFacade; - private final InstanceProvider instanceProvider; private final ParticipantService participantService; @@ -139,7 +139,7 @@ public ResponseEntity> getCertification ) { LocalDate kstDate = DateUtil.convertToKST(LocalDateTime.now()); - Instance instance = instanceProvider.findById(instanceId); + Instance instance = instanceService.findInstanceById(instanceId); Participant participant = participantService.findByJoinInfo( userPrincipal.getUser().getId(), instanceId); diff --git a/src/main/java/com/genius/gitget/challenge/instance/controller/InstanceDetailController.java b/src/main/java/com/genius/gitget/challenge/instance/controller/InstanceDetailController.java index 7134a5ce..0dbaf390 100644 --- a/src/main/java/com/genius/gitget/challenge/instance/controller/InstanceDetailController.java +++ b/src/main/java/com/genius/gitget/challenge/instance/controller/InstanceDetailController.java @@ -8,7 +8,7 @@ import com.genius.gitget.challenge.instance.dto.detail.InstanceResponse; import com.genius.gitget.challenge.instance.dto.detail.JoinRequest; import com.genius.gitget.challenge.instance.dto.detail.JoinResponse; -import com.genius.gitget.challenge.instance.service.InstanceDetailService; +import com.genius.gitget.challenge.instance.service.InstanceDetailFacade; import com.genius.gitget.global.security.domain.UserPrincipal; import com.genius.gitget.global.util.response.dto.SingleResponse; import java.time.LocalDate; @@ -30,7 +30,7 @@ @RequiredArgsConstructor @RequestMapping("/api/challenges") public class InstanceDetailController { - private final InstanceDetailService instanceDetailService; + private final InstanceDetailFacade instanceDetailFacade; @GetMapping("/{instanceId}") @@ -38,7 +38,7 @@ public ResponseEntity> getInstanceDetail( @AuthenticationPrincipal UserPrincipal userPrincipal, @PathVariable Long instanceId ) { - InstanceResponse instanceDetailInformation = instanceDetailService.getInstanceDetailInformation( + InstanceResponse instanceDetailInformation = instanceDetailFacade.getInstanceDetailInformation( userPrincipal.getUser(), instanceId); return ResponseEntity.ok().body( @@ -58,7 +58,7 @@ public ResponseEntity> joinChallenge( .repository(repo) .todayDate(kstDate) .build(); - JoinResponse joinResponse = instanceDetailService.joinNewChallenge(userPrincipal.getUser(), joinRequest); + JoinResponse joinResponse = instanceDetailFacade.joinNewChallenge(userPrincipal.getUser(), joinRequest); return ResponseEntity.ok().body( new SingleResponse<>(JOIN_SUCCESS.getStatus(), JOIN_SUCCESS.getMessage(), joinResponse) @@ -70,7 +70,7 @@ public ResponseEntity> quitChallenge( @AuthenticationPrincipal UserPrincipal userPrincipal, @PathVariable Long instanceId ) { - JoinResponse joinResponse = instanceDetailService.quitChallenge(userPrincipal.getUser(), instanceId); + JoinResponse joinResponse = instanceDetailFacade.quitChallenge(userPrincipal.getUser(), instanceId); return ResponseEntity.ok().body( new SingleResponse<>(QUIT_SUCCESS.getStatus(), QUIT_SUCCESS.getMessage(), joinResponse) diff --git a/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailFacade.java b/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailFacade.java new file mode 100644 index 00000000..f500cdd4 --- /dev/null +++ b/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailFacade.java @@ -0,0 +1,14 @@ +package com.genius.gitget.challenge.instance.service; + +import com.genius.gitget.challenge.instance.dto.detail.InstanceResponse; +import com.genius.gitget.challenge.instance.dto.detail.JoinRequest; +import com.genius.gitget.challenge.instance.dto.detail.JoinResponse; +import com.genius.gitget.challenge.user.domain.User; + +public interface InstanceDetailFacade { + InstanceResponse getInstanceDetailInformation(User user, Long instanceId); + + JoinResponse joinNewChallenge(User user, JoinRequest joinRequest); + + public JoinResponse quitChallenge(User user, Long instanceId); +} diff --git a/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailService.java b/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailFacadeService.java similarity index 75% rename from src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailService.java rename to src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailFacadeService.java index f620a615..dbbac1f0 100644 --- a/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailService.java +++ b/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailFacadeService.java @@ -10,8 +10,7 @@ import com.genius.gitget.challenge.instance.dto.detail.JoinRequest; import com.genius.gitget.challenge.instance.dto.detail.JoinResponse; import com.genius.gitget.challenge.instance.dto.detail.LikesInfo; -import com.genius.gitget.challenge.likes.domain.Likes; -import com.genius.gitget.challenge.likes.repository.LikesRepository; +import com.genius.gitget.challenge.likes.service.LikesService; import com.genius.gitget.challenge.participant.domain.JoinStatus; import com.genius.gitget.challenge.participant.domain.Participant; import com.genius.gitget.challenge.participant.service.ParticipantService; @@ -21,52 +20,55 @@ import com.genius.gitget.global.file.service.FilesService; import com.genius.gitget.global.util.exception.BusinessException; import java.time.LocalDate; -import java.util.Optional; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.kohsuke.github.GitHub; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Slf4j -@Service -@Transactional(readOnly = true) -@RequiredArgsConstructor -public class InstanceDetailService { - private final UserService userService; +import org.springframework.stereotype.Component; + +@Component +public class InstanceDetailFacadeService implements InstanceDetailFacade { + + private final InstanceService instanceService; private final FilesService filesService; - private final InstanceProvider instanceProvider; private final ParticipantService participantService; + private final LikesService likesService; + private final UserService userService; private final GithubService githubService; - private final LikesRepository likesRepository; + public InstanceDetailFacadeService(InstanceService instanceService, FilesService filesService, + ParticipantService participantService, LikesService likesService, + UserService userService, GithubService githubService) { + this.instanceService = instanceService; + this.filesService = filesService; + this.participantService = participantService; + this.likesService = likesService; + this.userService = userService; + this.githubService = githubService; + } + @Override public InstanceResponse getInstanceDetailInformation(User user, Long instanceId) { - Instance instance = instanceProvider.findById(instanceId); + + // 인스턴스 정보 + Instance instance = instanceService.findInstanceById(instanceId); + + // 파일 객체 생성 FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); - LikesInfo likesInfo = getLikesInfo(user.getId(), instance); - if (participantService.hasJoinedParticipant(user.getId(), instanceId)) { + // 좋아요 정보 + LikesInfo likesInfo = likesService.getLikesInfo(user.getId(), instance); + + if (participantService.hasJoinedParticipant(user.getId(), instance.getId())) { return InstanceResponse.createByEntity(instance, likesInfo, JoinStatus.YES, fileResponse); } - return InstanceResponse.createByEntity(instance, likesInfo, JoinStatus.NO, fileResponse); } - private LikesInfo getLikesInfo(Long userId, Instance instance) { - Optional optionalLikes = likesRepository.findSpecificLike(userId, instance.getId()); - if (optionalLikes.isPresent()) { - Likes likes = optionalLikes.get(); - return LikesInfo.createExist(likes.getId(), instance.getLikesCount()); - } - return LikesInfo.createNotExist(instance.getLikesCount()); - } - - @Transactional + @Override public JoinResponse joinNewChallenge(User user, JoinRequest joinRequest) { + User persistUser = userService.findUserById(user.getId()); - Instance instance = instanceProvider.findById(joinRequest.instanceId()); + + Instance instance = instanceService.findInstanceById(joinRequest.instanceId()); String repository = joinRequest.repository(); @@ -103,9 +105,9 @@ private void validateGithub(User user, String repository) { githubService.validateGithubRepository(gitHub, repositoryFullName); } - @Transactional + @Override public JoinResponse quitChallenge(User user, Long instanceId) { - Instance instance = instanceProvider.findById(instanceId); + Instance instance = instanceService.findInstanceById(instanceId); Participant participant = participantService.findByJoinInfo(user.getId(), instanceId); if (instance.getProgress() == Progress.DONE) { diff --git a/src/main/java/com/genius/gitget/challenge/instance/service/InstanceProvider.java b/src/main/java/com/genius/gitget/challenge/instance/service/InstanceProvider.java deleted file mode 100644 index 3992c34e..00000000 --- a/src/main/java/com/genius/gitget/challenge/instance/service/InstanceProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.genius.gitget.challenge.instance.service; - -import static com.genius.gitget.global.util.exception.ErrorCode.INSTANCE_NOT_FOUND; - -import com.genius.gitget.challenge.instance.domain.Instance; -import com.genius.gitget.challenge.instance.domain.Progress; -import com.genius.gitget.challenge.instance.repository.InstanceRepository; -import com.genius.gitget.global.util.exception.BusinessException; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional(readOnly = true) -@RequiredArgsConstructor -public class InstanceProvider { - private final InstanceRepository instanceRepository; - - public Instance findById(Long instanceId) { - return instanceRepository.findById(instanceId) - .orElseThrow(() -> new BusinessException(INSTANCE_NOT_FOUND)); - } - - public List findAllByProgress(Progress progress) { - return instanceRepository.findAllByProgress(progress); - } -} diff --git a/src/main/java/com/genius/gitget/challenge/likes/service/LikesService.java b/src/main/java/com/genius/gitget/challenge/likes/service/LikesService.java index 6f456b34..19055f54 100644 --- a/src/main/java/com/genius/gitget/challenge/likes/service/LikesService.java +++ b/src/main/java/com/genius/gitget/challenge/likes/service/LikesService.java @@ -1,6 +1,7 @@ package com.genius.gitget.challenge.likes.service; import com.genius.gitget.challenge.instance.domain.Instance; +import com.genius.gitget.challenge.instance.dto.detail.LikesInfo; import com.genius.gitget.challenge.instance.repository.InstanceRepository; import com.genius.gitget.challenge.likes.domain.Likes; import com.genius.gitget.challenge.likes.repository.LikesRepository; @@ -10,6 +11,7 @@ import com.genius.gitget.global.util.exception.ErrorCode; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -65,6 +67,16 @@ public void deleteLikes(Long likesId) { likesRepository.deleteById(findLikes.getId()); } + public LikesInfo getLikesInfo(Long userId, Instance instance) { + Optional optionalLikes = likesRepository.findSpecificLike(userId, instance.getId()); + if (optionalLikes.isPresent()) { + Likes likes = optionalLikes.get(); + return LikesInfo.createExist(likes.getId(), instance.getLikesCount()); + } + + return LikesInfo.createNotExist(instance.getLikesCount()); + } + private List verifyUser(User user) { return userRepository.findAllByIdentifier(user.getIdentifier()); } diff --git a/src/main/java/com/genius/gitget/schedule/service/ProgressService.java b/src/main/java/com/genius/gitget/schedule/service/ProgressService.java index 21752b0d..2aaf8147 100644 --- a/src/main/java/com/genius/gitget/schedule/service/ProgressService.java +++ b/src/main/java/com/genius/gitget/schedule/service/ProgressService.java @@ -6,7 +6,7 @@ import com.genius.gitget.challenge.certification.service.CertificationService; import com.genius.gitget.challenge.instance.domain.Instance; import com.genius.gitget.challenge.instance.domain.Progress; -import com.genius.gitget.challenge.instance.service.InstanceProvider; +import com.genius.gitget.challenge.instance.repository.InstanceRepository; import com.genius.gitget.challenge.participant.domain.JoinResult; import com.genius.gitget.challenge.participant.domain.Participant; import java.time.LocalDate; @@ -22,13 +22,13 @@ @Transactional(readOnly = true) @RequiredArgsConstructor public class ProgressService { - private final InstanceProvider instanceProvider; private final CertificationService certificationService; + private final InstanceRepository instanceRepository; private final double SUCCESS_THRESHOLD = 85; @Transactional public void updateToActivity(LocalDate currentDate) { - List preActivities = instanceProvider.findAllByProgress(Progress.PREACTIVITY); + List preActivities = instanceRepository.findAllByProgress(Progress.PREACTIVITY); for (Instance preActivity : preActivities) { LocalDate startedDate = preActivity.getStartedDate().toLocalDate(); LocalDate completedDate = preActivity.getCompletedDate().toLocalDate(); @@ -53,8 +53,8 @@ private void updateActivityInstance(Instance preActivity) { @Transactional public void updateToDone(LocalDate currentDate) { List instances = new ArrayList<>(); - instances.addAll(instanceProvider.findAllByProgress(Progress.PREACTIVITY)); - instances.addAll(instanceProvider.findAllByProgress(Progress.ACTIVITY)); + instances.addAll(instanceRepository.findAllByProgress(Progress.PREACTIVITY)); + instances.addAll(instanceRepository.findAllByProgress(Progress.ACTIVITY)); for (Instance instance : instances) { LocalDate startedDate = instance.getStartedDate().toLocalDate(); diff --git a/src/test/java/com/genius/gitget/challenge/instance/service/InstanceDetailServiceTest.java b/src/test/java/com/genius/gitget/challenge/instance/service/InstanceDetailServiceTest.java index 82be2061..39cfb550 100644 --- a/src/test/java/com/genius/gitget/challenge/instance/service/InstanceDetailServiceTest.java +++ b/src/test/java/com/genius/gitget/challenge/instance/service/InstanceDetailServiceTest.java @@ -14,7 +14,6 @@ import com.genius.gitget.challenge.instance.dto.detail.JoinRequest; import com.genius.gitget.challenge.instance.dto.detail.JoinResponse; import com.genius.gitget.challenge.instance.repository.InstanceRepository; -import com.genius.gitget.challenge.likes.dto.UserLikesAddResponse; import com.genius.gitget.challenge.likes.facade.LikesFacade; import com.genius.gitget.challenge.participant.domain.JoinResult; import com.genius.gitget.challenge.participant.domain.JoinStatus; @@ -26,10 +25,11 @@ import com.genius.gitget.challenge.user.repository.UserRepository; import com.genius.gitget.global.security.constants.ProviderInfo; import com.genius.gitget.global.util.exception.BusinessException; -import com.genius.gitget.global.util.exception.ErrorCode; import java.time.LocalDate; import java.time.LocalDateTime; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; @@ -42,8 +42,9 @@ @SpringBootTest @Transactional class InstanceDetailServiceTest { + @Autowired - InstanceDetailService instanceDetailService; + InstanceDetailFacade instanceDetailFacade; @Autowired LikesFacade likesFacade; @Autowired @@ -64,292 +65,409 @@ class InstanceDetailServiceTest { @Value("${github.yeon-repository}") private String targetRepo; - - @Test - @DisplayName("챌린지 참여에 필요한 정보를 전달했을 때, 참여 정보가 저장이 되어야 한다.") - public void should_saveParticipantInfo_when_passInfo() { - //given - User savedUser = getSavedUser(githubId); - Instance instance = getSavedInstance(Progress.PREACTIVITY); - LocalDate todayDate = LocalDate.of(2024, 1, 30); - JoinRequest joinRequest = JoinRequest.builder() - .instanceId(instance.getId()) - .repository(targetRepo) - .todayDate(todayDate) - .build(); - - //when - JoinResponse joinResponse = instanceDetailService.joinNewChallenge(savedUser, joinRequest); - - //then - assertThat(joinResponse.joinStatus()).isEqualTo(JoinStatus.YES); - assertThat(joinResponse.joinResult()).isEqualTo(JoinResult.READY); - assertThat(instance.getParticipantCount()).isEqualTo(1); - } - - @Test - @DisplayName("챌린지 참여 요청을 했을 때, 인스턴스가 존재하지 않는다면 예외가 발생한다.") - public void should_throwException_when_instanceNotExist() { - //given - User savedUser = getSavedUser(githubId); - JoinRequest joinRequest = JoinRequest.builder() - .instanceId(1L) - .repository(targetRepo) - .build(); - - //when & then - assertThatThrownBy(() -> instanceDetailService.joinNewChallenge(savedUser, joinRequest)) - .isInstanceOf(BusinessException.class) - .hasMessageContaining(INSTANCE_NOT_FOUND.getMessage()); - } - - @ParameterizedTest - @DisplayName("챌린지 참여 요청을 했을 때, 인스턴스의 상태가 시작 전이 아니라면 예외가 발생한다.") - @EnumSource(mode = Mode.INCLUDE, names = {"ACTIVITY", "DONE"}) - public void should_throwException_when_instanceProgressNotPreactivity(Progress progress) { - //given - User savedUser = getSavedUser(githubId); - Instance savedInstance = getSavedInstance(progress); - LocalDate todayDate = LocalDate.of(2024, 1, 30); - JoinRequest joinRequest = JoinRequest.builder() - .repository(targetRepo) - .instanceId(savedInstance.getId()) - .todayDate(todayDate) - .build(); - - //when & then - assertThatThrownBy(() -> instanceDetailService.joinNewChallenge(savedUser, joinRequest)) - .isInstanceOf(BusinessException.class) - .hasMessageContaining(CAN_NOT_JOIN_INSTANCE.getMessage()); - } - - @Test - @DisplayName("챌린지 참여 요청을 했을 때, 사용자가 이미 참여한 챌린지인 경우 예외가 발생한다.") - public void should_throwException_when_userAlreadyJoined() { - //given - User user = getSavedUser(githubId); - Instance instance = getSavedInstance(Progress.PREACTIVITY); - LocalDate todayDate = LocalDate.of(2024, 1, 30); - JoinRequest joinRequest = JoinRequest.builder() - .repository(targetRepo) - .instanceId(instance.getId()) - .todayDate(todayDate) - .build(); - - //when - instanceDetailService.joinNewChallenge(user, joinRequest); - - //then - assertThatThrownBy(() -> instanceDetailService.joinNewChallenge(user, joinRequest)) - .isInstanceOf(BusinessException.class) - .hasMessageContaining(CAN_NOT_JOIN_INSTANCE.getMessage()); - } - - @Test - @DisplayName("챌린지 시작 당일에 챌린지 참여 요청을 하면 예외가 발생한다") - public void should_throwException_when_joinAtStartedDate() { - //given - LocalDate today = LocalDate.of(2024, 1, 30); - - User user = getSavedUser(githubId); - Instance instance = getSavedInstance(Progress.PREACTIVITY, today); - JoinRequest joinRequest = JoinRequest.builder() - .repository(targetRepo) - .instanceId(instance.getId()) - .todayDate(today) - .build(); - - //when - assertThatThrownBy(() -> instanceDetailService.joinNewChallenge(user, joinRequest)) - .isInstanceOf(BusinessException.class) - .hasMessageContaining(ErrorCode.CAN_NOT_JOIN_INSTANCE.getMessage()); - } - - @Test - @DisplayName("아직 시작하지 않은 챌린지에 대해 취소 요청을 하면 ParticipantInfo가 삭제된다.") - public void should_joinStatusIsNo_when_quitChallenge() { - //given - User savedUser = getSavedUser(githubId); - Instance savedInstance = getSavedInstance(Progress.PREACTIVITY); - LocalDate todayDate = LocalDate.of(2024, 1, 30); - - //when - instanceDetailService.joinNewChallenge(savedUser, - new JoinRequest(savedInstance.getId(), targetRepo, todayDate)); - JoinResponse joinResponse = instanceDetailService.quitChallenge(savedUser, savedInstance.getId()); - - //then - assertThat(savedInstance.getParticipantCount()).isEqualTo(0); - assertThat(joinResponse.participantId()).isEqualTo(null); - assertThat(joinResponse.joinResult()).isEqualTo(null); - assertThat(joinResponse.joinStatus()).isEqualTo(null); - } - - @Test - @DisplayName("진행 중인 챌린지에 대해 취소 요청을 하면 인스턴스의 참여 인원 수가 줄어들고, 참여 정보가 변경된다") - public void should_changeParticipantInfo_when_requestQuitInstance() { - //given - User savedUser = getSavedUser(githubId); - Instance savedInstance = getSavedInstance(Progress.PREACTIVITY); - LocalDate todayDate = LocalDate.of(2024, 1, 30); - JoinRequest joinRequest = JoinRequest.builder() - .instanceId(savedInstance.getId()) - .repository(targetRepo) - .todayDate(todayDate) - .build(); - - //when - instanceDetailService.joinNewChallenge(savedUser, joinRequest); - savedInstance.updateProgress(Progress.ACTIVITY); - instanceDetailService.quitChallenge(savedUser, savedInstance.getId()); - Participant participant = participantService.findByJoinInfo(savedUser.getId(), - savedInstance.getId()); - - //then - assertThat(savedInstance.getParticipantCount()).isEqualTo(0); - assertThat(participant.getJoinResult()).isEqualTo(JoinResult.FAIL); - assertThat(participant.getJoinStatus()).isEqualTo(JoinStatus.NO); - } - - @Test - @DisplayName("챌린지 취소 요청을 할 때 인스턴스가 존재하지 않으면 예외가 발생한다.") - public void should_throwException_when_instanceNotExist_quitChallenge() { - //given - User savedUser = getSavedUser(githubId); - - //when & then - assertThatThrownBy(() -> instanceDetailService.quitChallenge(savedUser, 1L)) - .isInstanceOf(BusinessException.class) - .hasMessageContaining(INSTANCE_NOT_FOUND.getMessage()); + @Nested + @DisplayName("챌린지 참여") + class Describe_joinChallenge { + + @Nested + @DisplayName("유효한 요청이 주어졌을 때") + class Context_with_validRequest { + + private User savedUser; + private Instance instance; + private JoinRequest joinRequest; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + instance = getSavedInstance(Progress.PREACTIVITY); + LocalDate todayDate = LocalDate.of(2024, 1, 30); + joinRequest = JoinRequest.builder() + .instanceId(instance.getId()) + .repository(targetRepo) + .todayDate(todayDate) + .build(); + } + + @Test + @DisplayName("참여 정보가 저장된다.") + void it_savesParticipantInfo() { + JoinResponse joinResponse = instanceDetailFacade.joinNewChallenge(savedUser, joinRequest); + + assertThat(joinResponse.joinStatus()).isEqualTo(JoinStatus.YES); + assertThat(joinResponse.joinResult()).isEqualTo(JoinResult.READY); + assertThat(instance.getParticipantCount()).isEqualTo(1); + } + } + + @Nested + @DisplayName("인스턴스가 존재하지 않을 때") + class Context_when_instanceNotExist { + + private User savedUser; + private JoinRequest joinRequest; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + joinRequest = JoinRequest.builder() + .instanceId(1L) // 존재하지 않는 인스턴스 ID + .repository(targetRepo) + .build(); + } + + @Test + @DisplayName("예외가 발생한다.") + void it_throwsException() { + assertThatThrownBy(() -> instanceDetailFacade.joinNewChallenge(savedUser, joinRequest)) + .isInstanceOf(BusinessException.class) + .hasMessageContaining(INSTANCE_NOT_FOUND.getMessage()); + } + } + + @Nested + @DisplayName("인스턴스의 상태가 시작 전이 아닌 경우") + class Context_when_instanceProgressNotPreactivity { + + private User savedUser; + private Instance instance; + private JoinRequest joinRequest; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + instance = getSavedInstance(Progress.ACTIVITY); + joinRequest = JoinRequest.builder() + .repository(targetRepo) + .instanceId(instance.getId()) + .todayDate(LocalDate.of(2024, 1, 30)) + .build(); + } + + @ParameterizedTest + @EnumSource(value = Progress.class, mode = Mode.INCLUDE, names = {"ACTIVITY", "DONE"}) + @DisplayName("예외가 발생한다.") + void it_throwsException(Progress progress) { + instance.updateProgress(progress); + + assertThatThrownBy(() -> instanceDetailFacade.joinNewChallenge(savedUser, joinRequest)) + .isInstanceOf(BusinessException.class) + .hasMessageContaining(CAN_NOT_JOIN_INSTANCE.getMessage()); + } + } + + @Nested + @DisplayName("이미 참여한 경우") + class Context_when_userAlreadyJoined { + + private User savedUser; + private Instance instance; + private JoinRequest joinRequest; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + instance = getSavedInstance(Progress.PREACTIVITY); + joinRequest = JoinRequest.builder() + .repository(targetRepo) + .instanceId(instance.getId()) + .todayDate(LocalDate.of(2024, 1, 30)) + .build(); + instanceDetailFacade.joinNewChallenge(savedUser, joinRequest); + } + + @Test + @DisplayName("예외가 발생한다.") + void it_throwsException() { + assertThatThrownBy(() -> instanceDetailFacade.joinNewChallenge(savedUser, joinRequest)) + .isInstanceOf(BusinessException.class) + .hasMessageContaining(CAN_NOT_JOIN_INSTANCE.getMessage()); + } + } + + @Nested + @DisplayName("챌린지 시작 당일에 참여 요청을 했을 때") + class Context_when_joinAtStartedDate { + + private User savedUser; + private Instance instance; + private JoinRequest joinRequest; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + instance = getSavedInstance(Progress.PREACTIVITY, LocalDate.of(2024, 1, 30)); + joinRequest = JoinRequest.builder() + .repository(targetRepo) + .instanceId(instance.getId()) + .todayDate(LocalDate.of(2024, 1, 30)) + .build(); + } + + @Test + @DisplayName("예외가 발생한다.") + void it_throwsException() { + assertThatThrownBy(() -> instanceDetailFacade.joinNewChallenge(savedUser, joinRequest)) + .isInstanceOf(BusinessException.class) + .hasMessageContaining(CAN_NOT_JOIN_INSTANCE.getMessage()); + } + } } - @Test - @DisplayName("챌린지 취소 요청을 할 때 참여 정보가 존재하지 않으면 예외가 발생한다.") - public void should_throwException_when_participantInfoNotExist() { - //given - User savedUser = getSavedUser(githubId); - Instance savedInstance = getSavedInstance(Progress.PREACTIVITY); - - //when & then - assertThatThrownBy(() -> instanceDetailService.quitChallenge(savedUser, savedInstance.getId())) - .isInstanceOf(BusinessException.class) - .hasMessageContaining(PARTICIPANT_NOT_FOUND.getMessage()); + @Nested + @DisplayName("챌린지 취소") + class Describe_quitChallenge { + + @Nested + @DisplayName("아직 시작하지 않은 챌린지에 대해 취소 요청을 했을 때") + class Context_when_quitBeforeStart { + + private User savedUser; + private Instance savedInstance; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + savedInstance = getSavedInstance(Progress.PREACTIVITY); + } + + @Test + @DisplayName("ParticipantInfo가 삭제된다.") + void it_deletesParticipantInfo() { + instanceDetailFacade.joinNewChallenge(savedUser, + new JoinRequest(savedInstance.getId(), targetRepo, LocalDate.of(2024, 1, 30))); + JoinResponse joinResponse = instanceDetailFacade.quitChallenge(savedUser, savedInstance.getId()); + + assertThat(savedInstance.getParticipantCount()).isEqualTo(0); + assertThat(joinResponse.participantId()).isNull(); + assertThat(joinResponse.joinResult()).isNull(); + assertThat(joinResponse.joinStatus()).isNull(); + } + } + + @Nested + @DisplayName("진행 중인 챌린지에 대해 취소 요청을 했을 때") + class Context_when_quitDuringActivity { + + private User savedUser; + private Instance savedInstance; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + savedInstance = getSavedInstance(Progress.PREACTIVITY); + instanceDetailFacade.joinNewChallenge(savedUser, + new JoinRequest(savedInstance.getId(), targetRepo, LocalDate.of(2024, 1, 30))); + savedInstance.updateProgress(Progress.ACTIVITY); + } + + @Test + @DisplayName("참여 인원 수가 줄어들고, 참여 정보가 변경된다.") + void it_changesParticipantInfo() { + instanceDetailFacade.quitChallenge(savedUser, savedInstance.getId()); + Participant participant = participantService.findByJoinInfo(savedUser.getId(), + savedInstance.getId()); + + assertThat(savedInstance.getParticipantCount()).isEqualTo(0); + assertThat(participant.getJoinResult()).isEqualTo(JoinResult.FAIL); + assertThat(participant.getJoinStatus()).isEqualTo(JoinStatus.NO); + } + } + + @Nested + @DisplayName("인스턴스가 존재하지 않을 때") + class Context_when_instanceNotExist { + + private User savedUser; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + } + + @Test + @DisplayName("예외가 발생한다.") + void it_throwsException() { + assertThatThrownBy(() -> instanceDetailFacade.quitChallenge(savedUser, 1L)) + .isInstanceOf(BusinessException.class) + .hasMessageContaining(INSTANCE_NOT_FOUND.getMessage()); + } + } + + @Nested + @DisplayName("참여 정보가 존재하지 않을 때") + class Context_when_participantInfoNotExist { + + private User savedUser; + private Instance savedInstance; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + savedInstance = getSavedInstance(Progress.PREACTIVITY); + } + + @Test + @DisplayName("예외가 발생한다.") + void it_throwsException() { + assertThatThrownBy(() -> instanceDetailFacade.quitChallenge(savedUser, savedInstance.getId())) + .isInstanceOf(BusinessException.class) + .hasMessageContaining(PARTICIPANT_NOT_FOUND.getMessage()); + } + } + + @Nested + @DisplayName("진행 상황이 DONE인 챌린지에 대해 취소 요청을 했을 때") + class Context_when_progressIsDone { + + @Test + @DisplayName("인스턴스의 진행 상황이 DONE이면 예외가 발생한다.") + public void should_throwException_when_progressIsDONE() { + //given + User savedUser = getSavedUser(githubId); + Instance savedInstance = getSavedInstance(Progress.PREACTIVITY); + LocalDate todayDate = LocalDate.of(2024, 1, 30); + JoinRequest joinRequest = JoinRequest.builder() + .instanceId(savedInstance.getId()) + .repository(targetRepo) + .todayDate(todayDate) + .build(); + + //when + instanceDetailFacade.joinNewChallenge(savedUser, joinRequest); + savedInstance.updateProgress(Progress.DONE); + + //then + assertThatThrownBy(() -> instanceDetailFacade.quitChallenge(savedUser, savedInstance.getId())) + .isInstanceOf(BusinessException.class) + .hasMessageContaining(CAN_NOT_QUIT_INSTANCE.getMessage()); + } + } } - @Test - @DisplayName("챌린지 취소 요청을 할 때, 인스턴스의 진행 상황이 DONE이면 예외가 발생한다.") - public void should_throwException_when_progressIsDONE() { - //given - User savedUser = getSavedUser(githubId); - Instance savedInstance = getSavedInstance(Progress.PREACTIVITY); - LocalDate todayDate = LocalDate.of(2024, 1, 30); - JoinRequest joinRequest = JoinRequest.builder() - .instanceId(savedInstance.getId()) - .repository(targetRepo) - .todayDate(todayDate) - .build(); - - //when - instanceDetailService.joinNewChallenge(savedUser, joinRequest); - savedInstance.updateProgress(Progress.DONE); - - //then - assertThatThrownBy(() -> instanceDetailService.quitChallenge(savedUser, savedInstance.getId())) - .isInstanceOf(BusinessException.class) - .hasMessageContaining(CAN_NOT_QUIT_INSTANCE.getMessage()); - } - - @Test - @DisplayName("사용자가 참여한 인스턴스에 대해 상세 조회를 하면 상세 페이지에 필요한 데이터들을 반환해야 한다.") - public void should_returnValues_when_joinedInstance() { - //given - User savedUser = getSavedUser(githubId); - Instance savedInstance = getSavedInstance(Progress.PREACTIVITY, LocalDate.now().plusDays(2)); - LocalDate todayDate = LocalDate.of(2024, 1, 30); - JoinRequest joinRequest = JoinRequest.builder() - .instanceId(savedInstance.getId()) - .repository(targetRepo) - .todayDate(todayDate) - .build(); - - //when - instanceDetailService.joinNewChallenge(savedUser, joinRequest); - InstanceResponse instanceResponse = instanceDetailService.getInstanceDetailInformation(savedUser, - savedInstance.getId()); - - //then - assertThat(instanceResponse.instanceId()).isEqualTo(savedInstance.getId()); - assertThat(instanceResponse.progress()).isEqualTo(Progress.PREACTIVITY); - assertThat(instanceResponse.remainDays()).isEqualTo(2); - assertThat(instanceResponse.participantCount()).isEqualTo(1); - assertThat(instanceResponse.pointPerPerson()).isEqualTo(100); - assertThat(instanceResponse.description()).isEqualTo(savedInstance.getDescription()); - assertThat(instanceResponse.joinStatus()).isEqualTo(JoinStatus.YES); - assertThat(instanceResponse.likesInfo().likesCount()).isEqualTo(0); - assertThat(instanceResponse.likesInfo().likesId()).isEqualTo(0); - assertThat(instanceResponse.likesInfo().isLiked()).isFalse(); - } - - @Test - @DisplayName("사용자가 참여하지 않은 챌린지에 대해 상세 조회를 하면 상세 페이지에 필요한 정보들을 반환할 수 있다.") - public void should_returnData_when_notJoinedInstance() { - //given - User savedUser = getSavedUser(githubId); - Instance savedInstance = getSavedInstance(Progress.PREACTIVITY, LocalDate.now().plusDays(2)); - - //when - InstanceResponse instanceResponse = instanceDetailService.getInstanceDetailInformation(savedUser, - savedInstance.getId()); - - //then - assertThat(instanceResponse.instanceId()).isEqualTo(savedInstance.getId()); - assertThat(instanceResponse.remainDays()).isEqualTo(2); - assertThat(instanceResponse.participantCount()).isEqualTo(0); - assertThat(instanceResponse.pointPerPerson()).isEqualTo(100); - assertThat(instanceResponse.description()).isEqualTo(savedInstance.getDescription()); - assertThat(instanceResponse.joinStatus()).isEqualTo(JoinStatus.NO); - assertThat(instanceResponse.likesInfo().likesCount()).isEqualTo(0); - assertThat(instanceResponse.likesInfo().likesId()).isEqualTo(0); - assertThat(instanceResponse.likesInfo().isLiked()).isFalse(); - } - - @Test - @DisplayName("시용자가 좋아요를 한 이후, 상세 정보를 요청하면 좋아요 관련된 정보를 받을 수 있다.") - public void should_returnLikesData_when_userPushLikes() { - //given - User savedUser = getSavedUser(githubId); - Instance savedInstance = getSavedInstance(Progress.PREACTIVITY, LocalDate.now().plusDays(2)); - - //when - UserLikesAddResponse userLikesAddResponse = likesFacade.addLikes(savedUser, savedUser.getIdentifier(), - savedInstance.getId()); - InstanceResponse instanceResponse = instanceDetailService.getInstanceDetailInformation(savedUser, - savedInstance.getId()); - - //then - assertThat(instanceResponse.instanceId()).isEqualTo(savedInstance.getId()); - assertThat(instanceResponse.remainDays()).isEqualTo(2); - assertThat(instanceResponse.participantCount()).isEqualTo(0); - assertThat(instanceResponse.pointPerPerson()).isEqualTo(100); - assertThat(instanceResponse.description()).isEqualTo(savedInstance.getDescription()); - assertThat(instanceResponse.joinStatus()).isEqualTo(JoinStatus.NO); - assertThat(instanceResponse.likesInfo().likesCount()).isEqualTo(1); - assertThat(instanceResponse.likesInfo().likesId()).isEqualTo(userLikesAddResponse.getLikesId()); - assertThat(instanceResponse.likesInfo().isLiked()).isTrue(); - } - - @Test - @DisplayName("상세 정보를 요청하는 인스턴스가 존재하지 않는다면 예외가 발생해야 한다.") - public void should_throwException_when_requestDetail_instanceNotExist() { - //given - User savedUser = getSavedUser(githubId); - - //when & then - assertThatThrownBy(() -> instanceDetailService.getInstanceDetailInformation(savedUser, 1L)) - .isInstanceOf(BusinessException.class) - .hasMessageContaining(INSTANCE_NOT_FOUND.getMessage()); + @Nested + @DisplayName("상세 조회") + class Describe_getInstanceDetailInformation { + + @Nested + @DisplayName("사용자가 참여한 인스턴스의 상세 정보를 조회할 때") + class Context_when_joinedInstance { + + private User savedUser; + private Instance savedInstance; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + savedInstance = getSavedInstance(Progress.PREACTIVITY, LocalDate.now().plusDays(2)); + } + + @Test + @DisplayName("필요한 데이터를 반환한다.") + void it_returnsInstanceDetail() { + instanceDetailFacade.joinNewChallenge(savedUser, + new JoinRequest(savedInstance.getId(), targetRepo, LocalDate.of(2024, 1, 30))); + InstanceResponse instanceResponse = instanceDetailFacade.getInstanceDetailInformation(savedUser, + savedInstance.getId()); + + assertThat(instanceResponse.instanceId()).isEqualTo(savedInstance.getId()); + assertThat(instanceResponse.progress()).isEqualTo(Progress.PREACTIVITY); + assertThat(instanceResponse.remainDays()).isEqualTo(2); + assertThat(instanceResponse.participantCount()).isEqualTo(1); + assertThat(instanceResponse.pointPerPerson()).isEqualTo(100); + assertThat(instanceResponse.description()).isEqualTo(savedInstance.getDescription()); + assertThat(instanceResponse.joinStatus()).isEqualTo(JoinStatus.YES); + assertThat(instanceResponse.likesInfo().likesCount()).isEqualTo(0); + assertThat(instanceResponse.likesInfo().likesId()).isEqualTo(0); + assertThat(instanceResponse.likesInfo().isLiked()).isFalse(); + } + } + + @Nested + @DisplayName("사용자가 참여하지 않은 인스턴스의 상세 정보를 조회할 때") + class Context_when_notJoinedInstance { + + private User savedUser; + private Instance savedInstance; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + savedInstance = getSavedInstance(Progress.PREACTIVITY, LocalDate.now().plusDays(2)); + } + + @Test + @DisplayName("필요한 정보를 반환할 수 있다.") + void it_returnsInstanceDetail() { + InstanceResponse instanceResponse = instanceDetailFacade.getInstanceDetailInformation(savedUser, + savedInstance.getId()); + + assertThat(instanceResponse.instanceId()).isEqualTo(savedInstance.getId()); + assertThat(instanceResponse.remainDays()).isEqualTo(2); + assertThat(instanceResponse.participantCount()).isEqualTo(0); + assertThat(instanceResponse.pointPerPerson()).isEqualTo(100); + assertThat(instanceResponse.description()).isEqualTo(savedInstance.getDescription()); + assertThat(instanceResponse.joinStatus()).isEqualTo(JoinStatus.NO); + assertThat(instanceResponse.likesInfo().likesCount()).isEqualTo(0); + assertThat(instanceResponse.likesInfo().likesId()).isEqualTo(0); + assertThat(instanceResponse.likesInfo().isLiked()).isFalse(); + } + } + + @Nested + @DisplayName("좋아요를 한 이후 상세 정보를 조회할 때") + class Context_when_userPushLikes { + + private User savedUser; + private Instance savedInstance; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + savedInstance = getSavedInstance(Progress.PREACTIVITY, LocalDate.now().plusDays(2)); + likesFacade.addLikes(savedUser, savedUser.getIdentifier(), savedInstance.getId()); + } + + @Test + @DisplayName("좋아요 관련된 정보를 반환한다.") + void it_returnsLikesData() { + InstanceResponse instanceResponse = instanceDetailFacade.getInstanceDetailInformation(savedUser, + savedInstance.getId()); + + assertThat(instanceResponse.instanceId()).isEqualTo(savedInstance.getId()); + assertThat(instanceResponse.remainDays()).isEqualTo(2); + assertThat(instanceResponse.participantCount()).isEqualTo(0); + assertThat(instanceResponse.pointPerPerson()).isEqualTo(100); + assertThat(instanceResponse.description()).isEqualTo(savedInstance.getDescription()); + assertThat(instanceResponse.joinStatus()).isEqualTo(JoinStatus.NO); + assertThat(instanceResponse.likesInfo().likesCount()).isEqualTo(1); + assertThat(instanceResponse.likesInfo().likesId()).isNotEqualTo(0); + assertThat(instanceResponse.likesInfo().isLiked()).isTrue(); + } + } + + @Nested + @DisplayName("상세 정보를 요청하는 인스턴스가 존재하지 않을 때") + class Context_when_instanceNotExist { + + private User savedUser; + + @BeforeEach + void setUp() { + savedUser = getSavedUser(githubId); + } + + @Test + @DisplayName("예외가 발생해야 한다.") + void it_throwsException() { + assertThatThrownBy(() -> instanceDetailFacade.getInstanceDetailInformation(savedUser, 1L)) + .isInstanceOf(BusinessException.class) + .hasMessageContaining(INSTANCE_NOT_FOUND.getMessage()); + } + } } + // 유틸리티 메서드 private User getSavedUser(String githubId) { User user = userRepository.save( User.builder() @@ -387,4 +505,4 @@ private Instance getSavedInstance(Progress progress, LocalDate startedDate) { .build() ); } -} \ No newline at end of file +} diff --git a/src/test/java/com/genius/gitget/challenge/instance/service/ProgressServiceTest.java b/src/test/java/com/genius/gitget/challenge/instance/service/ProgressServiceTest.java index 0bd5716a..f4aa324f 100644 --- a/src/test/java/com/genius/gitget/challenge/instance/service/ProgressServiceTest.java +++ b/src/test/java/com/genius/gitget/challenge/instance/service/ProgressServiceTest.java @@ -38,8 +38,6 @@ @Transactional @ActiveProfiles({"github"}) class ProgressServiceTest { - @Autowired - private InstanceDetailService instanceDetailService; @Autowired private ProgressService scheduleService; @Autowired @@ -53,7 +51,8 @@ class ProgressServiceTest { @Autowired private CertificationRepository certificationRepository; @Autowired - private InstanceProvider instanceProvider; + private InstanceDetailFacade instanceDetailFacade; + @Value("${github.yeon-personalKey}") private String personalKey; @@ -77,7 +76,7 @@ public void should_updateToActivity_when_conditionMatches() { getSavedInstance(startedDate, completedDate); githubFacade.registerGithubPersonalToken(user, personalKey); - instanceDetailService.joinNewChallenge( + instanceDetailFacade.joinNewChallenge( user, JoinRequest.builder() .repository(targetRepo) @@ -90,10 +89,10 @@ public void should_updateToActivity_when_conditionMatches() { .orElseThrow(() -> new BusinessException(ErrorCode.PARTICIPANT_NOT_FOUND)); //when - List preActivities = instanceProvider.findAllByProgress(Progress.PREACTIVITY); + List preActivities = instanceRepository.findAllByProgress(Progress.PREACTIVITY); assertThat(participant1.getJoinResult()).isEqualTo(JoinResult.READY); scheduleService.updateToActivity(currentDate); - List activities = instanceProvider.findAllByProgress(Progress.ACTIVITY); + List activities = instanceRepository.findAllByProgress(Progress.ACTIVITY); //then assertThat(preActivities.size()).isEqualTo(3); @@ -116,7 +115,7 @@ public void should_updateToActivity_when_dDay() { getSavedInstance(startedDate, completedDate); githubFacade.registerGithubPersonalToken(user, personalKey); - instanceDetailService.joinNewChallenge( + instanceDetailFacade.joinNewChallenge( user, JoinRequest.builder() .repository(targetRepo) @@ -129,10 +128,10 @@ public void should_updateToActivity_when_dDay() { .orElseThrow(() -> new BusinessException(ErrorCode.PARTICIPANT_NOT_FOUND)); //when - List preActivities = instanceProvider.findAllByProgress(Progress.PREACTIVITY); + List preActivities = instanceRepository.findAllByProgress(Progress.PREACTIVITY); assertThat(participant1.getJoinResult()).isEqualTo(JoinResult.READY); scheduleService.updateToActivity(currentDate); - List activities = instanceProvider.findAllByProgress(Progress.ACTIVITY); + List activities = instanceRepository.findAllByProgress(Progress.ACTIVITY); //then assertThat(preActivities.size()).isEqualTo(3); @@ -153,9 +152,9 @@ public void should_updateToDone_when_conditionMatches() { getSavedInstance(startedDate, completedDate); //when - List activities = instanceProvider.findAllByProgress(Progress.PREACTIVITY); + List activities = instanceRepository.findAllByProgress(Progress.PREACTIVITY); scheduleService.updateToDone(currentDate); - List done = instanceProvider.findAllByProgress(Progress.DONE); + List done = instanceRepository.findAllByProgress(Progress.DONE); //then assertThat(activities.size()).isEqualTo(3); @@ -183,7 +182,7 @@ public void should_updateToSuccess_then_rateOverThreshold() { scheduleService.updateToDone(currentDate); //then - List done = instanceProvider.findAllByProgress(Progress.DONE); + List done = instanceRepository.findAllByProgress(Progress.DONE); assertThat(done.size()).isEqualTo(3); assertThat(participant1.getJoinResult()).isEqualTo(JoinResult.SUCCESS); } @@ -209,7 +208,7 @@ public void should_updateToFail_when_rateUnderThreshold() { scheduleService.updateToDone(currentDate); //then - List done = instanceProvider.findAllByProgress(Progress.DONE); + List done = instanceRepository.findAllByProgress(Progress.DONE); assertThat(done.size()).isEqualTo(3); assertThat(participant1.getJoinResult()).isEqualTo(JoinResult.FAIL); }