API tests: support TENANT_AND_REGION_FROM_VNF flag
[vid.git] / vid-automation / src / main / java / org / onap / simulator / presetGenerator / presets / mso / PresetMSOCreateVfModuleALaCarteCypress.java
1 package org.onap.simulator.presetGenerator.presets.mso;
2
3 import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;
4
5 import com.google.common.collect.ImmutableMap;
6 import java.util.Map;
7
8 public class PresetMSOCreateVfModuleALaCarteCypress extends PresetMSOCreateVfModuleBase {
9
10     protected final Map<Keys, String> names;
11
12     public enum Keys {
13         lcpCloudRegionId, tenantId,
14         modelVersionId, modelName, modelVersion, modelCustomizationId, modelCustomizationName, instanceName, modelInvariantId
15     }
16
17     public static Map<Keys, String> lcpCloudRegionIdAndTenantIdNames(String lcpCloudRegionId, String tenantId) {
18       return ImmutableMap.of(
19           Keys.lcpCloudRegionId, lcpCloudRegionId,
20           Keys.tenantId, tenantId
21       );
22     }
23
24     public static final Map<Keys, String> module0Names = ImmutableMap.<Keys, String>builder()
25             .put(Keys.instanceName, "mimazepubi")
26             .put(Keys.modelInvariantId, "b34833bb-6aa9-4ad6-a831-70b06367a091")
27             .put(Keys.modelVersionId, "f8360508-3f17-4414-a2ed-6bc71161e8db")
28             .put(Keys.modelName, "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0")
29             .put(Keys.modelVersion, "5")
30             .put(Keys.modelCustomizationId, "a55961b2-2065-4ab0-a5b7-2fcee1c227e3")
31             .put(Keys.modelCustomizationName, "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0")
32             .build();
33
34     public static final Map<Keys, String> module2Names = ImmutableMap.<Keys, String>builder()
35             .put(Keys.instanceName, "bnmgtrx")
36             .put(Keys.modelInvariantId, "eff8cc59-53a1-4101-aed7-8cf24ecf8339")
37             .put(Keys.modelVersionId, "0a0dd9d4-31d3-4c3a-ae89-a02f383e6a9a")
38             .put(Keys.modelName, "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2")
39             .put(Keys.modelVersion, "6")
40             .put(Keys.modelCustomizationId, "3cd946bb-50e0-40d8-96d3-c9023520b557")
41             .put(Keys.modelCustomizationName, "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2")
42             .build();
43
44     public PresetMSOCreateVfModuleALaCarteCypress(String overrideRequestId, String serviceInstanceId, String vnfInstanceId, Map<Keys, String> names, Map<Keys, String> lcpCloudRegionIdAndTenantIdNames, String testApi, boolean withTestApi) {
45         super(overrideRequestId, DEFAULT_INSTANCE_ID, serviceInstanceId, vnfInstanceId, "vfModule");
46         this.names = ImmutableMap.<Keys, String>builder().putAll(names).putAll(lcpCloudRegionIdAndTenantIdNames).build();
47         this.msoTestApi = testApi;
48         this.withTestApi = withTestApi;
49     }
50
51     @Override
52     public Object getRequestBody() {
53         return "" +
54                 "{" +
55                 "  \"requestDetails\":{" +
56                 "    \"modelInfo\":{" +
57                 "      \"modelType\":\"vfModule\"," +
58                 "      \"modelInvariantId\":\"" + names.get(Keys.modelInvariantId) + "\"," +
59                 "      \"modelVersionId\":\"" + names.get(Keys.modelVersionId) + "\"," +
60                 "      \"modelName\":\"" + names.get(Keys.modelName) + "\"," +
61                 "      \"modelVersion\":\"" + names.get(Keys.modelVersion) + "\"," +
62                 "      \"modelCustomizationId\":\"" + names.get(Keys.modelCustomizationId) + "\"," +
63                 "      \"modelCustomizationName\":\"" + names.get(Keys.modelCustomizationName) + "\"" +
64                 "    }," +
65                 "    \"cloudConfiguration\":{" +
66                 "      \"lcpCloudRegionId\":\"" + defaultIfEmpty(names.get(Keys.lcpCloudRegionId), "hvf6") + "\"," +
67                       addCloudOwnerIfNeeded() +
68                 "      \"tenantId\":\"" + defaultIfEmpty(names.get(Keys.tenantId), "624eb554b0d147c19ff8885341760481") + "\"" +
69                 "    }," +
70                 "    \"requestInfo\":{" +
71                 "      \"instanceName\":\"" + names.get(Keys.instanceName) + "\"," +
72                 "      \"source\":\"VID\"," +
73                 "      \"suppressRollback\":true," +
74                 "      \"requestorId\":\"us16807000\"" +
75                 "    }," +
76                 "    \"relatedInstanceList\":[{" +
77                 "        \"relatedInstance\":{" +
78                 "          \"instanceId\":\"" + serviceInstanceId + "\"," +
79                 "          \"modelInfo\":{" +
80                 "            \"modelType\":\"service\"," +
81                 "            \"modelName\":\"action-data\"," +
82                 "            \"modelInvariantId\":\"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," +
83                 "            \"modelVersion\":\"1.0\"," +
84                 "            \"modelVersionId\":\"2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd\"" +
85                 "          }" +
86                 "        }" +
87                 "      }, {" +
88                 "        \"relatedInstance\":{" +
89                 "          \"instanceId\":\"" + vnfInstanceId + "\"," +
90                 "          \"modelInfo\":{" +
91                 "            \"modelType\":\"vnf\"," +
92                 "            \"modelName\":\"2017-488_PASQUALE-vPE\"," +
93                 "            \"modelInvariantId\":\"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\"," +
94                 "            \"modelVersion\":\"5.0\"," +
95                 "            \"modelVersionId\":\"69e09f68-8b63-4cc9-b9ff-860960b5db09\"," +
96                 "            \"modelCustomizationId\":\"1da7b585-5e61-4993-b95e-8e6606c81e45\"," +
97                 "            \"modelCustomizationName\":\"2017-488_PASQUALE-vPE 0\"" +
98                 "          }" +
99                 "        }" +
100                 "      }" +
101                 "    ]," +
102                 "    \"requestParameters\":{" +
103                         addTestApi()+
104                 "      \"userParams\":[" +
105                 "      ]," +
106                 "      \"usePreload\":false" +
107                 "    }" +
108                 "  }" +
109                 "}";
110     }
111 }