Skip to content

Commit 7b0b68f

Browse files
authored
πŸ› Fix: BattleVoteServiceImplTest μ‹œκ°„λŒ€ 뢈일치둜 15μ‹œ(UTC) 이후 CI μ‹€νŒ¨ (#442)
1 parent 23496d1 commit 7b0b68f

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

β€Žsrc/test/java/com/swyp/picke/domain/vote/service/BattleVoteServiceImplTest.javaβ€Ž

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.swyp.picke.domain.vote.entity.BattleVote;
2727
import com.swyp.picke.domain.vote.repository.BattleVoteRepository;
2828
import java.time.LocalDate;
29+
import java.time.ZoneId;
2930
import java.util.List;
3031
import java.util.Optional;
3132
import org.junit.jupiter.api.DisplayName;
@@ -75,10 +76,20 @@ class BattleVoteServiceImplTest {
7576
@InjectMocks
7677
private BattleVoteServiceImpl battleVoteService;
7778

79+
/**
80+
* BattleVoteServiceImpl은 "였늘"을 KST둜 νŒλ‹¨ν•œλ‹€(LocalDate.now(KST)).
81+
* ν…ŒμŠ€νŠΈκ°€ μ‹œμŠ€ν…œ κΈ°λ³Έ μ‹œκ°„λŒ€λ₯Ό μ“°λ©΄ UTC λŸ¬λ„ˆμ—μ„œ 15μ‹œ μ΄ν›„λ‘œ ν•˜λ£¨κ°€ μ–΄κΈ‹λ‚˜ μ‹€νŒ¨ν•œλ‹€.
82+
*/
83+
private static final ZoneId KST = ZoneId.of("Asia/Seoul");
84+
85+
private static LocalDate today() {
86+
return LocalDate.now(KST);
87+
}
88+
7889
@Test
7990
@DisplayName("였늘 배틀이 μ•„λ‹ˆλ©΄ 졜초 사전 νˆ¬ν‘œ μ‹œ BATTLE_ENTRY ν¬λ ˆλ”§μ„ μ°¨κ°ν•œλ‹€")
8091
void preVote_chargesBattleEntryCreditForPastBattle() {
81-
Battle battle = battle(100L, LocalDate.now().minusDays(1));
92+
Battle battle = battle(100L, today().minusDays(1));
8293
User user = user(10L);
8394
BattleOption option = option(201L, battle, BattleOptionLabel.A);
8495

@@ -99,7 +110,7 @@ void preVote_chargesBattleEntryCreditForPastBattle() {
99110
@Test
100111
@DisplayName("였늘 배틀이면 졜초 사전 νˆ¬ν‘œ μ‹œ ν¬λ ˆλ”§μ„ μ°¨κ°ν•˜μ§€ μ•ŠλŠ”λ‹€")
101112
void preVote_doesNotChargeBattleEntryCreditForTodayBattle() {
102-
Battle battle = battle(100L, LocalDate.now());
113+
Battle battle = battle(100L, today());
103114
User user = user(10L);
104115
BattleOption option = option(201L, battle, BattleOptionLabel.A);
105116

@@ -119,15 +130,15 @@ void preVote_doesNotChargeBattleEntryCreditForTodayBattle() {
119130
@Test
120131
@DisplayName("였늘의 배틀이라도 였늘 이미 무료 μ§„μž…μ„ μ‚¬μš©ν–ˆλ‹€λ©΄ ν¬λ ˆλ”§μ„ μ°¨κ°ν•œλ‹€")
121132
void preVote_chargesBattleEntryCreditWhenFreeEntryAlreadyUsedToday() {
122-
Battle battle = battle(100L, LocalDate.now());
133+
Battle battle = battle(100L, today());
123134
User user = user(10L);
124135
BattleOption option = option(201L, battle, BattleOptionLabel.A);
125136

126137
when(battleService.findById(100L)).thenReturn(battle);
127138
when(userRepository.findById(10L)).thenReturn(Optional.of(user));
128139
when(battleOptionRepository.findById(201L)).thenReturn(Optional.of(option));
129140
when(battleVoteRepository.findByBattleAndUser(battle, user)).thenReturn(Optional.empty());
130-
when(battleVoteRepository.existsByUserIdAndBattle_TargetDate(10L, LocalDate.now())).thenReturn(true);
141+
when(battleVoteRepository.existsByUserIdAndBattle_TargetDate(10L, today())).thenReturn(true);
131142
when(userBattleService.getUserBattleStatus(user, battle))
132143
.thenReturn(new UserBattleStatusResponse(100L, UserBattleStep.NONE));
133144

@@ -140,7 +151,7 @@ void preVote_chargesBattleEntryCreditWhenFreeEntryAlreadyUsedToday() {
140151
@Test
141152
@DisplayName("이미 사전 νˆ¬ν‘œν•œ 배틀이면 μ˜΅μ…˜ λ³€κ²½ μ‹œ μΆ”κ°€ μ°¨κ°ν•˜μ§€ μ•ŠλŠ”λ‹€")
142153
void preVote_doesNotChargeAgainWhenVoteAlreadyExists() {
143-
Battle battle = battle(100L, LocalDate.now().minusDays(1));
154+
Battle battle = battle(100L, today().minusDays(1));
144155
User user = user(10L);
145156
BattleOption oldOption = option(200L, battle, BattleOptionLabel.B);
146157
BattleOption newOption = option(201L, battle, BattleOptionLabel.A);

0 commit comments

Comments
Β (0)