Skip to content

Instantly share code, notes, and snippets.

@billydh
billydh / StoreConfiguration.kt
Created December 1, 2020 00:46
with constructor injection
package com.thecodebrews.kotlinspringvaluedemo
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
import javax.annotation.PostConstruct
@Component
class StoreConfiguration(
@Value("\${store.no-of-customers-capacity}") val capacity: Int
) {
package com.thecodebrews.kotlinspringvaluedemo
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
import javax.annotation.PostConstruct
@Component
class StoreConfiguration {
@Value("\${store.size-in-meter-square}")
val size: Int = 0
@billydh
billydh / KotlinspringvaluedemoApplication.kt
Last active December 1, 2020 00:37
Spring Value constructor level
package com.thecodebrews.kotlinspringvaluedemo
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import javax.annotation.PostConstruct
@SpringBootApplication
class KotlinspringvaluedemoApplication(
@Value("\${application.name}") private val appName: String
package com.thecodebrews.kotlinspringvaluedemo
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import javax.annotation.PostConstruct
@SpringBootApplication
class KotlinspringvaluedemoApplication {
@Value("\${store.name}")
@billydh
billydh / application.properties
Last active December 1, 2020 01:03
for Spring @value demo
store.name=mydemostore
store.address=123 Some Street, Some City, Some Country
store.size-in-meter-square=20
store.no-of-customers-capacity=10
application.name=SpringValueIsCool
package io.codebrews.kotlinkafkadynamodemo
import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient
object MockSchemaRegistry {
val client = MockSchemaRegistryClient()
}
package io.codebrews.kotlinkafkadynamodemo
import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient
import io.confluent.kafka.serializers.KafkaAvroDeserializer
class MockKafkaAvroDeserializer : KafkaAvroDeserializer(MockSchemaRegistry.client)
package io.codebrews.kotlinkafkadynamodemo
import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient
import io.confluent.kafka.serializers.KafkaAvroSerializer
class MockKafkaAvroSerializer : KafkaAvroSerializer(MockSchemaRegistry.client)
package io.codebrews.kotlinkafkadynamodemo.kafka
import com.nhaarman.mockitokotlin2.given
import com.nhaarman.mockitokotlin2.timeout
import com.nhaarman.mockitokotlin2.verify
import io.codebrews.createuserrequest.CreateUserRequest
import io.codebrews.kotlinkafkadynamodemo.config.KafkaConfigProperties
import io.codebrews.kotlinkafkadynamodemo.service.CreateUserRequestHandler
import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig
import org.apache.kafka.clients.producer.ProducerConfig
@billydh
billydh / application.yml
Created November 24, 2020 07:50
initial application.yml for test
application:
dynamo:
customer-table-name: "demo-customer-info"
region: "ap-southeast-2"
endpoint: "http://localhost:8042"
kafka:
broker: "localhost:9092"
serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
schema-registry-url: "http://localhost:8081"