Merge from ecomp 718fd196 - Integration Tests
[vid.git] / vid-automation / src / main / java / org / onap / simulator / presetGenerator / presets / aai / PresetAAIGetCloudOwnersByCloudRegionId.java
1 package org.onap.simulator.presetGenerator.presets.aai;
2
3 import com.google.common.collect.ImmutableMap;
4 import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset;
5 import org.springframework.http.HttpMethod;
6
7 import java.util.Collections;
8 import java.util.List;
9 import java.util.Map;
10 import java.util.UUID;
11
12 import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
13 import static org.apache.commons.lang3.RandomStringUtils.randomNumeric;
14
15 public class PresetAAIGetCloudOwnersByCloudRegionId extends BaseAAIPreset {
16     public static final String SOME_LEGACY_REGION = "some legacy region";
17     public static final String JUST_ANOTHER_REGION = "just another region";
18     public static final String MY_REGION = "my region";
19     public static final String LCP_REGION_TEXT = "lcpRegionText";
20     public static final String ATT_AIC = "irma-aic";
21     public static final String MDT_1 = "mdt1";
22     public static final String ATT_NC = "att-nc";
23     public static final String hvf3 = "hvf3";
24     public static final String olson3 = "olson3";
25     public static final String olson5B = "olson5b";
26     public static final String ATT_SABABA = "att-sababa";
27     public static final String AAIAIC_25 = "AAIAIC25";
28     public static final String ONE = "One";
29     public static final String hvf6 = "hvf6";
30     public static final String AUK51A = "auk51a";
31     private final String cloudRegionId;
32     private final String cloudOwner;
33
34     //Since there is a cache of cloudRegionToCloudOwner, we can't have 2 preset of same cloud region that return different cloud owner.
35     //So all the preset instance must be declared here, for conflicts prevention.
36     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_SOME_LEGACY_REGION_TO_ATT_AIC =
37             new PresetAAIGetCloudOwnersByCloudRegionId(SOME_LEGACY_REGION, ATT_AIC);
38
39     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_JUST_ANOTHER_REGION_TO_ATT_AIC =
40             new PresetAAIGetCloudOwnersByCloudRegionId(JUST_ANOTHER_REGION, ATT_AIC);
41
42     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MDT1_TO_ATT_NC =
43             new PresetAAIGetCloudOwnersByCloudRegionId(MDT_1, ATT_NC);
44
45     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_RDM3_TO_ATT_NC =
46             new PresetAAIGetCloudOwnersByCloudRegionId(olson3, ATT_NC);
47
48     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MTN3_TO_ATT_SABABA =
49             new PresetAAIGetCloudOwnersByCloudRegionId(hvf3, ATT_SABABA);
50
51     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_AAIAIC25_TO_ATT_AIC =
52             new PresetAAIGetCloudOwnersByCloudRegionId(AAIAIC_25, ATT_AIC);
53
54     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_ONE_TO_ATT_AIC =
55             new PresetAAIGetCloudOwnersByCloudRegionId(ONE, ATT_AIC);
56
57     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MTN6_TO_ATT_AIC =
58             new PresetAAIGetCloudOwnersByCloudRegionId(hvf6, ATT_AIC);
59
60     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MY_REGION_TO_ATT_AIC =
61             new PresetAAIGetCloudOwnersByCloudRegionId(MY_REGION, ATT_AIC);
62
63     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_LCP_REGION_TEXT_TO_ATT_AIC =
64             new PresetAAIGetCloudOwnersByCloudRegionId(LCP_REGION_TEXT, ATT_AIC);
65
66     public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_AUK51A_TO_ATT_NC =
67             new PresetAAIGetCloudOwnersByCloudRegionId(AUK51A, ATT_NC);
68
69     public PresetAAIGetCloudOwnersByCloudRegionId(String cloudRegionId, String cloudOwnerResult) {
70         this.cloudRegionId = cloudRegionId;
71         this.cloudOwner = cloudOwnerResult;
72     }
73
74     @Override
75     public Object getResponseBody() {
76         return "" +
77                 "{" +
78                 "  \"cloud-region\": [{" +
79                 "      \"cloud-owner\": \"" + cloudOwner + "\"," +
80                 "      \"cloud-region-id\": \"" + cloudRegionId + "\"," +
81                 "      \"cloud-region-version\": \"2.5\"," +
82                 "      \"identity-url\": \"http://" + randomAlphabetic(5) + ":5000/v2.0\"," +
83                 "      \"complex-name\": \"" + cloudRegionId + "\"," +
84                 "      \"resource-version\": \"" + randomNumeric(5) + "\"," +
85                 "      \"relationship-list\": {" +
86                 "        \"relationship\": [{" +
87                 "            \"related-to\": \"pserver\"," +
88                 "            \"relationship-label\": \"org.onap.relationships.inventory.LocatedIn\"," +
89                 "            \"related-link\": \"/aai/v12/cloud-infrastructure/pservers/pserver/" + randomAlphabetic(5) + "\"," +
90                 "            \"relationship-data\": [{" +
91                 "                \"relationship-key\": \"pserver.hostname\"," +
92                 "                \"relationship-value\": \"" + randomAlphabetic(5) + "\"" +
93                 "              }" +
94                 "            ]," +
95                 "            \"related-to-property\": [{" +
96                 "                \"property-key\": \"pserver.pserver-name2\"" +
97                 "              }" +
98                 "            ]" +
99                 "          }, {" +
100                 "            \"related-to\": \"l3-network\"," +
101                 "            \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
102                 "            \"related-link\": \"/aai/v12/network/l3-networks/l3-network/" + UUID.randomUUID() + "\"," +
103                 "            \"relationship-data\": [{" +
104                 "                \"relationship-key\": \"l3-network.network-id\"," +
105                 "                \"relationship-value\": \"" + UUID.randomUUID() + "\"" +
106                 "              }" +
107                 "            ]," +
108                 "            \"related-to-property\": [{" +
109                 "                \"property-key\": \"l3-network.network-name\"," +
110                 "                \"property-value\": \"" + randomAlphabetic(5) + "\"" +
111                 "              }" +
112                 "            ]" +
113                 "          }" +
114                 "        ]" +
115                 "      }" +
116                 "    }" +
117                 "  ]" +
118                 "}";
119     }
120
121     @Override
122     public HttpMethod getReqMethod() {
123         return HttpMethod.GET;
124     }
125
126     @Override
127     public String getReqPath() {
128         return getRootPath() + "/cloud-infrastructure/cloud-regions";
129     }
130
131     @Override
132     public Map<String, List> getQueryParams() {
133         return ImmutableMap.of("cloud-region-id", Collections.singletonList(cloudRegionId));
134     }
135 }