Skip to content

Commit

Permalink
feat: 가게 상태 변경 기능 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
1o18z committed Sep 23, 2023
1 parent 56cf391 commit d389bd7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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<Unit> {
updateShopStatusUseCase.update(shopId)

return ResponseEntity.noContent().build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -69,4 +72,7 @@ abstract class WebIntegrationTestSupport : AnnotationSpec() {

@MockkBean
protected lateinit var getProductQuery: GetProductQuery

@MockkBean
protected lateinit var updateShopStatusUseCase: UpdateShopStatusUseCase
}
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit d389bd7

Please sign in to comment.