From 0c3b78bfdde9e7825913b356f654aa093fc0fe7b Mon Sep 17 00:00:00 2001 From: Toropanov Nikolai Date: Fri, 1 Oct 2021 15:18:44 +0300 Subject: [PATCH] add find system by type method --- .../src/main/java/io/github/adven27/env/core/Environment.kt | 4 ++-- .../adven27/env/mq/kafka/embedded/EmbeddedKafkaSystem.kt | 2 +- .../adven27/env/mq/kafka/embedded/EmbeddedKafkaSystemTest.kt | 2 +- example/src/test/kotlin/EnvTest.kt | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/env-core/src/main/java/io/github/adven27/env/core/Environment.kt b/env-core/src/main/java/io/github/adven27/env/core/Environment.kt index c59dc2d..ab8acf8 100644 --- a/env-core/src/main/java/io/github/adven27/env/core/Environment.kt +++ b/env-core/src/main/java/io/github/adven27/env/core/Environment.kt @@ -102,8 +102,8 @@ open class Environment @JvmOverloads constructor( "\n\n ==================================================\n\n" @Suppress("UNCHECKED_CAST") - fun find(name: String): T = (systems[name] ?: error("System $name not found")) as T - inline fun find() = systems.values.filterIsInstance().single() + fun env(name: String): T = (systems[name] ?: error("System $name not found")) as T + inline fun env() = systems.values.filterIsInstance().single() companion object : KLogging() { private fun start( diff --git a/env-mq-kafka-embedded/src/main/java/io/github/adven27/env/mq/kafka/embedded/EmbeddedKafkaSystem.kt b/env-mq-kafka-embedded/src/main/java/io/github/adven27/env/mq/kafka/embedded/EmbeddedKafkaSystem.kt index 902b1bd..4a017eb 100644 --- a/env-mq-kafka-embedded/src/main/java/io/github/adven27/env/mq/kafka/embedded/EmbeddedKafkaSystem.kt +++ b/env-mq-kafka-embedded/src/main/java/io/github/adven27/env/mq/kafka/embedded/EmbeddedKafkaSystem.kt @@ -31,7 +31,7 @@ open class EmbeddedKafkaSystem( CONTROLLED_SHUTDOWN, NUMBER_OF_PARTITIONS, *topics - ).brokerProperties(properties), + ).brokerProperties(mapOf("group.initial.rebalance.delay.ms" to "0") + properties), defaultPort ) diff --git a/env-mq-kafka-embedded/src/test/kotlin/io/github/adven27/env/mq/kafka/embedded/EmbeddedKafkaSystemTest.kt b/env-mq-kafka-embedded/src/test/kotlin/io/github/adven27/env/mq/kafka/embedded/EmbeddedKafkaSystemTest.kt index 4d03769..dd70356 100644 --- a/env-mq-kafka-embedded/src/test/kotlin/io/github/adven27/env/mq/kafka/embedded/EmbeddedKafkaSystemTest.kt +++ b/env-mq-kafka-embedded/src/test/kotlin/io/github/adven27/env/mq/kafka/embedded/EmbeddedKafkaSystemTest.kt @@ -25,5 +25,5 @@ class EmbeddedKafkaSystemTest { } class SomeEnvironment : Environment("EMBEDDED_KAFKA" to EmbeddedKafkaSystem("some-topic")) { - fun kafka() = find() + fun kafka() = env() } diff --git a/example/src/test/kotlin/EnvTest.kt b/example/src/test/kotlin/EnvTest.kt index ed63c3c..ea31ad7 100644 --- a/example/src/test/kotlin/EnvTest.kt +++ b/example/src/test/kotlin/EnvTest.kt @@ -61,6 +61,6 @@ class SomeEnvironment : Environment( }, "WIREMOCK" to WiremockSystem() ) { - fun rabbit() = find() - fun postgres() = find() + fun rabbit() = env() + fun postgres() = env() }