2 * Copyright © 2017-2018 AT&T Intellectual Property.
3 * Modifications Copyright © 2018 IBM.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
20 import kotlinx.coroutines.runBlocking
21 import org.junit.Assert
22 import org.junit.Before
24 import org.junit.runner.RunWith
25 import org.onap.ccsdk.apps.controllerblueprints.TestApplication
26 import org.onap.ccsdk.apps.controllerblueprints.core.deleteDir
27 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService
28 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
29 import org.onap.ccsdk.apps.controllerblueprints.core.normalizedPathName
30 import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService
31 import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService
32 import org.springframework.beans.factory.annotation.Autowired
33 import org.springframework.test.context.ContextConfiguration
34 import org.springframework.test.context.TestPropertySource
35 import org.springframework.test.context.junit4.SpringRunner
37 @RunWith(SpringRunner::class)
38 @ContextConfiguration(classes = arrayOf(TestApplication::class))
39 @TestPropertySource(locations = arrayOf("classpath:application.properties"))
40 class BluePrintEnhancerServiceImplTest {
43 lateinit var modelTypeLoadService: ModelTypeLoadService
46 lateinit var resourceDictionaryLoadService: ResourceDictionaryLoadService
49 lateinit var bluePrintEnhancerService: BluePrintEnhancerService
52 lateinit var bluePrintValidatorService: BluePrintValidatorService
57 modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type")
58 resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary")
59 resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/test-dictionary")
64 @Throws(Exception::class)
65 fun testEnhancementAndValidation() {
67 val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
68 testComponentInvokeEnhancementAndValidation(basePath, "base-enhance")
72 @Throws(Exception::class)
73 fun testComponentInvokeEnhancementAndValidation() {
74 val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/component_invoke"
75 testComponentInvokeEnhancementAndValidation(basePath, "component-enhance")
79 @Throws(Exception::class)
80 fun testGoldenEnhancementAndValidation() {
81 val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/golden"
82 testComponentInvokeEnhancementAndValidation(basePath, "golden-enhance")
86 @Throws(Exception::class)
87 fun testCapabilityRestconfEnhancementAndValidation() {
88 val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_restconf"
89 testComponentInvokeEnhancementAndValidation(basePath, "capability_restconf-enhance")
93 private fun testComponentInvokeEnhancementAndValidation(basePath: String, targetDirName: String) {
95 val targetPath = normalizedPathName("target/blueprints/enrichment", targetDirName)
99 val bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath)
100 Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext)
102 // Validate the Generated BluePrints
103 val valid = bluePrintValidatorService.validateBluePrints(targetPath)
104 Assert.assertTrue("blueprint($basePath) validation failed ", valid)
106 deleteDir(targetPath)