summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons')
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml5
-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
-rwxr-xr-xms/blueprintsprocessor/modules/commons/pom.xml10
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/cluster/HazelcastClusterService.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt2
6 files changed, 52 insertions, 32 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
index 698f519f5..57008da11 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
@@ -61,6 +61,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
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)
}
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml
index f653986bd..8bb9b0b68 100755
--- a/ms/blueprintsprocessor/modules/commons/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/pom.xml
@@ -54,6 +54,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk-jvm</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
@@ -64,6 +69,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<scope>test</scope>
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/cluster/HazelcastClusterService.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/cluster/HazelcastClusterService.kt
index fb9056776..870e0ed64 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/cluster/HazelcastClusterService.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/cluster/HazelcastClusterService.kt
@@ -180,7 +180,7 @@ open class HazelcastClusterService(private val applicationEventPublisher: Applic
}
/** Return interface may change and it will be included in BluePrintClusterService */
- @UseExperimental
+ @OptIn
suspend fun clusterScheduler(name: String): IScheduledExecutorService {
check(::hazelcast.isInitialized) { "failed to start and join cluster" }
return hazelcast.getScheduledExecutorService(name)
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt
index 744236685..f5552a691 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt
@@ -150,7 +150,7 @@ suspend fun <T> mdcWebCoroutineScope(
replaceWith = ReplaceWith("mdcWebCoroutineScope")
)
/** Used in Rest controller API methods to populate MDC context to nested coroutines from reactor web filter context. */
-@UseExperimental(InternalCoroutinesApi::class)
+@OptIn(InternalCoroutinesApi::class)
fun <T> monoMdc(
context: CoroutineContext = EmptyCoroutineContext,
block: suspend CoroutineScope.() -> T?