rename project

This commit is contained in:
Denis Savosin
2024-10-15 13:23:57 +07:00
parent 0a38f7fdd8
commit 5be84b4b1a
96 changed files with 333 additions and 331 deletions

View File

@@ -10,7 +10,7 @@ plugins {
kotlin("plugin.spring") version "1.9.23"
}
group = "com.example"
group = "com.github.dannecron.demo"
version = "single-version"
java {

View File

@@ -1,3 +0,0 @@
package com.example.demo.http.exceptions
class NotFoundException: RuntimeException()

View File

@@ -1,3 +0,0 @@
package com.example.demo.http.exceptions
class UnprocessableException(override val message: String): RuntimeException(message)

View File

@@ -1,3 +0,0 @@
package com.example.demo.http.responses
class NotFoundResponse: BaseResponse(ResponseStatus.NOT_FOUND)

View File

@@ -1,7 +0,0 @@
package com.example.demo.providers
import com.example.demo.models.Shop
interface ShopProvider {
fun getRandomShop(): Shop?
}

View File

@@ -1,3 +0,0 @@
package com.example.demo.providers.html
class Center: Tag("center")

View File

@@ -1,12 +0,0 @@
package com.example.demo.providers.html
class Html: Tag("html")
fun html(init: Html.() -> Unit): Html {
val tag = Html()
tag.init()
return tag
}
fun Html.table(init : Table.() -> Unit) = doInit(Table(), init)
fun Html.center(init : Center.() -> Unit) = doInit(Center(), init)

View File

@@ -1,3 +0,0 @@
package com.example.demo.providers.html
class TD: Tag("td")

View File

@@ -1,19 +0,0 @@
package com.example.demo.services.database.city
import com.example.demo.models.City
import com.example.demo.services.database.exceptions.CityNotFoundException
import com.example.demo.services.database.exceptions.AlreadyDeletedException
import com.example.demo.services.kafka.dto.CityCreateDto
import org.springframework.stereotype.Service
import java.util.*
@Service
interface CityService {
fun findByGuid(guid: UUID): City?
fun create(name: String): City
fun create(kafkaCityDto: CityCreateDto): City
@Throws(CityNotFoundException::class, AlreadyDeletedException::class)
fun delete(guid: UUID): City
}

View File

@@ -1,13 +0,0 @@
package com.example.demo.services.database.customer
import com.example.demo.models.Customer
import com.example.demo.models.CustomerExtended
import com.example.demo.services.database.exceptions.CityNotFoundException
import java.util.*
interface CustomerService {
fun findByGuid(guid: UUID): CustomerExtended?
@Throws(CityNotFoundException::class)
fun create(name: String, cityGuid: UUID?): Customer
}

View File

@@ -1,3 +0,0 @@
package com.example.demo.services.database.exceptions
class AlreadyDeletedException: RuntimeException()

View File

@@ -1,3 +0,0 @@
package com.example.demo.services.database.exceptions
class CityNotFoundException: ModelNotFoundException("city")

View File

@@ -1,9 +0,0 @@
package com.example.demo.services.kafka
import com.example.demo.models.Product
import com.example.demo.services.kafka.exceptions.InvalidArgumentException
interface Producer {
@Throws(InvalidArgumentException::class)
fun produceProductInfo(topicName: String, product: Product)
}

View File

@@ -1,3 +0,0 @@
package com.example.demo.services.kafka.exceptions
class InvalidArgumentException(argName: String): RuntimeException("invalid argument $argName")

View File

@@ -1,3 +0,0 @@
package com.example.demo.services.validation.exceptions
class SchemaNotFoundException: RuntimeException()

View File

@@ -1,4 +1,4 @@
package com.example.demo
package com.github.dannecron.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

View File

@@ -1,17 +1,17 @@
package com.example.demo.config
package com.github.dannecron.demo.config
import com.example.demo.config.properties.KafkaProperties
import com.example.demo.config.properties.ValidationProperties
import com.example.demo.providers.*
import com.example.demo.services.database.city.CityService
import com.example.demo.services.database.city.CityServiceImpl
import com.example.demo.services.database.customer.CustomerService
import com.example.demo.services.database.customer.CustomerServiceImpl
import com.example.demo.services.database.product.ProductService
import com.example.demo.services.database.product.ProductServiceImpl
import com.example.demo.services.kafka.Producer
import com.example.demo.services.validation.SchemaValidator
import com.example.demo.services.validation.SchemaValidatorImp
import com.github.dannecron.demo.config.properties.KafkaProperties
import com.github.dannecron.demo.config.properties.ValidationProperties
import com.github.dannecron.demo.providers.*
import com.github.dannecron.demo.services.database.city.CityService
import com.github.dannecron.demo.services.database.city.CityServiceImpl
import com.github.dannecron.demo.services.database.customer.CustomerService
import com.github.dannecron.demo.services.database.customer.CustomerServiceImpl
import com.github.dannecron.demo.services.database.product.ProductService
import com.github.dannecron.demo.services.database.product.ProductServiceImpl
import com.github.dannecron.demo.services.kafka.Producer
import com.github.dannecron.demo.services.validation.SchemaValidator
import com.github.dannecron.demo.services.validation.SchemaValidatorImp
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
@@ -39,7 +39,7 @@ class AppConfig(
}
@Bean
fun shopProvider(): ShopProvider = MockedShopProvider()
fun shopProvider(): ShopProvider = com.github.dannecron.demo.providers.MockedShopProvider()
@Bean
fun productService(

View File

@@ -1,8 +1,8 @@
package com.example.demo.config
package com.github.dannecron.demo.config
import com.example.demo.config.properties.KafkaProperties
import com.example.demo.services.database.city.CityService
import com.example.demo.services.kafka.Consumer
import com.github.dannecron.demo.config.properties.KafkaProperties
import com.github.dannecron.demo.services.database.city.CityService
import com.github.dannecron.demo.services.kafka.Consumer
import io.micrometer.core.instrument.MeterRegistry
import org.apache.kafka.clients.consumer.ConsumerConfig
import org.apache.kafka.common.serialization.StringDeserializer

View File

@@ -1,9 +1,9 @@
package com.example.demo.config
package com.github.dannecron.demo.config
import com.example.demo.config.properties.KafkaProperties
import com.example.demo.services.kafka.Producer
import com.example.demo.services.kafka.ProducerImpl
import com.example.demo.services.validation.SchemaValidator
import com.github.dannecron.demo.config.properties.KafkaProperties
import com.github.dannecron.demo.services.kafka.Producer
import com.github.dannecron.demo.services.kafka.ProducerImpl
import com.github.dannecron.demo.services.validation.SchemaValidator
import org.apache.kafka.clients.producer.ProducerConfig
import org.apache.kafka.common.serialization.StringSerializer
import org.springframework.beans.factory.annotation.Autowired

View File

@@ -1,4 +1,4 @@
package com.example.demo.config.properties
package com.github.dannecron.demo.config.properties
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.bind.ConstructorBinding

View File

@@ -1,4 +1,4 @@
package com.example.demo.config.properties
package com.github.dannecron.demo.config.properties
import org.springframework.boot.context.properties.ConfigurationProperties

View File

@@ -1,7 +1,7 @@
package com.example.demo.http.controllers
package com.github.dannecron.demo.http.controllers
import com.example.demo.http.exceptions.NotFoundException
import com.example.demo.services.database.customer.CustomerService
import com.github.dannecron.demo.http.exceptions.NotFoundException
import com.github.dannecron.demo.services.database.customer.CustomerService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType

View File

@@ -1,6 +1,6 @@
package com.example.demo.http.controllers
package com.github.dannecron.demo.http.controllers
import com.example.demo.providers.html.renderProductTable
import com.github.dannecron.demo.providers.html.renderProductTable
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController

View File

@@ -1,16 +1,16 @@
package com.example.demo.http.controllers
package com.github.dannecron.demo.http.controllers
import com.example.demo.http.exceptions.NotFoundException
import com.example.demo.http.exceptions.UnprocessableException
import com.example.demo.http.requests.CreateProductRequest
import com.example.demo.http.responses.NotFoundResponse
import com.example.demo.http.responses.makeOkResponse
import com.example.demo.http.responses.page.PageResponse
import com.example.demo.models.Product
import com.example.demo.services.database.exceptions.AlreadyDeletedException
import com.example.demo.services.database.product.ProductService
import com.example.demo.services.database.exceptions.ProductNotFoundException
import com.example.demo.services.kafka.exceptions.InvalidArgumentException
import com.github.dannecron.demo.http.exceptions.NotFoundException
import com.github.dannecron.demo.http.exceptions.UnprocessableException
import com.github.dannecron.demo.http.requests.CreateProductRequest
import com.github.dannecron.demo.http.responses.NotFoundResponse
import com.github.dannecron.demo.http.responses.makeOkResponse
import com.github.dannecron.demo.http.responses.page.PageResponse
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.services.database.exceptions.AlreadyDeletedException
import com.github.dannecron.demo.services.database.product.ProductService
import com.github.dannecron.demo.services.database.exceptions.ProductNotFoundException
import com.github.dannecron.demo.services.kafka.exceptions.InvalidArgumentException
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.responses.ApiResponse

View File

@@ -1,7 +1,7 @@
package com.example.demo.http.controllers
package com.github.dannecron.demo.http.controllers
import com.example.demo.http.exceptions.NotFoundException
import com.example.demo.providers.ShopProvider
import com.github.dannecron.demo.http.exceptions.NotFoundException
import com.github.dannecron.demo.providers.ShopProvider
import jakarta.servlet.http.HttpServletResponse
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToJsonElement

View File

@@ -1,8 +1,8 @@
package com.example.demo.http.exceptions
package com.github.dannecron.demo.http.exceptions
import com.example.demo.http.responses.BadRequestResponse
import com.example.demo.http.responses.NotFoundResponse
import com.example.demo.http.responses.UnprocessableResponse
import com.github.dannecron.demo.http.responses.BadRequestResponse
import com.github.dannecron.demo.http.responses.NotFoundResponse
import com.github.dannecron.demo.http.responses.UnprocessableResponse
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.http.converter.HttpMessageNotReadableException

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.http.exceptions
class NotFoundException: RuntimeException()

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.http.exceptions
class UnprocessableException(override val message: String): RuntimeException(message)

View File

@@ -1,4 +1,4 @@
package com.example.demo.http.requests
package com.github.dannecron.demo.http.requests
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotBlank

View File

@@ -1,4 +1,4 @@
package com.example.demo.http.responses
package com.github.dannecron.demo.http.responses
data class BadRequestResponse(
val cause: String,

View File

@@ -1,4 +1,4 @@
package com.example.demo.http.responses
package com.github.dannecron.demo.http.responses
open class BaseResponse(val status: ResponseStatus)

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.http.responses
class NotFoundResponse: BaseResponse(ResponseStatus.NOT_FOUND)

View File

@@ -1,4 +1,4 @@
package com.example.demo.http.responses
package com.github.dannecron.demo.http.responses
import com.fasterxml.jackson.annotation.JsonValue

View File

@@ -1,4 +1,4 @@
package com.example.demo.http.responses
package com.github.dannecron.demo.http.responses
import org.springframework.validation.ObjectError

View File

@@ -1,4 +1,4 @@
package com.example.demo.http.responses.page
package com.github.dannecron.demo.http.responses.page
import kotlinx.serialization.Serializable

View File

@@ -1,4 +1,4 @@
package com.example.demo.http.responses.page
package com.github.dannecron.demo.http.responses.page
import kotlinx.serialization.Serializable
import org.springframework.data.domain.Page

View File

@@ -1,7 +1,7 @@
package com.example.demo.models
package com.github.dannecron.demo.models
import com.example.demo.services.serializables.OffsetDateTimeSerialization
import com.example.demo.services.serializables.UuidSerialization
import com.github.dannecron.demo.services.serializables.OffsetDateTimeSerialization
import com.github.dannecron.demo.services.serializables.UuidSerialization
import kotlinx.serialization.Serializable
import org.springframework.data.annotation.Id
import org.springframework.data.relational.core.mapping.Column

View File

@@ -1,7 +1,7 @@
package com.example.demo.models
package com.github.dannecron.demo.models
import com.example.demo.services.serializables.OffsetDateTimeSerialization
import com.example.demo.services.serializables.UuidSerialization
import com.github.dannecron.demo.services.serializables.OffsetDateTimeSerialization
import com.github.dannecron.demo.services.serializables.UuidSerialization
import kotlinx.serialization.Serializable
import org.springframework.data.annotation.Id
import org.springframework.data.relational.core.mapping.Column

View File

@@ -1,4 +1,4 @@
package com.example.demo.models
package com.github.dannecron.demo.models
import kotlinx.serialization.Serializable

View File

@@ -1,4 +1,4 @@
package com.example.demo.models
package com.github.dannecron.demo.models
data class CustomerLocal(val name: String, val city: City, val orders: List<Order>) {
/**

View File

@@ -1,3 +1,3 @@
package com.example.demo.models
package com.github.dannecron.demo.models
data class Order(val products: List<Product>, val isDelivered: Boolean)

View File

@@ -1,9 +1,9 @@
package com.example.demo.models
package com.github.dannecron.demo.models
import com.example.demo.services.serializables.OffsetDateTimeSerialization
import com.example.demo.services.serializables.UuidSerialization
import com.example.demo.utils.roundTo
import com.github.dannecron.demo.services.serializables.OffsetDateTimeSerialization
import com.github.dannecron.demo.services.serializables.UuidSerialization
import com.github.dannecron.demo.utils.roundTo
import kotlinx.serialization.Serializable
import org.springframework.data.annotation.Id
import org.springframework.data.relational.core.mapping.Column

View File

@@ -1,4 +1,4 @@
package com.example.demo.models
package com.github.dannecron.demo.models
data class Shop(val name: String, val customers: List<CustomerLocal>) {
fun checkAllCustomersAreFrom(city: City): Boolean = customers.count { cus -> cus.city == city } == customers.count()

View File

@@ -1,6 +1,6 @@
package com.example.demo.providers
package com.github.dannecron.demo.providers
import com.example.demo.models.City
import com.github.dannecron.demo.models.City
import org.springframework.data.jdbc.repository.query.Query
import org.springframework.data.repository.CrudRepository
import org.springframework.data.repository.query.Param

View File

@@ -1,6 +1,6 @@
package com.example.demo.providers
package com.github.dannecron.demo.providers
import com.example.demo.models.Customer
import com.github.dannecron.demo.models.Customer
import org.springframework.data.repository.CrudRepository
import org.springframework.stereotype.Repository
import java.util.*

View File

@@ -1,10 +1,10 @@
package com.example.demo.providers
package com.github.dannecron.demo.providers
import com.example.demo.models.*
import com.github.dannecron.demo.models.*
import java.time.OffsetDateTime
import java.util.*
class MockedShopProvider: ShopProvider {
class MockedShopProvider: com.github.dannecron.demo.providers.ShopProvider {
override fun getRandomShop(): Shop? {
val productOne = makeProduct(id = 1, name = "one", price = 11.2)
val productTwo = makeProduct(id = 2, name = "two", price = 13.2)

View File

@@ -1,6 +1,6 @@
package com.example.demo.providers
package com.github.dannecron.demo.providers
import com.example.demo.models.Product
import com.github.dannecron.demo.models.Product
import org.springframework.data.jdbc.repository.query.Query
import org.springframework.data.repository.CrudRepository
import org.springframework.data.repository.PagingAndSortingRepository

View File

@@ -0,0 +1,7 @@
package com.github.dannecron.demo.providers
import com.github.dannecron.demo.models.Shop
interface ShopProvider {
fun getRandomShop(): Shop?
}

View File

@@ -1,4 +1,4 @@
package com.example.demo.providers.html
package com.github.dannecron.demo.providers.html
class Attribute(val name : String, val value : String) {
override fun toString() = """$name="$value" """

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.providers.html
class Center: Tag("center")

View File

@@ -0,0 +1,14 @@
package com.github.dannecron.demo.providers.html
class Html: com.github.dannecron.demo.providers.html.Tag("html")
fun html(init: com.github.dannecron.demo.providers.html.Html.() -> Unit): com.github.dannecron.demo.providers.html.Html {
val tag = com.github.dannecron.demo.providers.html.Html()
tag.init()
return tag
}
fun com.github.dannecron.demo.providers.html.Html.table(init : com.github.dannecron.demo.providers.html.Table.() -> Unit) = doInit(
com.github.dannecron.demo.providers.html.Table(), init)
fun com.github.dannecron.demo.providers.html.Html.center(init : com.github.dannecron.demo.providers.html.Center.() -> Unit) = doInit(
com.github.dannecron.demo.providers.html.Center(), init)

View File

@@ -1,10 +1,10 @@
package com.example.demo.providers.html
package com.github.dannecron.demo.providers.html
fun getTitleColor() = "#b9c9fe"
fun getCellColor(index: Int, row: Int) = if ((index + row) %2 == 0) "#dce4ff" else "#eff2ff"
fun renderProductTable(): String {
return html {
return com.github.dannecron.demo.providers.html.html {
table {
tr(color = getTitleColor()) {

View File

@@ -1,4 +1,4 @@
package com.example.demo.providers.html
package com.github.dannecron.demo.providers.html
data class InnerProduct(val description: String, val price: Double, val popularity: Int)

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.providers.html
class TD: Tag("td")

View File

@@ -1,4 +1,4 @@
package com.example.demo.providers.html
package com.github.dannecron.demo.providers.html
class TR: Tag("tr")

View File

@@ -1,4 +1,4 @@
package com.example.demo.providers.html
package com.github.dannecron.demo.providers.html
class Table: Tag("table")

View File

@@ -1,4 +1,4 @@
package com.example.demo.providers.html
package com.github.dannecron.demo.providers.html
open class Tag(val name: String) {
val children: MutableList<Tag> = ArrayList()

View File

@@ -1,4 +1,4 @@
package com.example.demo.providers.html
package com.github.dannecron.demo.providers.html
class Text(val text: String): Tag("b") {
override fun toString() = text

View File

@@ -0,0 +1,19 @@
package com.github.dannecron.demo.services.database.city
import com.github.dannecron.demo.models.City
import com.github.dannecron.demo.services.database.exceptions.CityNotFoundException
import com.github.dannecron.demo.services.database.exceptions.AlreadyDeletedException
import com.github.dannecron.demo.services.kafka.dto.CityCreateDto
import org.springframework.stereotype.Service
import java.util.*
@Service
interface CityService {
fun findByGuid(guid: UUID): City?
fun create(name: String): City
fun create(kafkaCityDto: CityCreateDto): City
@Throws(CityNotFoundException::class, AlreadyDeletedException::class)
fun delete(guid: UUID): City
}

View File

@@ -1,10 +1,10 @@
package com.example.demo.services.database.city
package com.github.dannecron.demo.services.database.city
import com.example.demo.models.City
import com.example.demo.providers.CityRepository
import com.example.demo.services.database.exceptions.CityNotFoundException
import com.example.demo.services.database.exceptions.AlreadyDeletedException
import com.example.demo.services.kafka.dto.CityCreateDto
import com.github.dannecron.demo.models.City
import com.github.dannecron.demo.providers.CityRepository
import com.github.dannecron.demo.services.database.exceptions.CityNotFoundException
import com.github.dannecron.demo.services.database.exceptions.AlreadyDeletedException
import com.github.dannecron.demo.services.kafka.dto.CityCreateDto
import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter
import java.util.*

View File

@@ -0,0 +1,13 @@
package com.github.dannecron.demo.services.database.customer
import com.github.dannecron.demo.models.Customer
import com.github.dannecron.demo.models.CustomerExtended
import com.github.dannecron.demo.services.database.exceptions.CityNotFoundException
import java.util.*
interface CustomerService {
fun findByGuid(guid: UUID): CustomerExtended?
@Throws(CityNotFoundException::class)
fun create(name: String, cityGuid: UUID?): Customer
}

View File

@@ -1,10 +1,10 @@
package com.example.demo.services.database.customer
package com.github.dannecron.demo.services.database.customer
import com.example.demo.models.Customer
import com.example.demo.models.CustomerExtended
import com.example.demo.providers.CityRepository
import com.example.demo.providers.CustomerRepository
import com.example.demo.services.database.exceptions.CityNotFoundException
import com.github.dannecron.demo.models.Customer
import com.github.dannecron.demo.models.CustomerExtended
import com.github.dannecron.demo.providers.CityRepository
import com.github.dannecron.demo.providers.CustomerRepository
import com.github.dannecron.demo.services.database.exceptions.CityNotFoundException
import java.time.OffsetDateTime
import java.util.*

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.services.database.exceptions
class AlreadyDeletedException: RuntimeException()

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.services.database.exceptions
class CityNotFoundException: ModelNotFoundException("city")

View File

@@ -1,3 +1,3 @@
package com.example.demo.services.database.exceptions
package com.github.dannecron.demo.services.database.exceptions
open class ModelNotFoundException(entityName: String): RuntimeException("$entityName not found")

View File

@@ -1,3 +1,3 @@
package com.example.demo.services.database.exceptions
package com.github.dannecron.demo.services.database.exceptions
class ProductNotFoundException: ModelNotFoundException("product")

View File

@@ -1,9 +1,9 @@
package com.example.demo.services.database.product
package com.github.dannecron.demo.services.database.product
import com.example.demo.models.Product
import com.example.demo.services.database.exceptions.AlreadyDeletedException
import com.example.demo.services.database.exceptions.ProductNotFoundException
import com.example.demo.services.kafka.exceptions.InvalidArgumentException
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.services.database.exceptions.AlreadyDeletedException
import com.github.dannecron.demo.services.database.exceptions.ProductNotFoundException
import com.github.dannecron.demo.services.kafka.exceptions.InvalidArgumentException
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.stereotype.Service

View File

@@ -1,11 +1,11 @@
package com.example.demo.services.database.product
package com.github.dannecron.demo.services.database.product
import com.example.demo.models.Product
import com.example.demo.providers.ProductRepository
import com.example.demo.services.database.exceptions.AlreadyDeletedException
import com.example.demo.services.database.exceptions.ProductNotFoundException
import com.example.demo.services.kafka.Producer
import com.example.demo.utils.LoggerDelegate
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.providers.ProductRepository
import com.github.dannecron.demo.services.database.exceptions.AlreadyDeletedException
import com.github.dannecron.demo.services.database.exceptions.ProductNotFoundException
import com.github.dannecron.demo.services.kafka.Producer
import com.github.dannecron.demo.utils.LoggerDelegate
import net.logstash.logback.marker.Markers
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable

View File

@@ -1,7 +1,7 @@
package com.example.demo.services.kafka
package com.github.dannecron.demo.services.kafka
import com.example.demo.services.database.city.CityService
import com.example.demo.services.kafka.dto.CityCreateDto
import com.github.dannecron.demo.services.database.city.CityService
import com.github.dannecron.demo.services.kafka.dto.CityCreateDto
import io.micrometer.core.instrument.Counter
import io.micrometer.core.instrument.MeterRegistry
import kotlinx.serialization.json.Json

View File

@@ -0,0 +1,9 @@
package com.github.dannecron.demo.services.kafka
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.services.kafka.exceptions.InvalidArgumentException
interface Producer {
@Throws(InvalidArgumentException::class)
fun produceProductInfo(topicName: String, product: Product)
}

View File

@@ -1,9 +1,9 @@
package com.example.demo.services.kafka
package com.github.dannecron.demo.services.kafka
import com.example.demo.models.Product
import com.example.demo.services.kafka.dto.ProductDto
import com.example.demo.services.validation.SchemaValidator
import com.example.demo.services.validation.SchemaValidator.Companion.SCHEMA_KAFKA_PRODUCT_SYNC
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.services.kafka.dto.ProductDto
import com.github.dannecron.demo.services.validation.SchemaValidator
import com.github.dannecron.demo.services.validation.SchemaValidator.Companion.SCHEMA_KAFKA_PRODUCT_SYNC
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToJsonElement
import org.springframework.kafka.core.KafkaTemplate

View File

@@ -1,4 +1,4 @@
package com.example.demo.services.kafka.dto
package com.github.dannecron.demo.services.kafka.dto
import kotlinx.serialization.Serializable

View File

@@ -1,7 +1,7 @@
package com.example.demo.services.kafka.dto
package com.github.dannecron.demo.services.kafka.dto
import com.example.demo.models.Product
import com.example.demo.services.kafka.exceptions.InvalidArgumentException
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.services.kafka.exceptions.InvalidArgumentException
import kotlinx.serialization.Serializable
import java.time.format.DateTimeFormatter

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.services.kafka.exceptions
class InvalidArgumentException(argName: String): RuntimeException("invalid argument $argName")

View File

@@ -1,4 +1,4 @@
package com.example.demo.services.serializables
package com.github.dannecron.demo.services.serializables
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind

View File

@@ -1,4 +1,4 @@
package com.example.demo.services.serializables
package com.github.dannecron.demo.services.serializables
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind

View File

@@ -1,7 +1,7 @@
package com.example.demo.services.validation
package com.github.dannecron.demo.services.validation
import com.example.demo.services.validation.exceptions.ElementNotValidException
import com.example.demo.services.validation.exceptions.SchemaNotFoundException
import com.github.dannecron.demo.services.validation.exceptions.ElementNotValidException
import com.github.dannecron.demo.services.validation.exceptions.SchemaNotFoundException
import kotlinx.serialization.json.JsonElement
interface SchemaValidator {

View File

@@ -1,7 +1,7 @@
package com.example.demo.services.validation
package com.github.dannecron.demo.services.validation
import com.example.demo.services.validation.exceptions.ElementNotValidException
import com.example.demo.services.validation.exceptions.SchemaNotFoundException
import com.github.dannecron.demo.services.validation.exceptions.ElementNotValidException
import com.github.dannecron.demo.services.validation.exceptions.SchemaNotFoundException
import io.github.optimumcode.json.schema.JsonSchema
import io.github.optimumcode.json.schema.ValidationError
import kotlinx.serialization.json.JsonElement

View File

@@ -1,4 +1,4 @@
package com.example.demo.services.validation.exceptions
package com.github.dannecron.demo.services.validation.exceptions
import io.github.optimumcode.json.schema.ValidationError

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.services.validation.exceptions
class SchemaNotFoundException: RuntimeException()

View File

@@ -1,4 +1,4 @@
package com.example.demo.utils
package com.github.dannecron.demo.utils
import kotlin.math.pow
import kotlin.math.roundToInt

View File

@@ -1,4 +1,4 @@
package com.example.demo.utils
package com.github.dannecron.demo.utils
import org.slf4j.Logger
import org.slf4j.LoggerFactory

View File

@@ -1,7 +1,7 @@
---
spring:
application:
name: Demo
name: demo
datasource:
url: jdbc:postgresql://${DB_URL:localhost:5432}/${DB_NAME:demo}?currentSchema=${DB_SCHEMA:public}
username: ${DB_USERNAME:postgres}

View File

@@ -1,6 +1,6 @@
package com.example.demo
package com.github.dannecron.demo
import com.example.demo.services.kafka.Producer
import com.github.dannecron.demo.services.kafka.Producer
import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase
import org.springframework.boot.test.mock.mockito.MockBean

View File

@@ -1,9 +1,9 @@
package com.example.demo
package com.github.dannecron.demo
import com.example.demo.config.properties.KafkaProperties
import com.example.demo.config.properties.ValidationProperties
import com.example.demo.services.kafka.Consumer
import com.example.demo.services.validation.SchemaValidator.Companion.SCHEMA_KAFKA_PRODUCT_SYNC
import com.github.dannecron.demo.config.properties.KafkaProperties
import com.github.dannecron.demo.config.properties.ValidationProperties
import com.github.dannecron.demo.services.kafka.Consumer
import com.github.dannecron.demo.services.validation.SchemaValidator.Companion.SCHEMA_KAFKA_PRODUCT_SYNC
import org.springframework.boot.test.context.TestConfiguration
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.context.annotation.Bean

View File

@@ -1,11 +1,11 @@
package com.example.demo.http.controllers
package com.github.dannecron.demo.http.controllers
import com.example.demo.BaseUnitTest
import com.example.demo.http.responses.ResponseStatus
import com.example.demo.models.City
import com.example.demo.models.Customer
import com.example.demo.models.CustomerExtended
import com.example.demo.services.database.customer.CustomerService
import com.github.dannecron.demo.BaseUnitTest
import com.github.dannecron.demo.http.responses.ResponseStatus
import com.github.dannecron.demo.models.City
import com.github.dannecron.demo.models.Customer
import com.github.dannecron.demo.models.CustomerExtended
import com.github.dannecron.demo.services.database.customer.CustomerService
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.eq
import org.mockito.kotlin.whenever

View File

@@ -1,6 +1,6 @@
package com.example.demo.http.controllers
package com.github.dannecron.demo.http.controllers
import com.example.demo.BaseUnitTest
import com.github.dannecron.demo.BaseUnitTest
import org.hamcrest.core.StringContains
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
@@ -8,7 +8,7 @@ import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.get
import kotlin.test.Test
@WebMvcTest(GreetingController::class)
@WebMvcTest(com.github.dannecron.demo.http.controllers.GreetingController::class)
class GreetingControllerTest(@Autowired val mockMvc: MockMvc): BaseUnitTest() {
@Test
fun greetings_shouldSeeGreetingMessage() {

View File

@@ -1,9 +1,9 @@
package com.example.demo.http.controllers
package com.github.dannecron.demo.http.controllers
import com.example.demo.BaseUnitTest
import com.example.demo.http.responses.ResponseStatus
import com.example.demo.models.Product
import com.example.demo.services.database.product.ProductService
import com.github.dannecron.demo.BaseUnitTest
import com.github.dannecron.demo.http.responses.ResponseStatus
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.services.database.product.ProductService
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.nullValue
import org.junit.jupiter.api.Test

View File

@@ -1,8 +1,8 @@
package com.example.demo.http.controllers
package com.github.dannecron.demo.http.controllers
import com.example.demo.BaseUnitTest
import com.example.demo.models.*
import com.example.demo.providers.ShopProvider
import com.github.dannecron.demo.BaseUnitTest
import com.github.dannecron.demo.models.*
import com.github.dannecron.demo.providers.ShopProvider
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.whenever
import org.springframework.beans.factory.annotation.Autowired

View File

@@ -1,10 +1,10 @@
package com.example.demo.services.database.city
package com.github.dannecron.demo.services.database.city
import com.example.demo.BaseDbTest
import com.example.demo.models.City
import com.example.demo.providers.CityRepository
import com.example.demo.services.database.exceptions.AlreadyDeletedException
import com.example.demo.services.database.exceptions.CityNotFoundException
import com.github.dannecron.demo.BaseDbTest
import com.github.dannecron.demo.models.City
import com.github.dannecron.demo.providers.CityRepository
import com.github.dannecron.demo.services.database.exceptions.AlreadyDeletedException
import com.github.dannecron.demo.services.database.exceptions.CityNotFoundException
import org.junit.jupiter.api.assertThrows
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration

View File

@@ -1,10 +1,10 @@
package com.example.demo.services.database.customer
package com.github.dannecron.demo.services.database.customer
import com.example.demo.BaseDbTest
import com.example.demo.models.City
import com.example.demo.providers.CityRepository
import com.example.demo.providers.CustomerRepository
import com.example.demo.services.database.exceptions.CityNotFoundException
import com.github.dannecron.demo.BaseDbTest
import com.github.dannecron.demo.models.City
import com.github.dannecron.demo.providers.CityRepository
import com.github.dannecron.demo.providers.CustomerRepository
import com.github.dannecron.demo.services.database.exceptions.CityNotFoundException
import org.junit.jupiter.api.assertThrows
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration

View File

@@ -1,10 +1,10 @@
package com.example.demo.services.database.product
package com.github.dannecron.demo.services.database.product
import com.example.demo.BaseDbTest
import com.example.demo.models.Product
import com.example.demo.providers.ProductRepository
import com.example.demo.services.database.exceptions.AlreadyDeletedException
import com.example.demo.services.database.exceptions.ProductNotFoundException
import com.github.dannecron.demo.BaseDbTest
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.providers.ProductRepository
import com.github.dannecron.demo.services.database.exceptions.AlreadyDeletedException
import com.github.dannecron.demo.services.database.exceptions.ProductNotFoundException
import org.junit.jupiter.api.assertThrows
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration

View File

@@ -1,11 +1,11 @@
package com.example.demo.services.database.product
package com.github.dannecron.demo.services.database.product
import com.example.demo.BaseUnitTest
import com.example.demo.models.Product
import com.example.demo.providers.ProductRepository
import com.example.demo.services.database.exceptions.ProductNotFoundException
import com.example.demo.services.kafka.Producer
import com.example.demo.services.kafka.exceptions.InvalidArgumentException
import com.github.dannecron.demo.BaseUnitTest
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.providers.ProductRepository
import com.github.dannecron.demo.services.database.exceptions.ProductNotFoundException
import com.github.dannecron.demo.services.kafka.Producer
import com.github.dannecron.demo.services.kafka.exceptions.InvalidArgumentException
import org.junit.jupiter.api.assertThrows
import org.junit.runner.RunWith
import org.mockito.kotlin.*

View File

@@ -1,8 +1,8 @@
package com.example.demo.services.kafka
package com.github.dannecron.demo.services.kafka
import com.example.demo.models.City
import com.example.demo.services.database.city.CityService
import com.example.demo.services.kafka.dto.CityCreateDto
import com.github.dannecron.demo.models.City
import com.github.dannecron.demo.services.database.city.CityService
import com.github.dannecron.demo.services.kafka.dto.CityCreateDto
import io.micrometer.core.instrument.MeterRegistry
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json

View File

@@ -1,9 +1,9 @@
package com.example.demo.services.kafka
package com.github.dannecron.demo.services.kafka
import com.example.demo.BaseUnitTest
import com.example.demo.models.Product
import com.example.demo.services.kafka.dto.ProductDto
import com.example.demo.services.validation.SchemaValidator
import com.github.dannecron.demo.BaseUnitTest
import com.github.dannecron.demo.models.Product
import com.github.dannecron.demo.services.kafka.dto.ProductDto
import com.github.dannecron.demo.services.validation.SchemaValidator
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToJsonElement
import org.junit.runner.RunWith

View File

@@ -1,9 +1,9 @@
package com.example.demo.services.validation
package com.github.dannecron.demo.services.validation
import com.example.demo.BaseUnitTest
import com.example.demo.services.validation.SchemaValidator.Companion.SCHEMA_KAFKA_PRODUCT_SYNC
import com.example.demo.services.validation.exceptions.ElementNotValidException
import com.example.demo.services.validation.exceptions.SchemaNotFoundException
import com.github.dannecron.demo.BaseUnitTest
import com.github.dannecron.demo.services.validation.SchemaValidator.Companion.SCHEMA_KAFKA_PRODUCT_SYNC
import com.github.dannecron.demo.services.validation.exceptions.ElementNotValidException
import com.github.dannecron.demo.services.validation.exceptions.SchemaNotFoundException
import kotlinx.serialization.json.Json
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments