Skip to content

Commit efe42f5

Browse files
author
github-actions
committed
chore: Java 스타일 수정
1 parent e7db315 commit efe42f5

File tree

5 files changed

+117
-120
lines changed

5 files changed

+117
-120
lines changed

backend/src/main/java/io/f1/backend/domain/game/app/ChatService.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010
import io.f1.backend.domain.question.entity.Question;
1111
import io.f1.backend.domain.user.dto.UserPrincipal;
1212

13-
import io.f1.backend.global.lock.DistributedLock;
14-
import java.util.concurrent.atomic.AtomicBoolean;
1513
import lombok.RequiredArgsConstructor;
1614

17-
import org.redisson.api.RLock;
18-
import org.redisson.api.RedissonClient;
1915
import org.springframework.context.ApplicationEventPublisher;
2016
import org.springframework.stereotype.Service;
2117

@@ -49,11 +45,10 @@ public void chat(Long roomId, UserPrincipal userPrincipal, ChatMessage chatMessa
4945
}
5046

5147
// false -> true
52-
if(room.compareAndSetAnsweredFlag(false, true)) {
48+
if (room.compareAndSetAnsweredFlag(false, true)) {
5349
eventPublisher.publishEvent(
5450
new GameCorrectAnswerEvent(
5551
room, userPrincipal.getUserId(), chatMessage, answer));
56-
5752
}
5853
}
5954
}

backend/src/main/java/io/f1/backend/domain/game/app/GameService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void onTimeout(GameTimeoutEvent event) {
145145
Room room = event.room();
146146

147147
// false -> true 여야 하는데 실패했을 때 => 이미 정답 처리가 된 경우 (onCorrectAnswer 로직 실행 중)
148-
if(!room.compareAndSetAnsweredFlag(false, true)) {
148+
if (!room.compareAndSetAnsweredFlag(false, true)) {
149149
return;
150150
}
151151

backend/src/main/java/io/f1/backend/domain/game/model/Room.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import io.f1.backend.global.exception.CustomException;
66
import io.f1.backend.global.exception.errorcode.RoomErrorCode;
77

8-
import java.util.concurrent.atomic.AtomicBoolean;
98
import lombok.Getter;
109

1110
import java.time.LocalDateTime;
@@ -17,6 +16,7 @@
1716
import java.util.concurrent.Executors;
1817
import java.util.concurrent.ScheduledExecutorService;
1918
import java.util.concurrent.ScheduledFuture;
19+
import java.util.concurrent.atomic.AtomicBoolean;
2020

2121
@Getter
2222
public class Room {

backend/src/test/java/io/f1/backend/domain/game/app/ChatServiceTests.java

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
import static org.junit.jupiter.api.Assertions.*;
55
import static org.mockito.ArgumentMatchers.any;
66
import static org.mockito.BDDMockito.given;
7-
import static org.mockito.Mockito.atLeastOnce;
87
import static org.mockito.Mockito.mock;
98
import static org.mockito.Mockito.never;
10-
import static org.mockito.Mockito.only;
119
import static org.mockito.Mockito.times;
1210
import static org.mockito.Mockito.verify;
1311

@@ -22,15 +20,9 @@
2220
import io.f1.backend.domain.question.entity.Question;
2321
import io.f1.backend.domain.user.dto.UserPrincipal;
2422
import io.f1.backend.domain.user.entity.User;
25-
import java.lang.reflect.Field;
26-
import java.time.Instant;
27-
import java.time.LocalDateTime;
28-
import java.util.Collections;
29-
import java.util.concurrent.CountDownLatch;
30-
import java.util.concurrent.ExecutorService;
31-
import java.util.concurrent.Executors;
32-
import java.util.concurrent.TimeUnit;
23+
3324
import lombok.extern.slf4j.Slf4j;
25+
3426
import org.junit.jupiter.api.BeforeEach;
3527
import org.junit.jupiter.api.DisplayName;
3628
import org.junit.jupiter.api.Test;
@@ -42,6 +34,14 @@
4234
import org.springframework.context.ApplicationEventPublisher;
4335
import org.springframework.security.core.context.SecurityContextHolder;
4436

37+
import java.lang.reflect.Field;
38+
import java.time.Instant;
39+
import java.time.LocalDateTime;
40+
import java.util.Collections;
41+
import java.util.concurrent.CountDownLatch;
42+
import java.util.concurrent.ExecutorService;
43+
import java.util.concurrent.Executors;
44+
4545
@Slf4j
4646
@ExtendWith(MockitoExtension.class)
4747
class ChatServiceTests {
@@ -61,7 +61,6 @@ void setUp() {
6161
SecurityContextHolder.clearContext();
6262
}
6363

64-
6564
@Test
6665
@DisplayName("정답이 아닐 때 이벤트가 발행되지 않는다.")
6766
void noEventWhenIncorrect() throws Exception {
@@ -111,7 +110,6 @@ void EventPublishedWhenCorrect() throws Exception {
111110

112111
// then
113112
verify(eventPublisher, times(1)).publishEvent(any(GameCorrectAnswerEvent.class));
114-
115113
}
116114

117115
@Test
@@ -146,22 +144,24 @@ void onlyOneCorrectPlayerWhenConcurrentCorrectAnswers() throws Exception {
146144

147145
for (int i = 0; i < userCount; i++) {
148146
final int idx = i;
149-
executor.submit(() -> {
150-
try {
151-
User user = createUser(idx);
152-
UserPrincipal principal = new UserPrincipal(user, Collections.emptyMap());
153-
chatService.chat(roomId, principal, msg);
154-
} finally {
155-
countDownLatch.countDown();
156-
}
157-
});
147+
executor.submit(
148+
() -> {
149+
try {
150+
User user = createUser(idx);
151+
UserPrincipal principal =
152+
new UserPrincipal(user, Collections.emptyMap());
153+
chatService.chat(roomId, principal, msg);
154+
} finally {
155+
countDownLatch.countDown();
156+
}
157+
});
158158
}
159159

160160
countDownLatch.await();
161161

162-
163162
// then: 이벤트는 단 1번만 발행돼야 함
164-
ArgumentCaptor<GameCorrectAnswerEvent> captor = ArgumentCaptor.forClass(GameCorrectAnswerEvent.class);
163+
ArgumentCaptor<GameCorrectAnswerEvent> captor =
164+
ArgumentCaptor.forClass(GameCorrectAnswerEvent.class);
165165
verify(eventPublisher, times(1)).publishEvent(captor.capture());
166166

167167
GameCorrectAnswerEvent event = captor.getValue();
@@ -173,31 +173,31 @@ void onlyOneCorrectPlayerWhenConcurrentCorrectAnswers() throws Exception {
173173
}
174174

175175
private Room createRoom(
176-
Long roomId,
177-
Long playerId,
178-
Long quizId,
179-
String password,
180-
int maxUserCount,
181-
boolean locked) {
176+
Long roomId,
177+
Long playerId,
178+
Long quizId,
179+
String password,
180+
int maxUserCount,
181+
boolean locked) {
182182
RoomSetting roomSetting = new RoomSetting("방제목", maxUserCount, locked, password);
183183
GameSetting gameSetting = new GameSetting(quizId, 10, 60);
184184
Player host = new Player(playerId, "nickname");
185185

186186
return new Room(roomId, roomSetting, gameSetting, host);
187187
}
188-
188+
189189
private User createUser(int i) {
190190
Long userId = i + 1L;
191191
String provider = "provider +" + i;
192192
String providerId = "providerId" + i;
193193
LocalDateTime lastLogin = LocalDateTime.now();
194194

195195
User user =
196-
User.builder()
197-
.provider(provider)
198-
.providerId(providerId)
199-
.lastLogin(lastLogin)
200-
.build();
196+
User.builder()
197+
.provider(provider)
198+
.providerId(providerId)
199+
.lastLogin(lastLogin)
200+
.build();
201201

202202
try {
203203
Field idField = User.class.getDeclaredField("id");
@@ -209,5 +209,4 @@ private User createUser(int i) {
209209

210210
return user;
211211
}
212-
213-
}
212+
}

0 commit comments

Comments
 (0)