From 18daf98b0f0e5882159a045798cca03679994da4 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: Fri, 6 Oct 2023 23:57:10 +0900 Subject: [PATCH 01/14] =?UTF-8?q?chore:=20=EC=8B=A0=EA=B7=9C=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EB=B6=84=EC=84=9D=20?= =?UTF-8?q?=EA=B3=BC=EC=A0=95=EC=97=90=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 | 6 ++++-- .github/workflows/mealkitary-test-coverage-automation.yml | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mealkitary-main-develop-ci.yml b/.github/workflows/mealkitary-main-develop-ci.yml index 50aafda..0ac55f9 100644 --- a/.github/workflows/mealkitary-main-develop-ci.yml +++ b/.github/workflows/mealkitary-main-develop-ci.yml @@ -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 @@ -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 diff --git a/.github/workflows/mealkitary-test-coverage-automation.yml b/.github/workflows/mealkitary-test-coverage-automation.yml index 6d94ef1..540a29b 100644 --- a/.github/workflows/mealkitary-test-coverage-automation.yml +++ b/.github/workflows/mealkitary-test-coverage-automation.yml @@ -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 @@ -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 From bb4b3fa9285be3504849dd8abe6acdb0e600beae 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: Fri, 6 Oct 2023 23:57:50 +0900 Subject: [PATCH 02/14] =?UTF-8?q?feat:=20kakao=20api=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=20=EB=B3=80=ED=99=98=EA=B8=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../address/KakaoApiAddressResolver.kt | 38 +++++++++++++++ .../addess/KakaoApiAddressResolverTest.kt | 47 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt create mode 100644 mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiAddressResolverTest.kt diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt new file mode 100644 index 0000000..f337dd4 --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt @@ -0,0 +1,38 @@ +package com.mealkitary.address + +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.context.annotation.Primary +import org.springframework.stereotype.Component + +@Primary +@Component +class KakaoApiAddressResolver( + private val kakaoApiWebClient: KakaoApiWebClient +) : AddressResolver { + + override fun resolve(fullAddress: String): ShopAddress { + val kakaoApiAddressResponse = kakaoApiWebClient.requestAddress(fullAddress) + + val x = kakaoApiAddressResponse.document.x + val y = kakaoApiAddressResponse.document.y + val roadAddress = kakaoApiAddressResponse.document.road_address + val address = kakaoApiAddressResponse.document.address + + return ShopAddress.of( + roadAddress.h_code, + Coordinates.of( + x, + y + ), + Address.of( + address.region_1depth_name, + address.region_2depth_name, + address.region_3depth_name, + roadAddress.road_name + ) + ) + } +} diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiAddressResolverTest.kt new file mode 100644 index 0000000..4bc10b6 --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiAddressResolverTest.kt @@ -0,0 +1,47 @@ +package com.mealkitary.addess + +import com.mealkitary.address.KakaoApiAddressResolver +import com.mealkitary.address.KakaoApiWebClient +import com.mealkitary.address.payload.KakaoApiAddressResponse +import io.kotest.core.spec.style.AnnotationSpec +import io.kotest.matchers.shouldBe +import io.mockk.every +import io.mockk.mockk + +class KakaoApiAddressResolverTest : AnnotationSpec() { + + private val kakaoApiWebClient = mockk() + private val kakaoApiAddressResolver = KakaoApiAddressResolver(kakaoApiWebClient) + + @Test + fun `Kakao API를 통해 해당하는 주소 정보를 받아온다`() { + val address = "경기도 남양주시 다산중앙로82번안길 132-12" + val response = KakaoApiAddressResponse( + document = KakaoApiAddressResponse.Document( + x = "127.166069448936", + y = "37.6120947950094", + address = KakaoApiAddressResponse.Address( + region_1depth_name = "경기", + region_2depth_name = "남양주시", + region_3depth_name = "다산동" + ), + road_address = KakaoApiAddressResponse.RoadAddress( + road_name = "다산중앙로82번안길", + h_code = "4136011200" + ) + ) + ) + + every { kakaoApiWebClient.requestAddress(address) } returns response + + val shopAddress = kakaoApiAddressResolver.resolve(address) + + shopAddress.address.region1DepthName shouldBe "경기" + shopAddress.address.region2DepthName shouldBe "남양주시" + shopAddress.address.region3DepthName shouldBe "다산동" + shopAddress.address.roadName shouldBe "다산중앙로82번안길" + shopAddress.cityCode shouldBe "4136011200" + shopAddress.coordinates.longitude shouldBe "127.166069448936" + shopAddress.coordinates.latitude shouldBe "37.6120947950094" + } +} From 12fdbdb2dd686b5076c11b290ccc1049df9c7f5b 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: Sat, 7 Oct 2023 00:01:23 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20kakao=20api=20webclient=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mealkitary/address/KakaoApiWebClient.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiWebClient.kt diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiWebClient.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiWebClient.kt new file mode 100644 index 0000000..6cc8c9d --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiWebClient.kt @@ -0,0 +1,32 @@ +package com.mealkitary.address + +import com.mealkitary.address.payload.KakaoApiAddressResponse +import org.springframework.beans.factory.annotation.Value +import org.springframework.stereotype.Component +import org.springframework.web.reactive.function.client.WebClient + +private const val KAKAO_API_BASE_URL = "/v2/local/search/address" +private const val FORMAT = "json" + +@Component +class KakaoApiWebClient( + private val webClient: WebClient, + @Value("\${kakaoapi.address.serviceKey}") + private val serviceKey: String, +) { + + fun requestAddress(query: String): KakaoApiAddressResponse { + val kakaoApiAddressResponse = webClient.get() + .uri { uriBuilder -> + uriBuilder.path("$KAKAO_API_BASE_URL.$FORMAT") + .queryParam("query", query) + .build() + } + .header("Authorization", "KakaoAK $serviceKey") + .retrieve() + .bodyToMono(KakaoApiAddressResponse::class.java) + .block() + + return kakaoApiAddressResponse!! + } +} From 5c6cf92c4a62fddb1e041128f94c21f2e04e5d08 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: Sat, 7 Oct 2023 00:01:41 +0900 Subject: [PATCH 04/14] =?UTF-8?q?feat:=20http=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EB=A1=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payload/KakaoApiAddressResponse.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/payload/KakaoApiAddressResponse.kt diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/payload/KakaoApiAddressResponse.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/payload/KakaoApiAddressResponse.kt new file mode 100644 index 0000000..ff7ff9e --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/payload/KakaoApiAddressResponse.kt @@ -0,0 +1,23 @@ +package com.mealkitary.address.payload + +class KakaoApiAddressResponse( + val document: Document +) { + class Document( + val x: String, + val y: String, + val address: Address, + val road_address: RoadAddress + ) + + class Address( + val region_1depth_name: String, + val region_2depth_name: String, + val region_3depth_name: String, + ) + + class RoadAddress( + val road_name: String, + val h_code: String + ) +} From 2f7329d98072ed9e733cb9ebf0ea3b2ae50b16c0 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: Sat, 7 Oct 2023 00:32:11 +0900 Subject: [PATCH 05/14] =?UTF-8?q?chore:=20build.gradle=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=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 --- mealkitary-api/build.gradle.kts | 11 ++++++++++- .../kakao-api-address-resolver/build.gradle.kts | 7 +++++++ .../simple-address-resolver/build.gradle.kts | 3 +++ settings.gradle.kts | 3 ++- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/build.gradle.kts create mode 100644 mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/build.gradle.kts diff --git a/mealkitary-api/build.gradle.kts b/mealkitary-api/build.gradle.kts index ae0108b..23fc584 100644 --- a/mealkitary-api/build.gradle.kts +++ b/mealkitary-api/build.gradle.kts @@ -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", diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/build.gradle.kts b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/build.gradle.kts new file mode 100644 index 0000000..a989f72 --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/build.gradle.kts @@ -0,0 +1,7 @@ +dependencies { + val mockWebServerVersion: String by properties + implementation("org.springframework.boot:spring-boot-starter-webflux") + implementation(project(":mealkitary-domain")) + testImplementation("com.squareup.okhttp3:mockwebserver:$mockWebServerVersion") + testImplementation("io.projectreactor:reactor-test") +} diff --git a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/build.gradle.kts b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/build.gradle.kts new file mode 100644 index 0000000..c685d19 --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/build.gradle.kts @@ -0,0 +1,3 @@ +dependencies { + implementation(project(":mealkitary-domain")) +} diff --git a/settings.gradle.kts b/settings.gradle.kts index fdb87a7..d600a3b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,7 +10,8 @@ include( "mealkitary-infrastructure:adapter-configuration", "mealkitary-infrastructure:adapter-business-registration-number-validator:open-api-brn-validator", "mealkitary-infrastructure:adapter-business-registration-number-validator:simple-brn-validator", - "mealkitary-infrastructure:adapter-address-resolver" + "mealkitary-infrastructure:adapter-address-resolver:kakao-api-address-resolver", + "mealkitary-infrastructure:adapter-address-resolver:simple-address-resolver" ) pluginManagement { From de3ebd8fcc6e8aa0cf4bf238168ffd2c491fc9cb 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: Sat, 7 Oct 2023 00:37:54 +0900 Subject: [PATCH 06/14] =?UTF-8?q?refactor:=20=EC=A2=8C=ED=91=9C=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=EC=9D=84=20String=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=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 | 4 ++-- .../application/service/RegisterShopServiceTest.kt | 2 +- .../service/UpdateShopStatusServiceTest.kt | 12 ++++++------ .../com/mealkitary/common/model/Coordinates.kt | 10 +++++----- .../mealkitary/shop/domain/shop/CoordinatesTest.kt | 8 ++++---- .../mealkitary/shop/domain/shop/ShopAddressTest.kt | 8 ++++---- .../shop/domain/shop/factory/ShopFactoryTest.kt | 8 ++++---- .../src/testFixtures/kotlin/data/ShopTestData.kt | 4 ++-- .../java/com/mealkitary}/SimpleAddressResolver.kt | 4 ++-- .../mealkitary/address}/SimpleAddressResolverTest.kt | 12 ++++++------ 10 files changed, 36 insertions(+), 36 deletions(-) rename mealkitary-infrastructure/adapter-address-resolver/{src/main/kotlin/com/mealkitary/address => simple-address-resolver/src/main/java/com/mealkitary}/SimpleAddressResolver.kt (96%) rename mealkitary-infrastructure/adapter-address-resolver/{src/test/kotlin => simple-address-resolver/src/test/kotlin/com/mealkitary/address}/SimpleAddressResolverTest.kt (87%) 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 90f93eb..df067ec 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 @@ -30,8 +30,8 @@ class GetShopServiceTest : AnnotationSpec() { ShopAddress.of( "1234567890", Coordinates.of( - 126.99599512792346, - 35.976749396987046 + "126.99599512792346", + "35.976749396987046" ), Address.of( "region1DepthName", 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 e61ca1c..98f4daa 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 @@ -67,7 +67,7 @@ class RegisterShopServiceTest : AnnotationSpec() { fun `service unit test - 가게 이름 형식에 맞지 않으면 예외를 발생한다`() { val request = RegisterShopRequest("invalid!#@", "123-23-12345", "경기도 안양시 동안구 벌말로 40") val expectedShopAddress = - ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + ShopAddress.of("1234567890", Coordinates.of("0.0", "0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) every { shopFactory.createOne(any(), any(), any()) 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 d8e47f7..115212a 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 @@ -31,8 +31,8 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopAddress.of( "1234567890", Coordinates.of( - 126.99599512792346, - 35.976749396987046 + "126.99599512792346", + "35.976749396987046" ), Address.of( "region1DepthName", @@ -63,8 +63,8 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopAddress.of( "1234567890", Coordinates.of( - 126.99599512792346, - 35.976749396987046 + "126.99599512792346", + "35.976749396987046" ), Address.of( "region1DepthName", @@ -95,8 +95,8 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopAddress.of( "1234567890", Coordinates.of( - 126.99599512792346, - 35.976749396987046 + "126.99599512792346", + "35.976749396987046" ), Address.of( "region1DepthName", diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt index d11bd0f..005e61c 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt @@ -6,20 +6,20 @@ import javax.persistence.Embeddable @Embeddable class Coordinates( @Column(name = "longitude", nullable = false) - val longitude: Double, + val longitude: String, @Column(name = "latitude", nullable = false) - val latitude: Double + val latitude: String ) { companion object { - fun of(longitude: Double, latitude: Double): Coordinates { + fun of(longitude: String, latitude: String): Coordinates { checkIsCoordinateRange(longitude, latitude) return Coordinates(longitude, latitude) } - private fun checkIsCoordinateRange(longitude: Double, latitude: Double) { - if (longitude !in -180.0..180.0 || latitude !in -90.0..90.0) { + private fun checkIsCoordinateRange(longitude: String, latitude: String) { + if (longitude.toDouble() !in -180.0..180.0 || latitude.toDouble() !in -90.0..90.0) { throw IllegalArgumentException("유효하지 않은 좌표 범위입니다.") } } 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 970576a..f6eb11c 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 @@ -10,8 +10,8 @@ class CoordinatesTest : AnnotationSpec() { @Test fun `범위를 벗어나는 좌표일 경우 예외를 발생한다`() { - val longitude = -188.023 - val latitude = 999.7412 + val longitude = "-188.023" + val latitude = "999.7412" shouldThrow { Coordinates.of(longitude, latitude) @@ -20,8 +20,8 @@ class CoordinatesTest : AnnotationSpec() { @Test fun `올바른 좌표를 입력했을 경우 객체를 생성한다`() { - val longitude = -150.653 - val latitude = 46.492 + val longitude = "-150.653" + val latitude = "46.492" val coordinates = Coordinates.of(longitude, 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 index d490ebd..495f603 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 @@ -14,8 +14,8 @@ class ShopAddressTest : AnnotationSpec() { fun `올바른 값들을 입력했을 경우 객체를 생성할 수 있다`() { val cityCode = "1234567890" val coordinates = Coordinates.of( - -150.653, - 46.492 + "-150.653", + "46.492" ) val address = Address.of( "region1DepthName", @@ -39,8 +39,8 @@ class ShopAddressTest : AnnotationSpec() { fun `지역 코드가 올바르지 않을 경우 예외를 발생한다`() { val cityCode = "25231491723109" val coordinates = Coordinates.of( - -150.653, - 46.492 + "-150.653", + "46.492" ) val address = Address.of( "region1DepthName", 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 709e531..85159dd 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 @@ -26,7 +26,7 @@ class ShopFactoryTest : AnnotationSpec() { @Test fun `실제로 유효한 사업자번호와 가게이름, 주소라면 가게를 생성한다`() { val expectedShopAddress = - ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + ShopAddress.of("1234567890", Coordinates.of("0.0", " 0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) every { shopBusinessNumberValidator.validate(any()) } answers { } every { addressResolver.resolveAddress("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress @@ -41,7 +41,7 @@ class ShopFactoryTest : AnnotationSpec() { @Test fun `가게 이름이 유효하지 않으면 예외를 발생한다`() { val expectedShopAddress = - ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + ShopAddress.of("1234567890", Coordinates.of("0.0", "0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) every { shopBusinessNumberValidator.validate(any()) } answers { } every { addressResolver.resolveAddress("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress @@ -57,8 +57,8 @@ class ShopFactoryTest : AnnotationSpec() { val shopAddress = ShopAddress.of( "1234567890", Coordinates.of( - 127.0, - 40.0 + "127.0", + "40.0" ), Address.of( "경기도", diff --git a/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt b/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt index 968438f..558235a 100644 --- a/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt +++ b/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt @@ -29,8 +29,8 @@ class ShopTestData { private var shopAddress: ShopAddress = ShopAddress.of( "1234567890", Coordinates.of( - 126.99599512792346, - 35.976749396987046 + "126.99599512792346", + "35.976749396987046" ), Address.of( "region1DepthName", diff --git a/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt similarity index 96% rename from mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt rename to mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt index f15e509..5e17a28 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/src/main/kotlin/com/mealkitary/address/SimpleAddressResolver.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt @@ -27,8 +27,8 @@ class SimpleAddressResolver : AddressResolver { return ShopAddress.of( "1234567890", Coordinates.of( - 127.0, - 40.0 + "127.0", + "40.0" ), Address.of( region1DepthName, diff --git a/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt similarity index 87% rename from mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt rename to mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt index 79a6e3e..b3b20a6 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/src/test/kotlin/SimpleAddressResolverTest.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt @@ -17,8 +17,8 @@ class SimpleAddressResolverTest : AnnotationSpec() { val shopAddress = resolver.resolveAddress(address) shopAddress.cityCode shouldBe "1234567890" - shopAddress.coordinates.longitude shouldBe 127.0 - shopAddress.coordinates.latitude shouldBe 40.0 + shopAddress.coordinates.longitude shouldBe "127.0" + shopAddress.coordinates.latitude shouldBe "40.0" shopAddress.address.region1DepthName shouldBe "서울특별시" shopAddress.address.region2DepthName shouldBe "강남구" shopAddress.address.region3DepthName shouldBe "역삼동" @@ -33,8 +33,8 @@ class SimpleAddressResolverTest : AnnotationSpec() { val shopAddress = resolver.resolveAddress(address) shopAddress.cityCode shouldBe "1234567890" - shopAddress.coordinates.longitude shouldBe 127.0 - shopAddress.coordinates.latitude shouldBe 40.0 + shopAddress.coordinates.longitude shouldBe "127.0" + shopAddress.coordinates.latitude shouldBe "40.0" shopAddress.address.region1DepthName shouldBe "경기도" shopAddress.address.region2DepthName shouldBe "남양주시" shopAddress.address.region3DepthName shouldBe "다산동" @@ -49,8 +49,8 @@ class SimpleAddressResolverTest : AnnotationSpec() { val shopAddress = resolver.resolveAddress(address) shopAddress.cityCode shouldBe "1234567890" - shopAddress.coordinates.longitude shouldBe 127.0 - shopAddress.coordinates.latitude shouldBe 40.0 + shopAddress.coordinates.longitude shouldBe "127.0" + shopAddress.coordinates.latitude shouldBe "40.0" shopAddress.address.region1DepthName shouldBe "제주특별자치도" shopAddress.address.region2DepthName shouldBe "한림읍" shopAddress.address.region3DepthName shouldBe "" From 607ec65a219c19acace9805d576b5e3e0a2de000 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: Sat, 7 Oct 2023 00:39:11 +0900 Subject: [PATCH 07/14] =?UTF-8?q?refactor:=20=EC=A2=8C=ED=91=9C=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=EC=9D=84=20String=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/application/service/RegisterShopServiceTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 98f4daa..951d1da 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 @@ -36,7 +36,7 @@ class RegisterShopServiceTest : AnnotationSpec() { val shopSlot = slot() val request = RegisterShopRequest("집밥뚝딱 안양점", "123-23-12345", "경기도 안양시 동안구 벌말로 40") val expectedShopAddress = - ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + ShopAddress.of("1234567890", Coordinates.of("0.0", "0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) val mockedShop = Shop( ShopTitle.from(request.title), From a9636e6ab4e02c23d968cd17f73eff90c8521f71 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: Sat, 7 Oct 2023 00:42:00 +0900 Subject: [PATCH 08/14] =?UTF-8?q?refactor:=20=EC=A3=BC=EC=86=8C=20?= =?UTF-8?q?=EB=B3=80=ED=99=98=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/application/service/RegisterShopServiceTest.kt | 2 +- .../shop/domain/shop/factory/AddressResolver.kt | 2 +- .../mealkitary/shop/domain/shop/factory/ShopFactory.kt | 4 ++-- .../shop/domain/shop/factory/ShopFactoryTest.kt | 6 +++--- .../src/main/java/com/mealkitary/SimpleAddressResolver.kt | 6 +++--- .../com/mealkitary/address/SimpleAddressResolverTest.kt | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) 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 951d1da..c06cff7 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 @@ -74,7 +74,7 @@ class RegisterShopServiceTest : AnnotationSpec() { } throws IllegalArgumentException("올바른 가게 이름 형식이 아닙니다.(한글, 영문, 공백, 숫자만 포함 가능)") every { saveShopPort.saveOne(any()) } answers { 1L } every { shopBusinessNumberValidator.validate(any()) } answers {} - every { addressResolver.resolveAddress("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress + every { addressResolver.resolve("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress shouldThrow { registerShopService.register(request) 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 index 83c3e12..70cb6e8 100644 --- 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 @@ -4,5 +4,5 @@ import com.mealkitary.shop.domain.shop.address.ShopAddress interface AddressResolver { - fun resolveAddress(address: String): ShopAddress + fun resolve(fullAddress: 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 da6efee..a1d52ab 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 @@ -15,10 +15,10 @@ class ShopFactory( private val addressResolver: AddressResolver ) { - fun createOne(title: String, brn: String, address: String): Shop { + fun createOne(title: String, brn: String, fullAddress: String): Shop { val shopBusinessNumber = ShopBusinessNumber.from(brn) - val shopAddress: ShopAddress = addressResolver.resolveAddress(address) + val shopAddress: ShopAddress = addressResolver.resolve(fullAddress) shopBusinessNumberValidator.validate(shopBusinessNumber) 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 85159dd..b83b9b9 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 @@ -29,7 +29,7 @@ class ShopFactoryTest : AnnotationSpec() { ShopAddress.of("1234567890", Coordinates.of("0.0", " 0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) every { shopBusinessNumberValidator.validate(any()) } answers { } - every { addressResolver.resolveAddress("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress + every { addressResolver.resolve("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress val shop = shopFactory.createOne("집밥뚝딱 안양점", "321-23-12345", "경기도 안양시 동안구 벌말로 40") @@ -44,7 +44,7 @@ class ShopFactoryTest : AnnotationSpec() { ShopAddress.of("1234567890", Coordinates.of("0.0", "0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) every { shopBusinessNumberValidator.validate(any()) } answers { } - every { addressResolver.resolveAddress("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress + every { addressResolver.resolve("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress shouldThrow { shopFactory.createOne("집밥뚝딱 ! 안양점", "321-23-12345", "경기도 안양시 동안구 벌말로 40") @@ -69,7 +69,7 @@ class ShopFactoryTest : AnnotationSpec() { ) every { shopBusinessNumberValidator.validate(any()) } answers { } - every { addressResolver.resolveAddress(address) } answers { shopAddress } + every { addressResolver.resolve(address) } answers { shopAddress } shouldThrow { shopFactory.createOne("집밥뚝딱 ! 안양점", "321-23-12345", "경기도 안양시 동안구 벌말로 40") diff --git a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt index 5e17a28..8659103 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt @@ -1,4 +1,4 @@ -package com.mealkitary.address +package com.mealkitary import com.mealkitary.common.model.Address import com.mealkitary.common.model.Coordinates @@ -11,8 +11,8 @@ private const val ADDRESS_MIN_LENGTH = 2 @Component class SimpleAddressResolver : AddressResolver { - override fun resolveAddress(address: String): ShopAddress { - val value = address.split(" ") + override fun resolve(fullAddress: String): ShopAddress { + val value = fullAddress.split(" ") if (value.size < ADDRESS_MIN_LENGTH) { throw IllegalArgumentException("주소 형식이 올바르지 않습니다.") diff --git a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt index b3b20a6..ece85f6 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt @@ -14,7 +14,7 @@ class SimpleAddressResolverTest : AnnotationSpec() { val address = "서울특별시 강남구 역삼동 논현로" val resolver = SimpleAddressResolver() - val shopAddress = resolver.resolveAddress(address) + val shopAddress = resolver.resolve(address) shopAddress.cityCode shouldBe "1234567890" shopAddress.coordinates.longitude shouldBe "127.0" @@ -30,7 +30,7 @@ class SimpleAddressResolverTest : AnnotationSpec() { val address = "경기도 남양주시 다산동" val resolver = SimpleAddressResolver() - val shopAddress = resolver.resolveAddress(address) + val shopAddress = resolver.resolve(address) shopAddress.cityCode shouldBe "1234567890" shopAddress.coordinates.longitude shouldBe "127.0" @@ -46,7 +46,7 @@ class SimpleAddressResolverTest : AnnotationSpec() { val address = "제주특별자치도 한림읍" val resolver = SimpleAddressResolver() - val shopAddress = resolver.resolveAddress(address) + val shopAddress = resolver.resolve(address) shopAddress.cityCode shouldBe "1234567890" shopAddress.coordinates.longitude shouldBe "127.0" @@ -63,7 +63,7 @@ class SimpleAddressResolverTest : AnnotationSpec() { val resolver = SimpleAddressResolver() shouldThrow { - resolver.resolveAddress(address) + resolver.resolve(address) } shouldHaveMessage "주소 형식이 올바르지 않습니다." } } From 0d24cff04affcc31cb14748b6378ee2bf803948c 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: Sat, 7 Oct 2023 10:56:23 +0900 Subject: [PATCH 09/14] =?UTF-8?q?refactor:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=ED=81=B4=EB=9E=98=EC=8A=A4=EC=97=90=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt index ece85f6..eaa6865 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt @@ -1,12 +1,11 @@ package com.mealkitary.address +import com.mealkitary.SimpleAddressResolver 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 From e161e7543e9215049585fd0232f006427c3c384b 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: Sat, 7 Oct 2023 10:57:15 +0900 Subject: [PATCH 10/14] =?UTF-8?q?test:=20kakao=20api=20webclient=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addess/KakaoApiWebClientTest.kt | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiWebClientTest.kt diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiWebClientTest.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiWebClientTest.kt new file mode 100644 index 0000000..84bd7e7 --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiWebClientTest.kt @@ -0,0 +1,105 @@ +package com.mealkitary.addess + +import com.fasterxml.jackson.databind.ObjectMapper +import com.mealkitary.address.KakaoApiWebClient +import com.mealkitary.address.payload.KakaoApiAddressResponse +import io.kotest.assertions.throwables.shouldThrow +import io.kotest.inspectors.forAll +import io.kotest.matchers.shouldBe +import okhttp3.mockwebserver.MockResponse +import okhttp3.mockwebserver.MockWebServer +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.springframework.http.HttpHeaders +import org.springframework.http.MediaType +import org.springframework.web.reactive.function.client.WebClient +import java.lang.RuntimeException + +class KakaoApiWebClientTest { + + private lateinit var mockWebServer: MockWebServer + private lateinit var webClient: WebClient + private lateinit var kakaoApiWebClient: KakaoApiWebClient + private val objectMapper = ObjectMapper() + + @BeforeEach + fun setUp() { + mockWebServer = MockWebServer() + mockWebServer.start() + webClient = WebClient.builder() + .baseUrl(mockWebServer.url("").toString()) + .codecs { configurer -> + configurer.defaultCodecs().maxInMemorySize(5 * 1024 * 1024) + } + .defaultHeaders { headers -> + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE) + } + .build() + + kakaoApiWebClient = KakaoApiWebClient(webClient, "serviceKey") + } + + @AfterEach + fun teardown() { + mockWebServer.shutdown() + } + + @Test + fun `200 OK를 받으면 아무 예외도 발생하지 않는다`() { + val address = "경기도 남양주시 다산중앙로82번안길 132-12" + val response = createResponse() + + mockWebServer.enqueue( + MockResponse() + .setBody(objectMapper.writeValueAsString(response)) + .setResponseCode(200) + .addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + ) + + val actualResponse = kakaoApiWebClient.requestAddress(address) + + val recordedRequest = mockWebServer.takeRequest() + recordedRequest.method shouldBe "GET" + + actualResponse.document.road_address.h_code shouldBe response.document.road_address.h_code + actualResponse.document.x shouldBe response.document.x + actualResponse.document.y shouldBe response.document.y + actualResponse.document.address.region_1depth_name shouldBe response.document.address.region_1depth_name + actualResponse.document.address.region_2depth_name shouldBe response.document.address.region_2depth_name + actualResponse.document.address.region_3depth_name shouldBe response.document.address.region_3depth_name + actualResponse.document.road_address.road_name shouldBe response.document.road_address.road_name + } + + @Test + fun `200이 아닌 코드는 RuntimeException으로 처리한다`() { + listOf(400, 401, 500).forAll { + mockWebServer.enqueue( + MockResponse() + .setResponseCode(it) + .setBody(objectMapper.writeValueAsString(createResponse())) + .addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + ) + shouldThrow { + kakaoApiWebClient.requestAddress("경기도남양주시다산중앙로82번안길132-12") + } + } + } + + private fun createResponse() = KakaoApiAddressResponse( + document = KakaoApiAddressResponse.Document( + x = "127.166069448936", + y = "37.6120947950094", + address = KakaoApiAddressResponse.Address( + region_1depth_name = "경기", + region_2depth_name = "남양주시", + region_3depth_name = "다산동" + ), + road_address = KakaoApiAddressResponse.RoadAddress( + road_name = "다산중앙로82번안길", + h_code = "4136011200" + ) + ) + ) +} From 14990ea27cfc7643201022360e9969e6c08c91ab Mon Sep 17 00:00:00 2001 From: le2sky Date: Sat, 7 Oct 2023 22:09:33 +0900 Subject: [PATCH 11/14] =?UTF-8?q?fix=20:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=84=A4=EC=A0=95=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter-address-resolver/build.gradle.kts | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 mealkitary-infrastructure/adapter-address-resolver/build.gradle.kts diff --git a/mealkitary-infrastructure/adapter-address-resolver/build.gradle.kts b/mealkitary-infrastructure/adapter-address-resolver/build.gradle.kts deleted file mode 100644 index fb0ef72..0000000 --- a/mealkitary-infrastructure/adapter-address-resolver/build.gradle.kts +++ /dev/null @@ -1,4 +0,0 @@ -dependencies { - implementation(project(":mealkitary-domain")) - testImplementation(testFixtures(project(":mealkitary-domain"))) -} From cea83b2e4d1cba9c7de3e696d05e42c40a57f679 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, 11 Oct 2023 19:41:02 +0900 Subject: [PATCH 12/14] =?UTF-8?q?refactor:=20=EA=B5=AC=EC=A1=B0=20?= =?UTF-8?q?=EB=B6=84=ED=95=B4=20=EC=84=A0=EC=96=B8=EC=9D=84=20=ED=86=B5?= =?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mealkitary/address/KakaoApiAddressResolver.kt | 5 +---- .../mealkitary/address/payload/KakaoApiAddressResponse.kt | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt index f337dd4..c4e6259 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt @@ -16,10 +16,7 @@ class KakaoApiAddressResolver( override fun resolve(fullAddress: String): ShopAddress { val kakaoApiAddressResponse = kakaoApiWebClient.requestAddress(fullAddress) - val x = kakaoApiAddressResponse.document.x - val y = kakaoApiAddressResponse.document.y - val roadAddress = kakaoApiAddressResponse.document.road_address - val address = kakaoApiAddressResponse.document.address + val (x, y, address, roadAddress) = kakaoApiAddressResponse.document return ShopAddress.of( roadAddress.h_code, diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/payload/KakaoApiAddressResponse.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/payload/KakaoApiAddressResponse.kt index ff7ff9e..95f800d 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/payload/KakaoApiAddressResponse.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/payload/KakaoApiAddressResponse.kt @@ -1,22 +1,22 @@ package com.mealkitary.address.payload -class KakaoApiAddressResponse( +data class KakaoApiAddressResponse( val document: Document ) { - class Document( + data class Document( val x: String, val y: String, val address: Address, val road_address: RoadAddress ) - class Address( + data class Address( val region_1depth_name: String, val region_2depth_name: String, val region_3depth_name: String, ) - class RoadAddress( + data class RoadAddress( val road_name: String, val h_code: String ) From 66d15093034419b4e7bf15803d37291b9d7ad09a 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, 11 Oct 2023 20:06:03 +0900 Subject: [PATCH 13/14] =?UTF-8?q?refactor:=20=EC=A0=80=EC=9E=A5=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EC=A2=8C=ED=91=9C=20=ED=83=80=EC=9E=85=EC=9D=84=20?= =?UTF-8?q?Double=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/mealkitary/common/model/Coordinates.kt | 10 +++++----- .../com/mealkitary/address/KakaoApiAddressResolver.kt | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt b/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt index 005e61c..d11bd0f 100644 --- a/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt +++ b/mealkitary-domain/src/main/kotlin/com/mealkitary/common/model/Coordinates.kt @@ -6,20 +6,20 @@ import javax.persistence.Embeddable @Embeddable class Coordinates( @Column(name = "longitude", nullable = false) - val longitude: String, + val longitude: Double, @Column(name = "latitude", nullable = false) - val latitude: String + val latitude: Double ) { companion object { - fun of(longitude: String, latitude: String): Coordinates { + fun of(longitude: Double, latitude: Double): Coordinates { checkIsCoordinateRange(longitude, latitude) return Coordinates(longitude, latitude) } - private fun checkIsCoordinateRange(longitude: String, latitude: String) { - if (longitude.toDouble() !in -180.0..180.0 || latitude.toDouble() !in -90.0..90.0) { + private fun checkIsCoordinateRange(longitude: Double, latitude: Double) { + if (longitude !in -180.0..180.0 || latitude !in -90.0..90.0) { throw IllegalArgumentException("유효하지 않은 좌표 범위입니다.") } } diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt index c4e6259..6a5e1b1 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt @@ -18,11 +18,15 @@ class KakaoApiAddressResolver( val (x, y, address, roadAddress) = kakaoApiAddressResponse.document + val (longitude, latitude) = listOf(x, y).map { + it.toDoubleOrNull() ?: throw IllegalArgumentException("유효하지 않은 좌표 범위입니다.") + } + return ShopAddress.of( roadAddress.h_code, Coordinates.of( - x, - y + longitude, + latitude ), Address.of( address.region_1depth_name, From 5cd6b713f1ac711fe7c7d4c89e960e5f47df98d6 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, 12 Oct 2023 00:37:31 +0900 Subject: [PATCH 14/14] =?UTF-8?q?test:=20=EB=B3=80=EA=B2=BD=EB=90=9C=20?= =?UTF-8?q?=EC=A2=8C=ED=91=9C=20=ED=83=80=EC=9E=85=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/application/service/GetShopServiceTest.kt | 4 ++-- .../application/service/RegisterShopServiceTest.kt | 4 ++-- .../service/UpdateShopStatusServiceTest.kt | 12 ++++++------ .../mealkitary/shop/domain/shop/CoordinatesTest.kt | 8 ++++---- .../mealkitary/shop/domain/shop/ShopAddressTest.kt | 8 ++++---- .../shop/domain/shop/factory/ShopFactoryTest.kt | 8 ++++---- .../src/testFixtures/kotlin/data/ShopTestData.kt | 4 ++-- .../mealkitary/addess/KakaoApiAddressResolverTest.kt | 4 ++-- .../java/com/mealkitary/SimpleAddressResolver.kt | 4 ++-- .../mealkitary/address/SimpleAddressResolverTest.kt | 12 ++++++------ 10 files changed, 34 insertions(+), 34 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 df067ec..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 @@ -30,8 +30,8 @@ class GetShopServiceTest : AnnotationSpec() { ShopAddress.of( "1234567890", Coordinates.of( - "126.99599512792346", - "35.976749396987046" + 126.99599512792346, + 35.976749396987046 ), Address.of( "region1DepthName", 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 c06cff7..b3b57b5 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 @@ -36,7 +36,7 @@ class RegisterShopServiceTest : AnnotationSpec() { val shopSlot = slot() val request = RegisterShopRequest("집밥뚝딱 안양점", "123-23-12345", "경기도 안양시 동안구 벌말로 40") val expectedShopAddress = - ShopAddress.of("1234567890", Coordinates.of("0.0", "0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) val mockedShop = Shop( ShopTitle.from(request.title), @@ -67,7 +67,7 @@ class RegisterShopServiceTest : AnnotationSpec() { fun `service unit test - 가게 이름 형식에 맞지 않으면 예외를 발생한다`() { val request = RegisterShopRequest("invalid!#@", "123-23-12345", "경기도 안양시 동안구 벌말로 40") val expectedShopAddress = - ShopAddress.of("1234567890", Coordinates.of("0.0", "0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) every { shopFactory.createOne(any(), any(), any()) 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 115212a..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 @@ -31,8 +31,8 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopAddress.of( "1234567890", Coordinates.of( - "126.99599512792346", - "35.976749396987046" + 126.99599512792346, + 35.976749396987046 ), Address.of( "region1DepthName", @@ -63,8 +63,8 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopAddress.of( "1234567890", Coordinates.of( - "126.99599512792346", - "35.976749396987046" + 126.99599512792346, + 35.976749396987046 ), Address.of( "region1DepthName", @@ -95,8 +95,8 @@ class UpdateShopStatusServiceTest : AnnotationSpec() { ShopAddress.of( "1234567890", Coordinates.of( - "126.99599512792346", - "35.976749396987046" + 126.99599512792346, + 35.976749396987046 ), Address.of( "region1DepthName", 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 f6eb11c..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 @@ -10,8 +10,8 @@ class CoordinatesTest : AnnotationSpec() { @Test fun `범위를 벗어나는 좌표일 경우 예외를 발생한다`() { - val longitude = "-188.023" - val latitude = "999.7412" + val longitude = -188.023 + val latitude = 999.7412 shouldThrow { Coordinates.of(longitude, latitude) @@ -20,8 +20,8 @@ class CoordinatesTest : AnnotationSpec() { @Test fun `올바른 좌표를 입력했을 경우 객체를 생성한다`() { - val longitude = "-150.653" - val latitude = "46.492" + val longitude = -150.653 + val latitude = 46.492 val coordinates = Coordinates.of(longitude, 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 index 495f603..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 @@ -14,8 +14,8 @@ class ShopAddressTest : AnnotationSpec() { fun `올바른 값들을 입력했을 경우 객체를 생성할 수 있다`() { val cityCode = "1234567890" val coordinates = Coordinates.of( - "-150.653", - "46.492" + -150.653, + 46.492 ) val address = Address.of( "region1DepthName", @@ -39,8 +39,8 @@ class ShopAddressTest : AnnotationSpec() { fun `지역 코드가 올바르지 않을 경우 예외를 발생한다`() { val cityCode = "25231491723109" val coordinates = Coordinates.of( - "-150.653", - "46.492" + -150.653, + 46.492 ) val address = Address.of( "region1DepthName", 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 b83b9b9..899d5fa 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 @@ -26,7 +26,7 @@ class ShopFactoryTest : AnnotationSpec() { @Test fun `실제로 유효한 사업자번호와 가게이름, 주소라면 가게를 생성한다`() { val expectedShopAddress = - ShopAddress.of("1234567890", Coordinates.of("0.0", " 0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) every { shopBusinessNumberValidator.validate(any()) } answers { } every { addressResolver.resolve("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress @@ -41,7 +41,7 @@ class ShopFactoryTest : AnnotationSpec() { @Test fun `가게 이름이 유효하지 않으면 예외를 발생한다`() { val expectedShopAddress = - ShopAddress.of("1234567890", Coordinates.of("0.0", "0.0"), Address.of("경기도", "안양시 동안구", "벌말로", "40")) + ShopAddress.of("1234567890", Coordinates.of(0.0, 0.0), Address.of("경기도", "안양시 동안구", "벌말로", "40")) every { shopBusinessNumberValidator.validate(any()) } answers { } every { addressResolver.resolve("경기도 안양시 동안구 벌말로 40") } returns expectedShopAddress @@ -57,8 +57,8 @@ class ShopFactoryTest : AnnotationSpec() { val shopAddress = ShopAddress.of( "1234567890", Coordinates.of( - "127.0", - "40.0" + 127.0, + 40.0 ), Address.of( "경기도", diff --git a/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt b/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt index 558235a..968438f 100644 --- a/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt +++ b/mealkitary-domain/src/testFixtures/kotlin/data/ShopTestData.kt @@ -29,8 +29,8 @@ class ShopTestData { private var shopAddress: ShopAddress = ShopAddress.of( "1234567890", Coordinates.of( - "126.99599512792346", - "35.976749396987046" + 126.99599512792346, + 35.976749396987046 ), Address.of( "region1DepthName", diff --git a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiAddressResolverTest.kt index 4bc10b6..78ff0b2 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiAddressResolverTest.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/test/kotlin/com/mealkitary/addess/KakaoApiAddressResolverTest.kt @@ -41,7 +41,7 @@ class KakaoApiAddressResolverTest : AnnotationSpec() { shopAddress.address.region3DepthName shouldBe "다산동" shopAddress.address.roadName shouldBe "다산중앙로82번안길" shopAddress.cityCode shouldBe "4136011200" - shopAddress.coordinates.longitude shouldBe "127.166069448936" - shopAddress.coordinates.latitude shouldBe "37.6120947950094" + shopAddress.coordinates.longitude shouldBe 127.166069448936 + shopAddress.coordinates.latitude shouldBe 37.6120947950094 } } diff --git a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt index 8659103..90b20dd 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/main/java/com/mealkitary/SimpleAddressResolver.kt @@ -27,8 +27,8 @@ class SimpleAddressResolver : AddressResolver { return ShopAddress.of( "1234567890", Coordinates.of( - "127.0", - "40.0" + 127.0, + 40.0 ), Address.of( region1DepthName, diff --git a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt index eaa6865..f02606b 100644 --- a/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt +++ b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt @@ -16,8 +16,8 @@ class SimpleAddressResolverTest : AnnotationSpec() { val shopAddress = resolver.resolve(address) shopAddress.cityCode shouldBe "1234567890" - shopAddress.coordinates.longitude shouldBe "127.0" - shopAddress.coordinates.latitude shouldBe "40.0" + shopAddress.coordinates.longitude shouldBe 127.0 + shopAddress.coordinates.latitude shouldBe 40.0 shopAddress.address.region1DepthName shouldBe "서울특별시" shopAddress.address.region2DepthName shouldBe "강남구" shopAddress.address.region3DepthName shouldBe "역삼동" @@ -32,8 +32,8 @@ class SimpleAddressResolverTest : AnnotationSpec() { val shopAddress = resolver.resolve(address) shopAddress.cityCode shouldBe "1234567890" - shopAddress.coordinates.longitude shouldBe "127.0" - shopAddress.coordinates.latitude shouldBe "40.0" + shopAddress.coordinates.longitude shouldBe 127.0 + shopAddress.coordinates.latitude shouldBe 40.0 shopAddress.address.region1DepthName shouldBe "경기도" shopAddress.address.region2DepthName shouldBe "남양주시" shopAddress.address.region3DepthName shouldBe "다산동" @@ -48,8 +48,8 @@ class SimpleAddressResolverTest : AnnotationSpec() { val shopAddress = resolver.resolve(address) shopAddress.cityCode shouldBe "1234567890" - shopAddress.coordinates.longitude shouldBe "127.0" - shopAddress.coordinates.latitude shouldBe "40.0" + shopAddress.coordinates.longitude shouldBe 127.0 + shopAddress.coordinates.latitude shouldBe 40.0 shopAddress.address.region1DepthName shouldBe "제주특별자치도" shopAddress.address.region2DepthName shouldBe "한림읍" shopAddress.address.region3DepthName shouldBe ""