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
--- /dev/null
+/*
+ * 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
+
+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.controllerblueprints", "org.onap.ccsdk.cds.blueprintsprocessor"],
+ entityManagerFactoryRef = "primaryEntityManager",
+ transactionManagerRef = "primaryTransactionManager"
+)
+@EnableJpaAuditing
+open class BlueprintDatabaseConfiguration(primaryDataSourceProperties: PrimaryDataSourceProperties) :
+ PrimaryDatabaseConfiguration(primaryDataSourceProperties) {
+
+ @Bean("primaryEntityManager")
+ open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
+ return primaryEntityManager(
+ "org.onap.ccsdk.cds.controllerblueprints",
+ "org.onap.ccsdk.cds.blueprintsprocessor"
+ )
+ }
+
+ @Bean("primaryDataSource")
+ override fun primaryDataSource(): DataSource {
+ return super.primaryDataSource()
+ }
+
+ @Bean("primaryTransactionManager")
+ override fun primaryTransactionManager(): PlatformTransactionManager {
+ return super.primaryTransactionManager()
+ }
+}
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
/**
* @author Serge Simard
* @version 1.0
*/
+@Repository
interface ResourceConfigSnapshotRepository : JpaRepository<ResourceConfigSnapshot, String> {
fun findByResourceIdAndResourceTypeAndStatus(
* @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())
status: ResourceConfigSnapshot.Status = RUNNING
): String =
withContext(Dispatchers.IO) {
- repository.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status)
+ resourceConfigSnapshotRepository.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status)
?.config_snapshot ?: Strings.EMPTY
}
// 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), " +
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
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
@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 {
// 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(
// 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(
}
}
- 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()
}
}
}
--- /dev/null
+/*
+ * 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()
+ }
+}
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
@Bean("primaryDBLibGenericService")
open fun primaryDBLibGenericService(dataSource: DataSource): PrimaryDBLibGenericService {
- return PrimaryDBLibGenericService(NamedParameterJdbcTemplate(dataSource))
+ return PrimaryDBLibGenericService(
+ NamedParameterJdbcTemplate(dataSource)
+ )
}
}
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(
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(
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
} 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
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
*/
@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"])
--- /dev/null
+/*
+ * 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()
+ }
+}
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)
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)
}
}
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]
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",
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" -> {
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>()
}
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
}
} 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
+ )
}
}
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
@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 {
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"
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
"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
"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
"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
"complexTypeOneKeys", "host",
"", inputMapToTestComplexTypeWithOneOutputKeyMapping
)
- assertEquals(expectedValueToTestComplexTypeWithOneOutputKeyMapping, outcome, "Unexpected outcome returned for complex type")
+ assertEquals(
+ expectedValueToTestComplexTypeWithOneOutputKeyMapping,
+ outcome,
+ "Unexpected outcome returned for complex type"
+ )
}
@Test
"complexTypeAllKeys", "host",
"", inputMapToTestComplexTypeWithAllOutputKeyMapping
)
- assertEquals(expectedValueToTestComplexTypeWithAllOutputKeyMapping, outcome, "Unexpected outcome returned for complex type")
+ assertEquals(
+ expectedValueToTestComplexTypeWithAllOutputKeyMapping,
+ outcome,
+ "Unexpected outcome returned for complex type"
+ )
}
private fun initInputMapAndExpectedValuesForPrimitiveType() {
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 {
}
}
- 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"
}
}
- 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"
</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"/>
package org.onap.ccsdk.cds.blueprintsprocessor.db
+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.primary.BluePrintDBLibPropertyService
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Import
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+import javax.sql.DataSource
@Configuration
+@Import(
+ BluePrintPropertyConfiguration::class,
+ BluePrintPropertiesService::class,
+ BluePrintCoreConfiguration::class
+)
@EnableConfigurationProperties
open class BluePrintDBLibConfiguration(private var bluePrintPropertiesService: BluePrintPropertiesService) {
PrimaryDataSourceProperties::class.java
)
}
+
+ @Bean("primaryNamedParameterJdbcTemplate")
+ open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate {
+ return NamedParameterJdbcTemplate(primaryDataSource)
+ }
}
/**
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * 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.
* limitations under the License.
*/
-package org.onap.ccsdk.cds.blueprintsprocessor.db.primary
+package org.onap.ccsdk.cds.blueprintsprocessor.db
-import org.onap.ccsdk.cds.blueprintsprocessor.db.AbstractDBLibGenericService
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
import org.springframework.stereotype.Service
class MariaDatabaseConfiguration(private val mariaDataSourceProperties: MariaDataSourceProperties) : BluePrintDBLibGenericService {
+ val log = LoggerFactory.getLogger(MariaDatabaseConfiguration::class.java)!!
+
override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate {
return mariaNamedParameterJdbcTemplate(mariaDataSource())
}
return mariaNamedParameterJdbcTemplate(mariaDataSource()).update(sql, params)
}
- val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
-
fun mariaDataSource(): DataSource {
val dataSource = DriverManagerDataSource()
dataSource.setDriverClassName(mariaDataSourceProperties.driverClassName)
import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDataSourceProperties
import org.slf4j.LoggerFactory
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.ComponentScan
-import org.springframework.context.annotation.Configuration
-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
import org.springframework.orm.jpa.JpaTransactionManager
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
import java.util.HashMap
import javax.sql.DataSource
-@Configuration
-@ConditionalOnProperty(
- name = ["blueprintsprocessor.db.primary.defaultConfig"], havingValue = "true",
- matchIfMissing = true
-)
-@ComponentScan
-@EnableJpaRepositories(
- basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.*",
- "org.onap.ccsdk.cds.controllerblueprints.*"],
- entityManagerFactoryRef = "primaryEntityManager",
- transactionManagerRef = "primaryTransactionManager"
-)
-@EnableJpaAuditing
open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) {
private val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
- @Bean("primaryEntityManager")
- open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
+ /** Child class will override with spring bean annotation 'primaryEntityManager' and passing entity [packagesToScan]*/
+ open fun primaryEntityManager(vararg packagesToScan: String): LocalContainerEntityManagerFactoryBean {
val em = LocalContainerEntityManagerFactoryBean()
em.dataSource = primaryDataSource()
- em.setPackagesToScan(
- "org.onap.ccsdk.cds.blueprintsprocessor.*",
- "org.onap.ccsdk.cds.controllerblueprints.*"
- )
+ em.setPackagesToScan(*packagesToScan)
em.jpaVendorAdapter = HibernateJpaVendorAdapter()
val properties = HashMap<String, Any>()
properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto
return em
}
- @Bean("primaryDataSource")
+ /** Child class will override with spring bean annotation 'primaryDataSource' */
open fun primaryDataSource(): DataSource {
val dataSource = DriverManagerDataSource()
dataSource.setDriverClassName(primaryDataSourceProperties.driverClassName)
return dataSource
}
- @Bean("primaryTransactionManager")
+ /** Child class will override with spring bean annotation 'primaryTransactionManager' */
open fun primaryTransactionManager(): PlatformTransactionManager {
val transactionManager = JpaTransactionManager()
transactionManager.entityManagerFactory = primaryEntityManager().getObject()
log.info("Initialised Primary Transaction Manager for url ${primaryDataSourceProperties.url}")
return transactionManager
}
-
- @Bean("primaryNamedParameterJdbcTemplate")
- open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate {
- return NamedParameterJdbcTemplate(primaryDataSource)
- }
}
--- /dev/null
+/*
+ * 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.db
+
+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.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.*")
+ }
+
+ @Bean("primaryDataSource")
+ override fun primaryDataSource(): DataSource {
+ return super.primaryDataSource()
+ }
+
+ @Bean("primaryTransactionManager")
+ override fun primaryTransactionManager(): PlatformTransactionManager {
+ return super.primaryTransactionManager()
+ }
+}
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.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.TestDatabaseConfiguration
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
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@ContextConfiguration(
- classes = [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"])
-@EnableAutoConfiguration
class PrimaryDatabaseConfigurationTest {
@Autowired
# See the License for the specific language governing permissions and
# limitations under the License.
#
-blueprintsprocessor.db.primary.defaultConfig=true
blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
blueprintsprocessor.db.username=sa
<dependency>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
<artifactId>config-snapshots</artifactId>
- <version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
--- /dev/null
+/*
+ * 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.configs.api
+
+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.functions.config.snapshots",
+ "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.config.snapshots",
+ "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()
+ }
+}
import org.onap.ccsdk.cds.controllerblueprints.management.api.RemoveAction
import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration
-import org.springframework.context.annotation.ComponentScan
-import org.springframework.test.annotation.DirtiesContext
+import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.AfterTest
import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
-@EnableAutoConfiguration
-@DirtiesContext
-@ComponentScan(
- basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
- "org.onap.ccsdk.cds.controllerblueprints"]
+@ContextConfiguration(
+ classes = [DesignerApiTestConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintManagementGRPCHandlerTest {
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
-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.primary.domain.BlueprintModelSearch
import org.onap.ccsdk.cds.controllerblueprints.core.compress
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(
- classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+ classes = [DesignerApiTestConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Configuration
@ComponentScan(
basePackages = ["org.onap.ccsdk.cds.controllerblueprints",
- "org.onap.ccsdk.cds.blueprintsprocessor"]
+ "org.onap.ccsdk.cds.blueprintsprocessor.designer.api",
+ "org.onap.ccsdk.cds.blueprintsprocessor.db.primary"]
)
@EnableAutoConfiguration
open class DesignerApiTestConfiguration
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
-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.designer.api.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@RunWith(SpringRunner::class)
@ContextConfiguration(
- classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+ classes = [DesignerApiTestConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
-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.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ContextConfiguration
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(
- classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+ classes = [DesignerApiTestConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
--- /dev/null
+/*
+ * 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.designer.api
+
+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.db.primary",
+ "org.onap.ccsdk.cds.blueprintsprocessor.designer.api"],
+ 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.designer.api"
+ )
+ }
+
+ @Bean("primaryDataSource")
+ override fun primaryDataSource(): DataSource {
+ return super.primaryDataSource()
+ }
+
+ @Bean("primaryTransactionManager")
+ override fun primaryTransactionManager(): PlatformTransactionManager {
+ return super.primaryTransactionManager()
+ }
+}
import org.junit.Assert
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.db.BluePrintDBLibConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load.ModelTypeLoadService
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load.ResourceDictionaryLoadService
@RunWith(SpringRunner::class)
@ContextConfiguration(
- classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+ classes = [DesignerApiTestConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintEnhancerServiceImplTest {
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
-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.designer.api.DesignerApiTestConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@RunWith(SpringRunner::class)
@ContextConfiguration(
- classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+ classes = [DesignerApiTestConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
-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.designer.api.DesignerApiTestConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@RunWith(SpringRunner::class)
@ContextConfiguration(
- classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+ classes = [DesignerApiTestConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
-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.designer.api.DesignerApiTestConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@RunWith(SpringRunner::class)
@ContextConfiguration(
- classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+ classes = [DesignerApiTestConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(SpringRunner::class)
@WebFluxTest
-@ContextConfiguration(classes = [ResourceController::class, ResourceResolutionDBService::class, SecurityProperties::class])
-@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
+@ContextConfiguration(
+ classes = [TestDatabaseConfiguration::class,
+ ResourceController::class, ResourceResolutionDBService::class, SecurityProperties::class]
+)
+@ComponentScan(
+ basePackages = ["org.onap.ccsdk.cds.controllerblueprints.core.service",
+ "org.onap.ccsdk.cds.blueprintsprocessor.resource.api",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution"]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class ResourceControllerTest {
@RunWith(SpringRunner::class)
@WebFluxTest
@ContextConfiguration(
- classes = [BluePrintCoreConfiguration::class,
+ classes = [TestDatabaseConfiguration::class, BluePrintCoreConfiguration::class,
BluePrintCatalogService::class, SecurityProperties::class]
)
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
val payloadDummyTemplateData = "PAYLOAD DATA"
var requestArguments = "bpName=$blueprintName&bpVersion=$blueprintVersion" +
- "&artifactName=$templatePrefix&resolutionKey=$resolutionKey"
+ "&artifactName=$templatePrefix&resolutionKey=$resolutionKey"
@AfterTest
fun cleanDir() {
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()
.get()
.uri(
"/api/v1/template?bpName=$blueprintName&bpVersion=$blueprintVersion" +
- "&artifactName=$templatePrefix&resolutionKey=notFound"
+ "&artifactName=$templatePrefix&resolutionKey=notFound"
)
.exchange()
.expectStatus().isNotFound
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"
--- /dev/null
+/*
+ * 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.resource.api
+
+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.db.primary",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution"],
+ 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()
+ }
+}
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration
-import org.springframework.context.annotation.ComponentScan
import org.springframework.test.annotation.DirtiesContext
+import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.BeforeTest
@RunWith(SpringRunner::class)
@DirtiesContext
-@EnableAutoConfiguration
-@ComponentScan(
- basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
- "org.onap.ccsdk.cds.controllerblueprints"]
+@ContextConfiguration(
+ classes = [SelfServiceApiTestConfiguration::class, TestDatabaseConfiguration::class]
)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintProcessingGRPCHandlerTest {
requestObs = blockingStub.process(object : StreamObserver<ExecutionServiceOutput> {
override fun onNext(executionServiceOuput: ExecutionServiceOutput) {
log.debug("onNext {}", executionServiceOuput)
- if ("1234".equals(executionServiceOuput.commonHeader.requestId)) {
+ if ("1234" == executionServiceOuput.commonHeader.requestId) {
Assert.assertEquals(
"Failed to process request, \'actionIdentifiers.mode\' not specified. Valid value are: \'sync\' or \'async\'.",
executionServiceOuput.status.errorMessage
--- /dev/null
+/*
+ * 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.selfservice.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 SelfServiceApiTestConfiguration
--- /dev/null
+/*
+ * 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.selfservice.api
+
+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.db.primary",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution"],
+ 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"
+ )
+ }
+
+ @Bean("primaryDataSource")
+ override fun primaryDataSource(): DataSource {
+ return super.primaryDataSource()
+ }
+
+ @Bean("primaryTransactionManager")
+ override fun primaryTransactionManager(): PlatformTransactionManager {
+ return super.primaryTransactionManager()
+ }
+}
@Test
fun testBlueprintRuntimeValidation() {
- val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ val blueprintBasePath =
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
assertNotNull(bluePrintRuntimeValidatorService, " failed to initilize bluePrintRuntimeValidatorService")
bluePrintRuntimeValidatorService.validateBluePrints(blueprintBasePath)