Skip to content

Commit 2b90a71

Browse files
committed
test: 테스트 코드 수정
1 parent bac8c0d commit 2b90a71

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

src/main/java/org/ezcode/codetest/infrastructure/judge0/Judge0Client.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void init() {
4949

5050
HttpClient httpClient = HttpClient.create(provider)
5151
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5_000)
52-
.responseTimeout(Duration.ofSeconds(30));
52+
.responseTimeout(Duration.ofSeconds(10));
5353

5454
this.webClient = WebClient.builder()
5555
.baseUrl(judge0ApiUrl)
@@ -70,8 +70,8 @@ public String submitAndGetToken(CodeCompileRequest request) {
7070
res -> Mono.error(new TimeoutException("Upstream 504 Gateway Timeout"))
7171
)
7272
.bodyToMono(ExecutionResultResponse.class)
73-
.timeout(Duration.ofSeconds(30))
74-
.retryWhen(Retry.backoff(5, Duration.ofSeconds(1))
73+
.timeout(Duration.ofSeconds(10))
74+
.retryWhen(Retry.backoff(3, Duration.ofSeconds(1))
7575
.maxBackoff(Duration.ofSeconds(4))
7676
.filter(ex -> {
7777
if (ex instanceof TimeoutException) {

src/test/java/org/ezcode/codetest/domain/submission/SubmissionDomainServiceTest.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ void firstSubmission_passed() {
118118

119119
// then
120120
then(submissionRepository).should().saveSubmission(any());
121-
then(ctx).should().incrementTotalSubmissions();
122-
then(ctx).should().incrementCorrectSubmissions();
123121
then(userProblemResultRepository).should().saveUserProblemResult(any());
124-
assertThat(submissionResult.isSolved()).isFalse();
122+
assertThat(submissionResult.isSolved()).isTrue();
123+
assertThat(submissionResult.hasBeenSolved()).isFalse();
125124
}
126125

127126
@Test
@@ -159,10 +158,9 @@ void firstSubmission_failed() {
159158

160159
// then
161160
then(submissionRepository).should().saveSubmission(any());
162-
then(ctx).should().incrementTotalSubmissions();
163-
then(ctx).should(never()).incrementCorrectSubmissions();
164161
then(userProblemResultRepository).should().saveUserProblemResult(any());
165162
assertThat(submissionResult.isSolved()).isFalse();
163+
assertThat(submissionResult.hasBeenSolved()).isFalse();
166164
}
167165

168166
@Test
@@ -200,10 +198,9 @@ void retryAfterWrong_passed() {
200198

201199
// then
202200
then(submissionRepository).should().saveSubmission(any());
203-
then(ctx).should().incrementTotalSubmissions();
204-
then(ctx).should().incrementCorrectSubmissions();
205201
then(userProblemResultRepository).should().updateUserProblemResult(userProblemResult, true);
206-
assertThat(submissionResult.isSolved()).isFalse();
202+
assertThat(submissionResult.isSolved()).isTrue();
203+
assertThat(submissionResult.hasBeenSolved()).isFalse();
207204
}
208205

209206
@Test
@@ -241,11 +238,10 @@ void retryAfterWrong_failedAgain() {
241238

242239
// then
243240
then(submissionRepository).should().saveSubmission(any());
244-
then(ctx).should().incrementTotalSubmissions();
245-
then(ctx).should(never()).incrementCorrectSubmissions();
246241
then(userProblemResultRepository).should(never())
247242
.updateUserProblemResult(any(UserProblemResult.class), anyBoolean());
248243
assertThat(submissionResult.isSolved()).isFalse();
244+
assertThat(submissionResult.hasBeenSolved()).isFalse();
249245
}
250246

251247
@Test
@@ -283,11 +279,10 @@ void retryAfterCorrect_passedAgain() {
283279

284280
// then
285281
then(submissionRepository).should().saveSubmission(any());
286-
then(ctx).should().incrementTotalSubmissions();
287-
then(ctx).should(never()).incrementCorrectSubmissions();
288282
then(userProblemResultRepository).should(never())
289283
.updateUserProblemResult(any(UserProblemResult.class), anyBoolean());
290-
assertThat(submissionResult.isSolved()).isTrue();
284+
assertThat(submissionResult.isSolved()).isFalse();
285+
assertThat(submissionResult.hasBeenSolved()).isTrue();
291286
}
292287

293288
@Test

src/test/java/org/ezcode/codetest/infrastructure/judge0/Judge0ClientTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void submitAndGetToken_throwTimeout() {
150150
mockWebServer.enqueue(new MockResponse()
151151
.setBody("{\"token\":\"late\"}")
152152
.setHeader("Content-Type", "application/json")
153-
.setBodyDelay(10, TimeUnit.SECONDS));
153+
.setBodyDelay(11, TimeUnit.SECONDS));
154154

155155
// when & then
156156
assertThatThrownBy(() -> judge0Client.submitAndGetToken(request))
@@ -182,7 +182,7 @@ void pollUntilDone_compileErrorMapping() {
182182
void pollUntilDone_throwTimeout() {
183183

184184
// given
185-
for (int i = 0; i < 65; i++) {
185+
for (int i = 0; i < 61; i++) {
186186
mockWebServer.enqueue(json("{\"status\":{\"id\":1}}"));
187187
}
188188

0 commit comments

Comments
 (0)