mirror of
https://github.com/Dannecron/spring-boot-demo.git
synced 2025-12-25 16:22:35 +03:00
rename project
This commit is contained in:
@@ -10,7 +10,7 @@ plugins {
|
||||
kotlin("plugin.spring") version "1.9.23"
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
group = "com.github.dannecron.demo"
|
||||
version = "single-version"
|
||||
|
||||
java {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.http.exceptions
|
||||
|
||||
class NotFoundException: RuntimeException()
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.http.exceptions
|
||||
|
||||
class UnprocessableException(override val message: String): RuntimeException(message)
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.http.responses
|
||||
|
||||
class NotFoundResponse: BaseResponse(ResponseStatus.NOT_FOUND)
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.example.demo.providers
|
||||
|
||||
import com.example.demo.models.Shop
|
||||
|
||||
interface ShopProvider {
|
||||
fun getRandomShop(): Shop?
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.providers.html
|
||||
|
||||
class Center: Tag("center")
|
||||
@@ -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)
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.providers.html
|
||||
|
||||
class TD: Tag("td")
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.services.database.exceptions
|
||||
|
||||
class AlreadyDeletedException: RuntimeException()
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.services.database.exceptions
|
||||
|
||||
class CityNotFoundException: ModelNotFoundException("city")
|
||||
@@ -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)
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.services.kafka.exceptions
|
||||
|
||||
class InvalidArgumentException(argName: String): RuntimeException("invalid argument $argName")
|
||||
@@ -1,3 +0,0 @@
|
||||
package com.example.demo.services.validation.exceptions
|
||||
|
||||
class SchemaNotFoundException: RuntimeException()
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo
|
||||
package com.github.dannecron.demo
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.runApplication
|
||||
@@ -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(
|
||||
@@ -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
|
||||
@@ -46,4 +46,4 @@ class KafkaConsumerConfig(
|
||||
|
||||
return factory
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -41,4 +41,4 @@ class KafkaProducerConfig(
|
||||
kafkaTemplate,
|
||||
schemaValidator,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -23,4 +23,4 @@ data class KafkaProperties @ConstructorBinding constructor(
|
||||
val autoStartup: Boolean,
|
||||
val autoOffsetReset: String,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.example.demo.config.properties
|
||||
package com.github.dannecron.demo.config.properties
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
|
||||
@ConfigurationProperties("validation")
|
||||
data class ValidationProperties(
|
||||
val schema: Map<String, String>
|
||||
)
|
||||
)
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -29,4 +29,4 @@ class ShopController (
|
||||
)
|
||||
)).toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -42,4 +42,4 @@ class ExceptionHandler {
|
||||
UnprocessableResponse(exception.javaClass.name, exception.allErrors),
|
||||
HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.http.exceptions
|
||||
|
||||
class NotFoundException: RuntimeException()
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.http.exceptions
|
||||
|
||||
class UnprocessableException(override val message: String): RuntimeException(message)
|
||||
@@ -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
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.http.responses
|
||||
package com.github.dannecron.demo.http.responses
|
||||
|
||||
data class BadRequestResponse(
|
||||
val cause: String,
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.http.responses
|
||||
package com.github.dannecron.demo.http.responses
|
||||
|
||||
open class BaseResponse(val status: ResponseStatus)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.http.responses
|
||||
|
||||
class NotFoundResponse: BaseResponse(ResponseStatus.NOT_FOUND)
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.http.responses
|
||||
package com.github.dannecron.demo.http.responses
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue
|
||||
|
||||
@@ -7,4 +7,4 @@ enum class ResponseStatus(@JsonValue val status: String) {
|
||||
NOT_FOUND("not found"),
|
||||
BAD_REQUEST("bad request"),
|
||||
UNPROCESSABLE("unprocessable");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.http.responses
|
||||
package com.github.dannecron.demo.http.responses
|
||||
|
||||
import org.springframework.validation.ObjectError
|
||||
|
||||
@@ -7,4 +7,4 @@ class UnprocessableResponse(
|
||||
val errors: List<ObjectError>?
|
||||
): BaseResponse(status = ResponseStatus.UNPROCESSABLE) {
|
||||
constructor(cause: String): this(cause, null)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.http.responses.page
|
||||
package com.github.dannecron.demo.http.responses.page
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -6,4 +6,4 @@ import kotlinx.serialization.Serializable
|
||||
data class PageMetaDto(
|
||||
val total: Long,
|
||||
val pages: Int,
|
||||
)
|
||||
)
|
||||
@@ -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
|
||||
@@ -15,4 +15,4 @@ data class PageResponse<T>(
|
||||
pages = page.totalPages
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -28,4 +28,4 @@ data class City(
|
||||
val deletedAt: OffsetDateTime?,
|
||||
) {
|
||||
fun isDeleted(): Boolean = deletedAt != null
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.models
|
||||
package com.github.dannecron.demo.models
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -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>) {
|
||||
/**
|
||||
@@ -13,4 +13,4 @@ data class CustomerLocal(val name: String, val city: City, val orders: List<Orde
|
||||
fun getOrderedProducts(): Set<Product> = orders.flatMap { order -> order.products }.toSet()
|
||||
|
||||
fun getTotalOrderPrice(): Double = orders.flatMap { ord -> ord.products }.sumOf { pr -> pr.getPriceDouble()}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
data class Order(val products: List<Product>, val isDelivered: Boolean)
|
||||
@@ -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
|
||||
@@ -34,4 +34,4 @@ data class Product(
|
||||
fun getPriceDouble(): Double = (price.toDouble() / 100).roundTo(2)
|
||||
|
||||
fun isDeleted(): Boolean = deletedAt != null
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
@@ -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
|
||||
@@ -14,4 +14,4 @@ interface CityRepository: CrudRepository<City, Long> {
|
||||
|
||||
@Query(value = "UPDATE City SET deleted_at = :deletedAt WHERE guid = :guid RETURNING *")
|
||||
fun softDelete(@Param("guid") guid: UUID, @Param("deletedAt") deletedAt: OffsetDateTime): City?
|
||||
}
|
||||
}
|
||||
@@ -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.*
|
||||
@@ -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)
|
||||
@@ -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
|
||||
@@ -15,4 +15,4 @@ interface ProductRepository: CrudRepository<Product, Long>, PagingAndSortingRepo
|
||||
|
||||
@Query(value = "UPDATE Product SET deleted_at = :deletedAt WHERE guid = :guid RETURNING *")
|
||||
fun softDelete(@Param("guid") guid: UUID, @Param("deletedAt") deletedAt: OffsetDateTime): Product?
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.github.dannecron.demo.providers
|
||||
|
||||
import com.github.dannecron.demo.models.Shop
|
||||
|
||||
interface ShopProvider {
|
||||
fun getRandomShop(): Shop?
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
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" """
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.providers.html
|
||||
|
||||
class Center: Tag("center")
|
||||
@@ -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)
|
||||
@@ -1,12 +1,12 @@
|
||||
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()) {
|
||||
tr(color = getTitleColor()) {
|
||||
|
||||
td {
|
||||
text("Product")
|
||||
@@ -22,17 +22,17 @@ fun renderProductTable(): String {
|
||||
val products = getInnerProducts()
|
||||
for ((i, product) in products.withIndex()) {
|
||||
tr {
|
||||
td (color = getCellColor(0, i+1)) {
|
||||
td(color = getCellColor(0, i + 1)) {
|
||||
text(product.description)
|
||||
}
|
||||
td (color = getCellColor(1, i+1)) {
|
||||
td(color = getCellColor(1, i + 1)) {
|
||||
text(product.price)
|
||||
}
|
||||
td (color = getCellColor(2, i+1)) {
|
||||
td(color = getCellColor(2, i + 1)) {
|
||||
text(product.popularity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.toString()
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -8,4 +8,4 @@ fun getInnerProducts(): Set<InnerProduct> {
|
||||
InnerProduct("two", 13.0, 20),
|
||||
InnerProduct("three", 14.0, 50)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.providers.html
|
||||
|
||||
class TD: Tag("td")
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.providers.html
|
||||
package com.github.dannecron.demo.providers.html
|
||||
|
||||
class TR: Tag("tr")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package com.example.demo.providers.html
|
||||
package com.github.dannecron.demo.providers.html
|
||||
|
||||
class Table: Tag("table")
|
||||
|
||||
fun Table.tr(color: String? = null, init : TR.() -> Unit) = doInit(TR(), init).set("bgcolor", color)
|
||||
fun Table.tr(color: String? = null, init : TR.() -> Unit) = doInit(TR(), init).set("bgcolor", color)
|
||||
@@ -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()
|
||||
@@ -25,4 +25,4 @@ fun <T: Tag> Tag.doInit(tag: T, init: T.() -> Unit): T {
|
||||
return tag
|
||||
}
|
||||
|
||||
fun Tag.text(s : Any?) = doInit(Text(s.toString()), {})
|
||||
fun Tag.text(s : Any?) = doInit(Text(s.toString()), {})
|
||||
@@ -1,5 +1,5 @@
|
||||
package com.example.demo.providers.html
|
||||
package com.github.dannecron.demo.providers.html
|
||||
|
||||
class Text(val text: String): Tag("b") {
|
||||
override fun toString() = text
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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.*
|
||||
@@ -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
|
||||
}
|
||||
@@ -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.*
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.services.database.exceptions
|
||||
|
||||
class AlreadyDeletedException: RuntimeException()
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.services.database.exceptions
|
||||
|
||||
class CityNotFoundException: ModelNotFoundException("city")
|
||||
@@ -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")
|
||||
@@ -1,3 +1,3 @@
|
||||
package com.example.demo.services.database.exceptions
|
||||
package com.github.dannecron.demo.services.database.exceptions
|
||||
|
||||
class ProductNotFoundException: ModelNotFoundException("product")
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -29,4 +29,4 @@ class Consumer(
|
||||
|
||||
cityService.create(cityCreateDto)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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
|
||||
@@ -31,4 +31,4 @@ class ProducerImpl(
|
||||
|
||||
kafkaTemplate.send(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.services.kafka.dto
|
||||
package com.github.dannecron.demo.services.kafka.dto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -27,4 +27,4 @@ data class ProductDto(
|
||||
updatedAt = product.updatedAt?.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME),
|
||||
deletedAt = product.deletedAt?.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.services.kafka.exceptions
|
||||
|
||||
class InvalidArgumentException(argName: String): RuntimeException("invalid argument $argName")
|
||||
@@ -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
|
||||
@@ -19,4 +19,4 @@ class OffsetDateTimeSerialization: KSerializer<OffsetDateTime> {
|
||||
encoder.encodeString(value.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -18,4 +18,4 @@ class UuidSerialization: KSerializer<UUID> {
|
||||
encoder.encodeString(value.toString())
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -11,4 +11,4 @@ interface SchemaValidator {
|
||||
companion object {
|
||||
const val SCHEMA_KAFKA_PRODUCT_SYNC = "kafka-product-sync"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -41,4 +41,4 @@ class SchemaValidatorImp(
|
||||
|
||||
return schema
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.example.demo.services.validation.exceptions
|
||||
package com.github.dannecron.demo.services.validation.exceptions
|
||||
|
||||
import io.github.optimumcode.json.schema.ValidationError
|
||||
|
||||
class ElementNotValidException(
|
||||
val validationErrors: List<ValidationError>,
|
||||
): RuntimeException()
|
||||
): RuntimeException()
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.dannecron.demo.services.validation.exceptions
|
||||
|
||||
class SchemaNotFoundException: RuntimeException()
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.utils
|
||||
package com.github.dannecron.demo.utils
|
||||
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.demo.utils
|
||||
package com.github.dannecron.demo.utils
|
||||
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
@@ -21,4 +21,4 @@ class LoggerDelegate<in R : Any> : ReadOnlyProperty<R, Logger> {
|
||||
}
|
||||
|
||||
|
||||
fun getLogger(forClass: Class<*>): Logger = LoggerFactory.getLogger(forClass)
|
||||
fun getLogger(forClass: Class<*>): Logger = LoggerFactory.getLogger(forClass)
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
@@ -16,4 +16,4 @@ import org.testcontainers.junit.jupiter.Testcontainers
|
||||
class BaseDbTest {
|
||||
@MockBean
|
||||
lateinit var producer: Producer
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -35,4 +35,4 @@ open class BaseUnitTest {
|
||||
schema = mapOf(SCHEMA_KAFKA_PRODUCT_SYNC to "kafka/product/sync.json"),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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() {
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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.*
|
||||
@@ -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
|
||||
@@ -76,4 +76,4 @@ class ConsumerKfkTest(
|
||||
|
||||
assertEquals(1.0, metricRegistry.get("kafka_consumer_city_create").counter().count())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -68,4 +68,4 @@ class ProducerImplTest: BaseUnitTest() {
|
||||
assertEquals(topic, actualArgument.headers[KafkaHeaders.TOPIC])
|
||||
assertEquals("some-custom-header", actualArgument.headers["X-Custom-Header"])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -95,4 +95,4 @@ class SchemaValidatorImpTest(
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user