move neko integration to sub-project

This commit is contained in:
Savosin Denis
2025-06-03 12:57:35 +07:00
parent a8639f8d15
commit 6e91c95e64
10 changed files with 64 additions and 48 deletions

View File

@@ -0,0 +1,7 @@
dependencies {
implementation(rootProject.libs.springFramework.context)
implementation(rootProject.libs.ktor.client.cio)
implementation(rootProject.libs.ktor.client.core)
testImplementation(rootProject.libs.ktor.client.mock)
}

View File

@@ -0,0 +1,12 @@
package com.github.dannecron.demo.edgeintegration.client
import com.github.dannecron.demo.edgeintegration.client.dto.ImagesResponse
import com.github.dannecron.demo.edgeintegration.client.exceptions.RequestException
interface Client {
@Throws(RequestException::class)
fun getCategories(): Set<String>
@Throws(RequestException::class)
fun getImages(category: String, amount: Int): ImagesResponse
}

View File

@@ -1,16 +1,18 @@
package com.github.dannecron.demo.services.neko
package com.github.dannecron.demo.edgeintegration.client
import com.github.dannecron.demo.services.neko.dto.CategoryFormat
import com.github.dannecron.demo.services.neko.dto.ImagesResponse
import com.github.dannecron.demo.services.neko.exceptions.RequestException
import io.ktor.client.*
import io.ktor.client.engine.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import com.github.dannecron.demo.edgeintegration.client.dto.CategoryFormat
import com.github.dannecron.demo.edgeintegration.client.dto.ImagesResponse
import com.github.dannecron.demo.edgeintegration.client.exceptions.RequestException
import io.ktor.client.HttpClient
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsText
import io.ktor.http.path
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.json.Json
import org.springframework.stereotype.Service
@Service
class ClientImpl(
engine: HttpClientEngine,
private val baseUrl: String,

View File

@@ -1,4 +1,4 @@
package com.github.dannecron.demo.services.neko.dto
package com.github.dannecron.demo.edgeintegration.client.dto
import kotlinx.serialization.Serializable

View File

@@ -1,4 +1,4 @@
package com.github.dannecron.demo.services.neko.dto
package com.github.dannecron.demo.edgeintegration.client.dto
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@@ -1,4 +1,4 @@
package com.github.dannecron.demo.services.neko.dto
package com.github.dannecron.demo.edgeintegration.client.dto
import kotlinx.serialization.Serializable

View File

@@ -1,3 +1,3 @@
package com.github.dannecron.demo.services.neko.exceptions
package com.github.dannecron.demo.edgeintegration.client.exceptions
class RequestException(message: String): RuntimeException(message)

View File

@@ -1,14 +1,21 @@
package com.github.dannecron.demo.services.neko
package com.github.dannecron.demo.edgeintegration.client
import com.github.dannecron.demo.BaseUnitTest
import com.github.dannecron.demo.services.neko.exceptions.RequestException
import io.ktor.client.engine.mock.*
import io.ktor.http.*
import io.ktor.utils.io.*
import com.github.dannecron.demo.edgeintegration.client.exceptions.RequestException
import io.ktor.client.engine.mock.MockEngine
import io.ktor.client.engine.mock.respond
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpStatusCode
import io.ktor.http.headersOf
import io.ktor.utils.io.ByteReadChannel
import org.junit.jupiter.api.assertThrows
import kotlin.test.*
import kotlin.test.Test
import kotlin.test.assertContains
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue
class ClientImplTest: BaseUnitTest() {
class ClientImplTest {
@Test
fun getCategories_success() {
val mockEngine = MockEngine { req ->

View File

@@ -23,19 +23,21 @@ micrometer-registry-prometheus = { module = "io.micrometer:micrometer-registry-p
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version = "5.4.0" }
otel-exporter = { module = "io.opentelemetry:opentelemetry-exporter-otlp" }
postgres = { module = "org.postgresql:postgresql", version = "42.7.5" }
spring-aspects = { module = "org.springframework:spring-aspects" }
spring-boot-devtools = { module = "org.springframework.boot:spring-boot-devtools" }
spring-boot-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator", version.ref = "spring-boot" }
spring-boot-starter-actuatorAutoconfigure = { module = "org.springframework.boot:spring-boot-actuator-autoconfigure" }
spring-boot-starter-jdbc = { module = "org.springframework.boot:spring-boot-starter-data-jdbc", version.ref = "spring-boot"}
spring-boot-starter-mustache = { module = "org.springframework.boot:spring-boot-starter-mustache", version.ref = "spring-boot" }
spring-boot-starter-test = { module = "org.springframework.boot:spring-boot-starter-test", version.ref = "spring-boot" }
spring-boot-starter-validation = { module = "org.springframework.boot:spring-boot-starter-validation", version.ref = "spring-boot" }
spring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web", version.ref = "spring-boot" }
spring-cloud-starter-streamKafka = { module = "org.springframework.cloud:spring-cloud-starter-stream-kafka", version.ref = "spring-cloud"}
spring-cloud-stream = { module = "org.springframework.cloud:spring-cloud-stream", version.ref = "spring-cloud"}
spring-cloud-streamTestBinder = { module = "org.springframework.cloud:spring-cloud-stream-test-binder", version.ref = "spring-cloud"}
spring-doc-openapi-starter = "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0"
springFramework-context = { module = "org.springframework:spring-context"}
springFramework-aspects = { module = "org.springframework:spring-aspects" }
springBoot-devtools = { module = "org.springframework.boot:spring-boot-devtools" }
springBoot-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator", version.ref = "spring-boot" }
springBoot-starter-actuatorAutoconfigure = { module = "org.springframework.boot:spring-boot-actuator-autoconfigure" }
springBoot-starter-jdbc = { module = "org.springframework.boot:spring-boot-starter-data-jdbc", version.ref = "spring-boot"}
springBoot-starter-mustache = { module = "org.springframework.boot:spring-boot-starter-mustache", version.ref = "spring-boot" }
springBoot-starter-test = { module = "org.springframework.boot:spring-boot-starter-test", version.ref = "spring-boot" }
springBoot-starter-validation = { module = "org.springframework.boot:spring-boot-starter-validation", version.ref = "spring-boot" }
springBoot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web", version.ref = "spring-boot" }
springCloud-starter-streamKafka = { module = "org.springframework.cloud:spring-cloud-starter-stream-kafka", version.ref = "spring-cloud"}
springCloud-stream = { module = "org.springframework.cloud:spring-cloud-stream", version.ref = "spring-cloud"}
springCloud-streamTestBinder = { module = "org.springframework.cloud:spring-cloud-stream-test-binder", version.ref = "spring-cloud"}
springData-commons = { module = "org.springframework.data:spring-data-commons", version.ref = "spring-boot" }
springDoc-openapi-starter = "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0"
testcontainers = { module = "org.testcontainers:testcontainers", version.ref = "testcontainers"}
testcontainers-junit-jupiter = { module = "org.testcontainers:junit-jupiter", version.ref = "testcontainers"}
testcontainers-postgresql = { module = "org.testcontainers:postgresql", version.ref = "testcontainers"}

View File

@@ -1,14 +0,0 @@
package com.github.dannecron.demo.services.neko
import com.github.dannecron.demo.services.neko.dto.ImagesResponse
import com.github.dannecron.demo.services.neko.exceptions.RequestException
import org.springframework.stereotype.Service
@Service
interface Client {
@Throws(RequestException::class)
fun getCategories(): Set<String>
@Throws(RequestException::class)
fun getImages(category: String, amount: Int): ImagesResponse
}