-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: StandardAnswer 업데이트시 기존 StandardAnswer 삭제 안 되던 버그 수정 (#173)
* fix: StandardAnswer 업데이트시 기존 StandardAnswer 삭제 안 되던 버그 수정 * refactor: lint
- Loading branch information
Showing
3 changed files
with
69 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...broker/apiserver/controller/v1/admin/problem/AdminLongProblemControllerIntegrationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.csbroker.apiserver.controller.v1.admin.problem | ||
|
||
import io.csbroker.apiserver.controller.IntegrationTest | ||
import io.csbroker.apiserver.dto.problem.longproblem.LongProblemUpsertRequestDto | ||
import io.csbroker.apiserver.model.LongProblem | ||
import io.csbroker.apiserver.model.StandardAnswer | ||
import io.csbroker.apiserver.model.Tag | ||
import io.kotest.matchers.shouldBe | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.http.HttpMethod | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status | ||
|
||
class AdminLongProblemControllerIntegrationTest : IntegrationTest() { | ||
|
||
@Test | ||
fun `문제 업데이트`() { | ||
// given | ||
val problem = save( | ||
LongProblem( | ||
title = "문제 제목", | ||
description = "문제 설명", | ||
creator = adminUser, | ||
), | ||
) | ||
save(StandardAnswer(content = "삭제될 모범 답안", longProblem = problem)) | ||
save(Tag(name = "tag1")) | ||
val updateRequestDto = LongProblemUpsertRequestDto( | ||
title = "Test problem", | ||
description = "This is a test problem", | ||
tags = mutableListOf("tag1"), | ||
standardAnswers = listOf("업데이트될 모범 답안"), | ||
gradingStandards = mutableListOf(), | ||
) | ||
|
||
// when | ||
val response = request( | ||
method = HttpMethod.PUT, | ||
url = "/api/admin/problems/long/${problem.id}", | ||
isAdmin = true, | ||
body = updateRequestDto, | ||
) | ||
|
||
// then | ||
response.andExpect(status().isOk) | ||
.andExpect { | ||
val standardAnswers = findAll<StandardAnswer>( | ||
"SELECT s FROM StandardAnswer s where s.longProblem.id = :id", | ||
mapOf("id" to problem.id), | ||
) | ||
standardAnswers.map { it.content }.toSet() shouldBe updateRequestDto.standardAnswers.toSet() | ||
} | ||
} | ||
} |