From d4fadc988246eb172ce8333bb3a06443591c5f19 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Wed, 11 Dec 2019 18:32:24 -0500 Subject: Metadata for name, version, tags and type Mandate Tosca.meta template name, version, type and tags. Auto copy metadata from Tosca.meta to ServiceTemplate definitions. Optimize Blueprint context and runtime creation from file path. Removed attached CBA zip file in test repository dirs Issue-ID: CCSDK-1992 Signed-off-by: Brinda Santh Change-Id: I5d9d7a4599234a38d431328dbd9b74bd831e0115 --- .../db/BlueprintProcessorCatalogServiceImplTest.kt | 25 ++++++++++++--------- .../MockBlueprintProcessorCatalogServiceImpl.kt | 6 ++--- .../commons/db-lib/src/test/resources/test-cba.zip | Bin 9554 -> 0 bytes 3 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip (limited to 'ms/blueprintsprocessor/modules/commons') diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt index e86dfab72..5d546c2ef 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt @@ -25,6 +25,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.db.mock.MockBlueprintProcessorCata import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service.BlueprintCatalogServiceImpl import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service.BlueprintProcessorCatalogServiceImpl import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.compress import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService @@ -62,8 +63,14 @@ class BlueprintProcessorCatalogServiceImplTest { @BeforeTest fun setup() { + deleteDir("target", "blueprints") - bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + + // Create sample CBA zip + normalizedFile("./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + .compress(normalizedFile("./target/blueprints/generated-cba.zip")) + + bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime( blueprintId, "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" ) @@ -76,11 +83,9 @@ class BlueprintProcessorCatalogServiceImplTest { @Test fun `test catalog service`() { - // TODO: I thing this test function should be remve and replace by the other one. - runBlocking { - // FIXME("Create ZIP from test blueprints") - val file = normalizedFile("./src/test/resources/test-cba.zip") + runBlocking { + val file = normalizedFile("./target/blueprints/generated-cba.zip") assertTrue(file.exists(), "couldn't get file ${file.absolutePath}") blueprintsProcessorCatalogService.saveToDatabase("1234", file) @@ -93,7 +98,7 @@ class BlueprintProcessorCatalogServiceImplTest { @Test fun `test save function`() { runBlocking { - val file = normalizedFile("./src/test/resources/test-cba.zip") + val file = normalizedFile("./target/blueprints/generated-cba.zip") assertTrue(file.exists(), "couldnt get file ${file.absolutePath}") val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId @@ -105,7 +110,7 @@ class BlueprintProcessorCatalogServiceImplTest { @Test fun `test get function`() { runBlocking { - val file = normalizedFile("./src/test/resources/test-cba.zip") + val file = normalizedFile("./target/blueprints/generated-cba.zip") assertTrue(file.exists(), "couldnt get file ${file.absolutePath}") val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId @@ -117,10 +122,10 @@ class BlueprintProcessorCatalogServiceImplTest { assertTrue( File( blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath + - "/baseconfiguration" + "/baseconfiguration" ).deleteRecursively(), "Couldn't get blueprint archive " + - "${blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath}/baseconfiguration " + - "from data base." + "${blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath}/baseconfiguration " + + "from data base." ) } diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt index 8dcf42668..248181f16 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt @@ -15,7 +15,7 @@ */ package org.onap.ccsdk.cds.blueprintsprocessor.db.mock -import io.mockk.every +import io.mockk.coEvery import io.mockk.mockk import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService @@ -28,8 +28,8 @@ open class MockBlueprintProcessorCatalogServiceImpl { @Bean(name = ["bluePrintRuntimeValidatorService"]) open fun bluePrintRuntimeValidatorService(): BluePrintValidatorService { val bluePrintValidatorService = mockk() - every { bluePrintValidatorService.validateBluePrints(any()) } returns true - every { bluePrintValidatorService.validateBluePrints(any>()) } returns true + coEvery { bluePrintValidatorService.validateBluePrints(any()) } returns true + coEvery { bluePrintValidatorService.validateBluePrints(any>()) } returns true return bluePrintValidatorService } } diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip deleted file mode 100644 index 785ec6c00..000000000 Binary files a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip and /dev/null differ -- cgit 1.2.3-korg