From b8539cca6f2bc572801640b3fcefe83dcecf5ef5 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Thu, 29 Aug 2019 16:46:22 -0400 Subject: [PATCH] Refactor Blueprint model controller to designer api. Change-Id: I6e729aab24262f6bdef4b92febf9f65a4819d142 Issue-ID: CCSDK-1663 Signed-off-by: Brinda Santh --- .../modules/inbounds/designer-api/pom.xml | 8 ++--- .../designer/api}/BluePrintModelHandler.kt | 2 +- .../designer/api}/BlueprintModelController.kt | 3 +- .../designer/api}/BlueprintModelControllerTest.kt | 21 ++++++----- .../designer/api/DesignerApiTestConfiguration.kt | 27 ++++++++++++++ .../src/test/resources/application-test.properties | 41 ++++++++++++++++++++++ .../src/test/resources/logback-test.xml | 39 ++++++++++++++++++++ 7 files changed, 121 insertions(+), 20 deletions(-) rename ms/{controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler => blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api}/BluePrintModelHandler.kt (99%) rename ms/{controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller => blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api}/BlueprintModelController.kt (96%) rename ms/{controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller => blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api}/BlueprintModelControllerTest.kt (90%) create mode 100644 ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt create mode 100755 ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/application-test.properties create mode 100644 ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/logback-test.xml diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml index 2586be255..7c1576e95 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml @@ -23,12 +23,8 @@ 4.0.0 designer-api jar - Blueprints Designer API - Blueprints Designer API - - - true - + Blueprints Processor Designer API + Blueprints Processor Designer API diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintModelHandler.kt similarity index 99% rename from ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/BluePrintModelHandler.kt rename to ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintModelHandler.kt index f40da68f6..d4bcd8e94 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/BluePrintModelHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintModelHandler.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.onap.ccsdk.cds.controllerblueprints.service.handler +package org.onap.ccsdk.cds.blueprintsprocessor.designer.api import org.onap.ccsdk.cds.controllerblueprints.core.* import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt similarity index 96% rename from ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelController.kt rename to ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt index a214f961e..98f521222 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt @@ -15,12 +15,11 @@ * limitations under the License. */ -package org.onap.ccsdk.cds.controllerblueprints.service.controller +package org.onap.ccsdk.cds.blueprintsprocessor.designer.api import kotlinx.coroutines.runBlocking import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch -import org.onap.ccsdk.cds.controllerblueprints.service.handler.BluePrintModelHandler import org.springframework.core.io.Resource import org.springframework.http.MediaType import org.springframework.http.ResponseEntity diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt similarity index 90% rename from ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelControllerTest.kt rename to ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt index 1ef717a5c..cd49870ae 100644 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.onap.ccsdk.cds.controllerblueprints.service.controller +package org.onap.ccsdk.cds.blueprintsprocessor.designer.api import kotlinx.coroutines.reactive.awaitSingle import kotlinx.coroutines.runBlocking @@ -26,21 +26,21 @@ import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters -import org.onap.ccsdk.cds.controllerblueprints.TestApplication +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.* import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration -import org.onap.ccsdk.cds.controllerblueprints.service.BluePrintDesignerCoreConfiguration import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.annotation.ComponentScan import org.springframework.core.io.ByteArrayResource import org.springframework.http.HttpMethod import org.springframework.http.HttpStatus import org.springframework.http.client.MultipartBodyBuilder 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.test.web.reactive.server.returnResult @@ -48,7 +48,6 @@ import org.springframework.util.Base64Utils import org.springframework.web.reactive.function.BodyInserters import java.io.File import java.nio.charset.StandardCharsets.UTF_8 -import java.nio.file.Paths import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -62,10 +61,10 @@ import kotlin.test.assertTrue @RunWith(SpringRunner::class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = [TestApplication::class, BluePrintDesignerCoreConfiguration::class]) -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.controllerblueprints"]) +@ContextConfiguration(classes = [DesignerApiTestConfiguration::class, + BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class]) +@TestPropertySource(locations = ["classpath:application-test.properties"]) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -@EnableAutoConfiguration class BlueprintModelControllerTest { private val log = LoggerFactory.getLogger(BlueprintModelControllerTest::class.java)!! @@ -79,7 +78,7 @@ class BlueprintModelControllerTest { private var bluePrintLoadConfiguration: BluePrintLoadConfiguration? = null - private val blueprintDir = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + private val blueprintDir = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" private var zipBlueprintFileName: String? = null private var testZipFile: File? = null @@ -99,7 +98,7 @@ class BlueprintModelControllerTest { val archiveDir = normalizedFile(bluePrintLoadConfiguration!!.blueprintArchivePath).reCreateDirs() assertTrue(archiveDir.exists(), "failed to create archiveDir(${archiveDir.absolutePath}") - val blueprintFile = Paths.get(blueprintDir).toFile().normalize() + val blueprintFile = normalizedFile(blueprintDir) testZipFile = blueprintFile.compress(zipBlueprintFileName!!) assertNotNull(testZipFile, "test zip is null") assertTrue(testZipFile!!.exists(), "Failed to create blueprint test zip(${testZipFile!!.absolutePath}") diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt new file mode 100644 index 000000000..03e016b8e --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt @@ -0,0 +1,27 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.designer.api + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Configuration + +@Configuration +@ComponentScan(basePackages = ["org.onap.ccsdk.cds.controllerblueprints", + "org.onap.ccsdk.cds.blueprintsprocessor"]) +@EnableAutoConfiguration +open class DesignerApiTestConfiguration diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/application-test.properties new file mode 100755 index 000000000..e22e522ee --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/application-test.properties @@ -0,0 +1,41 @@ +# +# Copyright © 2019 IBM. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +spring.main.banner-mode=off +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false +logging.level.org.springframework.web=INFO +logging.level.org.hibernate.SQL=warn +logging.level.org.hibernate.type.descriptor.sql=debug + +blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 +blueprintsprocessor.db.username=sa +blueprintsprocessor.db.password= +blueprintsprocessor.db.driverClassName=org.h2.Driver +blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop +blueprintsprocessor.db.hibernateDDLAuto=update +blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect + +# Load Resource Source Mappings +resourceSourceMappings=processor-db=source-db,input=source-input,default=source-default,sdnc=source-rest,aai-data=source-rest,capability=source-capability +# Controller Blueprints Core Configuration +blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy +blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive +blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work + +# Python executor +blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints +blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/logback-test.xml new file mode 100644 index 000000000..feb4514d6 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/logback-test.xml @@ -0,0 +1,39 @@ + + + + + + + + %d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n + + + + + + + + + + + + + + + -- 2.16.6