[#44] 매장 기능 도입 #45

Merged
pricelees merged 116 commits from feat/#44 into main 2025-09-20 03:15:06 +00:00
2 changed files with 78 additions and 92 deletions
Showing only changes of commit f62ac181ee - Show all commits

View File

@ -1,9 +1,7 @@
package roomescape.theme package roomescape.theme
import io.kotest.matchers.date.shouldBeAfter
import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.nulls.shouldNotBeNull
import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import org.hamcrest.CoreMatchers.equalTo import org.hamcrest.CoreMatchers.equalTo
import org.springframework.data.repository.findByIdOrNull import org.springframework.data.repository.findByIdOrNull
import org.springframework.http.HttpMethod import org.springframework.http.HttpMethod
@ -54,7 +52,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createStoreAdmin(permissionLevel = it) val admin = AdminFixture.createStoreAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.POST, method = HttpMethod.POST,
requestBody = createRequest, requestBody = createRequest,
endpoint = endpoint, endpoint = endpoint,
@ -67,7 +65,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createHqAdmin(permissionLevel = it) val admin = AdminFixture.createHqAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.POST, method = HttpMethod.POST,
requestBody = createRequest, requestBody = createRequest,
endpoint = endpoint, endpoint = endpoint,
@ -81,7 +79,7 @@ class AdminThemeApiTest(
test("정상 생성 및 감사 정보 확인") { test("정상 생성 및 감사 정보 확인") {
runTest( runTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
using = { using = {
body(createRequest) body(createRequest)
}, },
@ -105,14 +103,12 @@ class AdminThemeApiTest(
} }
test("이미 동일한 이름의 테마가 있으면 실패한다.") { test("이미 동일한 이름의 테마가 있으면 실패한다.") {
val token = testAuthUtil.defaultHqAdminLogin()
val alreadyExistsName: String = initialize("테스트를 위한 테마 생성 및 이름 반환") { val alreadyExistsName: String = initialize("테스트를 위한 테마 생성 및 이름 반환") {
dummyInitializer.createTheme(token, createRequest).name dummyInitializer.createTheme().name
} }
runTest( runTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
using = { using = {
body(createRequest.copy(name = alreadyExistsName)) body(createRequest.copy(name = alreadyExistsName))
}, },
@ -127,9 +123,8 @@ class AdminThemeApiTest(
} }
test("금액이 ${MIN_PRICE}원 미만이면 실패한다.") { test("금액이 ${MIN_PRICE}원 미만이면 실패한다.") {
val token = testAuthUtil.defaultHqAdminLogin()
runTest( runTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
using = { using = {
body(createRequest.copy(price = (MIN_PRICE - 1))) body(createRequest.copy(price = (MIN_PRICE - 1)))
}, },
@ -146,7 +141,7 @@ class AdminThemeApiTest(
context("입력된 시간이 ${MIN_DURATION}분 미만이면 실패한다.") { context("입력된 시간이 ${MIN_DURATION}분 미만이면 실패한다.") {
test("field: availableMinutes") { test("field: availableMinutes") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.POST, method = HttpMethod.POST,
endpoint = endpoint, endpoint = endpoint,
requestBody = createRequest.copy(availableMinutes = (MIN_DURATION - 1).toShort()), requestBody = createRequest.copy(availableMinutes = (MIN_DURATION - 1).toShort()),
@ -156,7 +151,7 @@ class AdminThemeApiTest(
test("field: expectedMinutesFrom") { test("field: expectedMinutesFrom") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.POST, method = HttpMethod.POST,
endpoint = endpoint, endpoint = endpoint,
requestBody = createRequest.copy(expectedMinutesFrom = (MIN_DURATION - 1).toShort()), requestBody = createRequest.copy(expectedMinutesFrom = (MIN_DURATION - 1).toShort()),
@ -166,7 +161,7 @@ class AdminThemeApiTest(
test("field: expectedMinutesTo") { test("field: expectedMinutesTo") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.POST, method = HttpMethod.POST,
endpoint = endpoint, endpoint = endpoint,
requestBody = createRequest.copy(expectedMinutesTo = (MIN_DURATION - 1).toShort()), requestBody = createRequest.copy(expectedMinutesTo = (MIN_DURATION - 1).toShort()),
@ -178,7 +173,7 @@ class AdminThemeApiTest(
context("시간 범위가 잘못 지정되면 실패한다.") { context("시간 범위가 잘못 지정되면 실패한다.") {
test("최소 예상 시간 > 최대 예상 시간") { test("최소 예상 시간 > 최대 예상 시간") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.POST, method = HttpMethod.POST,
endpoint = endpoint, endpoint = endpoint,
requestBody = createRequest.copy(expectedMinutesFrom = 100, expectedMinutesTo = 99), requestBody = createRequest.copy(expectedMinutesFrom = 100, expectedMinutesTo = 99),
@ -188,7 +183,7 @@ class AdminThemeApiTest(
test("최대 예상 시간 > 이용 가능 시간") { test("최대 예상 시간 > 이용 가능 시간") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.POST, method = HttpMethod.POST,
endpoint = endpoint, endpoint = endpoint,
requestBody = createRequest.copy( requestBody = createRequest.copy(
@ -204,7 +199,7 @@ class AdminThemeApiTest(
context("입력된 인원이 ${MIN_PARTICIPANTS}명 미만이면 실패한다.") { context("입력된 인원이 ${MIN_PARTICIPANTS}명 미만이면 실패한다.") {
test("field: minParticipants") { test("field: minParticipants") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.POST, method = HttpMethod.POST,
endpoint = endpoint, endpoint = endpoint,
requestBody = createRequest.copy(minParticipants = (MIN_PARTICIPANTS - 1).toShort()), requestBody = createRequest.copy(minParticipants = (MIN_PARTICIPANTS - 1).toShort()),
@ -214,7 +209,7 @@ class AdminThemeApiTest(
test("field: maxParticipants") { test("field: maxParticipants") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.POST, method = HttpMethod.POST,
endpoint = endpoint, endpoint = endpoint,
requestBody = createRequest.copy(maxParticipants = (MIN_PARTICIPANTS - 1).toShort()), requestBody = createRequest.copy(maxParticipants = (MIN_PARTICIPANTS - 1).toShort()),
@ -226,7 +221,7 @@ class AdminThemeApiTest(
context("인원 범위가 잘못 지정되면 실패한다.") { context("인원 범위가 잘못 지정되면 실패한다.") {
test("최소 인원 > 최대 인원") { test("최소 인원 > 최대 인원") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.POST, method = HttpMethod.POST,
endpoint = endpoint, endpoint = endpoint,
requestBody = createRequest.copy(minParticipants = 10, maxParticipants = 9), requestBody = createRequest.copy(minParticipants = 10, maxParticipants = 9),
@ -262,17 +257,15 @@ class AdminThemeApiTest(
test("정상 응답") { test("정상 응답") {
val createdThemes = initialize("Active 상태 테마 2개 / Inactive 상태 테마 1개 생성") { val createdThemes = initialize("Active 상태 테마 2개 / Inactive 상태 테마 1개 생성") {
val token = testAuthUtil.defaultHqAdminLogin()
listOf( listOf(
dummyInitializer.createTheme(token, createRequest.copy(name = "test1", isActive = true)), dummyInitializer.createTheme(createRequest.copy(name = "test1", isActive = true)),
dummyInitializer.createTheme(token, createRequest.copy(name = "test2", isActive = false)), dummyInitializer.createTheme(createRequest.copy(name = "test2", isActive = false)),
dummyInitializer.createTheme(token, createRequest.copy(name = "test3", isActive = true)) dummyInitializer.createTheme(createRequest.copy(name = "test3", isActive = true))
) )
} }
runTest( runTest(
token = testAuthUtil.defaultStoreAdminLogin(), token = testAuthUtil.defaultStoreAdminLogin().second,
on = { on = {
get(endpoint) get(endpoint)
}, },
@ -314,7 +307,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createStoreAdmin(permissionLevel = it) val admin = AdminFixture.createStoreAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.POST, method = HttpMethod.POST,
requestBody = createRequest, requestBody = createRequest,
endpoint = endpoint, endpoint = endpoint,
@ -326,13 +319,13 @@ class AdminThemeApiTest(
test("정상 응답") { test("정상 응답") {
val token = testAuthUtil.defaultHqAdminLogin() val token = testAuthUtil.defaultHqAdminLogin().second
val themes: List<ThemeEntity> = initialize("Active 상태인 테마 1개 / Inactive 상태인 테마 2개 생성") { val themes: List<ThemeEntity> = initialize("Active 상태인 테마 1개 / Inactive 상태인 테마 2개 생성") {
listOf( listOf(
dummyInitializer.createTheme(token, createRequest.copy(name = "active-1", isActive = true)), dummyInitializer.createTheme(createRequest.copy(isActive = true)),
dummyInitializer.createTheme(token, createRequest.copy(name = "inactive-1", isActive = false)), dummyInitializer.createTheme(createRequest.copy(isActive = false)),
dummyInitializer.createTheme(token, createRequest.copy(name = "inactive-2", isActive = false)) dummyInitializer.createTheme(createRequest.copy(isActive = false))
) )
} }
@ -378,7 +371,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createStoreAdmin(permissionLevel = it) val admin = AdminFixture.createStoreAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.GET, method = HttpMethod.GET,
endpoint = endpoint, endpoint = endpoint,
expectedErrorCode = AuthErrorCode.ACCESS_DENIED expectedErrorCode = AuthErrorCode.ACCESS_DENIED
@ -390,7 +383,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createHqAdmin(permissionLevel = it) val admin = AdminFixture.createHqAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.GET, method = HttpMethod.GET,
endpoint = endpoint, endpoint = endpoint,
expectedErrorCode = AuthErrorCode.ACCESS_DENIED expectedErrorCode = AuthErrorCode.ACCESS_DENIED
@ -401,13 +394,13 @@ class AdminThemeApiTest(
} }
test("정상 응답") { test("정상 응답") {
val token = testAuthUtil.defaultHqAdminLogin() val token = testAuthUtil.defaultHqAdminLogin().second
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runTest( runTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
on = { on = {
get("/admin/themes/${createdTheme.id}") get("/admin/themes/${createdTheme.id}")
}, },
@ -433,7 +426,7 @@ class AdminThemeApiTest(
test("테마가 없으면 실패한다.") { test("테마가 없으면 실패한다.") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.GET, method = HttpMethod.GET,
endpoint = "/admin/themes/$INVALID_PK", endpoint = "/admin/themes/$INVALID_PK",
expectedErrorCode = ThemeErrorCode.THEME_NOT_FOUND expectedErrorCode = ThemeErrorCode.THEME_NOT_FOUND
@ -467,7 +460,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createStoreAdmin(permissionLevel = it) val admin = AdminFixture.createStoreAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.DELETE, method = HttpMethod.DELETE,
endpoint = endpoint, endpoint = endpoint,
expectedErrorCode = AuthErrorCode.ACCESS_DENIED expectedErrorCode = AuthErrorCode.ACCESS_DENIED
@ -479,7 +472,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createHqAdmin(permissionLevel = it) val admin = AdminFixture.createHqAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.DELETE, method = HttpMethod.DELETE,
endpoint = endpoint, endpoint = endpoint,
expectedErrorCode = AuthErrorCode.ACCESS_DENIED expectedErrorCode = AuthErrorCode.ACCESS_DENIED
@ -490,13 +483,13 @@ class AdminThemeApiTest(
} }
test("정상 삭제") { test("정상 삭제") {
val token = testAuthUtil.defaultHqAdminLogin() val token = testAuthUtil.defaultHqAdminLogin().second
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runTest( runTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
on = { on = {
delete("/admin/themes/${createdTheme.id}") delete("/admin/themes/${createdTheme.id}")
}, },
@ -510,7 +503,7 @@ class AdminThemeApiTest(
test("테마가 없으면 실패한다.") { test("테마가 없으면 실패한다.") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.DELETE, method = HttpMethod.DELETE,
endpoint = "/admin/themes/$INVALID_PK", endpoint = "/admin/themes/$INVALID_PK",
expectedErrorCode = ThemeErrorCode.THEME_NOT_FOUND expectedErrorCode = ThemeErrorCode.THEME_NOT_FOUND
@ -547,7 +540,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createStoreAdmin(permissionLevel = it) val admin = AdminFixture.createStoreAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = endpoint, endpoint = endpoint,
requestBody = request, requestBody = request,
@ -560,7 +553,7 @@ class AdminThemeApiTest(
val admin = AdminFixture.createHqAdmin(permissionLevel = it) val admin = AdminFixture.createHqAdmin(permissionLevel = it)
runExceptionTest( runExceptionTest(
token = testAuthUtil.adminLogin(admin), token = testAuthUtil.adminLogin(admin).second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = endpoint, endpoint = endpoint,
requestBody = request, requestBody = request,
@ -574,11 +567,22 @@ class AdminThemeApiTest(
val updateRequest = ThemeUpdateRequest(name = "modified") val updateRequest = ThemeUpdateRequest(name = "modified")
test("정상 수정 및 감사 정보 변경 확인") { test("정상 수정 및 감사 정보 변경 확인") {
val createdTheme = initialize("테스트를 위한 관리자1의 테마 생성") { val createdThemeId: Long = initialize("테스트를 위한 관리자1의 테마 생성") {
dummyInitializer.createTheme(testAuthUtil.defaultHqAdminLogin(), createRequest) runTest(
token = testAuthUtil.defaultHqAdminLogin().second,
using = {
body(createRequest)
},
on = {
post("/admin/themes")
},
expect = {
statusCode(HttpStatus.CREATED.value())
}
).extract().path("data.id")
} }
val otherAdminToken: String = initialize("감사 정보 변경 확인을 위한 관리자2 로그인") { val (otherAdmin, otherAdminToken) = initialize("감사 정보 변경 확인을 위한 관리자2 로그인") {
testAuthUtil.adminLogin( testAuthUtil.adminLogin(
AdminFixture.createHqAdmin(permissionLevel = AdminPermissionLevel.WRITABLE) AdminFixture.createHqAdmin(permissionLevel = AdminPermissionLevel.WRITABLE)
) )
@ -590,30 +594,26 @@ class AdminThemeApiTest(
body(updateRequest) body(updateRequest)
}, },
on = { on = {
patch("/admin/themes/${createdTheme.id}") patch("/admin/themes/${createdThemeId}")
}, },
expect = { expect = {
statusCode(HttpStatus.OK.value()) statusCode(HttpStatus.OK.value())
} }
).also { ).also {
val updatedTheme = themeRepository.findByIdOrNull(createdTheme.id)!! val updatedTheme = themeRepository.findByIdOrNull(createdThemeId)!!
updatedTheme.id shouldBe createdTheme.id
updatedTheme.name shouldBe updateRequest.name updatedTheme.name shouldBe updateRequest.name
updatedTheme.updatedBy shouldNotBe createdTheme.updatedBy updatedTheme.updatedBy shouldBe otherAdmin.id
updatedTheme.updatedAt shouldBeAfter createdTheme.updatedAt
} }
} }
test("입력값이 없으면 수정하지 않는다.") { test("입력값이 없으면 수정하지 않는다.") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runTest( runTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
using = { using = {
body(ThemeUpdateRequest()) body(ThemeUpdateRequest())
}, },
@ -633,7 +633,7 @@ class AdminThemeApiTest(
test("테마가 없으면 실패한다.") { test("테마가 없으면 실패한다.") {
runExceptionTest( runExceptionTest(
token = testAuthUtil.defaultHqAdminLogin(), token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/$INVALID_PK", endpoint = "/admin/themes/$INVALID_PK",
requestBody = updateRequest, requestBody = updateRequest,
@ -642,13 +642,12 @@ class AdminThemeApiTest(
} }
test("금액이 ${MIN_PRICE}원 미만이면 실패한다.") { test("금액이 ${MIN_PRICE}원 미만이면 실패한다.") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = updateRequest.copy(price = (MIN_PRICE - 1)), requestBody = updateRequest.copy(price = (MIN_PRICE - 1)),
@ -658,13 +657,12 @@ class AdminThemeApiTest(
context("입력된 시간이 ${MIN_DURATION}분 미만이면 실패한다.") { context("입력된 시간이 ${MIN_DURATION}분 미만이면 실패한다.") {
test("field: availableMinutes") { test("field: availableMinutes") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = updateRequest.copy(availableMinutes = (MIN_DURATION - 1).toShort()), requestBody = updateRequest.copy(availableMinutes = (MIN_DURATION - 1).toShort()),
@ -673,13 +671,12 @@ class AdminThemeApiTest(
} }
test("field: expectedMinutesFrom") { test("field: expectedMinutesFrom") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = updateRequest.copy(expectedMinutesFrom = (MIN_DURATION - 1).toShort()), requestBody = updateRequest.copy(expectedMinutesFrom = (MIN_DURATION - 1).toShort()),
@ -688,13 +685,12 @@ class AdminThemeApiTest(
} }
test("field: expectedMinutesTo") { test("field: expectedMinutesTo") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = updateRequest.copy(expectedMinutesTo = (MIN_DURATION - 1).toShort()), requestBody = updateRequest.copy(expectedMinutesTo = (MIN_DURATION - 1).toShort()),
@ -705,13 +701,12 @@ class AdminThemeApiTest(
context("시간 범위가 잘못 지정되면 실패한다.") { context("시간 범위가 잘못 지정되면 실패한다.") {
test("최소 예상 시간 > 최대 예상 시간") { test("최소 예상 시간 > 최대 예상 시간") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = updateRequest.copy(expectedMinutesFrom = 100, expectedMinutesTo = 99), requestBody = updateRequest.copy(expectedMinutesFrom = 100, expectedMinutesTo = 99),
@ -721,9 +716,8 @@ class AdminThemeApiTest(
test("최대 예상 시간 > 이용 가능 시간") { test("최대 예상 시간 > 이용 가능 시간") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
val requestBody = updateRequest.copy( val requestBody = updateRequest.copy(
@ -733,7 +727,7 @@ class AdminThemeApiTest(
) )
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = requestBody, requestBody = requestBody,
@ -745,13 +739,12 @@ class AdminThemeApiTest(
context("입력된 인원이 ${MIN_PARTICIPANTS}명 미만이면 실패한다.") { context("입력된 인원이 ${MIN_PARTICIPANTS}명 미만이면 실패한다.") {
test("field: minParticipants") { test("field: minParticipants") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = updateRequest.copy(minParticipants = (MIN_PARTICIPANTS - 1).toShort()), requestBody = updateRequest.copy(minParticipants = (MIN_PARTICIPANTS - 1).toShort()),
@ -760,13 +753,12 @@ class AdminThemeApiTest(
} }
test("field: maxParticipants") { test("field: maxParticipants") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = updateRequest.copy(maxParticipants = (MIN_PARTICIPANTS - 1).toShort()), requestBody = updateRequest.copy(maxParticipants = (MIN_PARTICIPANTS - 1).toShort()),
@ -777,13 +769,12 @@ class AdminThemeApiTest(
context("인원 범위가 잘못 지정되면 실패한다.") { context("인원 범위가 잘못 지정되면 실패한다.") {
test("최소 인원 > 최대 인원") { test("최소 인원 > 최대 인원") {
val token = testAuthUtil.defaultHqAdminLogin()
val createdTheme = initialize("테스트를 위한 테마 생성") { val createdTheme = initialize("테스트를 위한 테마 생성") {
dummyInitializer.createTheme(token, createRequest) dummyInitializer.createTheme()
} }
runExceptionTest( runExceptionTest(
token = token, token = testAuthUtil.defaultHqAdminLogin().second,
method = HttpMethod.PATCH, method = HttpMethod.PATCH,
endpoint = "/admin/themes/${createdTheme.id}", endpoint = "/admin/themes/${createdTheme.id}",
requestBody = updateRequest.copy(minParticipants = 10, maxParticipants = 9), requestBody = updateRequest.copy(minParticipants = 10, maxParticipants = 9),

View File

@ -4,7 +4,6 @@ import org.hamcrest.CoreMatchers.equalTo
import org.springframework.http.HttpMethod import org.springframework.http.HttpMethod
import org.springframework.http.HttpStatus import org.springframework.http.HttpStatus
import roomescape.supports.* import roomescape.supports.*
import roomescape.supports.ThemeFixture.createRequest
import roomescape.theme.exception.ThemeErrorCode import roomescape.theme.exception.ThemeErrorCode
import roomescape.theme.infrastructure.persistence.ThemeEntity import roomescape.theme.infrastructure.persistence.ThemeEntity
import roomescape.theme.web.ThemeIdListRequest import roomescape.theme.web.ThemeIdListRequest
@ -14,10 +13,9 @@ class ThemeApiTest : FunSpecSpringbootTest() {
context("입력된 모든 ID에 대한 테마를 조회한다.") { context("입력된 모든 ID에 대한 테마를 조회한다.") {
test("정상 응답 + 없는 테마가 있으면 생략한다.") { test("정상 응답 + 없는 테마가 있으면 생략한다.") {
val themeIds: List<Long> = initialize("목록 조회를 위한 3개의 테마 생성 및 일부 존재하지 않는 ID 추가") { val themeIds: List<Long> = initialize("목록 조회를 위한 3개의 테마 생성 및 일부 존재하지 않는 ID 추가") {
val token = testAuthUtil.defaultHqAdminLogin()
val themeIds = mutableListOf(INVALID_PK) val themeIds = mutableListOf(INVALID_PK)
(1..3).forEach { (1..3).forEach { _ ->
themeIds.add(dummyInitializer.createTheme(token, createRequest.copy(name = "test$it")).id) themeIds.add(dummyInitializer.createTheme().id)
} }
themeIds themeIds
@ -41,10 +39,7 @@ class ThemeApiTest : FunSpecSpringbootTest() {
context("ID로 테마 정보를 조회한다.") { context("ID로 테마 정보를 조회한다.") {
test("정상 응답") { test("정상 응답") {
val createdTheme: ThemeEntity = initialize("조회를 위한 테마 생성") { val createdTheme: ThemeEntity = initialize("조회를 위한 테마 생성") {
dummyInitializer.createTheme( dummyInitializer.createTheme()
adminToken = testAuthUtil.defaultHqAdminLogin(),
request = createRequest
)
} }
runTest( runTest(