2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
23 import java.io.Serializable;
24 import java.util.Collections;
25 import java.util.HashMap;
27 import java.util.UUID;
28 import org.onap.so.bpmn.common.BuildingBlockExecution;
29 import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
31 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
32 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
36 * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
39 public class StubbedBuildingBlockExecution implements BuildingBlockExecution {
41 private static final String CLOUD_OWNER = "CLOUD_OWNER";
42 private static final String LCP_CLOUD_REGIONID = "RegionOnce";
43 private static final String TENANT_ID = UUID.randomUUID().toString();
44 private final Map<String, Serializable> execution = new HashMap<>();
45 private final GeneralBuildingBlock generalBuildingBlock;
47 StubbedBuildingBlockExecution() {
48 generalBuildingBlock = getGeneralBuildingBlockValue();
52 public GeneralBuildingBlock getGeneralBuildingBlock() {
53 return generalBuildingBlock;
56 @SuppressWarnings("unchecked")
58 public <T> T getVariable(final String key) {
59 return (T) execution.get(key);
63 public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
68 public void setVariable(final String key, final Serializable value) {
69 execution.put(key, value);
73 public Map<ResourceKey, String> getLookupMap() {
74 return Collections.emptyMap();
78 public String getFlowToBeCalled() {
82 public static String getTenantId() {
86 private GeneralBuildingBlock getGeneralBuildingBlockValue() {
87 final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
88 buildingBlock.setCloudRegion(getCloudRegion());
92 private CloudRegion getCloudRegion() {
93 final CloudRegion cloudRegion = new CloudRegion();
94 cloudRegion.setCloudOwner(CLOUD_OWNER);
95 cloudRegion.setLcpCloudRegionId(LCP_CLOUD_REGIONID);
96 cloudRegion.setTenantId(TENANT_ID);