2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
20 import org.junit.runner.RunWith
21 import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
22 import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
23 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
24 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
25 import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
26 import org.springframework.beans.factory.annotation.Autowired
27 import org.springframework.test.context.ContextConfiguration
28 import org.springframework.test.context.junit4.SpringRunner
29 import kotlin.test.assertNotNull
31 @RunWith(SpringRunner::class)
32 @ContextConfiguration(classes = [CapabilityResourceAssignmentProcessor::class, BluePrintScriptsServiceImpl::class,
33 MockCapabilityService::class])
34 class CapabilityResourceAssignmentProcessorTest {
37 lateinit var capabilityResourceAssignmentProcessor: CapabilityResourceAssignmentProcessor
40 fun `test kotlin capability`() {
42 val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
43 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
45 val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
47 capabilityResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
48 capabilityResourceAssignmentProcessor.resourceDictionaries = hashMapOf()
51 val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
52 scriptPropertyInstances["mock-service1"] = MockCapabilityService()
53 scriptPropertyInstances["mock-service2"] = MockCapabilityService()
55 val resourceAssignmentProcessor = capabilityResourceAssignmentProcessor
56 .getKotlinResourceAssignmentProcessorInstance(
57 "ResourceAssignmentProcessor_cba\$ScriptResourceAssignmentProcessor", scriptPropertyInstances)
59 assertNotNull(resourceAssignmentProcessor, "couldn't get kotlin script resource assignment processor")
61 val resourceAssignment = ResourceAssignment().apply {
63 dictionaryName = "ra-dict-name"
64 dictionarySource = "capability"
65 property = PropertyDefinition().apply {
70 val processorName = resourceAssignmentProcessor.apply(resourceAssignment)
71 assertNotNull(processorName, "couldn't get kotlin script resource assignment processor name")
72 println(processorName)
77 open class MockCapabilityService {