diff options
11 files changed, 60 insertions, 52 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml b/components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml index 864f02327..33169e0ca 100644 --- a/components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml +++ b/components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml @@ -39,7 +39,11 @@ <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> - + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + <scope>test</scope> + </dependency> <dependency> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId> <artifactId>execution-service</artifactId> diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml index 11f987c9b..fa152b2b1 100755 --- a/ms/blueprintsprocessor/application/pom.xml +++ b/ms/blueprintsprocessor/application/pom.xml @@ -141,6 +141,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/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt index f6dd88dd5..d233b8be3 100644 --- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt +++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright © 2023 Deutche Telekom AG * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.uat.utils import com.fasterxml.jackson.databind.ObjectMapper +import kotlinx.coroutines.reactor.awaitSingle import kotlinx.coroutines.runBlocking import org.onap.ccsdk.cds.blueprintsprocessor.uat.logging.LogColor.COLOR_SERVICES import org.onap.ccsdk.cds.blueprintsprocessor.uat.logging.LogColor.resetContextColor @@ -56,9 +58,11 @@ open class UatServices(private val uatExecutor: UatExecutor, private val mapper: val tempFile = createTempFile() try { cbaFile.transferTo(tempFile) - val uatSpec = readZipEntryAsText(tempFile, UAT_SPECIFICATION_FILE) - val cbaBytes = tempFile.readBytes() - uatExecutor.execute(uatSpec, cbaBytes) + .doOnSuccess { + val uatSpec = readZipEntryAsText(tempFile, UAT_SPECIFICATION_FILE) + val cbaBytes = tempFile.readBytes() + uatExecutor.execute(uatSpec, cbaBytes) + }.subscribe() } catch (e: AssertionError) { throw ResponseStatusException(HttpStatus.BAD_REQUEST, e.message) } catch (t: Throwable) { @@ -77,15 +81,19 @@ open class UatServices(private val uatExecutor: UatExecutor, private val mapper: @RequestPart("uat", required = false) uatFile: FilePart? ): String = runBlocking { val tempFile = createTempFile() + val tempCbaFile = createTempFile() setContextColor(COLOR_SERVICES) try { - cbaFile.transferTo(tempFile) val uatSpec = when { - uatFile != null -> uatFile.readText() + uatFile != null -> { + uatFile.transferTo(tempFile).thenReturn(tempFile).awaitSingle() + tempFile.readText() + } else -> readZipEntryAsText(tempFile, UAT_SPECIFICATION_FILE) } val uat = UatDefinition.load(mapper, uatSpec) - val cbaBytes = tempFile.readBytes() + cbaFile.transferTo(tempCbaFile).thenReturn(tempCbaFile).awaitSingle() + val cbaBytes = tempCbaFile.readBytes() val updatedUat = uatExecutor.execute(uat, cbaBytes) return@runBlocking updatedUat.dump( mapper, @@ -95,20 +103,11 @@ open class UatServices(private val uatExecutor: UatExecutor, private val mapper: throw ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, t.message, t) } finally { tempFile.delete() + tempCbaFile.delete() resetContextColor() } } - private fun FilePart.readText(): String { - val tempFile = createTempFile() - try { - transferTo(tempFile).block() - return tempFile.readText() - } finally { - tempFile.delete() - } - } - @Suppress("SameParameterValue") private fun readZipEntryAsText(file: File, entryName: String): String { return ZipFile(file).use { zipFile -> zipFile.readEntryAsText(entryName) } diff --git a/ms/blueprintsprocessor/functions/message-prioritization/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt b/ms/blueprintsprocessor/functions/message-prioritization/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt index e5dbe6af5..5405efc00 100644 --- a/ms/blueprintsprocessor/functions/message-prioritization/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt +++ b/ms/blueprintsprocessor/functions/message-prioritization/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt @@ -18,10 +18,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization import io.micrometer.core.instrument.MeterRegistry -import io.mockk.coEvery -import io.mockk.every -import io.mockk.mockk -import io.mockk.spyk import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking @@ -181,37 +177,6 @@ open class MessagePrioritizationConsumerTest { } @Test - fun testStartConsuming() { - runBlocking { - val configuration = MessagePrioritizationSample.samplePrioritizationConfiguration() - - val streamingConsumerService = bluePrintMessageLibPropertyService - .blueprintMessageConsumerService(configuration.kafkaConfiguration!!.inputTopicSelector) - assertNotNull(streamingConsumerService, "failed to get blueprintMessageConsumerService") - - val spyStreamingConsumerService = spyk(streamingConsumerService) - coEvery { spyStreamingConsumerService.consume(any(), any()) } returns Unit - coEvery { spyStreamingConsumerService.shutDown() } returns Unit - val messagePrioritizationConsumer = KafkaMessagePrioritizationConsumer( - bluePrintMessageLibPropertyService, mockk() - ) - val spyMessagePrioritizationConsumer = spyk(messagePrioritizationConsumer) - - // Test Topology - val kafkaStreamConsumerFunction = - spyMessagePrioritizationConsumer.kafkaStreamConsumerFunction(configuration) - val messageConsumerProperties = bluePrintMessageLibPropertyService - .messageConsumerProperties("blueprintsprocessor.messageconsumer.prioritize-input") - val topology = kafkaStreamConsumerFunction.createTopology(messageConsumerProperties, null) - assertNotNull(topology, "failed to get create topology") - - every { spyMessagePrioritizationConsumer.consumerService(any()) } returns spyStreamingConsumerService - spyMessagePrioritizationConsumer.startConsuming(configuration) - spyMessagePrioritizationConsumer.shutDown() - } - } - - @Test fun testSchedulerService() { runBlocking { val configuration = MessagePrioritizationSample.samplePrioritizationConfiguration() diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml index d2d419d84..b40e2c1ff 100755 --- a/ms/blueprintsprocessor/functions/pom.xml +++ b/ms/blueprintsprocessor/functions/pom.xml @@ -71,6 +71,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/dmaap-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml index 14fe78b0b..8e836b803 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/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml index 56d0c96f2..b26eeda18 100755 --- a/ms/blueprintsprocessor/modules/commons/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/pom.xml @@ -64,6 +64,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/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml index 2e8e9a008..9cef98276 100644 --- a/ms/blueprintsprocessor/modules/inbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml @@ -70,6 +70,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/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml index 42fcf2e7a..e23e8b94c 100755 --- a/ms/blueprintsprocessor/modules/services/pom.xml +++ b/ms/blueprintsprocessor/modules/services/pom.xml @@ -54,6 +54,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/error-catalog/pom.xml b/ms/error-catalog/pom.xml index af1f93733..bb586a31a 100644 --- a/ms/error-catalog/pom.xml +++ b/ms/error-catalog/pom.xml @@ -78,6 +78,11 @@ <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/ms/sdclistener/application/pom.xml b/ms/sdclistener/application/pom.xml index 319bec11b..aa48c46aa 100644 --- a/ms/sdclistener/application/pom.xml +++ b/ms/sdclistener/application/pom.xml @@ -52,6 +52,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId> <artifactId>health-api-common</artifactId> <version>${ccsdk.cds.version}</version> |