Skip to content

Commit

Permalink
Merge pull request #68 from le2sky/develop
Browse files Browse the repository at this point in the history
[배포] v0.4.0(PR#63, PR#65, PR#67)
  • Loading branch information
le2sky authored Sep 8, 2023
2 parents 4bb8d89 + 3218bcd commit 218c07c
Show file tree
Hide file tree
Showing 76 changed files with 1,045 additions and 234 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ktlintVersion=11.0.0
springBootVersion=2.7.11
springDependencyManagementVersion=1.0.15.RELEASE
# project
applicationVersion=0.3.1
applicationVersion=0.4.0
projectGroup=com.mealkitary
# test
kotestVersion=4.4.3
Expand Down
15 changes: 15 additions & 0 deletions mealkitary-api/src/docs/asciidoc/reservation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,18 @@ include::{snippets}/reservation-post-accept/path-parameters.adoc[]
===== 응답

include::{snippets}/reservation-post-accept/http-response.adoc[]

==== 예약 거절

결제된 예약에 대해서 예약 거절 처리합니다.
결제된 예약이 아닌 경우, 거절 처리할 수 없습니다.

===== 요청

include::{snippets}/reservation-post-reject/curl-request.adoc[]
include::{snippets}/reservation-post-reject/http-request.adoc[]
include::{snippets}/reservation-post-reject/path-parameters.adoc[]

===== 응답

include::{snippets}/reservation-post-reject/http-response.adoc[]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.reservation.adapter.input.web
package com.mealkitary.reservation.web

import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.reservation.application.port.input.AcceptReservationUseCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.reservation.adapter.input.web
package com.mealkitary.reservation.web

import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.reservation.application.port.input.GetReservationQuery
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.mealkitary.reservation.adapter.input.web
package com.mealkitary.reservation.web

import com.mealkitary.common.utils.HttpResponseUtils
import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.reservation.adapter.input.web.request.PayReservationWebRequest
import com.mealkitary.reservation.application.port.input.PayReservationUseCase
import com.mealkitary.reservation.web.request.PayReservationWebRequest
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mealkitary.reservation.web

import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.reservation.application.port.input.RejectReservationUseCase
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/reservations")
class RejectReservationController(
private val rejectReservationUseCase: RejectReservationUseCase
) {

@PostMapping("/{reservationId}/reject")
fun rejectReservation(@PathVariable("reservationId") reservationId: String): ResponseEntity<Unit> {
rejectReservationUseCase.reject(UUIDUtils.fromString(reservationId))

return ResponseEntity.noContent().build()
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mealkitary.reservation.adapter.input.web
package com.mealkitary.reservation.web

import com.mealkitary.common.utils.HttpResponseUtils
import com.mealkitary.reservation.adapter.input.web.request.ReserveProductWebRequest
import com.mealkitary.reservation.application.port.input.ReserveProductUseCase
import com.mealkitary.reservation.web.request.ReserveProductWebRequest
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.reservation.adapter.input.web.request
package com.mealkitary.reservation.web.request

import com.mealkitary.reservation.application.port.input.PayReservationRequest
import java.util.UUID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.reservation.adapter.input.web.request
package com.mealkitary.reservation.web.request

import com.mealkitary.common.validation.DateValid
import com.mealkitary.reservation.application.port.input.ReserveProductRequest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.reservation.adapter.input.web.request
package com.mealkitary.reservation.web.request

import com.mealkitary.reservation.application.port.input.ReservedProduct
import javax.validation.constraints.NotBlank
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.shop.adapter.input.web
package com.mealkitary.shop.web

import com.mealkitary.common.utils.HttpResponseUtils
import com.mealkitary.shop.application.port.input.GetProductQuery
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.shop.adapter.input.web
package com.mealkitary.shop.web

import com.mealkitary.common.utils.HttpResponseUtils
import com.mealkitary.shop.application.port.input.GetReservableTimeQuery
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.shop.adapter.input.web
package com.mealkitary.shop.web

import com.mealkitary.common.utils.HttpResponseUtils
import com.mealkitary.shop.application.port.input.GetShopQuery
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.docs.reservation

import com.docs.RestDocsSupport
import com.mealkitary.reservation.adapter.input.web.AcceptReservationController
import com.mealkitary.reservation.application.port.input.AcceptReservationUseCase
import com.mealkitary.reservation.web.AcceptReservationController
import io.mockk.every
import io.mockk.mockk
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.docs.reservation

import com.docs.RestDocsSupport
import com.mealkitary.reservation.adapter.input.web.GetReservationController
import com.mealkitary.reservation.application.port.input.GetReservationQuery
import com.mealkitary.reservation.application.port.input.ReservationResponse
import com.mealkitary.reservation.application.port.input.ReservedProduct
import com.mealkitary.reservation.web.GetReservationController
import io.mockk.every
import io.mockk.mockk
import org.springframework.http.MediaType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.docs.reservation

import com.docs.RestDocsSupport
import com.mealkitary.reservation.adapter.input.web.PayReservationController
import com.mealkitary.reservation.adapter.input.web.request.PayReservationWebRequest
import com.mealkitary.reservation.application.port.input.PayReservationUseCase
import com.mealkitary.reservation.web.PayReservationController
import com.mealkitary.reservation.web.request.PayReservationWebRequest
import io.mockk.every
import io.mockk.mockk
import org.springframework.http.MediaType
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.docs.reservation

import com.docs.RestDocsSupport
import com.mealkitary.reservation.application.port.input.RejectReservationUseCase
import com.mealkitary.reservation.web.RejectReservationController
import io.mockk.every
import io.mockk.mockk
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders
import org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest
import org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse
import org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint
import org.springframework.restdocs.request.RequestDocumentation.parameterWithName
import org.springframework.restdocs.request.RequestDocumentation.pathParameters
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.util.UUID

class RejectReservationControllerDocsTest : RestDocsSupport() {

private val rejectReservationUseCase = mockk<RejectReservationUseCase>()

@Test
fun `api docs test - rejectReservation`() {
val id = UUID.randomUUID()
every { rejectReservationUseCase.reject(any()) }.answers { }

mvc.perform(
RestDocumentationRequestBuilders.post("/reservations/{reservationId}/reject", id)
)
.andExpect(status().isNoContent)
.andDo(
document(
"reservation-post-reject",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("reservationId").description("거절 대상 예약의 식별자")
),
)
)
}

override fun initController() = RejectReservationController(rejectReservationUseCase)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.docs.reservation

import com.docs.RestDocsSupport
import com.mealkitary.reservation.adapter.input.web.ReserveProductController
import com.mealkitary.reservation.adapter.input.web.request.ReserveProductWebRequest
import com.mealkitary.reservation.adapter.input.web.request.ReservedWebProduct
import com.mealkitary.reservation.application.port.input.ReserveProductUseCase
import com.mealkitary.reservation.web.ReserveProductController
import com.mealkitary.reservation.web.request.ReserveProductWebRequest
import com.mealkitary.reservation.web.request.ReservedWebProduct
import io.mockk.every
import io.mockk.mockk
import org.springframework.http.MediaType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.docs.shop

import com.docs.RestDocsSupport
import com.mealkitary.shop.adapter.input.web.GetProductController
import com.mealkitary.shop.application.port.input.GetProductQuery
import com.mealkitary.shop.application.port.input.ProductResponse
import com.mealkitary.shop.web.GetProductController
import io.mockk.every
import io.mockk.mockk
import org.springframework.http.MediaType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.docs.shop

import com.docs.RestDocsSupport
import com.mealkitary.shop.adapter.input.web.GetReservableTimeController
import com.mealkitary.shop.application.port.input.GetReservableTimeQuery
import com.mealkitary.shop.web.GetReservableTimeController
import io.mockk.every
import io.mockk.mockk
import org.springframework.http.MediaType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.docs.shop

import com.docs.RestDocsSupport
import com.mealkitary.shop.adapter.input.web.GetShopController
import com.mealkitary.shop.application.port.input.GetShopQuery
import com.mealkitary.shop.application.port.input.ShopResponse
import com.mealkitary.shop.web.GetShopController
import io.mockk.every
import io.mockk.mockk
import org.springframework.http.MediaType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package com.mealkitary

import com.fasterxml.jackson.databind.ObjectMapper
import com.mealkitary.reservation.adapter.input.web.AcceptReservationController
import com.mealkitary.reservation.adapter.input.web.GetReservationController
import com.mealkitary.reservation.adapter.input.web.PayReservationController
import com.mealkitary.reservation.adapter.input.web.ReserveProductController
import com.mealkitary.reservation.application.port.input.AcceptReservationUseCase
import com.mealkitary.reservation.application.port.input.GetReservationQuery
import com.mealkitary.reservation.application.port.input.PayReservationUseCase
import com.mealkitary.reservation.application.port.input.RejectReservationUseCase
import com.mealkitary.reservation.application.port.input.ReserveProductUseCase
import com.mealkitary.shop.adapter.input.web.GetProductController
import com.mealkitary.shop.adapter.input.web.GetReservableTimeController
import com.mealkitary.shop.adapter.input.web.GetShopController
import com.mealkitary.reservation.web.AcceptReservationController
import com.mealkitary.reservation.web.GetReservationController
import com.mealkitary.reservation.web.PayReservationController
import com.mealkitary.reservation.web.RejectReservationController
import com.mealkitary.reservation.web.ReserveProductController
import com.mealkitary.shop.application.port.input.GetProductQuery
import com.mealkitary.shop.application.port.input.GetReservableTimeQuery
import com.mealkitary.shop.application.port.input.GetShopQuery
import com.mealkitary.shop.web.GetProductController
import com.mealkitary.shop.web.GetReservableTimeController
import com.mealkitary.shop.web.GetShopController
import com.ninjasquad.springmockk.MockkBean
import io.kotest.core.spec.style.AnnotationSpec
import io.kotest.extensions.spring.SpringExtension
Expand All @@ -27,6 +29,7 @@ import org.springframework.test.web.servlet.MockMvc
ReserveProductController::class,
PayReservationController::class,
AcceptReservationController::class,
RejectReservationController::class,
GetReservationController::class,
GetShopController::class,
GetReservableTimeController::class,
Expand All @@ -52,6 +55,9 @@ abstract class WebIntegrationTestSupport : AnnotationSpec() {
@MockkBean
protected lateinit var acceptReservationUseCase: AcceptReservationUseCase

@MockkBean
protected lateinit var rejectReservationUseCase: RejectReservationUseCase

@MockkBean
protected lateinit var getReservationQuery: GetReservationQuery

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.reservation.adapter.input.web
package com.mealkitary.reservation.web

import com.mealkitary.WebIntegrationTestSupport
import com.mealkitary.common.exception.EntityNotFoundException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.reservation.adapter.input.web
package com.mealkitary.reservation.web

import com.mealkitary.WebIntegrationTestSupport
import com.mealkitary.common.exception.EntityNotFoundException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mealkitary.reservation.adapter.input.web
package com.mealkitary.reservation.web

import com.mealkitary.WebIntegrationTestSupport
import com.mealkitary.common.exception.EntityNotFoundException
import com.mealkitary.reservation.adapter.input.web.request.PayReservationWebRequest
import com.mealkitary.reservation.web.request.PayReservationWebRequest
import io.mockk.every
import org.springframework.http.MediaType
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.mealkitary.reservation.web

import com.mealkitary.WebIntegrationTestSupport
import com.mealkitary.common.exception.EntityNotFoundException
import io.mockk.every
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
import java.util.UUID

class RejectReservationControllerTest : WebIntegrationTestSupport() {

@Test
fun `api integration test - rejectReservation`() {
val id = UUID.randomUUID()
every { rejectReservationUseCase.reject(any()) } answers {}

mvc.perform(
MockMvcRequestBuilders.post("/reservations/{reservationId}/reject", id.toString())
)
.andExpect(MockMvcResultMatchers.status().isNoContent)
}

@Test
fun `api integration test - 예약 식별자가 UUID 형태가 아니라면 400 에러를 발생한다`() {
mvc.perform(
MockMvcRequestBuilders.post("/reservations/{reservationId}/reject", "invalid-uuid-test")
)
.andExpect(MockMvcResultMatchers.status().isBadRequest)
.andExpect(MockMvcResultMatchers.jsonPath("$.status").value("400"))
.andExpect(MockMvcResultMatchers.jsonPath("$.message").value("잘못된 UUID 형식입니다."))
}

@Test
fun `api integration test - 내부에서 EntityNotFound 에러가 발생하면 404 에러를 발생한다`() {
val id = UUID.randomUUID()
every { rejectReservationUseCase.reject(any()) }.throws(EntityNotFoundException("존재하지 않는 예약입니다."))

mvc.perform(
MockMvcRequestBuilders.post("/reservations/{reservationId}/reject", id.toString())
)
.andExpect(MockMvcResultMatchers.status().isNotFound)
.andExpect(MockMvcResultMatchers.jsonPath("$.status").value("404"))
.andExpect(MockMvcResultMatchers.jsonPath("$.message").value("존재하지 않는 예약입니다."))
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.mealkitary.reservation.adapter.input.web
package com.mealkitary.reservation.web

import com.mealkitary.WebIntegrationTestSupport
import com.mealkitary.common.exception.EntityNotFoundException
import com.mealkitary.reservation.adapter.input.web.request.ReserveProductWebRequest
import com.mealkitary.reservation.adapter.input.web.request.ReservedWebProduct
import com.mealkitary.reservation.web.request.ReserveProductWebRequest
import com.mealkitary.reservation.web.request.ReservedWebProduct
import io.mockk.every
import org.springframework.http.MediaType
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.shop.adapter.input.web
package com.mealkitary.shop.web

import com.mealkitary.WebIntegrationTestSupport
import com.mealkitary.common.exception.EntityNotFoundException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.shop.adapter.input.web
package com.mealkitary.shop.web

import com.mealkitary.WebIntegrationTestSupport
import com.mealkitary.common.exception.EntityNotFoundException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mealkitary.shop.adapter.input.web
package com.mealkitary.shop.web

import com.mealkitary.WebIntegrationTestSupport
import com.mealkitary.shop.application.port.input.ShopResponse
Expand Down
Loading

0 comments on commit 218c07c

Please sign in to comment.