Skip to content

Commit

Permalink
test: 테스트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRivaski committed Aug 22, 2024
1 parent 530bd70 commit 3693238
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public class MainPageEventInfoResponseDto {

private String fcfsHint;

@JsonProperty("isFcfsAvailable")
private boolean isFcfsAvailable;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime nextFcfsStartTime;
private LocalDateTime fcfsStartTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ public MainPageEventInfoResponseDto getEventPageInfo() {

int remainDrawCount = totalDrawWinner - (int) drawRepository.count();

String fcfsTime = "";
if(firstFcfsSetting.getStartTime().getMinute() != 0){
fcfsTime = firstFcfsSetting.getStartTime().format(fcfsTimeFormatter);
}
else
fcfsTime = firstFcfsSetting.getStartTime().format(fcfsTimeMinFormatter);

String fcfsTime = "";
if(firstFcfsSetting.getStartTime().getMinute() != 0){
fcfsTime = firstFcfsSetting.getStartTime().format(fcfsTimeFormatter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.softeer.backend.fo_domain.draw.dto.history.DrawHistoryLoserResponseDto;
import com.softeer.backend.fo_domain.draw.dto.history.DrawHistoryResponseDto;
import com.softeer.backend.fo_domain.draw.dto.history.DrawHistoryWinnerResponseDto;
import com.softeer.backend.fo_domain.draw.exception.DrawException;
import com.softeer.backend.fo_domain.draw.repository.DrawParticipationInfoRepository;
import com.softeer.backend.fo_domain.draw.repository.DrawRepository;
import com.softeer.backend.fo_domain.draw.util.DrawAttendanceCountUtil;
Expand Down Expand Up @@ -40,8 +41,7 @@
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;


@Transactional
Expand Down Expand Up @@ -135,7 +135,7 @@ void getDrawMainPageFullAttend() {

when(shareInfoRepository.findShareInfoByUserId(userId)).thenReturn(Optional.ofNullable(shareInfo));

when(drawAttendanceCountUtil.handleAttendanceCount(userId, drawParticipationInfo)).thenReturn(7);
lenient().when(drawAttendanceCountUtil.handleAttendanceCount(userId, drawParticipationInfo)).thenReturn(7);

DrawMainFullAttendResponseDto expectedResponse = DrawMainFullAttendResponseDto
.builder()
Expand Down Expand Up @@ -215,29 +215,9 @@ void participateDrawEventZero() {

when(shareInfoRepository.findShareInfoByUserId(userId)).thenReturn(Optional.ofNullable(shareInfo));

ArrayList<String> images = new ArrayList<>();
images.add("left");
images.add("left");
images.add("right");

DrawLoseModalResponseDto drawLoseModalResponseDto = DrawLoseModalResponseDto.builder()
.isDrawWin(false)
.images(images)
.shareUrl("https://softeer.site/share/of8w")
.build();

when(drawResponseGenerateUtil.generateDrawLoserResponse(userId)).thenReturn(drawLoseModalResponseDto);

// when
DrawModalResponseDto actualResponse = drawService.participateDrawEvent(userId);

// then
assertThat(actualResponse).isNotNull();
assertThat(actualResponse.isDrawWin()).isEqualTo(false);
assertThat(((DrawLoseModalResponseDto) actualResponse).getShareUrl()).isEqualTo("https://softeer.site/share/of8w");
assertThat(actualResponse.getImages().get(0)).isEqualTo("left");
assertThat(actualResponse.getImages().get(1)).isEqualTo("left");
assertThat(actualResponse.getImages().get(2)).isEqualTo("right");
// When & Then
assertThatThrownBy(() -> drawService.participateDrawEvent(userId))
.isInstanceOf(DrawException.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void testGetEventPageInfo() {
assertThat(response.getStartDate()).isEqualTo("2024.08.01");
assertThat(response.getEndDate()).isEqualTo("2024.08.31");
assertThat(response.getFcfsHint()).isEqualTo("퀴즈 힌트");
assertThat(response.getNextFcfsStartTime()).isEqualTo(LocalDateTime.of(2024, 8, 22, 11, 0));
assertThat(response.getFcfsStartTime()).isEqualTo(LocalDateTime.of(2024, 8, 22, 11, 0));
}

@Test
Expand Down

0 comments on commit 3693238

Please sign in to comment.