From 82753f0646ae2181baf247f51d2909058dcc3707 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Wed, 31 Jul 2019 12:31:09 -0400 Subject: Fix conflicting catalog service instance names. Change-Id: Iec330d87f9609d42c05f8d4c7c8515fa37310a6e Issue-ID: CCSDK-1046 Signed-off-by: Brinda Santh --- .../db/BlueprintProcessorCatalogServiceImpl.kt | 2 +- .../db/primary/PrimaryDatabaseConfiguration.kt | 12 ++++++--- .../db/BlueprintProcessorCatalogServiceImplTest.kt | 29 ++++++++++------------ .../MockBlueprintProcessorCatalogServiceImpl.kt | 12 ++++++--- 4 files changed, 31 insertions(+), 24 deletions(-) (limited to 'ms/blueprintsprocessor/modules/commons/db-lib') diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt index 9faf879f0..9d5d630de 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt @@ -39,7 +39,7 @@ import java.util.* /** * Similar/Duplicate implementation in [org.onap.ccsdk.cds.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl] */ -@Service +@Service("blueprintsProcessorCatalogService") class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService, private val bluePrintPathConfiguration: BluePrintPathConfiguration, private val blueprintModelRepository: BlueprintProcessorModelRepository) diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt index 4ea407ada..a62867053 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt @@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Primary +import org.springframework.data.jpa.repository.config.EnableJpaAuditing import org.springframework.data.jpa.repository.config.EnableJpaRepositories import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate import org.springframework.jdbc.datasource.DriverManagerDataSource @@ -33,10 +34,12 @@ import javax.sql.DataSource @Configuration @EnableJpaRepositories( - basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.*"], - entityManagerFactoryRef = "primaryEntityManager", - transactionManagerRef = "primaryTransactionManager" + basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.*", + "org.onap.ccsdk.cds.controllerblueprints.*"], + entityManagerFactoryRef = "primaryEntityManager", + transactionManagerRef = "primaryTransactionManager" ) +@EnableJpaAuditing open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) { val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!! @@ -45,7 +48,8 @@ open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean { val em = LocalContainerEntityManagerFactoryBean() em.dataSource = primaryDataSource() - em.setPackagesToScan("org.onap.ccsdk.cds.blueprintsprocessor.*") + em.setPackagesToScan("org.onap.ccsdk.cds.blueprintsprocessor.*", + "org.onap.ccsdk.cds.controllerblueprints.*") em.jpaVendorAdapter = HibernateJpaVendorAdapter() val properties = HashMap() properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto 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 e40efd0c4..fe8172b85 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 @@ -20,14 +20,14 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith -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 import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.db.mock.MockBlueprintProcessorCatalogServiceImpl import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +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 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.db.resources.BlueprintCatalogServiceImpl import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.context.annotation.ComponentScan @@ -41,17 +41,14 @@ import kotlin.test.assertTrue @RunWith(SpringRunner::class) @EnableAutoConfiguration -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) +@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor"]) @ContextConfiguration(classes = [BlueprintProcessorCatalogServiceImpl::class, BluePrintCoreConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class]) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BlueprintProcessorCatalogServiceImplTest { @Autowired - lateinit var blueprintCatalog: BluePrintCatalogService - - @Autowired - lateinit var blueprintProcessorCatalogServiceImpl: BlueprintProcessorCatalogServiceImpl + lateinit var blueprintsProcessorCatalogService: BlueprintCatalogServiceImpl @Autowired lateinit var blueprintCoreConfiguration: BluePrintCoreConfiguration @@ -64,7 +61,7 @@ class BlueprintProcessorCatalogServiceImplTest { fun setup() { deleteDir("target", "blueprints") bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(blueprintId, - "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") } @AfterTest @@ -81,10 +78,10 @@ class BlueprintProcessorCatalogServiceImplTest { val file = normalizedFile("./src/test/resources/test-cba.zip") assertTrue(file.exists(), "couldn't get file ${file.absolutePath}") - blueprintCatalog.saveToDatabase("1234", file) - blueprintCatalog.getFromDatabase("baseconfiguration", "1.0.0") + blueprintsProcessorCatalogService.saveToDatabase("1234", file) + blueprintsProcessorCatalogService.getFromDatabase("baseconfiguration", "1.0.0") - blueprintCatalog.deleteFromDatabase("baseconfiguration", "1.0.0") + blueprintsProcessorCatalogService.deleteFromDatabase("baseconfiguration", "1.0.0") } } @@ -96,7 +93,7 @@ class BlueprintProcessorCatalogServiceImplTest { val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId - blueprintProcessorCatalogServiceImpl.save(metadata, file) + blueprintsProcessorCatalogService.save(metadata, file) } } @@ -108,8 +105,8 @@ class BlueprintProcessorCatalogServiceImplTest { val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId - blueprintProcessorCatalogServiceImpl.save(metadata, file) - blueprintProcessorCatalogServiceImpl.get("baseconfiguration", "1.0.0", true) + blueprintsProcessorCatalogService.save(metadata, file) + blueprintsProcessorCatalogService.get("baseconfiguration", "1.0.0", true) } assertTrue(File(blueprintCoreConfiguration.bluePrintPathConfiguration().blueprintArchivePath + @@ -121,7 +118,7 @@ class BlueprintProcessorCatalogServiceImplTest { @Test fun `test delete function`() { runBlocking { - blueprintProcessorCatalogServiceImpl.delete("baseconfiguration", "1.0.0") + blueprintsProcessorCatalogService.delete("baseconfiguration", "1.0.0") } } } \ No newline at end of file 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 08de33270..b98fc0c44 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,15 +15,21 @@ */ package org.onap.ccsdk.cds.blueprintsprocessor.db.mock +import io.mockk.every import io.mockk.mockk import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration + @Configuration open class MockBlueprintProcessorCatalogServiceImpl { - @Bean(name = ["blueprintProcessorCatalogServiceImpl"]) - open fun createBlueprintProcessorCatalogServiceImpl(): BluePrintValidatorService { - return mockk() + @Bean(name = ["bluePrintRuntimeValidatorService"]) + open fun bluePrintRuntimeValidatorService(): BluePrintValidatorService { + val bluePrintValidatorService = mockk() + every { bluePrintValidatorService.validateBluePrints(any()) } returns true + every { bluePrintValidatorService.validateBluePrints(any>()) } returns true + return bluePrintValidatorService } } \ No newline at end of file -- cgit 1.2.3-korg