Merge "Automation adds release-notes.rst"
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / resource-api / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / resource / api / TemplateControllerTest.kt
index 649f6b5..0984235 100644 (file)
 package org.onap.ccsdk.cds.blueprintsprocessor.resource.api
 
 import kotlinx.coroutines.runBlocking
-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.functions.resource.resolution.db.TemplateResolutionService
 import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.autoconfigure.security.SecurityProperties
 import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
 import org.springframework.context.annotation.ComponentScan
-import org.springframework.http.HttpStatus
 import org.springframework.http.MediaType
 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.springframework.web.reactive.function.BodyInserters
-import java.io.File
-import java.nio.file.Paths
 import kotlin.test.AfterTest
-import kotlin.test.BeforeTest
-import kotlin.test.assertTrue
 
 @RunWith(SpringRunner::class)
 @WebFluxTest
-@ContextConfiguration(classes = [BluePrintCoreConfiguration::class,
-    BluePrintCatalogService::class, SecurityProperties::class])
+@ContextConfiguration(
+    classes = [TestDatabaseConfiguration::class, BluePrintCoreConfiguration::class,
+        BluePrintCatalogService::class, ErrorCatalogTestConfiguration::class]
+)
 @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
 @TestPropertySource(locations = ["classpath:application-test.properties"])
 class TemplateControllerTest {
@@ -62,7 +56,7 @@ class TemplateControllerTest {
     val payloadDummyTemplateData = "PAYLOAD DATA"
 
     var requestArguments = "bpName=$blueprintName&bpVersion=$blueprintVersion" +
-            "&artifactName=$templatePrefix&resolutionKey=$resolutionKey"
+        "&artifactName=$templatePrefix&resolutionKey=$resolutionKey"
 
     @AfterTest
     fun cleanDir() {
@@ -120,13 +114,13 @@ class TemplateControllerTest {
     fun `get returns 400 error if missing arg`() {
         runBlocking {
             val arguments = "bpBADName=$blueprintName" +
-                    "&bpBADVersion=$blueprintVersion" +
-                    "&artifactName=$templatePrefix" +
-                    "&resolutionKey=$resolutionKey"
+                "&bpBADVersion=$blueprintVersion" +
+                "&artifactName=$templatePrefix" +
+                "&resolutionKey=$resolutionKey"
 
             webTestClient.get().uri("/api/v1/template?$arguments")
                 .exchange()
-                .expectStatus().isBadRequest
+                .expectStatus().isNotFound
         }
     }
 
@@ -136,8 +130,10 @@ class TemplateControllerTest {
 
             webTestClient
                 .get()
-                .uri("/api/v1/template?bpName=$blueprintName&bpVersion=$blueprintVersion" +
-                        "&artifactName=$templatePrefix&resolutionKey=bob")
+                .uri(
+                    "/api/v1/template?bpName=$blueprintName&bpVersion=$blueprintVersion" +
+                        "&artifactName=$templatePrefix&resolutionKey=notFound"
+                )
                 .exchange()
                 .expectStatus().isNotFound
         }
@@ -158,7 +154,7 @@ class TemplateControllerTest {
 
     private fun get(expectedType: String, resKey: String) {
         var requestArguments = "bpName=$blueprintName&bpVersion=$blueprintVersion" +
-                "&artifactName=$templatePrefix&resolutionKey=$resKey"
+            "&artifactName=$templatePrefix&resolutionKey=$resKey"
 
         if (expectedType.isNotEmpty()) {
             requestArguments = "$requestArguments&format=$expectedType"
@@ -179,4 +175,4 @@ class TemplateControllerTest {
                 .expectBody().equals(payloadDummyTemplateData)
         }
     }
-}
\ No newline at end of file
+}