Templating constants added to ResourceAssignment
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / resource-resolution / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / resource / resolution / mock / MockRestResourceResolutionProcessor.kt
1 /*
2  * Copyright © 2019 IBM, Bell Canada.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock
17
18 import com.fasterxml.jackson.databind.JsonNode
19 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.RestResourceSource
20 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
21 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor
22 import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
23 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
24 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
25 import org.slf4j.LoggerFactory
26
27 class MockRestResourceResolutionProcessor(
28     private val blueprintRestLibPropertyService:
29         MockBluePrintRestLibPropertyService
30 ) : RestResourceResolutionProcessor(blueprintRestLibPropertyService) {
31
32     private val logger = LoggerFactory.getLogger(MockRestResourceResolutionProcessor::class.java)
33
34     override fun resolveInputKeyMappingVariables(
35         inputKeyMapping: Map<String, String>,
36         templatingConstants: Map<String, String>?
37     ): Map<String, JsonNode> {
38         this.raRuntimeService.putResolutionStore("service-instance-id", "10".asJsonPrimitive())
39         this.raRuntimeService.putResolutionStore("vnf_name", "vnf1".asJsonPrimitive())
40         this.raRuntimeService.putResolutionStore("vnf-id", "123456".asJsonPrimitive())
41         return super.resolveInputKeyMappingVariables(inputKeyMapping, templatingConstants)
42     }
43
44     override fun getName(): String {
45         return "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-rest"
46     }
47
48     override fun blueprintWebClientService(
49         resourceAssignment: ResourceAssignment,
50         restResourceSource: RestResourceSource
51     ): BlueprintWebClientService {
52         return blueprintRestLibPropertyService.mockBlueprintWebClientService(resourceAssignment.dictionarySource!!)
53     }
54 }