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 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-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 9245697..97dab4a 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 @@ -76,7 +76,7 @@ class RegisterShopServiceTest : AnnotationSpec() { } throws IllegalArgumentException("올바른 가게 이름 형식이 아닙니다.(한글, 영문, 공백, 숫자만 포함 가능)") every { saveShopPort.saveOne(any()) } answers { UUID.randomUUID() } 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 76a34b5..a79b7fc 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.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 1e37835..262d6bb 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 0f80762..a63526c 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/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"))) -} 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/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..6a5e1b1 --- /dev/null +++ b/mealkitary-infrastructure/adapter-address-resolver/kakao-api-address-resolver/src/main/kotlin/com/mealkitary/address/KakaoApiAddressResolver.kt @@ -0,0 +1,39 @@ +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, y, address, roadAddress) = kakaoApiAddressResponse.document + + val (longitude, latitude) = listOf(x, y).map { + it.toDoubleOrNull() ?: throw IllegalArgumentException("유효하지 않은 좌표 범위입니다.") + } + + return ShopAddress.of( + roadAddress.h_code, + Coordinates.of( + longitude, + latitude + ), + 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/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!! + } +} 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..95f800d --- /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 + +data class KakaoApiAddressResponse( + val document: Document +) { + data class Document( + val x: String, + val y: String, + val address: Address, + val road_address: RoadAddress + ) + + data class Address( + val region_1depth_name: String, + val region_2depth_name: String, + val region_3depth_name: String, + ) + + data class RoadAddress( + val road_name: String, + val h_code: String + ) +} 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..78ff0b2 --- /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 + } +} 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" + ) + ) + ) +} 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/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 89% 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 2e57312..4bd5799 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 @@ -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/src/test/kotlin/SimpleAddressResolverTest.kt b/mealkitary-infrastructure/adapter-address-resolver/simple-address-resolver/src/test/kotlin/com/mealkitary/address/SimpleAddressResolverTest.kt similarity index 90% 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..f02606b 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 @@ -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 @@ -14,7 +13,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 +29,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 +45,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 +62,7 @@ class SimpleAddressResolverTest : AnnotationSpec() { val resolver = SimpleAddressResolver() shouldThrow { - resolver.resolveAddress(address) + resolver.resolve(address) } shouldHaveMessage "주소 형식이 올바르지 않습니다." } } 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 {