Skip to content

Commit

Permalink
Merge pull request #146 from softeerbootcamp4th/feature/145-fix-draw
Browse files Browse the repository at this point in the history
[fix] 추첨 이벤트 결과 당첨자 1명만 조회되던 버그 수정 (#145)
  • Loading branch information
win-luck authored Aug 23, 2024
2 parents dd75b82 + 8bb4d39 commit de7622d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

public interface DrawEventWinningInfoRepository extends JpaRepository<DrawEventWinningInfo, Long>, CustomDrawEventWinningInfoRepository {
@EntityGraph(attributePaths = {"eventUser"})
List<DrawEventWinningInfo> findAllById(Long id);
List<DrawEventWinningInfo> findAllByDrawEventId(Long eventId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public List<ResponseDrawWinnerDto> getDrawEventWinner(String drawEventId) {
if(drawEvent == null) throw new DrawEventException(ErrorCode.EVENT_NOT_FOUND);

// 당첨자 목록 반환
return deWinningInfoRepository.findAllById(drawEvent.getId())
return deWinningInfoRepository.findAllByDrawEventId(drawEvent.getId())
.stream()
.map(ResponseDrawWinnerDto::new)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ void getDrawEventWinner() {
var eventMetadata = createEventMetadata(eventId, EventType.draw, Instant.now());
eventMetadata.updateDrawEvent(drawEvent);
when(emRepository.findFirstByEventId(eventId)).thenReturn(Optional.of(eventMetadata));
when(deWinningInfoRepository.findAllById(drawEvent.getId())).thenReturn(List.of(DrawEventWinningInfo.of(1L, drawEvent, eventUser)));
when(deWinningInfoRepository.findAllByDrawEventId(drawEvent.getId())).thenReturn(List.of(DrawEventWinningInfo.of(1L, drawEvent, eventUser)));

// when
var result = deService.getDrawEventWinner(eventId);

// then
assertThat(result).isNotEmpty();
verify(emRepository, times(1)).findFirstByEventId(eventId);
verify(deWinningInfoRepository, times(1)).findAllById(drawEvent.getId());
verify(deWinningInfoRepository, times(1)).findAllByDrawEventId(drawEvent.getId());
}

@DisplayName("getDrawEventStatus: 대응되는 이벤트가 존재하지 않으면 예외 반환")
Expand Down

0 comments on commit de7622d

Please sign in to comment.