From 6447f7362d3334f78c6c8f81ee4d735b402d7df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de> Date: Thu, 15 Apr 2021 17:22:51 +0200 Subject: [PATCH] Fix some code style issues --- theodolite-quarkus/build.gradle | 6 ++--- .../kotlin/theodolite/k8s/TopicManager.kt | 24 +++++++++---------- .../kotlin/theodolite/k8s/TopicManagerTest.kt | 17 +++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 theodolite-quarkus/src/test/kotlin/theodolite/k8s/TopicManagerTest.kt diff --git a/theodolite-quarkus/build.gradle b/theodolite-quarkus/build.gradle index 2f58f4c8a..8b61bf506 100644 --- a/theodolite-quarkus/build.gradle +++ b/theodolite-quarkus/build.gradle @@ -18,16 +18,16 @@ dependencies { implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' implementation 'io.quarkus:quarkus-arc' implementation 'io.quarkus:quarkus-resteasy' - testImplementation 'io.quarkus:quarkus-junit5' - testImplementation 'io.rest-assured:rest-assured' implementation 'com.google.code.gson:gson:2.8.5' - implementation 'org.slf4j:slf4j-simple:1.7.29' implementation 'io.github.microutils:kotlin-logging:1.12.0' implementation 'io.fabric8:kubernetes-client:5.0.0-alpha-2' implementation 'io.quarkus:quarkus-kubernetes-client' implementation 'org.apache.kafka:kafka-clients:2.7.0' implementation 'khttp:khttp:1.0.0' + + testImplementation 'io.quarkus:quarkus-junit5' + testImplementation 'io.rest-assured:rest-assured' } group 'theodolite' diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/TopicManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/TopicManager.kt index 43dc69725..067dcbde0 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/TopicManager.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/TopicManager.kt @@ -8,21 +8,21 @@ private val logger = KotlinLogging.logger {} /** * Manages the topics related tasks - * @param kafkaConfig Kafka Configuration as HashMap + * @param kafkaConfig Kafka configuration as a Map * @constructor Creates a KafkaAdminClient */ -class TopicManager(private val kafkaConfig: HashMap<String, Any>) { +class TopicManager(private val kafkaConfig: Map<String, Any>) { /** - * Creates topics. - * @param newTopics List of all Topic that should be created + * Create topics. + * @param newTopics Collection of all topic that should be created */ fun createTopics(newTopics: Collection<NewTopic>) { - var kafkaAdmin: AdminClient = AdminClient.create(this.kafkaConfig) + val kafkaAdmin: AdminClient = AdminClient.create(this.kafkaConfig) val result = kafkaAdmin.createTopics(newTopics) - result.all().get()// wait for the future object + result.all().get() // wait for the future to be completed logger.info { - "Topics created finished with result: ${ + "Topic creation finished with result: ${ result.values().map { it -> it.key + ": " + it.value.isDone } .joinToString(separator = ",") } " @@ -31,14 +31,14 @@ class TopicManager(private val kafkaConfig: HashMap<String, Any>) { } /** - * Removes topics. - * @param topics List of names with the topics to remove. + * Remove topics. + * @param topics Collection of names for the topics to remove. */ - fun removeTopics(topics: List<String>) { - var kafkaAdmin: AdminClient = AdminClient.create(this.kafkaConfig) + fun removeTopics(topics: Collection<String>) { + val kafkaAdmin: AdminClient = AdminClient.create(this.kafkaConfig) try { val result = kafkaAdmin.deleteTopics(topics) - result.all().get() // wait for the future object + result.all().get() // wait for the future to be completed logger.info { "Topics deletion finished with result: ${ result.values().map { it -> it.key + ": " + it.value.isDone } diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/k8s/TopicManagerTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/k8s/TopicManagerTest.kt new file mode 100644 index 000000000..4548a8f9d --- /dev/null +++ b/theodolite-quarkus/src/test/kotlin/theodolite/k8s/TopicManagerTest.kt @@ -0,0 +1,17 @@ +package theodolite.k8s + +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach + +import org.junit.jupiter.api.Assertions.* + +internal class TopicManagerTest { + + @BeforeEach + fun setUp() { + } + + @AfterEach + fun tearDown() { + } +} \ No newline at end of file -- GitLab