diff options
author | Brinda Santh <bs2796@att.com> | 2019-11-27 19:42:17 -0500 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2019-11-29 05:18:04 +0000 |
commit | ebdd198e47b2da08a2aa470177a3baa4a2cf1c4c (patch) | |
tree | 591145cb25216307a9778df15c69700fffb5d849 /ms/blueprintsprocessor/functions | |
parent | 4947afebcfbee275e2f3a804d0a5648428f69908 (diff) |
Optimize spring data JPA UT.
Test case based database configuration, so that we can define what repositories and entities can be used for testing.
Issue-ID: CCSDK-1735
Signed-off-by: Brinda Santh <bs2796@att.com>
Change-Id: I4f8a7eb4ed47fec9ab17eb9552648ebd0de01236
Diffstat (limited to 'ms/blueprintsprocessor/functions')
20 files changed, 268 insertions, 86 deletions
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt index cb7467b60..e1806438b 100644 --- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt +++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt @@ -16,6 +16,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository import javax.transaction.Transactional /** @@ -24,6 +25,7 @@ import javax.transaction.Transactional * @author Serge Simard * @version 1.0 */ +@Repository interface ResourceConfigSnapshotRepository : JpaRepository<ResourceConfigSnapshot, String> { fun findByResourceIdAndResourceTypeAndStatus( diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt index fcbc15702..9260b79e8 100644 --- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt +++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt @@ -32,7 +32,7 @@ import java.util.UUID * @version 1.0 */ @Service -class ResourceConfigSnapshotService(private val repository: ResourceConfigSnapshotRepository) { +open class ResourceConfigSnapshotService(private val resourceConfigSnapshotRepository: ResourceConfigSnapshotRepository) { private val log = LoggerFactory.getLogger(ResourceConfigSnapshotService::class.toString()) @@ -42,7 +42,7 @@ class ResourceConfigSnapshotService(private val repository: ResourceConfigSnapsh status: ResourceConfigSnapshot.Status = RUNNING ): String = withContext(Dispatchers.IO) { - repository.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status) + resourceConfigSnapshotRepository.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status) ?.config_snapshot ?: Strings.EMPTY } @@ -63,18 +63,18 @@ class ResourceConfigSnapshotService(private val repository: ResourceConfigSnapsh // Overwrite configuration snapshot entry of resId/resType if (resId.isNotEmpty() && resType.isNotEmpty()) { - repository.findByResourceIdAndResourceTypeAndStatus(resId, resType, status) + resourceConfigSnapshotRepository.findByResourceIdAndResourceTypeAndStatus(resId, resType, status) ?.let { log.info( "Overwriting configuration snapshot entry for resourceId=($resId), " + "resourceType=($resType), status=($status)" ) - repository.deleteByResourceIdAndResourceTypeAndStatus(resId, resType, status) + resourceConfigSnapshotRepository.deleteByResourceIdAndResourceTypeAndStatus(resId, resType, status) } } var storedSnapshot: ResourceConfigSnapshot try { - storedSnapshot = repository.saveAndFlush(resourceConfigSnapshotEntry) + storedSnapshot = resourceConfigSnapshotRepository.saveAndFlush(resourceConfigSnapshotEntry) log.info( "Stored configuration snapshot for resourceId=($resId), " + "resourceType=($resType), status=($status), " + diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt index c472337ac..450da1c9f 100644 --- a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt @@ -23,10 +23,7 @@ import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor.Companion.DIFF_JSON import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor.Companion.DIFF_XML import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor.Companion.OPERATION_DIFF @@ -36,11 +33,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db.Reso import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db.ResourceConfigSnapshotService import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.context.annotation.ComponentScan import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource @@ -48,13 +43,12 @@ import org.springframework.test.context.junit4.SpringRunner @RunWith(SpringRunner::class) @ContextConfiguration( - classes = [ResourceConfigSnapshotService::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, - BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class] + classes = [ResourceConfigSnapshotService::class, TestDatabaseConfiguration::class] ) @TestPropertySource(locations = ["classpath:application-test.properties"]) -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) -@EnableAutoConfiguration +@ComponentScan( + basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots"] +) @Suppress("SameParameterValue") class ComponentConfigSnapshotsExecutorTest { @@ -346,9 +340,9 @@ class ComponentConfigSnapshotsExecutorTest { // then; we should get JSON-patches differences in our response property val diffJson = "[{\"op\":\"add\",\"path\":\"/system-uptime-information/last-configured-time/new-child-object\",\"value\":{\"property\":\"value\"}}," + - "{\"op\":\"replace\",\"path\":\"/system-uptime-information/system-booted-time/time-length\",\"value\":\"14:52:54\"}," + - "{\"op\":\"replace\",\"path\":\"/system-uptime-information/time-source\",\"value\":\" DNS CLOCK \"}," + - "{\"op\":\"add\",\"path\":\"/system-uptime-information/uptime-information/load-average-10\",\"value\":\"0.05\"}]" + "{\"op\":\"replace\",\"path\":\"/system-uptime-information/system-booted-time/time-length\",\"value\":\"14:52:54\"}," + + "{\"op\":\"replace\",\"path\":\"/system-uptime-information/time-source\",\"value\":\" DNS CLOCK \"}," + + "{\"op\":\"add\",\"path\":\"/system-uptime-information/uptime-information/load-average-10\",\"value\":\"0.05\"}]" assertEquals( diffJson.asJsonPrimitive(), bluePrintRuntimeService.getNodeTemplateAttributeValue( @@ -394,13 +388,13 @@ class ComponentConfigSnapshotsExecutorTest { // then; we should get XML-patches differences in our response property val diffXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + - "<diff>" + - "<replace sel=\"/output[1]/interface-information[1]/interface-flapped[1]/@seconds\">2343</replace>" + - "<replace sel=\"/output[1]/interface-information[1]/interface-flapped[1]/text()[1]\">34</replace>" + - "<replace sel=\"/output[1]/interface-information[1]/traffic-statistics[1]/input-packets[1]/text()[1]\">09098789</replace>" + - "<replace sel=\"/output[1]/interface-information[1]/traffic-statistics[1]/output-packets[1]/text()[1]\">2828828</replace>" + - "<add sel=\"/output[1]/interface-information[1]/physical-interface[1]\"><interface-name>TEGig400-int01</interface-name></add>" + - "</diff>" + "<diff>" + + "<replace sel=\"/output[1]/interface-information[1]/interface-flapped[1]/@seconds\">2343</replace>" + + "<replace sel=\"/output[1]/interface-information[1]/interface-flapped[1]/text()[1]\">34</replace>" + + "<replace sel=\"/output[1]/interface-information[1]/traffic-statistics[1]/input-packets[1]/text()[1]\">09098789</replace>" + + "<replace sel=\"/output[1]/interface-information[1]/traffic-statistics[1]/output-packets[1]/text()[1]\">2828828</replace>" + + "<add sel=\"/output[1]/interface-information[1]/physical-interface[1]\"><interface-name>TEGig400-int01</interface-name></add>" + + "</diff>" assertEquals( diffXml.asJsonPrimitive(), bluePrintRuntimeService.getNodeTemplateAttributeValue( @@ -411,30 +405,47 @@ class ComponentConfigSnapshotsExecutorTest { } } - private fun preparePayload(filename: String, resId: String, resType: String, status: ResourceConfigSnapshot.Status) { + private fun preparePayload( + filename: String, + resId: String, + resType: String, + status: ResourceConfigSnapshot.Status + ) { runBlocking { - cfgSnapshotService.write(JacksonUtils.getClassPathFileContent("payload/requests/$filename"), resId, resType, status) + cfgSnapshotService.write( + JacksonUtils.getClassPathFileContent("payload/requests/$filename"), + resId, + resType, + status + ) } } private fun prepareRequestProperties(oper: String, resId: String, resType: String, optional: String = "") { cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_OPERATION] = oper.asJsonPrimitive() - cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_ID] = resId.asJsonPrimitive() - cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_TYPE] = resType.asJsonPrimitive() + cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_ID] = + resId.asJsonPrimitive() + cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_TYPE] = + resType.asJsonPrimitive() // Optional inputs - cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_DIFF_CONTENT_TYPE] = "".asJsonPrimitive() - cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_SNAPSHOT] = "".asJsonPrimitive() + cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_DIFF_CONTENT_TYPE] = + "".asJsonPrimitive() + cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_SNAPSHOT] = + "".asJsonPrimitive() cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_STATUS] = ResourceConfigSnapshot.Status.RUNNING.name.asJsonPrimitive() when (oper) { OPERATION_DIFF -> - cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_DIFF_CONTENT_TYPE] = optional.asJsonPrimitive() + cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_DIFF_CONTENT_TYPE] = + optional.asJsonPrimitive() OPERATION_STORE -> - cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_SNAPSHOT] = optional.asJsonPrimitive() + cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_SNAPSHOT] = + optional.asJsonPrimitive() OPERATION_FETCH -> - cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_STATUS] = optional.asJsonPrimitive() + cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_STATUS] = + optional.asJsonPrimitive() } } } diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/TestDatabaseConfiguration.kt new file mode 100644 index 000000000..96045ee07 --- /dev/null +++ b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/TestDatabaseConfiguration.kt @@ -0,0 +1,58 @@ +/* + * Copyright © 2018-2019 AT&T Intellectual Property. + * + * 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.functions.config.snapshots + +import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDataSourceProperties +import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDatabaseConfiguration +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Import +import org.springframework.data.jpa.repository.config.EnableJpaAuditing +import org.springframework.data.jpa.repository.config.EnableJpaRepositories +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean +import org.springframework.transaction.PlatformTransactionManager +import javax.sql.DataSource + +@Configuration +@Import(BluePrintDBLibConfiguration::class) +@EnableJpaRepositories( + basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots"], + entityManagerFactoryRef = "primaryEntityManager", + transactionManagerRef = "primaryTransactionManager" +) +@EnableJpaAuditing +open class TestDatabaseConfiguration(primaryDataSourceProperties: PrimaryDataSourceProperties) : + PrimaryDatabaseConfiguration(primaryDataSourceProperties) { + + @Bean("primaryEntityManager") + open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean { + return primaryEntityManager( + "org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots" + ) + } + + @Bean("primaryDataSource") + override fun primaryDataSource(): DataSource { + return super.primaryDataSource() + } + + @Bean("primaryTransactionManager") + override fun primaryTransactionManager(): PlatformTransactionManager { + return super.primaryTransactionManager() + } +} diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt index be65c1d7c..37d853cfe 100644 --- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt +++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization -import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDBLibGenericService +import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDBLibGenericService import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db.MessagePrioritization import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.topology.MessageAggregateProcessor import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.topology.MessageOutputProcessor @@ -36,7 +36,9 @@ open class TestDatabaseConfiguration { @Bean("primaryDBLibGenericService") open fun primaryDBLibGenericService(dataSource: DataSource): PrimaryDBLibGenericService { - return PrimaryDBLibGenericService(NamedParameterJdbcTemplate(dataSource)) + return PrimaryDBLibGenericService( + NamedParameterJdbcTemplate(dataSource) + ) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt index 155270cd9..a2a3a753b 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt @@ -16,7 +16,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository +@Repository interface ResourceResolutionRepository : JpaRepository<ResourceResolution, String> { fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName( diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt index 610a3cfe3..642a41b1c 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt @@ -16,8 +16,10 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository import javax.transaction.Transactional +@Repository interface TemplateResolutionRepository : JpaRepository<TemplateResolution, String> { fun findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence( diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt index 8ca0ab63f..53698ca82 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt @@ -19,7 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.pro import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService -import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDBLibGenericService +import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDBLibGenericService import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt index e1f708341..83dd0ce34 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt @@ -121,7 +121,7 @@ class ResourceResolutionComponentTest { } catch (e: BluePrintProcessorException) { assertEquals( "Can't proceed with the resolution: can't persist resolution without a correlation key. " + - "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.", + "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.", e.message ) return@runBlocking diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt index e46d457cd..264b45789 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt @@ -25,23 +25,14 @@ import org.junit.Assert import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.PayloadUtils -import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.CapabilityResourceResolutionProcessor -import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.DatabaseResourceAssignmentProcessor -import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.DefaultResourceResolutionProcessor -import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.InputResourceResolutionProcessor import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.MockCapabilityScriptRA -import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -63,12 +54,7 @@ import kotlin.test.assertTrue */ @RunWith(SpringRunner::class) @ContextConfiguration( - classes = [ResourceResolutionServiceImpl::class, - InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class, - DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class, - CapabilityResourceResolutionProcessor::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, - BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class] + classes = [TestDatabaseConfiguration::class] ) @TestPropertySource(locations = ["classpath:application-test.properties"]) @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/TestDatabaseConfiguration.kt new file mode 100644 index 000000000..121fff7cb --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/TestDatabaseConfiguration.kt @@ -0,0 +1,60 @@ +/* + * Copyright © 2018-2019 AT&T Intellectual Property. + * + * 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.functions.resource.resolution + +import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDataSourceProperties +import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDatabaseConfiguration +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Import +import org.springframework.data.jpa.repository.config.EnableJpaAuditing +import org.springframework.data.jpa.repository.config.EnableJpaRepositories +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean +import org.springframework.transaction.PlatformTransactionManager +import javax.sql.DataSource + +@Configuration +@Import(BluePrintDBLibConfiguration::class) +@EnableJpaRepositories( + basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution", + "org.onap.ccsdk.cds.blueprintsprocessor.db.primary"], + entityManagerFactoryRef = "primaryEntityManager", + transactionManagerRef = "primaryTransactionManager" +) +@EnableJpaAuditing +open class TestDatabaseConfiguration(primaryDataSourceProperties: PrimaryDataSourceProperties) : + PrimaryDatabaseConfiguration(primaryDataSourceProperties) { + + @Bean("primaryEntityManager") + open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean { + return primaryEntityManager( + "org.onap.ccsdk.cds.blueprintsprocessor.db.primary", + "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db" + ) + } + + @Bean("primaryDataSource") + override fun primaryDataSource(): DataSource { + return super.primaryDataSource() + } + + @Bean("primaryTransactionManager") + override fun primaryTransactionManager(): PlatformTransactionManager { + return super.primaryTransactionManager() + } +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt index 18a9f3233..71d895574 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt @@ -139,7 +139,12 @@ class TemplateResolutionServiceTest { val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix) verify { templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence( - eq(resourceId), eq(resourceType), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence) + eq(resourceId), + eq(resourceType), + eq(blueprintName), + eq(blueprintVersion), + eq(artifactPrefix), + eq(occurrence) ) } assertEquals(tr, res) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt index d6331fe33..61e9f51c9 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt @@ -23,14 +23,14 @@ class MockBluePrintRestLibPropertyService(bluePrintProperties: BluePrintProperti BluePrintRestLibPropertyService(bluePrintProperties) { fun mockBlueprintWebClientService(selector: String): - MockBlueprintWebClientService { + MockBlueprintWebClientService { val prefix = "blueprintsprocessor.restclient.$selector" val restClientProperties = restClientProperties(prefix) return mockBlueprintWebClientService(restClientProperties) } private fun mockBlueprintWebClientService(restClientProperties: RestClientProperties): - MockBlueprintWebClientService { + MockBlueprintWebClientService { return MockBlueprintWebClientService(restClientProperties) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt index ef5c79eab..e27f3ef1b 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt @@ -27,7 +27,8 @@ import org.springframework.http.MediaType import java.nio.charset.Charset import java.util.Base64 -class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties) : BlueprintWebClientService { +class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties) : + BlueprintWebClientService { private var mockServer: ClientAndServer private var port: String = if (restClientProperties.url.split(":")[2].isEmpty()) "8080" else restClientProperties.url.split(":")[2] @@ -41,7 +42,7 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient setRequest("GET", "/aai/v14/network/generic-vnfs/generic-vnf/123456") setRequest( "GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" + - "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name" + "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name" ) setRequestWithPayload( "PUT", "/query", @@ -66,7 +67,11 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient mockServer.close() } - override fun exchangeResource(method: String, path: String, payload: String): BlueprintWebClientService.WebClientResponse<String> { + override fun exchangeResource( + method: String, + path: String, + payload: String + ): BlueprintWebClientService.WebClientResponse<String> { val header = arrayOf(BasicHeader(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION])) return when (method) { "POST" -> { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt index 0a4de9218..774c4021a 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt @@ -24,9 +24,9 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @Configuration -open class MockDatabaseConfiguration { +open class MockDBLibGenericService { - @Bean(name = ["MariaDatabaseConfiguration", "MySqlDatabaseConfiguration", "PrimaryDatabaseConfiguration"]) + @Bean(name = ["MariaDatabaseConfiguration", "MySqlDatabaseConfiguration"]) open fun createDatabaseConfiguration(): BluePrintDBLibGenericService { return mockk<BluePrintDBLibGenericService>() } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt index a7379e22a..3600156ce 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt @@ -81,7 +81,7 @@ class MockRestResourceResolutionProcessor( logger.info( "MockRestResource ($dSource) dictionary information: " + - "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})" + "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})" ) // Get the Rest Client Service @@ -102,7 +102,10 @@ class MockRestResourceResolutionProcessor( } } catch (e: Exception) { ResourceAssignmentUtils.setFailedResourceDataValue(executionRequest, e.message) - throw BluePrintProcessorException("Failed in template resolutionKey ($executionRequest) assignments with: ${e.message}", e) + throw BluePrintProcessorException( + "Failed in template resolutionKey ($executionRequest) assignments with: ${e.message}", + e + ) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt index da2282018..57d2c1b60 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt @@ -18,15 +18,12 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.pro import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDBLibGenericService import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService -import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDatabaseConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.TestDatabaseConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockBlueprintProcessorCatalogServiceImpl -import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockDatabaseConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockDBLibGenericService import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils @@ -39,10 +36,10 @@ import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @ContextConfiguration( - classes = [DatabaseResourceAssignmentProcessor::class, BluePrintPropertyConfiguration::class, - BluePrintPropertiesService::class, BluePrintDBLibPropertyService::class, BluePrintDBLibConfiguration::class, - BluePrintCoreConfiguration::class, MockDatabaseConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class, - BluePrintPropertiesService::class, PrimaryDatabaseConfiguration::class] + classes = [TestDatabaseConfiguration::class, + PrimaryDBLibGenericService::class, BluePrintDBLibPropertyService::class, + DatabaseResourceAssignmentProcessor::class, MockDBLibGenericService::class, + MockBlueprintProcessorCatalogServiceImpl::class] ) @TestPropertySource(locations = ["classpath:application-test.properties"]) class DatabaseResourceResolutionProcessorTest { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt index 17bb5e6b0..cf8dc0c59 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt @@ -56,7 +56,8 @@ class InputResourceResolutionProcessorTest { every { resourceAssignmentRuntimeService.getInputValue("rr-name") } returns textNode inputResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService - inputResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils.resourceDefinitions(bluePrintContext.rootPath) + inputResourceResolutionProcessor.resourceDictionaries = + ResourceAssignmentUtils.resourceDefinitions(bluePrintContext.rootPath) val resourceAssignment = ResourceAssignment().apply { name = "rr-name" diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt index 7631339e8..c564d33c6 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt @@ -112,7 +112,9 @@ class ResourceAssignmentUtilsTest { properties = mapOfPropertiesHost } - every { resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("ip-address") } returns myDataTypeIpaddress + every { + resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("ip-address") + } returns myDataTypeIpaddress every { resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("host") } returns myDataTypeHost @@ -171,13 +173,21 @@ class ResourceAssignmentUtilsTest { "sample-value", "string", "", inputMapToTestPrimitiveTypeWithValue ) - assertEquals(expectedValueToTestPrimitiveType, outcome, "Unexpected outcome returned for primitive type of simple String") + assertEquals( + expectedValueToTestPrimitiveType, + outcome, + "Unexpected outcome returned for primitive type of simple String" + ) outcome = prepareResponseNodeForTest( "sample-key-value", "string", "", inputMapToTestPrimitiveTypeWithKeyValue ) - assertEquals(expectedValueToTestPrimitiveType, outcome, "Unexpected outcome returned for primitive type of key-value String") + assertEquals( + expectedValueToTestPrimitiveType, + outcome, + "Unexpected outcome returned for primitive type of key-value String" + ) } @Test @@ -186,13 +196,21 @@ class ResourceAssignmentUtilsTest { "listOfString", "list", "string", inputMapToTestCollectionOfPrimitiveType ) - assertEquals(expectedValueToTesCollectionOfPrimitiveType, outcome, "unexpected outcome returned for list of String") + assertEquals( + expectedValueToTesCollectionOfPrimitiveType, + outcome, + "unexpected outcome returned for list of String" + ) outcome = prepareResponseNodeForTest( "mapOfString", "map", "string", inputMapToTestCollectionOfPrimitiveType ) - assertEquals(expectedValueToTesCollectionOfPrimitiveType, outcome, "unexpected outcome returned for map of String") + assertEquals( + expectedValueToTesCollectionOfPrimitiveType, + outcome, + "unexpected outcome returned for map of String" + ) } @Test @@ -201,13 +219,21 @@ class ResourceAssignmentUtilsTest { "listOfMyDataTypeWithOneOutputKeyMapping", "list", "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping ) - assertEquals(expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping, outcome, "unexpected outcome returned for list of String") + assertEquals( + expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping, + outcome, + "unexpected outcome returned for list of String" + ) outcome = prepareResponseNodeForTest( "listOfMyDataTypeWithAllOutputKeyMapping", "list", "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping ) - assertEquals(expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping, outcome, "unexpected outcome returned for list of String") + assertEquals( + expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping, + outcome, + "unexpected outcome returned for list of String" + ) } @Test @@ -216,7 +242,11 @@ class ResourceAssignmentUtilsTest { "complexTypeOneKeys", "host", "", inputMapToTestComplexTypeWithOneOutputKeyMapping ) - assertEquals(expectedValueToTestComplexTypeWithOneOutputKeyMapping, outcome, "Unexpected outcome returned for complex type") + assertEquals( + expectedValueToTestComplexTypeWithOneOutputKeyMapping, + outcome, + "Unexpected outcome returned for complex type" + ) } @Test @@ -225,7 +255,11 @@ class ResourceAssignmentUtilsTest { "complexTypeAllKeys", "host", "", inputMapToTestComplexTypeWithAllOutputKeyMapping ) - assertEquals(expectedValueToTestComplexTypeWithAllOutputKeyMapping, outcome, "Unexpected outcome returned for complex type") + assertEquals( + expectedValueToTestComplexTypeWithAllOutputKeyMapping, + outcome, + "Unexpected outcome returned for complex type" + ) } private fun initInputMapAndExpectedValuesForPrimitiveType() { @@ -340,7 +374,12 @@ class ResourceAssignmentUtilsTest { val outputKeyMapping = prepareOutputKeyMapping(dictionary_source) - return ResourceAssignmentUtils.parseResponseNode(responseNode, resourceAssignment, resourceAssignmentRuntimeService, outputKeyMapping) + return ResourceAssignmentUtils.parseResponseNode( + responseNode, + resourceAssignment, + resourceAssignmentRuntimeService, + outputKeyMapping + ) } private fun prepareRADataDictionaryOfPrimaryType(dictionary_source: String): ResourceAssignment { @@ -354,7 +393,11 @@ class ResourceAssignmentUtilsTest { } } - private fun prepareRADataDictionaryCollection(dictionary_source: String, sourceType: String, schema: String): ResourceAssignment { + private fun prepareRADataDictionaryCollection( + dictionary_source: String, + sourceType: String, + schema: String + ): ResourceAssignment { return ResourceAssignment().apply { name = "ipAddress-list" dictionaryName = "sample-licenses" @@ -368,7 +411,11 @@ class ResourceAssignmentUtilsTest { } } - private fun prepareRADataDictionaryComplexType(dictionary_source: String, sourceType: String, schema: String): ResourceAssignment { + private fun prepareRADataDictionaryComplexType( + dictionary_source: String, + sourceType: String, + schema: String + ): ResourceAssignment { return ResourceAssignment().apply { name = "ipAddress-complexType" dictionaryName = "sample-licenses" diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml index f915b1ae3..7087c232c 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml @@ -24,6 +24,7 @@ </appender> <logger name="org.springframework" level="warn"/> + <logger name="org.springframework.data.repository" level="debug"/> <logger name="org.hibernate" level="info"/> <logger name="org.mockserver.mock" level="warn"/> <logger name="org.onap.ccsdk.cds.controllerblueprints" level="warn"/> |