Reenable tests 42/143442/3
authorFiete Ostkamp <fiete.ostkamp@telekom.de>
Wed, 4 Mar 2026 08:10:43 +0000 (09:10 +0100)
committerFiete Ostkamp <fiete.ostkamp@telekom.de>
Wed, 4 Mar 2026 08:40:09 +0000 (09:40 +0100)
- blueprints-core module (125 tests)
- blueprint-validation (4 tests)
- health-api (2 tests)
- (potentially) fix sonarqube job [0]

[0] there may surface new modules that cause the job to fail
Issue-ID: CCSDK-4152
Change-Id: Ife650d77b24b3f2ce96a4cae89f61b9a65f46394
Signed-off-by: Fiete Ostkamp <fiete.ostkamp@telekom.de>
components/model-catalog/blueprint-model/cba-assembly-descriptor/pom.xml
ms/blueprintsprocessor/modules/blueprints/blueprint-core/pom.xml
ms/blueprintsprocessor/modules/blueprints/blueprint-validation/pom.xml
ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt

index f18a5bb..941db1d 100644 (file)
     <name>Components Model Catalog - Blueprints Model - CBA Assembly Descriptor</name>
     <description>Shared assembly descriptor</description>
 
+    <properties>
+        <!-- This module contains no code to scan for sonarqube
+        and not setting skip to true here breaks the whole sonarqube job -->
+        <sonar.skip>true</sonar.skip>
+    </properties>
+
     <build>
         <plugins>
             <plugin>
index 73ce4c5..c544d2e 100644 (file)
             <artifactId>commons-compress</artifactId>
         </dependency>
         <!--Testing dependencies-->
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.bytebuddy</groupId>
+            <artifactId>byte-buddy</artifactId>
+            <version>${bytebuddy.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
index 37e9817..ee20ccf 100644 (file)
         </dependency>
 
         <!--Testing dependencies-->
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.bytebuddy</groupId>
+            <artifactId>byte-buddy</artifactId>
+            <version>${bytebuddy.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>io.mockk</groupId>
index 1f3d256..df4942e 100644 (file)
  */
 
 package org.onap.ccsdk.cds.blueprintsprocessor.healthapi
-/*
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotNull
+import org.junit.Before
 import org.junit.Test
 import org.junit.runner.RunWith
-import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
-import org.springframework.context.annotation.ComponentScan
-import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.TestPropertySource
-import org.springframework.test.context.junit4.SpringRunner
-import org.springframework.test.web.reactive.server.WebTestClient
-*/
+import org.mockito.InjectMocks
+import org.mockito.Mock
+import org.mockito.Mockito
+import org.mockito.junit.MockitoJUnitRunner
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ApplicationHealth
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.WebClientEnpointResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.CombinedHealthService
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
+import org.springframework.boot.actuate.health.Status
 
 /**
- *Unit tests for making sure that two endpoints is up and running
+ * Unit tests for CombinedHealthService verifying health check aggregation logic.
  *
  * @author Shaaban Ebrahim
  * @version 1.0
  */
-/*
-@RunWith(SpringRunner::class)
-@WebFluxTest
-@ContextConfiguration(
-    classes = [BluePrintRuntimeService::class, BluePrintCoreConfiguration::class,
-        BluePrintCatalogService::class, ComponentScriptExecutor::class]
-)
-@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
-@TestPropertySource(locations = ["classpath:application-test.properties"])
+@RunWith(MockitoJUnitRunner::class)
 class HealthCheckApplicationTests {
 
-    @Autowired
-    lateinit var webTestClient: WebTestClient
+    @Mock
+    private val endPointExecution: EndPointExecution? = null
 
-    @Test
-    fun testHealthApiUp() {
-        webTestClient.get().uri("/api/v1/combinedHealth")
-            .exchange()
-            .expectStatus().is2xxSuccessful
+    @Mock
+    private val healthCheckProperties: HealthCheckProperties? = null
+
+    @InjectMocks
+    private var combinedHealthService: CombinedHealthService? = null
+
+    @Before
+    fun setup() {
+        Mockito.`when`(healthCheckProperties!!.getBluePrintBaseURL())
+            .thenReturn("http://cds-blueprints-processor-http:8080/")
+        Mockito.`when`(healthCheckProperties.getCDSListenerBaseURL())
+            .thenReturn("http://cds-sdc-listener:8080/")
     }
 
     @Test
-    fun testMetricsApiUp() {
-        webTestClient.get().uri("/api/v1/combinedMetrics")
-            .exchange()
-            .expectStatus().is2xxSuccessful
+    fun testGetCombinedHealthCheckWhenServicesAreDown() {
+        Mockito.`when`(
+            endPointExecution!!.retrieveWebClientResponse(anyObject())
+        ).thenReturn(WebClientEnpointResponse(BlueprintWebClientService.WebClientResponse(500, "")))
+
+        val result = combinedHealthService!!.getCombinedHealthCheck()
+
+        assertNotNull(result)
+        assertEquals(2, result.size)
+        result.forEach { health ->
+            assertNotNull(health)
+            assertEquals(Status.DOWN, health!!.status)
+        }
     }
-}
 
-*/
+    @Test
+    fun testGetCombinedHealthCheckWhenServicesAreUp() {
+        val successResponse = WebClientEnpointResponse(
+            BlueprintWebClientService.WebClientResponse(200, "")
+        )
+        val healthUp = ApplicationHealth(Status.UP, hashMapOf())
+
+        Mockito.`when`(
+            endPointExecution!!.retrieveWebClientResponse(anyObject())
+        ).thenReturn(successResponse)
+        Mockito.`when`(
+            endPointExecution.getHealthFromWebClientEnpointResponse(anyObject())
+        ).thenReturn(healthUp)
+
+        val result = combinedHealthService!!.getCombinedHealthCheck()
 
-class HealthCheckApplicationTests
+        assertNotNull(result)
+        assertEquals(2, result.size)
+        result.forEach { health ->
+            assertNotNull(health)
+            assertEquals(Status.UP, health!!.status)
+        }
+    }
+
+    /**
+     * Kotlin + Mockito workaround: Mockito.any() returns null, but Kotlin throws NPE
+     * when null is passed to a non-nullable parameter. Using an unchecked cast tells the
+     * Kotlin compiler the result is non-null, so it skips the null-check at the call site.
+     * Mockito intercepts the mock call before any real code runs, so null is never used.
+     */
+    @Suppress("UNCHECKED_CAST")
+    private fun <T> anyObject(): T = Mockito.any<T>() as T
+}