mirror of
https://github.com/Dannecron/spring-boot-demo.git
synced 2025-12-26 00:32:34 +03:00
add schema validator
use ConfigurationProperties instead of Value for configuration
This commit is contained in:
@@ -1,9 +1,33 @@
|
||||
package com.example.demo
|
||||
|
||||
import com.example.demo.config.KafkaProperties
|
||||
import com.example.demo.services.kafka.Consumer
|
||||
import org.springframework.boot.test.context.TestConfiguration
|
||||
import org.springframework.boot.test.mock.mockito.MockBean
|
||||
import org.springframework.context.annotation.Bean
|
||||
|
||||
open class BaseUnitTest {
|
||||
@MockBean
|
||||
lateinit var consumer: Consumer
|
||||
|
||||
@TestConfiguration
|
||||
class TestConfig {
|
||||
@Bean
|
||||
fun kafkaProperties(): KafkaProperties = KafkaProperties(
|
||||
bootstrapServers = "localhost:1111",
|
||||
producer = KafkaProperties.Producer(
|
||||
product = KafkaProperties.Producer.Product(
|
||||
defaultSyncTopic = "some-default",
|
||||
),
|
||||
),
|
||||
consumer = KafkaProperties.Consumer(
|
||||
groupId = "group",
|
||||
topics = "topic",
|
||||
autoStartup = false,
|
||||
),
|
||||
validation = KafkaProperties.Validation(
|
||||
schema = mapOf("product-sync" to "foo"),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user