Merge from ecomp 718fd196 - Integration Tests
[vid.git] / vid-automation / src / main / java / org / onap / simulator / presetGenerator / presets / aai / PresetAAIGetPortMirroringSourcePorts.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
11 public class PresetAAIGetPortMirroringSourcePorts extends BaseAAIPreset {
12     public PresetAAIGetPortMirroringSourcePorts(String configurationId, String interfaceId, String interfaceName, boolean isPortMirrored) {
13         this.configurationId = configurationId;
14         this.interfaceId = interfaceId;
15         this.interfaceName = interfaceName;
16         this.isPortMirrored = isPortMirrored;
17     }
18
19     private final String configurationId;
20     private final String interfaceId;
21     private final String interfaceName;
22     private final boolean isPortMirrored;
23
24     @Override
25     public HttpMethod getReqMethod() {
26         return HttpMethod.PUT;
27     }
28
29     @Override
30     public String getReqPath() {
31         return getRootPath() + "/query";
32     }
33
34     @Override
35     public Map<String, List> getQueryParams() {
36         return ImmutableMap.of(
37                 "format", Collections.singletonList("simple"));
38     }
39
40     @Override
41     public Object getRequestBody() {
42         return ImmutableMap.of(
43                 "start", "/network/configurations/configuration/" + getConfigurationId(),
44                 "query", "query/pserver-fromConfiguration"
45         );
46     }
47
48     public String getConfigurationId() {
49         return configurationId;
50     }
51
52     public String getInterfaceId() {
53         return interfaceId;
54     }
55
56     public String getInterfaceName() { return interfaceName; }
57
58     public boolean getIsPortMirrored() { return isPortMirrored; }
59
60     @Override
61     public Object getResponseBody() {
62         return "{\n" +
63                 "    \"results\": [\n" +
64                 "        {\n" +
65                 "            \"id\": \"4876980240\",\n" +
66                 "            \"node-type\": \"l-interface\",\n" +
67                 "            \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zolson5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
68                 "            \"properties\": {\n" +
69                 "                \"interface-name\": " + doubleQuoteIfNotNull(getInterfaceName()) + ",\n" +
70                 "                \"selflink\": \"https://netw.onap.org:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
71                 "                \"interface-id\": " + doubleQuoteIfNotNull(getInterfaceId()) + ",\n" +
72                 "                \"macaddr\": \"02:6d:e7:bf:87:6f\",\n" +
73                 "                \"network-name\": \"APP-C-24595-D-T001-vprobe_int_pktmirror_net_1\",\n" +
74                 "                \"is-port-mirrored\": " + getIsPortMirrored() + ",\n" +
75                 "                \"resource-version\": \"1519383879190\",\n" +
76                 "                \"in-maint\": false,\n" +
77                 "                \"is-ip-unnumbered\": false\n" +
78                 "            },\n" +
79                 "            \"related-to\": [\n" +
80                 "                {\n" +
81                 "                    \"id\": \"4999893128\",\n" +
82                 "                    \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
83                 "                    \"node-type\": \"l3-interface-ipv4-address-list\",\n" +
84                 "                    \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zolson5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib/l3-interface-ipv4-address-list/107.244.46.254\"\n" +
85                 "                },\n" +
86                 "                {\n" +
87                 "                    \"id\": \"6150074384\",\n" +
88                 "                    \"relationship-label\": \"org.onap.relationships.inventory.Source\",\n" +
89                 "                    \"node-type\": \"logical-link\",\n" +
90                 "                    \"url\": \"/aai/v12/network/logical-links/logical-link/PMC_a22607fb-8392-42f4-bbe7-b8d845a97183_Sourcezrdm5bepdg_147_lb_2_Gn_UntrustedVrf_5_RVMI_Destzrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"\n" +
91                 "                },\n" +
92                 "                {\n" +
93                 "                    \"id\": \"6975434912\",\n" +
94                 "                    \"relationship-label\": \"tosca.relationships.network.LinksTo\",\n" +
95                 "                    \"node-type\": \"logical-link\",\n" +
96                 "                    \"url\": \"/aai/v12/network/logical-links/logical-link/PMC_a22607fb-8392-42f4-bbe7-b8d845a97183_Sourcezrdm5bepdg_147_lb_1_Gn_UntrustedVrf_5_RVMI_Destzrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"\n" +
97                 "                },\n" +
98                 "                {\n" +
99                 "                    \"id\": \"7007121568\",\n" +
100                 "                    \"relationship-label\": \"tosca.relationships.network.LinksTo\",\n" +
101                 "                    \"node-type\": \"logical-link\",\n" +
102                 "                    \"url\": \"/aai/v12/network/logical-links/logical-link/PMC_9c099448-a0e1-451d-ac20-c5e3ada8cccd_Sourcezrdm5bepdg_147_lb_2_Gn_UntrustedVrf_5_RVMI_Destzrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"\n" +
103                 "                },\n" +
104                 "                {\n" +
105                 "                    \"id\": \"7048110232\",\n" +
106                 "                    \"relationship-label\": \"tosca.relationships.network.LinksTo\",\n" +
107                 "                    \"node-type\": \"logical-link\",\n" +
108                 "                    \"url\": \"/aai/v12/network/logical-links/logical-link/PMC_9c099448-a0e1-451d-ac20-c5e3ada8cccd_Sourcezrdm5bepdg_147_lb_1_Gn_UntrustedVrf_5_RVMI_Destzrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"\n" +
109                 "                },\n" +
110                 "                {\n" +
111                 "                    \"id\": \"5491453960\",\n" +
112                 "                    \"relationship-label\": \"tosca.relationships.network.BindsTo\",\n" +
113                 "                    \"node-type\": \"vserver\",\n" +
114                 "                    \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a\"\n" +
115                 "                }\n" +
116                 "            ]\n" +
117                 "        }\n" +
118                 "    ]\n" +
119                 "}";
120     }
121
122     private String doubleQuoteIfNotNull(String str) {
123         if (str == null) {
124             return null;
125         } else {
126             return "\"" + str + "\"";
127         }
128     }
129 }