diff --git a/mealkitary-api/src/main/kotlin/com/mealkitary/shop/web/UpdateShopStatusController.kt b/mealkitary-api/src/main/kotlin/com/mealkitary/shop/web/UpdateShopStatusController.kt new file mode 100644 index 0000000..aeb88a0 --- /dev/null +++ b/mealkitary-api/src/main/kotlin/com/mealkitary/shop/web/UpdateShopStatusController.kt @@ -0,0 +1,22 @@ +package com.mealkitary.shop.web + +import com.mealkitary.shop.application.port.input.UpdateShopStatusUseCase +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("/shops") +class UpdateShopStatusController( + private val updateShopStatusUseCase: UpdateShopStatusUseCase +) { + + @PostMapping("/{shopId}/status") + fun updateShopStatus(@PathVariable("shopId") shopId: Long): ResponseEntity { + updateShopStatusUseCase.update(shopId) + + return ResponseEntity.noContent().build() + } +} diff --git a/mealkitary-api/src/test/kotlin/com/mealkitary/WebIntegrationTestSupport.kt b/mealkitary-api/src/test/kotlin/com/mealkitary/WebIntegrationTestSupport.kt index 337dfb9..2aa5cde 100644 --- a/mealkitary-api/src/test/kotlin/com/mealkitary/WebIntegrationTestSupport.kt +++ b/mealkitary-api/src/test/kotlin/com/mealkitary/WebIntegrationTestSupport.kt @@ -14,9 +14,11 @@ 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.application.port.input.UpdateShopStatusUseCase import com.mealkitary.shop.web.GetProductController import com.mealkitary.shop.web.GetReservableTimeController import com.mealkitary.shop.web.GetShopController +import com.mealkitary.shop.web.UpdateShopStatusController import com.ninjasquad.springmockk.MockkBean import io.kotest.core.spec.style.AnnotationSpec import io.kotest.extensions.spring.SpringExtension @@ -33,7 +35,8 @@ import org.springframework.test.web.servlet.MockMvc GetReservationController::class, GetShopController::class, GetReservableTimeController::class, - GetProductController::class + GetProductController::class, + UpdateShopStatusController::class ] ) abstract class WebIntegrationTestSupport : AnnotationSpec() { @@ -69,4 +72,7 @@ abstract class WebIntegrationTestSupport : AnnotationSpec() { @MockkBean protected lateinit var getProductQuery: GetProductQuery + + @MockkBean + protected lateinit var updateShopStatusUseCase: UpdateShopStatusUseCase } diff --git a/mealkitary-api/src/test/kotlin/com/mealkitary/shop/web/UpdateShopStatusControllerTest.kt b/mealkitary-api/src/test/kotlin/com/mealkitary/shop/web/UpdateShopStatusControllerTest.kt new file mode 100644 index 0000000..6f39494 --- /dev/null +++ b/mealkitary-api/src/test/kotlin/com/mealkitary/shop/web/UpdateShopStatusControllerTest.kt @@ -0,0 +1,20 @@ +package com.mealkitary.shop.web + +import com.mealkitary.WebIntegrationTestSupport +import io.mockk.every +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders +import org.springframework.test.web.servlet.result.MockMvcResultMatchers + +class UpdateShopStatusControllerTest : WebIntegrationTestSupport() { + + @Test + fun `api integration test - updateShopStatus`() { + val shopId = 1L + every { updateShopStatusUseCase.update(any()) } answers {} + + mvc.perform( + MockMvcRequestBuilders.post("/shops/{shopId}/status", shopId) + ) + .andExpect(MockMvcResultMatchers.status().isNoContent) + } +}