Metadata for name, version, tags and type
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / selfservice-api / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / selfservice / api / ExecutionServiceControllerTest.kt
index e1a498a..3119b80 100644 (file)
@@ -22,6 +22,7 @@ import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.controllerblueprints.core.compress
 import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
@@ -36,17 +37,21 @@ import org.springframework.test.context.junit4.SpringRunner
 import org.springframework.test.web.reactive.server.WebTestClient
 import org.springframework.web.reactive.function.BodyInserters
 import java.io.File
-import java.util.*
+import java.util.UUID
 import kotlin.test.AfterTest
 import kotlin.test.BeforeTest
 import kotlin.test.assertTrue
 
 @RunWith(SpringRunner::class)
 @WebFluxTest
-@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class,
-    BluePrintCatalogService::class, SecurityProperties::class])
-@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
-    "org.onap.ccsdk.cds.controllerblueprints"])
+@ContextConfiguration(
+    classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class,
+        BluePrintCatalogService::class, SecurityProperties::class]
+)
+@ComponentScan(
+    basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
+        "org.onap.ccsdk.cds.controllerblueprints"]
+)
 @TestPropertySource(locations = ["classpath:application-test.properties"])
 class ExecutionServiceControllerTest {
 
@@ -58,6 +63,10 @@ class ExecutionServiceControllerTest {
     @BeforeTest
     fun init() {
         deleteDir("target", "blueprints")
+
+        // Create sample CBA zip
+        normalizedFile("./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+            .compress(normalizedFile("./target/blueprints/generated-cba.zip"))
     }
 
     @AfterTest
@@ -71,15 +80,17 @@ class ExecutionServiceControllerTest {
             blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile())
 
             val executionServiceInput = JacksonUtils
-                    .readValueFromClassPathFile("execution-input/default-input.json",
-                            ExecutionServiceInput::class.java)!!
+                .readValueFromClassPathFile(
+                    "execution-input/default-input.json",
+                    ExecutionServiceInput::class.java
+                )!!
 
             webTestClient
-                    .post()
-                    .uri("/api/v1/execution-service/process")
-                    .body(BodyInserters.fromObject(executionServiceInput))
-                    .exchange()
-                    .expectStatus().isOk
+                .post()
+                .uri("/api/v1/execution-service/process")
+                .body(BodyInserters.fromObject(executionServiceInput))
+                .exchange()
+                .expectStatus().isOk
         }
     }
 
@@ -89,21 +100,23 @@ class ExecutionServiceControllerTest {
             blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile())
 
             val executionServiceInput = JacksonUtils
-                    .readValueFromClassPathFile("execution-input/faulty-input.json",
-                            ExecutionServiceInput::class.java)!!
+                .readValueFromClassPathFile(
+                    "execution-input/faulty-input.json",
+                    ExecutionServiceInput::class.java
+                )!!
 
             webTestClient
-                    .post()
-                    .uri("/api/v1/execution-service/process")
-                    .body(BodyInserters.fromObject(executionServiceInput))
-                    .exchange()
-                    .expectStatus().is5xxServerError
+                .post()
+                .uri("/api/v1/execution-service/process")
+                .body(BodyInserters.fromObject(executionServiceInput))
+                .exchange()
+                .expectStatus().is5xxServerError
         }
     }
 
     private fun loadTestCbaFile(): File {
-        val testCbaFile = normalizedFile("./src/test/resources/test-cba.zip")
+        val testCbaFile = normalizedFile("./target/blueprints/generated-cba.zip")
         assertTrue(testCbaFile.exists(), "couldn't get file ${testCbaFile.absolutePath}")
         return testCbaFile
     }
-}
\ No newline at end of file
+}