Skip to content

Commit

Permalink
Merge pull request #91 from le2sky/develop
Browse files Browse the repository at this point in the history
[๋ฐฐํฌ] v0.6.0(PR#86,PR#87,PR#90)
  • Loading branch information
le2sky committed Oct 13, 2023
2 parents fe3e6e2 + 99f7c95 commit fe809ff
Show file tree
Hide file tree
Showing 73 changed files with 964 additions and 223 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/mealkitary-main-develop-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ jobs:
./mealkitary-infrastructure/adapter-firebase-notification/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-business-registration-number-validator/simple-brn-validator/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-business-registration-number-validator/open-api-brn-validator/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-address-resolver/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/build/test-results/**/*.xml
- name: Jacoco Coverage ๋ฆฌํฌํŠธ ์ „์†ก
uses: codecov/codecov-action@v3
Expand All @@ -71,7 +72,8 @@ jobs:
./mealkitary-infrastructure/adapter-firebase-notification/build/reports/jacoco/test/jacocoTestReport.xml,
./mealkitary-infrastructure/adapter-business-registration-number-validator/simple-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml,
./mealkitary-infrastructure/adapter-business-registration-number-validator/open-api-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml,
./mealkitary-infrastructure/adapter-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml
./mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml,
./mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml
name: mealkitary-codecov
verbose: true

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/mealkitary-test-coverage-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ jobs:
./mealkitary-infrastructure/adapter-firebase-notification/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-business-registration-number-validator/simple-brn-validator/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-business-registration-number-validator/open-api-brn-validator/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-address-resolver/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/build/test-results/**/*.xml
./mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/build/test-results/**/*.xml
- name: Jacoco Coverage ๋ฆฌํฌํŠธ ์ „์†ก
uses: codecov/codecov-action@v3
Expand All @@ -59,6 +60,7 @@ jobs:
./mealkitary-infrastructure/adapter-firebase-notification/build/reports/jacoco/test/jacocoTestReport.xml,
./mealkitary-infrastructure/adapter-business-registration-number-validator/simple-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml,
./mealkitary-infrastructure/adapter-business-registration-number-validator/open-api-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml,
./mealkitary-infrastructure/adapter-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml
./mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml,
./mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml
name: mealkitary-codecov
verbose: true
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.5.1
applicationVersion=0.6.0
projectGroup=com.mealkitary
# test
kotestVersion=4.4.3
Expand Down
11 changes: 10 additions & 1 deletion mealkitary-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ dependencies {
implementation(project(":mealkitary-infrastructure:adapter-paymentgateway-tosspayments"))
implementation(project(":mealkitary-infrastructure:adapter-firebase-notification"))
implementation(project(":mealkitary-infrastructure:adapter-configuration"))
implementation(project(":mealkitary-infrastructure:adapter-address-resolver"))
implementation(
project(
":mealkitary-infrastructure:adapter-address-resolver:kakao-api-address-resolver",
)
)
implementation(
project(
":mealkitary-infrastructure:adapter-address-resolver:simple-address-resolver",
)
)
implementation(
project(
":mealkitary-infrastructure:adapter-business-registration-number-validator:open-api-brn-validator",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.reservation.application.port.input.GetReservationQuery
import com.mealkitary.reservation.application.port.input.ReservationResponse
import org.springframework.http.ResponseEntity
import org.springframework.util.StringUtils
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -22,10 +23,18 @@ class GetReservationController(
getReservationQuery.loadOneReservationById(UUIDUtils.fromString(reservationId))

@GetMapping
fun getAllReservation(@RequestParam("shopId") shopIdParam: Long?): ResponseEntity<List<ReservationResponse>> {
val shopId = requireNotNull(shopIdParam) { "๊ฐ€๊ฒŒ ์‹๋ณ„์ž๋Š” ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค." }
fun getAllReservation(@RequestParam("shopId") shopId: String?): ResponseEntity<List<ReservationResponse>> {
if (!StringUtils.hasText(shopId)) {
throw IllegalArgumentException("๊ฐ€๊ฒŒ ์‹๋ณ„์ž๋Š” ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.")
}

return HttpResponseUtils
.mapToResponseEntity(emptiableList = getReservationQuery.loadAllReservationByShopId(shopId))
.mapToResponseEntity(
emptiableList = getReservationQuery.loadAllReservationByShopId(
UUIDUtils.fromString(
shopId!!
)
)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mealkitary.reservation.web.request

import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.common.validation.DateValid
import com.mealkitary.reservation.application.port.input.ReserveProductRequest
import java.time.LocalDateTime
Expand All @@ -8,7 +9,7 @@ import javax.validation.constraints.NotNull

data class ReserveProductWebRequest(
@field:NotNull(message = "์˜ˆ์•ฝ ๋Œ€์ƒ ๊ฐ€๊ฒŒ ์‹๋ณ„์ž๋Š” ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.")
val shopId: Long? = null,
val shopId: String? = null,

@field:Valid
@field:NotNull(message = "์˜ˆ์•ฝ ์ƒํ’ˆ ๋ชฉ๋ก์€ ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.")
Expand All @@ -21,7 +22,7 @@ data class ReserveProductWebRequest(

fun mapToServiceRequest(): ReserveProductRequest {
return ReserveProductRequest(
shopId!!,
UUIDUtils.fromString(shopId!!),
products!!.map { it.mapToServiceObject() },
LocalDateTime.parse(reservedAt!!)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mealkitary.shop.web

import com.mealkitary.common.utils.HttpResponseUtils
import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.shop.application.port.input.GetProductQuery
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
Expand All @@ -14,8 +15,8 @@ class GetProductController(
) {

@GetMapping("/{shopId}/products")
fun getAllProductOfShop(@PathVariable("shopId") shopId: Long) =
fun getAllProductOfShop(@PathVariable("shopId") shopId: String) =
HttpResponseUtils.mapToResponseEntity(
emptiableList = getProductQuery.loadAllProductByShopId(shopId)
emptiableList = getProductQuery.loadAllProductByShopId(UUIDUtils.fromString(shopId))
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mealkitary.shop.web

import com.mealkitary.common.utils.HttpResponseUtils
import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.shop.application.port.input.GetReservableTimeQuery
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
Expand All @@ -14,8 +15,8 @@ class GetReservableTimeController(
) {

@GetMapping("/{shopId}/reservable-time")
fun getAllReservableTimeOfShop(@PathVariable("shopId") shopId: Long) =
fun getAllReservableTimeOfShop(@PathVariable("shopId") shopId: String) =
HttpResponseUtils.mapToResponseEntity(
emptiableList = getReservableTimeQuery.loadAllReservableTimeByShopId(shopId)
emptiableList = getReservableTimeQuery.loadAllReservableTimeByShopId(UUIDUtils.fromString(shopId))
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mealkitary.shop.web

import com.mealkitary.common.utils.UUIDUtils
import com.mealkitary.shop.application.port.input.UpdateShopStatusUseCase
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PathVariable
Expand All @@ -14,8 +15,8 @@ class UpdateShopStatusController(
) {

@PostMapping("/{shopId}/status")
fun updateShopStatus(@PathVariable("shopId") shopId: Long): ResponseEntity<Unit> {
updateShopStatusUseCase.update(shopId)
fun updateShopStatus(@PathVariable("shopId") shopId: String): ResponseEntity<Unit> {
updateShopStatusUseCase.update(UUIDUtils.fromString(shopId))

return ResponseEntity.noContent().build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ class GetReservationControllerDocsTest : RestDocsSupport() {
@Test
fun `api docs test - getAllReservation`() {
val reservationId = UUID.randomUUID()
val shopId = UUID.randomUUID()
val reserveAt = LocalDateTime.of(
LocalDate.of(2023, 6, 23), LocalTime.of(6, 30)
)
every { getReservationQuery.loadAllReservationByShopId(1L) } answers {
every { getReservationQuery.loadAllReservationByShopId(shopId) } answers {
listOf(
ReservationResponse(
reservationId,
Expand All @@ -119,7 +120,7 @@ class GetReservationControllerDocsTest : RestDocsSupport() {
)
}

mvc.perform(RestDocumentationRequestBuilders.get("/reservations?shopId=1"))
mvc.perform(RestDocumentationRequestBuilders.get("/reservations?shopId=$shopId"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andDo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class ReserveProductControllerDocsTest : RestDocsSupport() {
@Test
fun `api docs test - reserveProduct`() {
val id = UUID.randomUUID()
val shopId = UUID.randomUUID()
every { reserveProductUseCase.reserve(any()) }.answers { id }
val reserveProductWebRequest = ReserveProductWebRequest(
1L,
shopId.toString(),
listOf(
ReservedWebProduct(
2L,
Expand Down Expand Up @@ -62,7 +63,7 @@ class ReserveProductControllerDocsTest : RestDocsSupport() {
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("shopId").type(JsonFieldType.NUMBER).description("์˜ˆ์•ฝ ๋Œ€์ƒ ๊ฐ€๊ฒŒ ์‹๋ณ„์ž"),
fieldWithPath("shopId").type(JsonFieldType.STRING).description("์˜ˆ์•ฝ ๋Œ€์ƒ ๊ฐ€๊ฒŒ ์‹๋ณ„์ž"),
fieldWithPath("products.[].productId").type(JsonFieldType.NUMBER).description("์˜ˆ์•ฝ ๋Œ€์ƒ ์ƒํ’ˆ ์‹๋ณ„์ž"),
fieldWithPath("products.[].name").type(JsonFieldType.STRING).description("์˜ˆ์•ฝ ๋Œ€์ƒ ์ƒํ’ˆ๋ช…"),
fieldWithPath("products.[].price").type(JsonFieldType.NUMBER).description("์˜ˆ์•ฝ ๋Œ€์ƒ ์ƒํ’ˆ ๊ฐ€๊ฒฉ"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ import org.springframework.restdocs.request.RequestDocumentation.parameterWithNa
import org.springframework.restdocs.request.RequestDocumentation.pathParameters
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.util.UUID

class GetProductControllerDocsTest : RestDocsSupport() {

private val getProductQuery = mockk<GetProductQuery>()

@Test
fun `api docs test - getAllProductOfShopTest`() {
every { getProductQuery.loadAllProductByShopId(1L) }.answers {
val shopId = UUID.randomUUID()
every { getProductQuery.loadAllProductByShopId(shopId) }.answers {
listOf(ProductResponse(1L, "๋ถ€๋Œ€์ฐŒ๊ฐœ", 15000))
}

mvc.perform(RestDocumentationRequestBuilders.get("/shops/{shopId}/products", 1))
mvc.perform(RestDocumentationRequestBuilders.get("/shops/{shopId}/products", shopId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andDo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ import org.springframework.restdocs.request.RequestDocumentation.pathParameters
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.time.LocalTime
import java.util.UUID

class GetReservableTimeControllerDocsTest : RestDocsSupport() {

private val getReservableTimeQuery = mockk<GetReservableTimeQuery>()

@Test
fun `api docs test - getAllReservableTimeOfShopTest`() {
every { getReservableTimeQuery.loadAllReservableTimeByShopId(1L) }.answers {
val shopId = UUID.randomUUID()
every { getReservableTimeQuery.loadAllReservableTimeByShopId(shopId) }.answers {
listOf(LocalTime.of(6, 30))
}

mvc.perform(RestDocumentationRequestBuilders.get("/shops/{shopId}/reservable-time", 1))
mvc.perform(RestDocumentationRequestBuilders.get("/shops/{shopId}/reservable-time", shopId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andDo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ import org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath
import org.springframework.restdocs.payload.PayloadDocumentation.responseFields
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.util.UUID

class GetShopControllerDocsTest : RestDocsSupport() {

private val getShopQuery = mockk<GetShopQuery>()

@Test
fun `api docs test - getAllShopTest`() {
val shopId = UUID.randomUUID()
every { getShopQuery.loadAllShop() }.answers {
listOf(ShopResponse(1L, "์ง‘๋ฐฅ๋š๋”ฑ"))
listOf(ShopResponse(shopId, "์ง‘๋ฐฅ๋š๋”ฑ"))
}

mvc.perform(RestDocumentationRequestBuilders.get("/shops/"))
Expand All @@ -38,7 +40,7 @@ class GetShopControllerDocsTest : RestDocsSupport() {
preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("[]").type(JsonFieldType.ARRAY).description("๊ฐ€๊ฒŒ ๋ชฉ๋ก ๋ฐฐ์—ด"),
fieldWithPath("[].id").type(JsonFieldType.NUMBER).description("๊ฐ€๊ฒŒ ์‹๋ณ„์ž"),
fieldWithPath("[].id").type(JsonFieldType.STRING).description("๊ฐ€๊ฒŒ ์‹๋ณ„์ž"),
fieldWithPath("[].title").type(JsonFieldType.STRING).description("๊ฐ€๊ฒŒ๋ช…")
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ import org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath
import org.springframework.restdocs.payload.PayloadDocumentation.requestFields
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.header
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.util.UUID

class RegisterShopControllerDocsTest : RestDocsSupport() {

private val registerShopUseCase = mockk<RegisterShopUseCase>()

@Test
fun `api docs test - registerShop`() {
every { registerShopUseCase.register(any()) } answers { 1L }
val shopId = UUID.randomUUID()
every { registerShopUseCase.register(any()) } answers { shopId }

val registerShopWebRequest = RegisterShopWebRequest("์ง‘๋ฐฅ๋š๋”ฑ ์•ˆ์–‘์ ", "123-23-12345", "๊ฒฝ๊ธฐ๋„ ์•ˆ์–‘์‹œ ๋™์•ˆ๊ตฌ ๋ฒŒ๋ง๋กœ")

Expand All @@ -36,7 +38,7 @@ class RegisterShopControllerDocsTest : RestDocsSupport() {
.content(objectMapper.writeValueAsString(registerShopWebRequest))
)
.andExpect(status().isCreated)
.andExpect(header().string("Location", "http://localhost/shops/1"))
.andExpect(header().string("Location", "http://localhost/shops/$shopId"))
.andDo(
MockMvcRestDocumentation.document(
"shop-post",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPri
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 UpdateShopStatusControllerDocsTest : RestDocsSupport() {

private val updateShopStatsUseCase = mockk<UpdateShopStatusUseCase>()

@Test
fun `api docs test - updateShopStatus`() {
val shopId = 1L
val shopId = UUID.randomUUID()
every { updateShopStatsUseCase.update(shopId) }.answers { }

mvc.perform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ class GetReservationControllerTest : WebIntegrationTestSupport() {
@Test
fun `api integration test - getAllReservation`() {
val reservationId = UUID.randomUUID()
val shopId = UUID.randomUUID()
val reserveAt = LocalDateTime.of(
LocalDate.of(2023, 6, 23), LocalTime.of(6, 30)
)
every { getReservationQuery.loadAllReservationByShopId(1L) } answers {
every { getReservationQuery.loadAllReservationByShopId(any()) } answers {
listOf(
ReservationResponse(
reservationId,
Expand All @@ -98,7 +99,7 @@ class GetReservationControllerTest : WebIntegrationTestSupport() {
)
}

mvc.perform(get("/reservations?shopId=1"))
mvc.perform(get("/reservations?shopId=$shopId"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.[0].reservationId").value(reservationId.toString()))
Expand Down Expand Up @@ -133,7 +134,7 @@ class GetReservationControllerTest : WebIntegrationTestSupport() {
fun `api integration test - getAllReservation - ํ•ด๋‹น ๊ฐ€๊ฒŒ์˜ ์˜ˆ์•ฝ์ด ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด 204 NoContent๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค`() {
every { getReservationQuery.loadAllReservationByShopId(any()) } answers { emptyList() }

mvc.perform(get("/reservations?shopId=1"))
mvc.perform(get("/reservations?shopId=${UUID.randomUUID()}"))
.andExpect(status().isNoContent())
}

Expand All @@ -147,6 +148,16 @@ class GetReservationControllerTest : WebIntegrationTestSupport() {
.andExpect(jsonPath("$.message").value("์ž˜๋ชป๋œ UUID ํ˜•์‹์ž…๋‹ˆ๋‹ค."))
}

@Test
fun `api integration test - ๊ฐ€๊ฒŒ ์‹๋ณ„์ž๊ฐ€ UUID ํ˜•ํƒœ๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด 400 ์—๋Ÿฌ๋ฅผ ๋ฐœ์ƒํ•œ๋‹ค`() {
mvc.perform(
get("/reservations?shopId=invalid-uuid-test")
)
.andExpect(status().isBadRequest)
.andExpect(jsonPath("$.status").value("400"))
.andExpect(jsonPath("$.message").value("์ž˜๋ชป๋œ UUID ํ˜•์‹์ž…๋‹ˆ๋‹ค."))
}

@Test
fun `api integration test - getOneReservation - ๋‚ด๋ถ€์—์„œ EntityNotFound ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด 404 ์—๋Ÿฌ๋ฅผ ๋ฐœ์ƒํ•œ๋‹ค`() {
every { getReservationQuery.loadOneReservationById(any()) }
Expand Down
Loading

0 comments on commit fe809ff

Please sign in to comment.