Enable JUnit tests 98/133298/2
authorFrank Kimmlingen <frank.kimmlingen@telekom.de>
Tue, 7 Mar 2023 15:36:48 +0000 (16:36 +0100)
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Tue, 14 Mar 2023 00:01:38 +0000 (00:01 +0000)
JUnit tests are no more executed: spring-boot-starter-test does not execute any junit4 tests by default

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

components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml
ms/blueprintsprocessor/application/pom.xml
ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt
ms/blueprintsprocessor/functions/message-prioritization/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt
ms/blueprintsprocessor/functions/pom.xml
ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
ms/blueprintsprocessor/modules/commons/pom.xml
ms/blueprintsprocessor/modules/inbounds/pom.xml
ms/blueprintsprocessor/modules/services/pom.xml
ms/error-catalog/pom.xml
ms/sdclistener/application/pom.xml

index 864f023..33169e0 100644 (file)
             <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>
index 11f987c..fa152b2 100755 (executable)
             <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.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
index f6dd88d..d233b8b 100644 (file)
@@ -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) }
index e5dbe6a..5405efc 100644 (file)
 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
@@ -180,37 +176,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 {
index d2d419d..b40e2c1 100755 (executable)
             <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.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
index 14fe78b..8e836b8 100644 (file)
             <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.glassfish.jersey.inject</groupId>
             <artifactId>jersey-hk2</artifactId>
index 56d0c96..b26eeda 100755 (executable)
             <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.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
index 2e8e9a0..9cef982 100644 (file)
             <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.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
index 42fcf2e..e23e8b9 100755 (executable)
             <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.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
index af1f937..bb586a3 100644 (file)
             <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>
index 319bec1..aa48c46 100644 (file)
             <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>health-api-common</artifactId>