From f4e1f01acf2f7b94bf68a3788a8d8458f19d592a Mon Sep 17 00:00:00 2001 From: Christopher Konkel <stu207811@mail.uni-kiel.de> Date: Sun, 7 Aug 2022 21:26:17 +0200 Subject: [PATCH] Partially fixed IntelliJ warnings (#361) --- .../theodolite/kubernetes/operator/BenchmarkStateChecker.kt | 4 ++-- .../theodolite/kubernetes/operator/ExecutionEventHandler.kt | 5 ++++- .../theodolite/kubernetes/operator/TheodoliteOperator.kt | 4 ++-- .../rocks/theodolite/kubernetes/patcher/AbstractPatcher.kt | 2 +- .../rocks/theodolite/kubernetes/slo/PrometheusResponse.kt | 4 ++-- .../src/test/kotlin/rocks/theodolite/core/ResultsTest.kt | 1 - .../rocks/theodolite/kubernetes/operator/ControllerTest.kt | 1 + 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateChecker.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateChecker.kt index c2c7db6cd..c8be7dbfa 100644 --- a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateChecker.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateChecker.kt @@ -195,9 +195,9 @@ class BenchmarkStateChecker( } -private fun <K, V> Map<K, V>.containsMatchLabels(matchLabels: Map<V, V>): Boolean { +private fun <K, V> Map<K, V>.containsMatchLabels(matchLabels: Map<K, V>): Boolean { for (kv in matchLabels) { - if (kv.value != this[kv.key as K]) { + if (kv.value != this[kv.key]) { return false } } diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandler.kt index 58120d25d..884606b13 100644 --- a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandler.kt @@ -34,7 +34,7 @@ class ExecutionEventHandler( override fun onAdd(execution: ExecutionCRD) { logger.info { "Add execution ${execution.metadata.name}." } execution.spec.name = execution.metadata.name - when (this.stateHandler.getExecutionState(execution.metadata.name)) { + when (val currentState = this.stateHandler.getExecutionState(execution.metadata.name)) { ExecutionState.NO_STATE -> this.stateHandler.setExecutionState(execution.spec.name, ExecutionState.PENDING) ExecutionState.RUNNING -> { this.stateHandler.setExecutionState(execution.spec.name, ExecutionState.RESTART) @@ -42,6 +42,9 @@ class ExecutionEventHandler( this.controller.stop(restart = true) } } + else -> { + logger.info { "ExecutionState '$currentState' is not handled." } + } } } diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteOperator.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteOperator.kt index 4d639fdb9..9e9a0eb5a 100644 --- a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteOperator.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteOperator.kt @@ -136,7 +136,7 @@ class TheodoliteOperator(private val client: NamespacedKubernetesClient) { ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>> { - return this.client.customResources( + return client.resources( ExecutionCRD::class.java, BenchmarkExecutionList::class.java ) @@ -146,7 +146,7 @@ class TheodoliteOperator(private val client: NamespacedKubernetesClient) { BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>> { - return this.client.customResources( + return client.resources( BenchmarkCRD::class.java, KubernetesBenchmarkList::class.java ) diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcher.kt index a20a26b35..0ed2a5e5a 100644 --- a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcher.kt @@ -27,4 +27,4 @@ abstract class AbstractPatcher : Patcher { abstract fun patchSingleResource(resource: HasMetadata, value: String): HasMetadata -} \ No newline at end of file +} diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/PrometheusResponse.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/PrometheusResponse.kt index 5222a78bd..7a3ac237a 100644 --- a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/PrometheusResponse.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/PrometheusResponse.kt @@ -31,8 +31,8 @@ data class PrometheusResponse( for (value in values) { val valueList = value as List<*> val timestamp = (valueList[0] as Double).toLong().toString() - val value = valueList[1].toString() - result.add(listOf(group, timestamp, value)) + val resultValue = valueList[1].toString() + result.add(listOf(group, timestamp, resultValue)) } } return Collections.unmodifiableList(result) diff --git a/theodolite/src/test/kotlin/rocks/theodolite/core/ResultsTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/core/ResultsTest.kt index 2dbeb44b9..42bc5883f 100644 --- a/theodolite/src/test/kotlin/rocks/theodolite/core/ResultsTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/core/ResultsTest.kt @@ -62,7 +62,6 @@ internal class ResultsTest { assertEquals(20000, maxRequiredInstances) } - @Test fun testGetMaxBenchmarkedLoadWhenAllSuccessfulCapacity() { val results = Results(Metric.from("capacity")) diff --git a/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ControllerTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ControllerTest.kt index bdb7cc6ce..301580bf3 100644 --- a/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ControllerTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ControllerTest.kt @@ -113,6 +113,7 @@ class ControllerTest { .getDeclaredMethod("getBenchmarks") method.isAccessible = true + @Suppress("UNCHECKED_CAST") val result = method.invoke(controller) as List<BenchmarkCRD> assertEquals(2, result.size) -- GitLab