2626import com .swyp .picke .domain .vote .entity .BattleVote ;
2727import com .swyp .picke .domain .vote .repository .BattleVoteRepository ;
2828import java .time .LocalDate ;
29+ import java .time .ZoneId ;
2930import java .util .List ;
3031import java .util .Optional ;
3132import 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