aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetCloudOwnersByCloudRegionId.java
blob: be075b4818c861497a79340b712235fab5eacfec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package org.onap.simulator.presetGenerator.presets.aai;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric;

import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset;
import org.springframework.http.HttpMethod;

public class PresetAAIGetCloudOwnersByCloudRegionId extends BaseAAIPreset {
    public static final String SOME_LEGACY_REGION = "some legacy region";
    public static final String JUST_ANOTHER_REGION = "just another region";
    public static final String MY_REGION = "my region";
    public static final String LCP_REGION_TEXT = "lcpRegionText";
    public static final String ATT_AIC = "irma-aic";
    public static final String MDT_1 = "mdt1";
    public static final String ATT_NC = "att-nc";
    public static final String hvf3 = "hvf3";
    public static final String olson3 = "olson3";
    public static final String olson5B = "olson5b";
    public static final String ATT_SABABA = "att-sababa";
    public static final String AAIAIC_25 = "JANET25";
    public static final String ONE = "One";
    public static final String hvf6 = "hvf6";
    private final String cloudRegionId;
    private final String cloudOwner;

    //Since there is a cache of cloudRegionToCloudOwner, we can't have 2 preset of same cloud region that return different cloud owner.
    //So all the preset instance must be declared here, for conflicts prevention.
    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_SOME_LEGACY_REGION_TO_ATT_AIC =
            new PresetAAIGetCloudOwnersByCloudRegionId(SOME_LEGACY_REGION, ATT_AIC);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_JUST_ANOTHER_REGION_TO_ATT_AIC =
            new PresetAAIGetCloudOwnersByCloudRegionId(JUST_ANOTHER_REGION, ATT_AIC);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MDT1_TO_ATT_NC =
            new PresetAAIGetCloudOwnersByCloudRegionId(MDT_1, ATT_NC);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_RDM3_TO_ATT_NC =
            new PresetAAIGetCloudOwnersByCloudRegionId(olson3, ATT_NC);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MTN3_TO_ATT_SABABA =
            new PresetAAIGetCloudOwnersByCloudRegionId(hvf3, ATT_SABABA);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_AAIAIC25_TO_ATT_AIC =
            new PresetAAIGetCloudOwnersByCloudRegionId(AAIAIC_25, ATT_AIC);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_ONE_TO_ATT_AIC =
            new PresetAAIGetCloudOwnersByCloudRegionId(ONE, ATT_AIC);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MTN6_TO_ATT_AIC =
            new PresetAAIGetCloudOwnersByCloudRegionId(hvf6, ATT_AIC);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MY_REGION_TO_ATT_AIC =
            new PresetAAIGetCloudOwnersByCloudRegionId(MY_REGION, ATT_AIC);

    public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_LCP_REGION_TEXT_TO_ATT_AIC =
            new PresetAAIGetCloudOwnersByCloudRegionId(LCP_REGION_TEXT, ATT_AIC);

    private PresetAAIGetCloudOwnersByCloudRegionId(String cloudRegionId, String cloudOwnerResult) {
        this.cloudRegionId = cloudRegionId;
        this.cloudOwner = cloudOwnerResult;
    }

    @Override
    public Object getResponseBody() {
        return "" +
                "{" +
                "  \"cloud-region\": [{" +
                "      \"cloud-owner\": \"" + cloudOwner + "\"," +
                "      \"cloud-region-id\": \"" + cloudRegionId + "\"," +
                "      \"cloud-region-version\": \"2.5\"," +
                "      \"identity-url\": \"http://" + randomAlphabetic(5) + ":5000/v2.0\"," +
                "      \"complex-name\": \"" + cloudRegionId + "\"," +
                "      \"resource-version\": \"" + randomNumeric(5) + "\"," +
                "      \"relationship-list\": {" +
                "        \"relationship\": [{" +
                "            \"related-to\": \"pserver\"," +
                "            \"relationship-label\": \"org.onap.relationships.inventory.LocatedIn\"," +
                "            \"related-link\": \"/aai/v12/cloud-infrastructure/pservers/pserver/" + randomAlphabetic(5) + "\"," +
                "            \"relationship-data\": [{" +
                "                \"relationship-key\": \"pserver.hostname\"," +
                "                \"relationship-value\": \"" + randomAlphabetic(5) + "\"" +
                "              }" +
                "            ]," +
                "            \"related-to-property\": [{" +
                "                \"property-key\": \"pserver.pserver-name2\"" +
                "              }" +
                "            ]" +
                "          }, {" +
                "            \"related-to\": \"l3-network\"," +
                "            \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
                "            \"related-link\": \"/aai/v12/network/l3-networks/l3-network/" + UUID.randomUUID() + "\"," +
                "            \"relationship-data\": [{" +
                "                \"relationship-key\": \"l3-network.network-id\"," +
                "                \"relationship-value\": \"" + UUID.randomUUID() + "\"" +
                "              }" +
                "            ]," +
                "            \"related-to-property\": [{" +
                "                \"property-key\": \"l3-network.network-name\"," +
                "                \"property-value\": \"" + randomAlphabetic(5) + "\"" +
                "              }" +
                "            ]" +
                "          }" +
                "        ]" +
                "      }" +
                "    }" +
                "  ]" +
                "}";
    }

    @Override
    public HttpMethod getReqMethod() {
        return HttpMethod.GET;
    }

    @Override
    public String getReqPath() {
        return getRootPath() + "/cloud-infrastructure/cloud-regions";
    }

    @Override
    public Map<String, List> getQueryParams() {
        return ImmutableMap.of("cloud-region-id", Collections.singletonList(cloudRegionId));
    }
}