From 0a56e962c8263a64d7944f522435e2b86b12cb06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 11:53:35 +0900 Subject: [PATCH 01/13] =?UTF-8?q?refactor:=20=EA=B0=80=EA=B2=8C=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=8B=9C=EC=97=90=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=EB=8F=84=20=EC=9E=85=EB=A0=A5=EB=B0=9B=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/request/RegisterShopWebRequest.kt | 7 ++- .../shop/RegisterShopControllerDocsTest.kt | 3 +- .../shop/web/RegisterShopControllerTest.kt | 22 +++++++-- .../port/input/RegisterShopRequest.kt | 3 +- .../service/RegisterShopService.kt | 14 +++--- .../application/service/GetShopServiceTest.kt | 16 +++++++ .../service/RegisterShopServiceTest.kt | 48 +++++++++++++++++-- .../service/UpdateShopStatusServiceTest.kt | 42 ++++++++++++++++ 8 files changed, 136 insertions(+), 19 deletions(-) diff --git a/mealkitary-api/src/main/kotlin/com/mealkitary/shop/web/request/RegisterShopWebRequest.kt b/mealkitary-api/src/main/kotlin/com/mealkitary/shop/web/request/RegisterShopWebRequest.kt index 034c616..2cdc615 100644 --- a/mealkitary-api/src/main/kotlin/com/mealkitary/shop/web/request/RegisterShopWebRequest.kt +++ b/mealkitary-api/src/main/kotlin/com/mealkitary/shop/web/request/RegisterShopWebRequest.kt @@ -8,8 +8,11 @@ data class RegisterShopWebRequest( val title: String? = null, @field:NotBlank(message = "사업자 번호는 필수입니다.") - val brn: String? = null + val brn: String? = null, + + @field:NotBlank(message = "주소는 필수입니다.") + val address: String? = null ) { - fun mapToServiceRequest() = RegisterShopRequest(title!!, brn!!) + fun mapToServiceRequest() = RegisterShopRequest(title!!, brn!!, address!!) } diff --git a/mealkitary-api/src/test/kotlin/com/docs/shop/RegisterShopControllerDocsTest.kt b/mealkitary-api/src/test/kotlin/com/docs/shop/RegisterShopControllerDocsTest.kt index 7006d8f..c00ef51 100644 --- a/mealkitary-api/src/test/kotlin/com/docs/shop/RegisterShopControllerDocsTest.kt +++ b/mealkitary-api/src/test/kotlin/com/docs/shop/RegisterShopControllerDocsTest.kt @@ -28,7 +28,7 @@ class RegisterShopControllerDocsTest : RestDocsSupport() { fun `api docs test - registerShop`() { every { registerShopUseCase.register(any()) } answers { 1L } - val registerShopWebRequest = RegisterShopWebRequest("집밥뚝딱 안양점", "123-23-12345") + val registerShopWebRequest = RegisterShopWebRequest("집밥뚝딱 안양점", "123-23-12345", "경기도 안양시 동안구 벌말로") mvc.perform( RestDocumentationRequestBuilders.post("/shops") @@ -45,6 +45,7 @@ class RegisterShopControllerDocsTest : RestDocsSupport() { requestFields( fieldWithPath("title").type(JsonFieldType.STRING).description("등록 대상 가게 이름"), fieldWithPath("brn").type(JsonFieldType.STRING).description("사업자 번호"), + fieldWithPath("address").type(JsonFieldType.STRING).description("가게 도로명 주소"), ), responseHeaders(headerWithName("Location").description("생성된 가게 리소스 URI")), ) diff --git a/mealkitary-api/src/test/kotlin/com/mealkitary/shop/web/RegisterShopControllerTest.kt b/mealkitary-api/src/test/kotlin/com/mealkitary/shop/web/RegisterShopControllerTest.kt index f62186a..521da7c 100644 --- a/mealkitary-api/src/test/kotlin/com/mealkitary/shop/web/RegisterShopControllerTest.kt +++ b/mealkitary-api/src/test/kotlin/com/mealkitary/shop/web/RegisterShopControllerTest.kt @@ -15,7 +15,7 @@ class RegisterShopControllerTest : WebIntegrationTestSupport() { fun `api integration test - registerShop`() { every { registerShopUseCase.register(any()) } answers { 1L } - val registerShopWebRequest = RegisterShopWebRequest("집밥뚝딱 안양점", "123-23-12345") + val registerShopWebRequest = RegisterShopWebRequest("집밥뚝딱 안양점", "123-23-12345", "경기도 안양시 동안구 벌말로 40") mvc.perform( MockMvcRequestBuilders.post("/shops") @@ -28,7 +28,7 @@ class RegisterShopControllerTest : WebIntegrationTestSupport() { @Test fun `api integration test - 가게 이름이 누락된 경우 400 에러를 발생한다`() { - val registerShopWebRequest = RegisterShopWebRequest(brn = "123-23-12345") + val registerShopWebRequest = RegisterShopWebRequest(brn = "123-23-12345", address = "경기도 안양시 동안구 벌말로 40") mvc.perform( MockMvcRequestBuilders.post("/shops") @@ -44,7 +44,7 @@ class RegisterShopControllerTest : WebIntegrationTestSupport() { @Test fun `api integration test - 사업자 번호가 누락된 경우 400 에러를 발생한다`() { - val registerShopWebRequest = RegisterShopWebRequest(title = "집밥뚝딱 안양점") + val registerShopWebRequest = RegisterShopWebRequest(title = "집밥뚝딱 안양점", address = "경기도 안양시 동안구 벌말로 40") mvc.perform( MockMvcRequestBuilders.post("/shops") @@ -58,6 +58,22 @@ class RegisterShopControllerTest : WebIntegrationTestSupport() { .andExpect(jsonPath("$..errors[0].reason").value("사업자 번호는 필수입니다.")) } + @Test + fun `api integration test - 주소가 누락된 경우 400 에러를 발생한다`() { + val registerShopWebRequest = RegisterShopWebRequest(title = "집밥뚝딱 안양점", brn = "123-23-12345") + + mvc.perform( + MockMvcRequestBuilders.post("/shops") + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(registerShopWebRequest)) + ) + .andExpect(status().isBadRequest) + .andExpect(jsonPath("$.status").value("400")) + .andExpect(jsonPath("$.message").value("잘못된 입력값입니다.")) + .andExpect(jsonPath("$..errors[0].field").value("address")) + .andExpect(jsonPath("$..errors[0].reason").value("주소는 필수입니다.")) + } + @Test fun `api integration test - JSON 형식이 아닌 경우 400 에러가 발생한다`() { mvc.perform( diff --git a/mealkitary-application/src/main/kotlin/com/mealkitary/shop/application/port/input/RegisterShopRequest.kt b/mealkitary-application/src/main/kotlin/com/mealkitary/shop/application/port/input/RegisterShopRequest.kt index b11e2f1..9598f31 100644 --- a/mealkitary-application/src/main/kotlin/com/mealkitary/shop/application/port/input/RegisterShopRequest.kt +++ b/mealkitary-application/src/main/kotlin/com/mealkitary/shop/application/port/input/RegisterShopRequest.kt @@ -2,5 +2,6 @@ package com.mealkitary.shop.application.port.input data class RegisterShopRequest( val title: String, - val brn: String + val brn: String, + val address: String ) diff --git a/mealkitary-application/src/main/kotlin/com/mealkitary/shop/application/service/RegisterShopService.kt b/mealkitary-application/src/main/kotlin/com/mealkitary/shop/application/service/RegisterShopService.kt index 8da3cab..f36d12c 100644 --- a/mealkitary-application/src/main/kotlin/com/mealkitary/shop/application/service/RegisterShopService.kt +++ b/mealkitary-application/src/main/kotlin/com/mealkitary/shop/application/service/RegisterShopService.kt @@ -3,23 +3,23 @@ package com.mealkitary.shop.application.service import com.mealkitary.shop.application.port.input.RegisterShopRequest import com.mealkitary.shop.application.port.input.RegisterShopUseCase import com.mealkitary.shop.application.port.output.SaveShopPort -import com.mealkitary.shop.domain.shop.factory.ShopBusinessNumberValidator import com.mealkitary.shop.domain.shop.factory.ShopFactory import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @Service -@Transactional(readOnly = true) +@Transactional class RegisterShopService( private val saveShopPort: SaveShopPort, - shopBusinessNumberValidator: ShopBusinessNumberValidator + private val shopFactory: ShopFactory ) : RegisterShopUseCase { - private val shopFactory = ShopFactory(shopBusinessNumberValidator) - - @Transactional override fun register(registerShopRequest: RegisterShopRequest): Long { - val shop = shopFactory.createOne(registerShopRequest.title, registerShopRequest.brn) + val shop = shopFactory.createOne( + registerShopRequest.title, + registerShopRequest.brn, + registerShopRequest.address + ) return saveShopPort.saveOne(shop) } diff --git a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt index 23b9d34..bec01bb 100644 --- a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt +++ b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt @@ -6,6 +6,9 @@ import com.mealkitary.shop.domain.shop.Shop import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle +import com.mealkitary.shop.domain.shop.address.Address +import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.shop.domain.shop.address.ShopAddress import io.kotest.core.spec.style.AnnotationSpec import io.kotest.matchers.shouldBe import io.mockk.every @@ -24,6 +27,19 @@ class GetShopServiceTest : AnnotationSpec() { ShopTitle.from("집밥뚝딱"), ShopStatus.VALID, ShopBusinessNumber.from("123-45-67890"), + ShopAddress.of( + "1234567890", + Coordinates.of( + 126.99599512792346, + 35.976749396987046 + ), + Address.of( + "region1DepthName", + "region2DepthName", + "region3DepthName", + "region4DepthName" + ) + ), mutableListOf(), mutableListOf() ) diff --git a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/RegisterShopServiceTest.kt b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/RegisterShopServiceTest.kt index 2e2e6be..73daf7d 100644 --- a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/RegisterShopServiceTest.kt +++ b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/RegisterShopServiceTest.kt @@ -2,8 +2,17 @@ package com.mealkitary.shop.application.service import com.mealkitary.shop.application.port.input.RegisterShopRequest import com.mealkitary.shop.application.port.output.SaveShopPort +import com.mealkitary.shop.domain.product.Product import com.mealkitary.shop.domain.shop.Shop +import com.mealkitary.shop.domain.shop.ShopBusinessNumber +import com.mealkitary.shop.domain.shop.ShopStatus +import com.mealkitary.shop.domain.shop.ShopTitle +import com.mealkitary.shop.domain.shop.address.Address +import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.shop.domain.shop.address.ShopAddress +import com.mealkitary.shop.domain.shop.factory.AddressResolver import com.mealkitary.shop.domain.shop.factory.ShopBusinessNumberValidator +import com.mealkitary.shop.domain.shop.factory.ShopFactory import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.AnnotationSpec import io.kotest.matchers.collections.shouldBeEmpty @@ -12,19 +21,36 @@ import io.kotest.matchers.throwable.shouldHaveMessage import io.mockk.every import io.mockk.mockk import io.mockk.slot +import java.time.LocalTime class RegisterShopServiceTest : AnnotationSpec() { private val saveShopPort = mockk() + private val shopFactory = mockk() private val shopBusinessNumberValidator = mockk() - private val registerShopService = RegisterShopService(saveShopPort, shopBusinessNumberValidator) + private val addressResolver = mockk() + private val registerShopService = RegisterShopService(saveShopPort, shopFactory) @Test fun `service unit test - 신규 가게를 등록한다`() { val shopSlot = slot() - val request = RegisterShopRequest("집밥뚝딱 안양점", "123-23-12345") + val request = RegisterShopRequest("집밥뚝딱 안양점", "123-23-12345", "경기도 안양시 동안구 벌말로 40") + val expectedShopAddress = + ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + + val mockedShop = Shop( + ShopTitle.from(request.title), + ShopStatus.VALID, + ShopBusinessNumber.from(request.brn), + expectedShopAddress, + emptyList().toMutableList(), + emptyList().toMutableList() + ) + + every { + shopFactory.createOne(request.title, request.brn, request.address) + } returns mockedShop every { saveShopPort.saveOne(capture(shopSlot)) } answers { 1L } - every { shopBusinessNumberValidator.validate(any()) } answers {} val result = registerShopService.register(request) @@ -32,15 +58,23 @@ class RegisterShopServiceTest : AnnotationSpec() { result shouldBe 1L capturedShop.businessNumber.value shouldBe "123-23-12345" capturedShop.title.value shouldBe "집밥뚝딱 안양점" + capturedShop.address shouldBe expectedShopAddress capturedShop.products.shouldBeEmpty() capturedShop.reservableTimes.shouldBeEmpty() } @Test fun `service unit test - 가게 이름 형식에 맞지 않으면 예외를 발생한다`() { - val request = RegisterShopRequest("invalid!#@", "123-23-12345") + val request = RegisterShopRequest("invalid!#@", "123-23-12345", "경기도 안양시 동안구 벌말로 40") + val expectedShopAddress = + ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + + every { + shopFactory.createOne(any(), any(), any()) + } throws IllegalArgumentException("올바른 가게 이름 형식이 아닙니다.(한글, 영문, 공백, 숫자만 포함 가능)") every { saveShopPort.saveOne(any()) } answers { 1L } every { shopBusinessNumberValidator.validate(any()) } answers {} + every { addressResolver.resolveAddress("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress shouldThrow { registerShopService.register(request) @@ -49,7 +83,11 @@ class RegisterShopServiceTest : AnnotationSpec() { @Test fun `service unit test - 사업자 번호 형식에 맞지 않으면 예외를 발생한다`() { - val request = RegisterShopRequest("집밥뚝딱 안양점", "invalid-brn") + val request = RegisterShopRequest("집밥뚝딱 안양점", "invalid-brn", "경기도 안양시 동안구 벌말로 40") + + every { + shopFactory.createOne(any(), any(), any()) + } throws IllegalArgumentException("올바른 사업자번호 형식이 아닙니다.") every { saveShopPort.saveOne(any()) } answers { 1L } every { shopBusinessNumberValidator.validate(any()) } answers {} diff --git a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt index b755b9a..108f25e 100644 --- a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt +++ b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt @@ -6,6 +6,9 @@ import com.mealkitary.shop.domain.shop.Shop import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle +import com.mealkitary.shop.domain.shop.address.Address +import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.shop.domain.shop.address.ShopAddress import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.AnnotationSpec import io.kotest.matchers.shouldBe @@ -25,6 +28,19 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopTitle.from("제목"), ShopStatus.VALID, ShopBusinessNumber.from("123-12-12345"), + ShopAddress.of( + "1234567890", + Coordinates.of( + 126.99599512792346, + 35.976749396987046 + ), + Address.of( + "region1DepthName", + "region2DepthName", + "region3DepthName", + "region4DepthName" + ) + ), mutableListOf(), mutableListOf() ) @@ -44,6 +60,19 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopTitle.from("제목"), ShopStatus.INVALID, ShopBusinessNumber.from("123-12-12345"), + ShopAddress.of( + "1234567890", + Coordinates.of( + 126.99599512792346, + 35.976749396987046 + ), + Address.of( + "region1DepthName", + "region2DepthName", + "region3DepthName", + "region4DepthName" + ) + ), mutableListOf(), mutableListOf() ) @@ -63,6 +92,19 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopTitle.from("제목"), ShopStatus.VALID, ShopBusinessNumber.from("123-12-12345"), + ShopAddress.of( + "1234567890", + Coordinates.of( + 126.99599512792346, + 35.976749396987046 + ), + Address.of( + "region1DepthName", + "region2DepthName", + "region3DepthName", + "region4DepthName" + ) + ), mutableListOf(), mutableListOf() ) From 362e52ff9e30db584293cc5f7357045a7508c0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 15:00:10 +0900 Subject: [PATCH 02/13] =?UTF-8?q?refactor:=20=EA=B0=80=EA=B2=8C=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=EC=97=90=20=EC=A3=BC=EC=86=8C=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mealkitary/shop/domain/shop/Shop.kt | 4 ++ .../shop/domain/shop/address/Address.kt | 34 +++++++++++ .../shop/domain/shop/address/Coordinates.kt | 27 +++++++++ .../shop/domain/shop/address/ShopAddress.kt | 30 ++++++++++ .../shop/domain/shop/AddressTest.kt | 28 +++++++++ .../shop/domain/shop/CoordinatesTest.kt | 31 ++++++++++ .../shop/domain/shop/ShopAddressTest.kt | 60 +++++++++++++++++++ .../testFixtures/kotlin/data/ShopTestData.kt | 24 +++++++- .../src/main/resources/data.sql | 8 +-- 9 files changed, 241 insertions(+), 5 deletions(-) create mode 100644 mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt create mode 100644 mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt create mode 100644 mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt create mode 100644 mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt create mode 100644 mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt create mode 100644 mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/Shop.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/Shop.kt index 79dcbe6..352c3cc 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/Shop.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/Shop.kt @@ -1,6 +1,7 @@ package com.mealkitary.shop.domain.shop import com.mealkitary.shop.domain.product.Product +import com.mealkitary.shop.domain.shop.address.ShopAddress import java.time.LocalDateTime import java.time.LocalTime import javax.persistence.CascadeType @@ -23,6 +24,7 @@ class Shop( title: ShopTitle, status: ShopStatus, businessNumber: ShopBusinessNumber, + address: ShopAddress, reservableTimes: MutableList, products: MutableList ) { @@ -58,6 +60,8 @@ class Shop( val businessNumber: ShopBusinessNumber = businessNumber + val address: ShopAddress = address + fun checkReservableShop() { if (status.isInvalidStatus()) { throw IllegalStateException("유효하지 않은 가게입니다.") diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt new file mode 100644 index 0000000..2cde784 --- /dev/null +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt @@ -0,0 +1,34 @@ +package com.mealkitary.shop.domain.shop.address + +import javax.persistence.Column +import javax.persistence.Embeddable + +@Embeddable +class Address( + @Column(name = "region_1depth_name", nullable = false) + val region1DepthName: String, + @Column(name = "region_2depth_name", nullable = false) + val region2DepthName: String, + @Column(name = "region_3depth_name") + val region3DepthName: String, + @Column(name = "region_4depth_name") + val region4DepthName: String +) { + + companion object { + fun of( + region1DepthName: String, + region2DepthName: String, + region3DepthName: String, + region4DepthName: String + ): Address { + + return Address( + region1DepthName, + region2DepthName, + region3DepthName, + region4DepthName + ) + } + } +} diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt new file mode 100644 index 0000000..c07a374 --- /dev/null +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt @@ -0,0 +1,27 @@ +package com.mealkitary.shop.domain.shop.address + +import javax.persistence.Column +import javax.persistence.Embeddable + +@Embeddable +class Coordinates( + @Column(name = "longitude", nullable = false) + val longitude: Double, + @Column(name = "latitude", nullable = false) + val latitude: Double +) { + + companion object { + fun of(longitude: Double, latitude: Double): Coordinates { + checkIsCoordinate(longitude, latitude) + + return Coordinates(longitude, latitude) + } + + private fun checkIsCoordinate(longitude: Double, latitude: Double) { + if (longitude !in -180.0..180.0 || latitude !in -90.0..90.0) { + throw IllegalArgumentException("유효하지 않은 좌표 범위입니다.") + } + } + } +} diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt new file mode 100644 index 0000000..5cf9e14 --- /dev/null +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt @@ -0,0 +1,30 @@ +package com.mealkitary.shop.domain.shop.address + +import javax.persistence.Column +import javax.persistence.Embeddable +import javax.persistence.Embedded + +@Embeddable +class ShopAddress private constructor( + @Column(name = "city_code", nullable = false) + val cityCode: String, + @Embedded + val coordinates: Coordinates, + @Embedded + val address: Address +) { + + companion object { + fun of(cityCode: String, coordinates: Coordinates, address: Address): ShopAddress { + checkIsCityCodeLength(cityCode) + + return ShopAddress(cityCode, coordinates, address) + } + + private fun checkIsCityCodeLength(cityCode: String) { + if (cityCode.length != 10) { + throw IllegalArgumentException("올바른 지역 코드가 아닙니다. (행정동 지역 코드는 10자리)") + } + } + } +} diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt new file mode 100644 index 0000000..e64d8df --- /dev/null +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt @@ -0,0 +1,28 @@ +package com.mealkitary.shop.domain.shop + +import com.mealkitary.shop.domain.shop.address.Address +import io.kotest.core.spec.style.AnnotationSpec +import io.kotest.matchers.shouldBe + +class AddressTest : AnnotationSpec() { + + @Test + fun `올바른 주소를 입력할 경우 객체를 생성할 수 있다`() { + val region1DepthName = "서울" + val region2DepthName = "강남구" + val region3DepthName = "논현동" + val region4DepthName = "논현로" + + val address = Address.of( + region1DepthName, + region2DepthName, + region3DepthName, + region4DepthName + ) + + address.region1DepthName shouldBe region1DepthName + address.region2DepthName shouldBe region2DepthName + address.region3DepthName shouldBe region3DepthName + address.region4DepthName shouldBe region4DepthName + } +} diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt new file mode 100644 index 0000000..910cae0 --- /dev/null +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt @@ -0,0 +1,31 @@ +package com.mealkitary.shop.domain.shop + +import com.mealkitary.shop.domain.shop.address.Coordinates +import io.kotest.assertions.throwables.shouldThrow +import io.kotest.core.spec.style.AnnotationSpec +import io.kotest.matchers.shouldBe +import io.kotest.matchers.throwable.shouldHaveMessage + +class CoordinatesTest : AnnotationSpec() { + + @Test + fun `범위를 벗어나는 좌표일 경우 예외를 발생한다`() { + val longitude = -188.023 + val latitude = 999.7412 + + shouldThrow { + Coordinates.of(longitude, latitude) + } shouldHaveMessage "유효하지 않은 좌표 범위입니다." + } + + @Test + fun `올바른 좌표를 입력했을 경우 객체를 생성한다`() { + val longitude = -150.653 + val latitude = 46.492 + + val coordinates = Coordinates.of(longitude, latitude) + + coordinates.longitude shouldBe longitude + coordinates.latitude shouldBe latitude + } +} diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt new file mode 100644 index 0000000..512ff4a --- /dev/null +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt @@ -0,0 +1,60 @@ +package com.mealkitary.shop.domain.shop + +import com.mealkitary.shop.domain.shop.address.Address +import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.shop.domain.shop.address.ShopAddress +import io.kotest.assertions.throwables.shouldThrow +import io.kotest.core.spec.style.AnnotationSpec +import io.kotest.matchers.shouldBe +import io.kotest.matchers.throwable.shouldHaveMessage + +class ShopAddressTest : AnnotationSpec() { + + @Test + fun `올바른 값들을 입력했을 경우 객체를 생성할 수 있다`() { + val cityCode = "1234567890" + val coordinates = Coordinates.of( + -150.653, + 46.492 + ) + val address = Address.of( + "region1DepthName", + "region2DepthName", + "region3DepthName", + "region4DepthName" + ) + + val shopAddress = ShopAddress.of( + cityCode, + coordinates, + address + ) + + shopAddress.cityCode shouldBe cityCode + shopAddress.coordinates shouldBe coordinates + shopAddress.address shouldBe address + } + + @Test + fun `지역 코드가 올바르지 않을 경우 예외를 발생한다`() { + val cityCode = "25231491723109" + val coordinates = Coordinates.of( + -150.653, + 46.492 + ) + val address = Address.of( + "region1DepthName", + "region2DepthName", + "region3DepthName", + "region4DepthName" + ) + + shouldThrow { + ShopAddress.of( + cityCode, + coordinates, + address + ) + } shouldHaveMessage "올바른 지역 코드가 아닙니다. (행정동 지역 코드는 10자리)" + } +} diff --git a/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt b/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt index 1389d2a..7f52f3c 100644 --- a/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt +++ b/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt @@ -5,6 +5,9 @@ import com.mealkitary.shop.domain.shop.Shop import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle +import com.mealkitary.shop.domain.shop.address.Address +import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.shop.domain.shop.address.ShopAddress import data.ProductTestData.Companion.defaultProduct import java.time.LocalTime @@ -22,7 +25,20 @@ class ShopTestData { defaultProduct().withId(1L).withName("부대찌개").build(), defaultProduct().withId(2L).withName("닭볶음탕").build() ), - private var shopBusinessNumber: ShopBusinessNumber = ShopBusinessNumber.from("123-45-67890") + private var shopBusinessNumber: ShopBusinessNumber = ShopBusinessNumber.from("123-45-67890"), + private var shopAddress: ShopAddress = ShopAddress.of( + "1234567890", + Coordinates.of( + 126.99599512792346, + 35.976749396987046 + ), + Address.of( + "region1DepthName", + "region2DepthName", + "region3DepthName", + "roadName" + ) + ) ) { fun withTitle(title: String): ShopBuilder { @@ -50,11 +66,17 @@ class ShopTestData { return this } + fun withAddress(shopAddress: ShopAddress): ShopBuilder { + this.shopAddress = shopAddress + return this + } + fun build(): Shop { return Shop( ShopTitle.from(this.title), this.shopStatus, this.shopBusinessNumber, + this.shopAddress, this.reservableTimes.toMutableList(), this.products.toMutableList() ) diff --git a/mealkitary-infrastructure/adapter-persistence-spring-data-jpa/src/main/resources/data.sql b/mealkitary-infrastructure/adapter-persistence-spring-data-jpa/src/main/resources/data.sql index 929806b..ab9372a 100644 --- a/mealkitary-infrastructure/adapter-persistence-spring-data-jpa/src/main/resources/data.sql +++ b/mealkitary-infrastructure/adapter-persistence-spring-data-jpa/src/main/resources/data.sql @@ -1,5 +1,5 @@ insert into shop -values (1, '123-12-12345', 'VALID', '집밥뚝딱 철산점'); +values (1, '경기도', '광명시', '철산동', '철산로', '1234567890', 30.03, 50.05, '123-12-12345', 'VALID', '집밥뚝딱 철산점'); insert into product values (1, '부대찌개', 15800, 1); insert into product @@ -17,7 +17,7 @@ values (1, '18:30'); insert into shop -values (2, '123-12-12345', 'VALID', '집밥뚝딱 안양점'); +values (2, '경기도', '안양시', '동안구', '경수대로', '1234567890', 30.03, 50.05, '123-12-12345', 'VALID', '집밥뚝딱 안양점'); insert into product values (4, '비비고 만두', 3200, 2); insert into product @@ -30,7 +30,7 @@ insert into reservable_time values (2, '19:30'); insert into shop -values (3, '123-12-12345', 'VALID', '집밥뚝딱 숭실대입구점'); +values (3, '서울시', '동작구', '상도동', '', '1234567890', 30.03, 50.05, '123-12-12345', 'VALID', '집밥뚝딱 숭실대입구점'); insert into product values (7, '왕만두', 4900, 3); insert into product @@ -48,7 +48,7 @@ values (3, '23:30'); insert into shop -values (4, '123-12-12345', 'VALID', '집밥뚝딱 다산점'); +values (4, '경기도', '남양주시', '다산동', '', '1234567890', 30.03, 50.05, '123-12-12345', 'VALID', '집밥뚝딱 다산점'); insert into product values (10, '김치찌개', 15800, 4); insert into reservable_time From c096b9a6c47d3f92eb0258b1e4882b80ef2b86c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 15:02:18 +0900 Subject: [PATCH 03/13] =?UTF-8?q?refactor:=20=EB=8F=84=EB=A1=9C=EB=AA=85?= =?UTF-8?q?=20=EC=A3=BC=EC=86=8C=EB=A5=BC=20=EC=A3=BC=EC=86=8C=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=EB=A1=9C=20=EB=B3=80=ED=99=98=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/shop/factory/AddressResolver.kt | 8 +++ .../shop/domain/shop/factory/ShopFactory.kt | 11 ++- .../domain/shop/factory/ShopFactoryTest.kt | 48 +++++++++++-- .../address/SimpleAddressResolver.kt | 41 +++++++++++ .../test/kotlin/SimpleAddressResolverTest.kt | 69 +++++++++++++++++++ 5 files changed, 170 insertions(+), 7 deletions(-) create mode 100644 mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/AddressResolver.kt create mode 100644 mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt create mode 100644 mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/AddressResolver.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/AddressResolver.kt new file mode 100644 index 0000000..83c3e12 --- /dev/null +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/AddressResolver.kt @@ -0,0 +1,8 @@ +package com.mealkitary.shop.domain.shop.factory + +import com.mealkitary.shop.domain.shop.address.ShopAddress + +interface AddressResolver { + + fun resolveAddress(address: String): ShopAddress +} diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt index 76cc4df..da6efee 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt @@ -5,21 +5,28 @@ import com.mealkitary.shop.domain.shop.Shop import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle +import com.mealkitary.shop.domain.shop.address.ShopAddress +import org.springframework.stereotype.Component import java.time.LocalTime +@Component class ShopFactory( - private val shopBusinessNumberValidator: ShopBusinessNumberValidator + private val shopBusinessNumberValidator: ShopBusinessNumberValidator, + private val addressResolver: AddressResolver ) { - fun createOne(title: String, brn: String): Shop { + fun createOne(title: String, brn: String, address: String): Shop { val shopBusinessNumber = ShopBusinessNumber.from(brn) + val shopAddress: ShopAddress = addressResolver.resolveAddress(address) + shopBusinessNumberValidator.validate(shopBusinessNumber) return Shop( ShopTitle.from(title), ShopStatus.VALID, shopBusinessNumber, + shopAddress, emptyList().toMutableList(), emptyList().toMutableList(), ) diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt index 34a8382..b700838 100644 --- a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt @@ -1,5 +1,8 @@ package com.mealkitary.shop.domain.shop.factory +import com.mealkitary.shop.domain.shop.address.Address +import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.shop.domain.shop.address.ShopAddress import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.AnnotationSpec import io.kotest.matchers.shouldBe @@ -10,31 +13,66 @@ import io.mockk.mockk class ShopFactoryTest : AnnotationSpec() { private val shopBusinessNumberValidator = mockk() - private val shopFactory = ShopFactory(shopBusinessNumberValidator) + private val addressResolver = mockk() + private val shopFactory = ShopFactory(shopBusinessNumberValidator, addressResolver) @Test fun `사업자번호가 유효하지 않으면 예외를 발생한다`() { shouldThrow { - shopFactory.createOne("집밥뚝딱 안양점", "32-12-3221") + shopFactory.createOne("집밥뚝딱 안양점", "32-12-3221", "경기도 안양시 동안구 벌말로 40") } shouldHaveMessage "올바른 사업자번호 형식이 아닙니다." } @Test - fun `실제로 유효한 사업자번호와 가게이름이라면 가게를 생성한다`() { + fun `실제로 유효한 사업자번호와 가게이름, 주소라면 가게를 생성한다`() { + val expectedShopAddress = + ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + every { shopBusinessNumberValidator.validate(any()) } answers { } + every { addressResolver.resolveAddress("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress - val shop = shopFactory.createOne("집밥뚝딱 안양점", "321-23-12345") + val shop = shopFactory.createOne("집밥뚝딱 안양점", "321-23-12345", "경기도 안양시 동안구 벌말로 40") shop.title.value shouldBe "집밥뚝딱 안양점" shop.businessNumber.value shouldBe "321-23-12345" + shop.address shouldBe expectedShopAddress } @Test fun `가게 이름이 유효하지 않으면 예외를 발생한다`() { + val expectedShopAddress = + ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + + every { shopBusinessNumberValidator.validate(any()) } answers { } + every { addressResolver.resolveAddress("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress + + shouldThrow { + shopFactory.createOne("집밥뚝딱 ! 안양점", "321-23-12345", "경기도 안양시 동안구 벌말로 40") + } shouldHaveMessage "올바른 가게 이름 형식이 아닙니다.(한글, 영문, 공백, 숫자만 포함 가능)" + } + + @Test + fun `도로명 주소를 받아 주소 객체를 생선한다`() { + val address = "경기도 안양시 동안구 벌말로" + val shopAddress = ShopAddress.of( + "1234567890", + Coordinates.of( + 127.0, + 40.0 + ), + Address.of( + "경기도", + "안양시", + "동안구", + "벌말로" + ) + ) + every { shopBusinessNumberValidator.validate(any()) } answers { } + every { addressResolver.resolveAddress(address) } answers { shopAddress } shouldThrow { - shopFactory.createOne("집밥뚝딱 ! 안양점", "321-23-12345") + shopFactory.createOne("집밥뚝딱 ! 안양점", "321-23-12345", "경기도 안양시 동안구 벌말로 40") } shouldHaveMessage "올바른 가게 이름 형식이 아닙니다.(한글, 영문, 공백, 숫자만 포함 가능)" } } diff --git a/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt new file mode 100644 index 0000000..b6c0cfc --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt @@ -0,0 +1,41 @@ +package com.mealkitary.address + +import com.mealkitary.shop.domain.shop.address.Address +import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.shop.domain.shop.address.ShopAddress +import com.mealkitary.shop.domain.shop.factory.AddressResolver +import org.springframework.stereotype.Component + +private const val ADDRESS_MIN_LENGTH = 2 + +@Component +class SimpleAddressResolver : AddressResolver { + + override fun resolveAddress(address: String): ShopAddress { + val value = address.split(" ") + + if (value.size < ADDRESS_MIN_LENGTH) { + throw IllegalArgumentException("주소 형식이 올바르지 않습니다.") + } + + val region1DepthName = value[0] + val region2DepthName = value[1] + val region3DepthName = value.getOrNull(2) ?: "" + val region4DepthName = value.getOrNull(3) ?: "" + + // TODO: 좌표 및 지역 코드를 카카오 API에서 받아올 예정 + return ShopAddress.of( + "1234567890", + Coordinates.of( + 127.0, + 40.0 + ), + Address.of( + region1DepthName, + region2DepthName, + region3DepthName, + region4DepthName + ) + ) + } +} diff --git a/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt new file mode 100644 index 0000000..bed0715 --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt @@ -0,0 +1,69 @@ +package com.mealkitary.address + +import io.kotest.assertions.throwables.shouldThrow +import io.kotest.core.spec.style.AnnotationSpec +import io.kotest.matchers.shouldBe +import io.kotest.matchers.throwable.shouldHaveMessage +import org.springframework.stereotype.Component + +@Component +class SimpleAddressResolverTest : AnnotationSpec() { + + @Test + fun `adapter unit test - 문자열 주소값을 받아 주소 객체를 생성한다`() { + val address = "서울특별시 강남구 역삼동 논현로" + val resolver = SimpleAddressResolver() + + val shopAddress = resolver.resolveAddress(address) + + shopAddress.cityCode shouldBe "1234567890" + shopAddress.coordinates.longitude shouldBe 127.0 + shopAddress.coordinates.latitude shouldBe 40.0 + shopAddress.address.region1DepthName shouldBe "서울특별시" + shopAddress.address.region2DepthName shouldBe "강남구" + shopAddress.address.region3DepthName shouldBe "역삼동" + shopAddress.address.region4DepthName shouldBe "논현로" + } + + @Test + fun `adapter unit test - 문자열 주소값이 3등분일 경우 3개의 정보를 가진 주소 객체를 생성한다`() { + val address = "경기도 남양주시 다산동" + val resolver = SimpleAddressResolver() + + val shopAddress = resolver.resolveAddress(address) + + shopAddress.cityCode shouldBe "1234567890" + shopAddress.coordinates.longitude shouldBe 127.0 + shopAddress.coordinates.latitude shouldBe 40.0 + shopAddress.address.region1DepthName shouldBe "경기도" + shopAddress.address.region2DepthName shouldBe "남양주시" + shopAddress.address.region3DepthName shouldBe "다산동" + shopAddress.address.region4DepthName shouldBe "" + } + + @Test + fun `adapter unit test - 문자열 주소값이 2등분일 경우 2개의 정보를 가진 주소 객체를 생성한다`() { + val address = "제주특별자치도 한림읍" + val resolver = SimpleAddressResolver() + + val shopAddress = resolver.resolveAddress(address) + + shopAddress.cityCode shouldBe "1234567890" + shopAddress.coordinates.longitude shouldBe 127.0 + shopAddress.coordinates.latitude shouldBe 40.0 + shopAddress.address.region1DepthName shouldBe "제주특별자치도" + shopAddress.address.region2DepthName shouldBe "한림읍" + shopAddress.address.region3DepthName shouldBe "" + shopAddress.address.region4DepthName shouldBe "" + } + + @Test + fun `adapter unit test - 문자열 주소값이 2등분 이하일 경우 예외를 발생한다`() { + val address = "제주특별자치도" + val resolver = SimpleAddressResolver() + + shouldThrow { + resolver.resolveAddress(address) + } shouldHaveMessage "주소 형식이 올바르지 않습니다." + } +} From 534af9cf03455e7f3582c78946b00ab7ff79fe7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 15:04:34 +0900 Subject: [PATCH 04/13] =?UTF-8?q?chore:=20=EC=A3=BC=EC=86=8C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=EA=B8=B0=20=EB=AA=A8=EB=93=88=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/mealkitary-main-develop-ci.yml | 4 +++- .github/workflows/mealkitary-test-coverage-automation.yml | 5 ++++- mealkitary-api/build.gradle.kts | 1 + .../adapter-address-resolver/build.gradle.kts | 8 ++++++++ settings.gradle.kts | 5 ++++- 5 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 mealkitary-infrastructure/adapter-address-resolver/build.gradle.kts diff --git a/.github/workflows/mealkitary-main-develop-ci.yml b/.github/workflows/mealkitary-main-develop-ci.yml index 901d7f2..cdfd207 100644 --- a/.github/workflows/mealkitary-main-develop-ci.yml +++ b/.github/workflows/mealkitary-main-develop-ci.yml @@ -55,6 +55,7 @@ jobs: ./mealkitary-infrastructure/adapter-paymentgateway-tosspayments/build/test-results/**/*.xml ./mealkitary-infrastructure/adapter-firebase-notification/build/test-results/**/*.xml ./mealkitary-infrastructure/business-registration-number-validator/adapter-simple-brn-validator/build/test-results/**/*.xml + ./mealkitary-infrastructure/adapter-address-resolver/build/test-results/**/*.xml - name: Jacoco Coverage 리포트 전송 uses: codecov/codecov-action@v3 @@ -67,7 +68,8 @@ jobs: ./mealkitary-infrastructure/adapter-persistence-spring-data-jpa/build/reports/jacoco/test/jacocoTestReport.xml, ./mealkitary-infrastructure/adapter-paymentgateway-tosspayments/build/reports/jacoco/test/jacocoTestReport.xml, ./mealkitary-infrastructure/adapter-firebase-notification/build/reports/jacoco/test/jacocoTestReport.xml, - ./mealkitary-infrastructure/business-registration-number-validator/adapter-simple-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml + ./mealkitary-infrastructure/business-registration-number-validator/adapter-simple-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml, + ./mealkitary-infrastructure/adapter-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml, name: mealkitary-codecov verbose: true diff --git a/.github/workflows/mealkitary-test-coverage-automation.yml b/.github/workflows/mealkitary-test-coverage-automation.yml index acd71d2..e25282a 100644 --- a/.github/workflows/mealkitary-test-coverage-automation.yml +++ b/.github/workflows/mealkitary-test-coverage-automation.yml @@ -43,6 +43,7 @@ jobs: ./mealkitary-infrastructure/adapter-paymentgateway-tosspayments/build/test-results/**/*.xml ./mealkitary-infrastructure/adapter-firebase-notification/build/test-results/**/*.xml ./mealkitary-infrastructure/business-registration-number-validator/adapter-simple-brn-validator/build/test-results/**/*.xml + ./mealkitary-infrastructure/adapter-address-resolver/build/test-results/**/*.xml - name: Jacoco Coverage 리포트 전송 uses: codecov/codecov-action@v3 @@ -55,6 +56,8 @@ jobs: ./mealkitary-infrastructure/adapter-persistence-spring-data-jpa/build/reports/jacoco/test/jacocoTestReport.xml, ./mealkitary-infrastructure/adapter-paymentgateway-tosspayments/build/reports/jacoco/test/jacocoTestReport.xml, ./mealkitary-infrastructure/adapter-firebase-notification/build/reports/jacoco/test/jacocoTestReport.xml, - ./mealkitary-infrastructure/business-registration-number-validator/adapter-simple-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml + ./mealkitary-infrastructure/business-registration-number-validator/adapter-simple-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml, + ./mealkitary-infrastructure/adapter-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml + name: mealkitary-codecov verbose: true diff --git a/mealkitary-api/build.gradle.kts b/mealkitary-api/build.gradle.kts index 5ffe9a6..6426857 100644 --- a/mealkitary-api/build.gradle.kts +++ b/mealkitary-api/build.gradle.kts @@ -21,6 +21,7 @@ dependencies { implementation(project(":mealkitary-infrastructure:adapter-persistence-spring-data-jpa")) implementation(project(":mealkitary-infrastructure:adapter-paymentgateway-tosspayments")) implementation(project(":mealkitary-infrastructure:adapter-firebase-notification")) + implementation(project(":mealkitary-infrastructure:adapter-address-resolver")) implementation( project( ":mealkitary-infrastructure:business-registration-number-validator:adapter-open-api-brn-validator", diff --git a/mealkitary-infrastructure/adapter-address-resolver/build.gradle.kts b/mealkitary-infrastructure/adapter-address-resolver/build.gradle.kts new file mode 100644 index 0000000..2f0606e --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/build.gradle.kts @@ -0,0 +1,8 @@ +dependencies { + val querydslVersion: String by properties + implementation("com.querydsl:querydsl-jpa:$querydslVersion") + implementation("com.h2database:h2") + implementation(project(":mealkitary-domain")) + implementation(project(":mealkitary-application")) + testImplementation(testFixtures(project(":mealkitary-domain"))) +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 52db22b..680a318 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,8 @@ include( "mealkitary-infrastructure:adapter-paymentgateway-tosspayments", "mealkitary-infrastructure:adapter-firebase-notification", "mealkitary-infrastructure:business-registration-number-validator:adapter-open-api-brn-validator", - "mealkitary-infrastructure:business-registration-number-validator:adapter-simple-brn-validator" + "mealkitary-infrastructure:business-registration-number-validator:adapter-simple-brn-validator", + "mealkitary-infrastructure:adapter-address-resolver" ) pluginManagement { @@ -36,3 +37,5 @@ pluginManagement { } } } +include("mealkitary-infrastructure:adapter-address-resolver") +findProject(":mealkitary-infrastructure:adapter-address-resolver")?.name = "adapter-address-resolver" From b5b20982c56ae168e36c6928de556d15a0b5afc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 16:16:29 +0900 Subject: [PATCH 05/13] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mealkitary/shop/domain/shop/factory/ShopFactory.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt index da6efee..0c80427 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt @@ -6,10 +6,8 @@ import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle import com.mealkitary.shop.domain.shop.address.ShopAddress -import org.springframework.stereotype.Component import java.time.LocalTime -@Component class ShopFactory( private val shopBusinessNumberValidator: ShopBusinessNumberValidator, private val addressResolver: AddressResolver From d85a9e20f6a124f0b5fde131ec2a6783aedf0ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 16:17:19 +0900 Subject: [PATCH 06/13] =?UTF-8?q?fix:=20=ED=8C=8C=EC=9D=BC=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=EB=AC=B8=EC=A0=9C=EB=A5=BC=20=EC=9C=84=ED=95=B4=20?= =?UTF-8?q?build.gradle=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mealkitary-api/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/mealkitary-api/build.gradle.kts b/mealkitary-api/build.gradle.kts index 6426857..c0ec197 100644 --- a/mealkitary-api/build.gradle.kts +++ b/mealkitary-api/build.gradle.kts @@ -6,6 +6,7 @@ val snippetsDir by extra { file("build/generated-snippets") } val asciidoctorExt: Configuration by configurations.creating bootJar.enabled = true +bootJar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE jar.enabled = false plugins { From c6e148fc44f29bc86cba45a5abb60047bdc52826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 16:43:42 +0900 Subject: [PATCH 07/13] =?UTF-8?q?refactor:=20=EC=A3=BC=EC=86=8C=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/application/service/GetShopServiceTest.kt | 2 +- .../application/service/UpdateShopStatusServiceTest.kt | 6 +++--- .../com/mealkitary/shop/domain/shop/address/Address.kt | 8 ++++---- .../kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt | 6 +++--- .../com/mealkitary/shop/domain/shop/ShopAddressTest.kt | 4 ++-- .../com/mealkitary/address/SimpleAddressResolver.kt | 4 ++-- .../src/test/kotlin/SimpleAddressResolverTest.kt | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt index bec01bb..73eec59 100644 --- a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt +++ b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt @@ -37,7 +37,7 @@ class GetShopServiceTest : AnnotationSpec() { "region1DepthName", "region2DepthName", "region3DepthName", - "region4DepthName" + "roadName" ) ), mutableListOf(), diff --git a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt index 108f25e..4881a16 100644 --- a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt +++ b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt @@ -38,7 +38,7 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { "region1DepthName", "region2DepthName", "region3DepthName", - "region4DepthName" + "roadName" ) ), mutableListOf(), @@ -70,7 +70,7 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { "region1DepthName", "region2DepthName", "region3DepthName", - "region4DepthName" + "roadName" ) ), mutableListOf(), @@ -102,7 +102,7 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { "region1DepthName", "region2DepthName", "region3DepthName", - "region4DepthName" + "roadName" ) ), mutableListOf(), diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt index 2cde784..3e89fd8 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt @@ -11,8 +11,8 @@ class Address( val region2DepthName: String, @Column(name = "region_3depth_name") val region3DepthName: String, - @Column(name = "region_4depth_name") - val region4DepthName: String + @Column(name = "road_name") + val roadName: String ) { companion object { @@ -20,14 +20,14 @@ class Address( region1DepthName: String, region2DepthName: String, region3DepthName: String, - region4DepthName: String + roadName: String ): Address { return Address( region1DepthName, region2DepthName, region3DepthName, - region4DepthName + roadName ) } } diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt index e64d8df..3a84bb7 100644 --- a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt @@ -11,18 +11,18 @@ class AddressTest : AnnotationSpec() { val region1DepthName = "서울" val region2DepthName = "강남구" val region3DepthName = "논현동" - val region4DepthName = "논현로" + val roadName = "논현로" val address = Address.of( region1DepthName, region2DepthName, region3DepthName, - region4DepthName + roadName ) address.region1DepthName shouldBe region1DepthName address.region2DepthName shouldBe region2DepthName address.region3DepthName shouldBe region3DepthName - address.region4DepthName shouldBe region4DepthName + address.roadName shouldBe roadName } } diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt index 512ff4a..9047495 100644 --- a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt @@ -21,7 +21,7 @@ class ShopAddressTest : AnnotationSpec() { "region1DepthName", "region2DepthName", "region3DepthName", - "region4DepthName" + "roadName" ) val shopAddress = ShopAddress.of( @@ -46,7 +46,7 @@ class ShopAddressTest : AnnotationSpec() { "region1DepthName", "region2DepthName", "region3DepthName", - "region4DepthName" + "roadName" ) shouldThrow { diff --git a/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt index b6c0cfc..c3aa189 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt @@ -21,7 +21,7 @@ class SimpleAddressResolver : AddressResolver { val region1DepthName = value[0] val region2DepthName = value[1] val region3DepthName = value.getOrNull(2) ?: "" - val region4DepthName = value.getOrNull(3) ?: "" + val roadName = value.getOrNull(3) ?: "" // TODO: 좌표 및 지역 코드를 카카오 API에서 받아올 예정 return ShopAddress.of( @@ -34,7 +34,7 @@ class SimpleAddressResolver : AddressResolver { region1DepthName, region2DepthName, region3DepthName, - region4DepthName + roadName ) ) } diff --git a/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt index bed0715..79a6e3e 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt @@ -22,7 +22,7 @@ class SimpleAddressResolverTest : AnnotationSpec() { shopAddress.address.region1DepthName shouldBe "서울특별시" shopAddress.address.region2DepthName shouldBe "강남구" shopAddress.address.region3DepthName shouldBe "역삼동" - shopAddress.address.region4DepthName shouldBe "논현로" + shopAddress.address.roadName shouldBe "논현로" } @Test @@ -38,7 +38,7 @@ class SimpleAddressResolverTest : AnnotationSpec() { shopAddress.address.region1DepthName shouldBe "경기도" shopAddress.address.region2DepthName shouldBe "남양주시" shopAddress.address.region3DepthName shouldBe "다산동" - shopAddress.address.region4DepthName shouldBe "" + shopAddress.address.roadName shouldBe "" } @Test @@ -54,7 +54,7 @@ class SimpleAddressResolverTest : AnnotationSpec() { shopAddress.address.region1DepthName shouldBe "제주특별자치도" shopAddress.address.region2DepthName shouldBe "한림읍" shopAddress.address.region3DepthName shouldBe "" - shopAddress.address.region4DepthName shouldBe "" + shopAddress.address.roadName shouldBe "" } @Test From a8e12ce30aa7a6ab2fc2f22b90a0185a0c81e20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 16:52:24 +0900 Subject: [PATCH 08/13] =?UTF-8?q?refactor:=20=EC=A7=80=EC=97=AD=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EA=B8=B8=EC=9D=B4=20=EC=83=81=EC=88=98=20?= =?UTF-8?q?=EC=B6=94=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mealkitary/shop/domain/shop/address/ShopAddress.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt index 5cf9e14..c74a16f 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt @@ -4,6 +4,8 @@ import javax.persistence.Column import javax.persistence.Embeddable import javax.persistence.Embedded +private const val CITY_CODE_LENGTH = 10 + @Embeddable class ShopAddress private constructor( @Column(name = "city_code", nullable = false) @@ -22,7 +24,7 @@ class ShopAddress private constructor( } private fun checkIsCityCodeLength(cityCode: String) { - if (cityCode.length != 10) { + if (cityCode.length != CITY_CODE_LENGTH) { throw IllegalArgumentException("올바른 지역 코드가 아닙니다. (행정동 지역 코드는 10자리)") } } From 4d21a4fd4d84977980a09818f57a9ee39be8f000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Tue, 3 Oct 2023 16:54:49 +0900 Subject: [PATCH 09/13] =?UTF-8?q?refactor:=20=EC=A2=8C=ED=91=9C=20?= =?UTF-8?q?=EB=B2=94=EC=9C=84=20=EA=B2=80=EC=A6=9D=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mealkitary/shop/domain/shop/address/Coordinates.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt index c07a374..db32f9a 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt @@ -13,12 +13,12 @@ class Coordinates( companion object { fun of(longitude: Double, latitude: Double): Coordinates { - checkIsCoordinate(longitude, latitude) + checkIsCoordinateRange(longitude, latitude) return Coordinates(longitude, latitude) } - private fun checkIsCoordinate(longitude: Double, latitude: Double) { + private fun checkIsCoordinateRange(longitude: Double, latitude: Double) { if (longitude !in -180.0..180.0 || latitude !in -90.0..90.0) { throw IllegalArgumentException("유효하지 않은 좌표 범위입니다.") } From a11411f494b013af6afe9b8ca8623fedcba352c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Wed, 4 Oct 2023 01:31:50 +0900 Subject: [PATCH 10/13] =?UTF-8?q?chore:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BD=A4=EB=A7=88=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/mealkitary-main-develop-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mealkitary-main-develop-ci.yml b/.github/workflows/mealkitary-main-develop-ci.yml index cdfd207..8b85b57 100644 --- a/.github/workflows/mealkitary-main-develop-ci.yml +++ b/.github/workflows/mealkitary-main-develop-ci.yml @@ -69,7 +69,7 @@ jobs: ./mealkitary-infrastructure/adapter-paymentgateway-tosspayments/build/reports/jacoco/test/jacocoTestReport.xml, ./mealkitary-infrastructure/adapter-firebase-notification/build/reports/jacoco/test/jacocoTestReport.xml, ./mealkitary-infrastructure/business-registration-number-validator/adapter-simple-brn-validator/build/reports/jacoco/test/jacocoTestReport.xml, - ./mealkitary-infrastructure/adapter-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml, + ./mealkitary-infrastructure/adapter-address-resolver/build/reports/jacoco/test/jacocoTestReport.xml name: mealkitary-codecov verbose: true From 828ec4cb4366e4ae625bbd79dde49c84851e26af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Thu, 5 Oct 2023 03:16:31 +0900 Subject: [PATCH 11/13] =?UTF-8?q?chore:=20=EC=A3=BC=EC=86=8C,=20=EC=A2=8C?= =?UTF-8?q?=ED=91=9C=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mealkitary/shop/application/service/GetShopServiceTest.kt | 4 ++-- .../shop/application/service/RegisterShopServiceTest.kt | 4 ++-- .../shop/application/service/UpdateShopStatusServiceTest.kt | 4 ++-- .../{shop/domain/shop/address => common/model}/Address.kt | 4 ++-- .../{shop/domain/shop/address => common/model}/Coordinates.kt | 2 +- .../com/mealkitary/shop/domain/shop/address/ShopAddress.kt | 2 ++ .../kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt | 2 +- .../kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt | 2 +- .../kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt | 4 ++-- .../mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt | 4 ++-- .../src/testFixtures/kotlin/data/ShopTestData.kt | 4 ++-- .../kotlin/com/mealkitary/address/SimpleAddressResolver.kt | 4 ++-- 12 files changed, 21 insertions(+), 19 deletions(-) rename mealkitary-domain/src/main/kotlin/com/mealkitary/{shop/domain/shop/address => common/model}/Address.kt (91%) rename mealkitary-domain/src/main/kotlin/com/mealkitary/{shop/domain/shop/address => common/model}/Coordinates.kt (93%) diff --git a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt index 73eec59..90f93eb 100644 --- a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt +++ b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/GetShopServiceTest.kt @@ -1,13 +1,13 @@ package com.mealkitary.shop.application.service +import com.mealkitary.common.model.Address +import com.mealkitary.common.model.Coordinates import com.mealkitary.shop.application.port.input.ShopResponse import com.mealkitary.shop.application.port.output.LoadShopPort import com.mealkitary.shop.domain.shop.Shop import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle -import com.mealkitary.shop.domain.shop.address.Address -import com.mealkitary.shop.domain.shop.address.Coordinates import com.mealkitary.shop.domain.shop.address.ShopAddress import io.kotest.core.spec.style.AnnotationSpec import io.kotest.matchers.shouldBe diff --git a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/RegisterShopServiceTest.kt b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/RegisterShopServiceTest.kt index 73daf7d..e61ca1c 100644 --- a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/RegisterShopServiceTest.kt +++ b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/RegisterShopServiceTest.kt @@ -1,5 +1,7 @@ package com.mealkitary.shop.application.service +import com.mealkitary.common.model.Address +import com.mealkitary.common.model.Coordinates import com.mealkitary.shop.application.port.input.RegisterShopRequest import com.mealkitary.shop.application.port.output.SaveShopPort import com.mealkitary.shop.domain.product.Product @@ -7,8 +9,6 @@ import com.mealkitary.shop.domain.shop.Shop import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle -import com.mealkitary.shop.domain.shop.address.Address -import com.mealkitary.shop.domain.shop.address.Coordinates import com.mealkitary.shop.domain.shop.address.ShopAddress import com.mealkitary.shop.domain.shop.factory.AddressResolver import com.mealkitary.shop.domain.shop.factory.ShopBusinessNumberValidator diff --git a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt index 4881a16..d8e47f7 100644 --- a/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt +++ b/mealkitary-application/src/test/kotlin/com/mealkitary/shop/application/service/UpdateShopStatusServiceTest.kt @@ -1,13 +1,13 @@ package com.mealkitary.shop.application.service +import com.mealkitary.common.model.Address +import com.mealkitary.common.model.Coordinates import com.mealkitary.shop.application.port.output.CheckExistenceShopPort import com.mealkitary.shop.application.port.output.LoadShopPort import com.mealkitary.shop.domain.shop.Shop import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle -import com.mealkitary.shop.domain.shop.address.Address -import com.mealkitary.shop.domain.shop.address.Coordinates import com.mealkitary.shop.domain.shop.address.ShopAddress import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.AnnotationSpec diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Address.kt similarity index 91% rename from mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt rename to mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Address.kt index 3e89fd8..099d9d3 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Address.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Address.kt @@ -1,10 +1,10 @@ -package com.mealkitary.shop.domain.shop.address +package com.mealkitary.common.model import javax.persistence.Column import javax.persistence.Embeddable @Embeddable -class Address( +class Address private constructor( @Column(name = "region_1depth_name", nullable = false) val region1DepthName: String, @Column(name = "region_2depth_name", nullable = false) diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt similarity index 93% rename from mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt rename to mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt index db32f9a..d11bd0f 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/Coordinates.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt @@ -1,4 +1,4 @@ -package com.mealkitary.shop.domain.shop.address +package com.mealkitary.common.model import javax.persistence.Column import javax.persistence.Embeddable diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt index c74a16f..2229f42 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/address/ShopAddress.kt @@ -1,5 +1,7 @@ package com.mealkitary.shop.domain.shop.address +import com.mealkitary.common.model.Address +import com.mealkitary.common.model.Coordinates import javax.persistence.Column import javax.persistence.Embeddable import javax.persistence.Embedded diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt index 3a84bb7..2c26e06 100644 --- a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/AddressTest.kt @@ -1,6 +1,6 @@ package com.mealkitary.shop.domain.shop -import com.mealkitary.shop.domain.shop.address.Address +import com.mealkitary.common.model.Address import io.kotest.core.spec.style.AnnotationSpec import io.kotest.matchers.shouldBe diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt index 910cae0..970576a 100644 --- a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/CoordinatesTest.kt @@ -1,6 +1,6 @@ package com.mealkitary.shop.domain.shop -import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.common.model.Coordinates import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.AnnotationSpec import io.kotest.matchers.shouldBe diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt index 9047495..d490ebd 100644 --- a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/ShopAddressTest.kt @@ -1,7 +1,7 @@ package com.mealkitary.shop.domain.shop -import com.mealkitary.shop.domain.shop.address.Address -import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.common.model.Address +import com.mealkitary.common.model.Coordinates import com.mealkitary.shop.domain.shop.address.ShopAddress import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.AnnotationSpec diff --git a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt index b700838..709e531 100644 --- a/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt +++ b/mealkitary-domain/src/test/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactoryTest.kt @@ -1,7 +1,7 @@ package com.mealkitary.shop.domain.shop.factory -import com.mealkitary.shop.domain.shop.address.Address -import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.common.model.Address +import com.mealkitary.common.model.Coordinates import com.mealkitary.shop.domain.shop.address.ShopAddress import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.AnnotationSpec diff --git a/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt b/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt index 7f52f3c..968438f 100644 --- a/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt +++ b/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt @@ -1,12 +1,12 @@ package data +import com.mealkitary.common.model.Address +import com.mealkitary.common.model.Coordinates import com.mealkitary.shop.domain.product.Product import com.mealkitary.shop.domain.shop.Shop import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle -import com.mealkitary.shop.domain.shop.address.Address -import com.mealkitary.shop.domain.shop.address.Coordinates import com.mealkitary.shop.domain.shop.address.ShopAddress import data.ProductTestData.Companion.defaultProduct import java.time.LocalTime diff --git a/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt index c3aa189..f15e509 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt @@ -1,7 +1,7 @@ package com.mealkitary.address -import com.mealkitary.shop.domain.shop.address.Address -import com.mealkitary.shop.domain.shop.address.Coordinates +import com.mealkitary.common.model.Address +import com.mealkitary.common.model.Coordinates import com.mealkitary.shop.domain.shop.address.ShopAddress import com.mealkitary.shop.domain.shop.factory.AddressResolver import org.springframework.stereotype.Component From 65a2a07b8ec70178debfa54e901af19decf1ef12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Thu, 5 Oct 2023 03:18:26 +0900 Subject: [PATCH 12/13] =?UTF-8?q?refactor:=20=EB=88=84=EB=9D=BD=EB=90=9C?= =?UTF-8?q?=20`@Component`=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mealkitary/shop/domain/shop/factory/ShopFactory.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt index 0c80427..da6efee 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/shop/domain/shop/factory/ShopFactory.kt @@ -6,8 +6,10 @@ import com.mealkitary.shop.domain.shop.ShopBusinessNumber import com.mealkitary.shop.domain.shop.ShopStatus import com.mealkitary.shop.domain.shop.ShopTitle import com.mealkitary.shop.domain.shop.address.ShopAddress +import org.springframework.stereotype.Component import java.time.LocalTime +@Component class ShopFactory( private val shopBusinessNumberValidator: ShopBusinessNumberValidator, private val addressResolver: AddressResolver From 621ebd70feb23968fd90426dc8c22857fbdb142f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8B=E1=85=B3=E1=86=AB?= =?UTF-8?q?=E1=84=8C=E1=85=B5?= Date: Thu, 5 Oct 2023 03:22:52 +0900 Subject: [PATCH 13/13] =?UTF-8?q?fix:=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EC=8A=A4=EC=BA=94=20=EB=AF=B8=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mealkitary/PersistenceIntegrationTestSupport.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mealkitary-infrastructure/adapter-persistence-spring-data-jpa/src/test/kotlin/com/mealkitary/PersistenceIntegrationTestSupport.kt b/mealkitary-infrastructure/adapter-persistence-spring-data-jpa/src/test/kotlin/com/mealkitary/PersistenceIntegrationTestSupport.kt index f6b6d25..1bdfea1 100644 --- a/mealkitary-infrastructure/adapter-persistence-spring-data-jpa/src/test/kotlin/com/mealkitary/PersistenceIntegrationTestSupport.kt +++ b/mealkitary-infrastructure/adapter-persistence-spring-data-jpa/src/test/kotlin/com/mealkitary/PersistenceIntegrationTestSupport.kt @@ -4,6 +4,7 @@ import com.mealkitary.reservation.application.service.AcceptReservationService import com.mealkitary.reservation.application.service.PayReservationService import com.mealkitary.reservation.application.service.RejectReservationService import com.mealkitary.shop.application.service.RegisterShopService +import com.mealkitary.shop.domain.shop.factory.ShopFactory import com.ninjasquad.springmockk.MockkBean import io.kotest.core.spec.style.AnnotationSpec import io.kotest.extensions.spring.SpringExtension @@ -36,4 +37,7 @@ abstract class PersistenceIntegrationTestSupport : AnnotationSpec() { @MockkBean private lateinit var registerShopService: RegisterShopService + + @MockkBean + private lateinit var shopFactory: ShopFactory }