aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/message-lib/src
diff options
context:
space:
mode:
authorFrank Kimmlingen <frank.kimmlingen@telekom.de>2023-03-07 16:36:48 +0100
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2023-03-17 12:58:21 +0000
commit4c9246c82b12a7b9e0f9ac0230abfdb369ce9ab1 (patch)
tree66fde9a672d14fe6d7e8d246e026e3f2bfeca06a /ms/blueprintsprocessor/modules/commons/message-lib/src
parentc0aebdf1f43ed6f64fcc76e19cbc2dfee2e0f3df (diff)
Enable JUnit tests and porting to java 17
JUnit tests are no more executed: spring-boot-starter-test does not execute any junit4 tests by default Fix enable tests and adopts the tests moslty to java 17 runtime Issue-ID: CCSDK-3859 Signed-off-by: Frank Kimmlingen <frank.kimmlingen@telekom.de> Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: I02a8d25350ca62262bfc6e07c2865cd8d7b4e6b2
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/message-lib/src')
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt55
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt10
2 files changed, 35 insertions, 30 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt
index 0d4310c79..cc0681c72 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt
@@ -22,31 +22,36 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.defaultToUUID
import kotlin.math.max
-class BlueprintMessageUtils {
- companion object {
- fun kafkaMetricTag(topic: String): MutableList<Tag> =
- mutableListOf(
- Tag.of(BluePrintConstants.METRIC_TAG_TOPIC, topic)
- )
-
- /**
- * get OS hostname's last 5 characters
- * Used to generate unique client ID.
- */
- fun getHostnameSuffix(): String =
- System.getenv("HOSTNAME").defaultToUUID().let {
- it.substring(max(0, it.length - 5))
- }
+object BlueprintMessageUtils {
- fun getMessageLogData(message: Any): String =
- when (message) {
- is CommonExecutionServiceData -> {
- val actionIdentifiers = message.actionIdentifiers
- val commonHeaders = message.commonHeader
- "requestID(${commonHeaders.requestId}), subrequestID(${commonHeaders.subRequestId}) " +
- "CBA(${actionIdentifiers.blueprintName}/${actionIdentifiers.blueprintVersion}/${actionIdentifiers.actionName})"
- }
- else -> "message($message)"
- }
+ fun getHostname(): String? {
+ return System.getenv("HOSTNAME")
+ }
+
+ fun kafkaMetricTag(topic: String): MutableList<Tag> =
+ mutableListOf(
+ Tag.of(BluePrintConstants.METRIC_TAG_TOPIC, topic)
+ )
+
+ /**
+ * get OS hostname's last 5 characters
+ * Used to generate unique client ID.
+ */
+ fun getHostnameSuffix(): String {
+ return getHostname().defaultToUUID().let {
+ it.substring(max(0, it.length - 5))
+ }
}
+
+ fun getMessageLogData(message: Any): String =
+ when (message) {
+ is CommonExecutionServiceData -> {
+ val actionIdentifiers = message.actionIdentifiers
+ val commonHeaders = message.commonHeader
+ "requestID(${commonHeaders.requestId}), subrequestID(${commonHeaders.subRequestId}) " +
+ "CBA(${actionIdentifiers.blueprintName}/${actionIdentifiers.blueprintVersion}/${actionIdentifiers.actionName})"
+ }
+
+ else -> "message($message)"
+ }
}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt
index 5d0c89415..aa4d00e16 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtilsTest.kt
@@ -18,7 +18,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.message.utils
import io.micrometer.core.instrument.Tag
import io.mockk.every
-import io.mockk.mockkStatic
+import io.mockk.mockkObject
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader
@@ -41,15 +41,15 @@ class BlueprintMessageUtilsTest {
@Test
fun testGetHostnameSuffix() {
- mockkStatic(System::class)
- every { System.getenv("HOSTNAME") } returns "qwertyuiop"
+ mockkObject(BlueprintMessageUtils)
+ every { BlueprintMessageUtils.getHostname() } returns "qwertyuiop"
assertEquals("yuiop", BlueprintMessageUtils.getHostnameSuffix())
}
@Test
fun testGetNullHostnameSuffix() {
- mockkStatic(System::class)
- every { System.getenv("HOSTNAME") } returns null
+ mockkObject(BlueprintMessageUtils)
+ every { BlueprintMessageUtils.getHostname() } returns null
assertEquals(5, BlueprintMessageUtils.getHostnameSuffix().length)
}