Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / adapter / vnfm / tasks / StubbedBuildingBlockExecution.java
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
22
23 import java.io.Serializable;
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.Map;
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;
33
34 /**
35  *
36  * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
37  *
38  */
39 public class StubbedBuildingBlockExecution implements BuildingBlockExecution {
40
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;
46
47     StubbedBuildingBlockExecution() {
48         generalBuildingBlock = getGeneralBuildingBlockValue();
49     }
50
51     @Override
52     public GeneralBuildingBlock getGeneralBuildingBlock() {
53         return generalBuildingBlock;
54     }
55
56     @SuppressWarnings("unchecked")
57     @Override
58     public <T> T getVariable(final String key) {
59         return (T) execution.get(key);
60     }
61
62     @Override
63     public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
64         return null;
65     }
66
67     @Override
68     public void setVariable(final String key, final Serializable value) {
69         execution.put(key, value);
70     }
71
72     @Override
73     public Map<ResourceKey, String> getLookupMap() {
74         return Collections.emptyMap();
75     }
76
77     @Override
78     public String getFlowToBeCalled() {
79         return null;
80     }
81
82     public static String getTenantId() {
83         return TENANT_ID;
84     }
85
86     private GeneralBuildingBlock getGeneralBuildingBlockValue() {
87         final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
88         buildingBlock.setCloudRegion(getCloudRegion());
89         return buildingBlock;
90     }
91
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);
97         return cloudRegion;
98     }
99
100 }