Change the header to SO
[so.git] / bpmn / MSOMockServer / src / main / java / org / openecomp / mso / bpmn / mock / StubResponseAAI.java
1 /*\r
2  * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.\r
3  */\r
4 /*- \r
5  * ============LICENSE_START======================================================= \r
6  * ONAP - SO \r
7  * ================================================================================ \r
8  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. \r
9  * ================================================================================ \r
10  * Licensed under the Apache License, Version 2.0 (the "License"); \r
11  * you may not use this file except in compliance with the License. \r
12  * You may obtain a copy of the License at \r
13  * \r
14  *      http://www.apache.org/licenses/LICENSE-2.0 \r
15  * \r
16  * Unless required by applicable law or agreed to in writing, software \r
17  * distributed under the License is distributed on an "AS IS" BASIS, \r
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
19  * See the License for the specific language governing permissions and \r
20  * limitations under the License. \r
21  * ============LICENSE_END========================================================= \r
22  */ \r
23 \r
24 package org.openecomp.mso.bpmn.mock;\r
25 \r
26 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;\r
27 import static com.github.tomakehurst.wiremock.client.WireMock.containing;\r
28 import static com.github.tomakehurst.wiremock.client.WireMock.delete;\r
29 import static com.github.tomakehurst.wiremock.client.WireMock.get;\r
30 import static com.github.tomakehurst.wiremock.client.WireMock.post;\r
31 import static com.github.tomakehurst.wiremock.client.WireMock.patch;\r
32 import static com.github.tomakehurst.wiremock.client.WireMock.put;\r
33 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;\r
34 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;\r
35 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;\r
36 \r
37 /**\r
38  * Reusable Mock StubResponses for AAI Endpoints\r
39  *\r
40  */\r
41 public class StubResponseAAI {\r
42 \r
43         public static void setupAllMocks() {\r
44 \r
45         }\r
46 \r
47 \r
48         /**\r
49          * Tunnel-XConnect Mock Stub Response\r
50          */\r
51         public static void MockPutTunnelXConnect(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String tunnelId){\r
52                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "/tunnel-xconnects/tunnel-xconnect/" + tunnelId))\r
53                                 .willReturn(aResponse()\r
54                                                 .withStatus(200)));\r
55         }\r
56 \r
57 \r
58         /**\r
59          * Allotted Resource Mock StubResponses below\r
60          */\r
61         public static void MockPutAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {\r
62                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))\r
63                                 .willReturn(aResponse()\r
64                                                 .withStatus(200)));\r
65         }\r
66 \r
67         public static void MockPutAllottedResource_500(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {\r
68                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))\r
69                                 .willReturn(aResponse()\r
70                                                 .withStatus(500)));\r
71         }\r
72 \r
73 \r
74         /**\r
75          * Service Instance Mock StubResponses below\r
76          */\r
77         public static void MockGetServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {\r
78                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))\r
79                                 .willReturn(aResponse()\r
80                                                 .withStatus(200)\r
81                                                 .withHeader("Content-Type", "text/xml")\r
82                                                 .withBodyFile(responseFile)));\r
83         }\r
84 \r
85         public static void MockGetServiceInstance_404(String customer, String serviceSubscription, String serviceInstanceId){\r
86                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))\r
87                                                 .willReturn(aResponse()\r
88                                                 .withStatus(404)));\r
89         }\r
90 \r
91         public static void MockGetServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId){\r
92                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))\r
93                                                 .willReturn(aResponse()\r
94                                                 .withStatus(500)));\r
95         }\r
96 \r
97         public static void MockGetServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId, String responseFile){\r
98                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))\r
99                                                 .willReturn(aResponse()\r
100                                                 .withStatus(500)\r
101                                                 .withHeader("Content-Type", "text/xml")\r
102                                                 .withBodyFile(responseFile)));\r
103         }\r
104 \r
105         public static void MockNodeQueryServiceInstanceByName(String serviceInstanceName, String responseFile){\r
106                 stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:" + serviceInstanceName))\r
107                                 .willReturn(aResponse()\r
108                                                 .withStatus(200)\r
109                                                 .withHeader("Content-Type", "text/xml")\r
110                                                 .withBodyFile(responseFile)));\r
111         }\r
112 \r
113         public static void MockNodeQueryServiceInstanceByName_404(String serviceInstanceName){\r
114                 stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))\r
115                                 .willReturn(aResponse()\r
116                                                 .withStatus(404)));\r
117         }\r
118 \r
119         public static void MockNodeQueryServiceInstanceByName_500(String serviceInstanceName){\r
120                 stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))\r
121                                 .willReturn(aResponse()\r
122                                                 .withStatus(500)));\r
123         }\r
124 \r
125         public static void MockNodeQueryServiceInstanceById(String serviceInstanceId, String responseFile){\r
126                 stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:" + serviceInstanceId))\r
127                                 .willReturn(aResponse()\r
128                                                 .withStatus(200)\r
129                                                 .withHeader("Content-Type", "text/xml")\r
130                                                 .withBodyFile(responseFile)));\r
131         }\r
132 \r
133         public static void MockNodeQueryServiceInstanceById_404(String serviceInstanceId){\r
134                 stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))\r
135                                 .willReturn(aResponse()\r
136                                                 .withStatus(404)));\r
137         }\r
138 \r
139         public static void MockNodeQueryServiceInstanceById_500(String serviceInstanceId){\r
140                 stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))\r
141                                 .willReturn(aResponse()\r
142                                                 .withStatus(500)));\r
143         }\r
144 \r
145         public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){\r
146                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))\r
147                                   .willReturn(aResponse()\r
148                                   .withStatus(204)));\r
149         }\r
150         \r
151         public static void MockGetServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){\r
152                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))\r
153                                   .willReturn(aResponse()\r
154                                   .withStatus(statusCode)));\r
155         }\r
156         \r
157         public static void MockGetServiceInstance(String customer, String serviceSubscription, String resourceVersion, int statusCode){\r
158                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" + resourceVersion))\r
159                                   .willReturn(aResponse()\r
160                                   .withStatus(200)\r
161                                   .withHeader("Content-Type", "text/xml")));\r
162         }\r
163         \r
164         public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){\r
165                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))\r
166                                 .willReturn(aResponse()\r
167                                                 .withStatus(statusCode)));\r
168         }\r
169         \r
170         public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String resourceVersion, int statusCode){\r
171                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" +1234))\r
172                                   .willReturn(aResponse()\r
173                                   .withStatus(statusCode)));\r
174         }\r
175 \r
176         public static void MockDeleteServiceInstance_404(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){\r
177                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))\r
178                                  .willReturn(aResponse()\r
179                                   .withStatus(404)));\r
180         }\r
181 \r
182         public static void MockDeleteServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){\r
183                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))\r
184                                  .willReturn(aResponse()\r
185                                   .withStatus(500)));\r
186         }\r
187 \r
188         public static void MockPutServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {\r
189                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))\r
190                                 .willReturn(aResponse()\r
191                                                 .withStatus(200)\r
192                                                 .withHeader("Content-Type", "text/xml")\r
193                                                 .withBodyFile(responseFile)));\r
194         }\r
195 \r
196         public static void MockPutServiceInstance_500(String globalCustId, String subscriptionType, String serviceInstanceId) {\r
197                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))\r
198                                 .willReturn(aResponse()\r
199                                                 .withStatus(500)));\r
200         }\r
201 \r
202 \r
203         /**\r
204          * Service-Subscription Mock StubResponses below\r
205          */\r
206         public static void MockGetServiceSubscription(String globalCustId, String subscriptionType, String responseFile) {\r
207                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))\r
208                                 .willReturn(aResponse()\r
209                                                 .withStatus(200)\r
210                                                 .withHeader("Content-Type", "text/xml")\r
211                                                 .withBodyFile(responseFile)));\r
212         }\r
213 \r
214         public static void MockDeleteServiceSubscription(String globalCustId, String subscriptionType, int statusCode) {\r
215                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))\r
216                                 .willReturn(aResponse()\r
217                                                 .withStatus(statusCode)));\r
218         }\r
219 \r
220         public static void MockDeleteServiceInstanceId(String globalCustId, String subscriptionType, String serviceInstanceId) {\r
221                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))\r
222                                 .willReturn(aResponse()\r
223                                                 .withStatus(200)));\r
224         }\r
225 \r
226         public static void MockPutServiceSubscription(String globalCustId, String subscriptionType) {\r
227                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))\r
228                                 .willReturn(aResponse()\r
229                                                 .withStatus(200)));\r
230         }\r
231         \r
232         public static void MockGetServiceSubscription(String globalCustId, String subscriptionType, int statusCode) {\r
233                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))\r
234                                 .willReturn(aResponse()\r
235                                 .withStatus(statusCode)));\r
236         }\r
237 \r
238         /**\r
239          * Customer Mock StubResponses below\r
240          */\r
241         public static void MockGetCustomer(String globalCustId, String responseFile) {\r
242                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))\r
243                                 .willReturn(aResponse()\r
244                                                 .withStatus(200)\r
245                                                 .withHeader("Content-Type", "text/xml")\r
246                                                 .withBodyFile(responseFile)));\r
247         }\r
248 \r
249         public static void MockDeleteCustomer(String globalCustId) {\r
250                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))\r
251                                 .willReturn(aResponse()\r
252                                                 .withStatus(200)));\r
253         }\r
254 \r
255         public static void MockPutCustomer(String globalCustId) {\r
256                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))\r
257                                 .willReturn(aResponse()\r
258                                                 .withStatus(200)));\r
259         }\r
260 \r
261         public static void MockPutCustomer_500(String globalCustId) {\r
262                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))\r
263                                 .willReturn(aResponse()\r
264                                                 .withStatus(500)));\r
265         }\r
266 \r
267 \r
268         /**\r
269          * Generic-Vnf Mock StubResponses below\r
270          */\r
271         \r
272         public static void MockGetGenericVnfById(String vnfId, String responseFile){\r
273                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))\r
274                                 .willReturn(aResponse()\r
275                                                 .withStatus(200)\r
276                                                 .withHeader("Content-Type", "text/xml")\r
277                                                 .withBodyFile(responseFile)));\r
278         }\r
279         \r
280         public static void MockGetGenericVnfById(String vnfId, String responseFile, int statusCode){\r
281                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))\r
282                                 .willReturn(aResponse()\r
283                                                 .withStatus(statusCode)\r
284                                                 .withHeader("Content-Type", "text/xml")\r
285                                                 .withBodyFile(responseFile)));\r
286         }\r
287         \r
288         public static void MockGetGenericVnfByIdWithPriority(String vnfId, int statusCode, String responseFile) {\r
289                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))\r
290                                 .atPriority(1)\r
291                                 .willReturn(aResponse()\r
292                                         .withStatus(statusCode)\r
293                                         .withHeader("Content-Type", "text/xml")\r
294                                         .withBodyFile(responseFile)));  \r
295         }\r
296         \r
297         public static void MockGetGenericVnfByIdWithPriority(String vnfId, String vfModuleId, int statusCode, String responseFile, int priority) {\r
298                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))\r
299                                 .atPriority(priority)\r
300                                 .willReturn(aResponse()\r
301                                         .withStatus(statusCode)\r
302                                         .withHeader("Content-Type", "text/xml")\r
303                                         .withBodyFile(responseFile)));  \r
304         }\r
305 \r
306         public static void MockGetGenericVnfByIdWithDepth(String vnfId, int depth, String responseFile){\r
307                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth))\r
308                                 .willReturn(aResponse()\r
309                                                 .withStatus(200)\r
310                                                 .withHeader("Content-Type", "text/xml")\r
311                                                 .withBodyFile(responseFile)));\r
312         }\r
313         \r
314         public static void MockGetGenericVnfById_404(String vnfId){\r
315                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))\r
316                                 .willReturn(aResponse()\r
317                                                 .withStatus(404)));\r
318         }\r
319 \r
320         public static void MockGetGenericVnfById_500(String vnfId){\r
321                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))\r
322                                 .willReturn(aResponse()\r
323                                                 .withStatus(500)));\r
324         }\r
325 \r
326         public static void MockGetGenericVnfByName(String vnfName, String responseFile){\r
327                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))\r
328                                 .willReturn(aResponse()\r
329                                                 .withStatus(200)\r
330                                                 .withHeader("Content-Type", "text/xml")\r
331                                                 .withBodyFile(responseFile)));\r
332         }\r
333         \r
334         public static void MockGetGenericVnfByNameWithDepth(String vnfName, int depth, String responseFile){\r
335                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth))\r
336                                 .willReturn(aResponse()\r
337                                                 .withStatus(200)\r
338                                                 .withHeader("Content-Type", "text/xml")\r
339                                                 .withBodyFile(responseFile)));\r
340         }\r
341 \r
342         public static void MockGetGenericVnfByName_404(String vnfName){\r
343                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))\r
344                                 .willReturn(aResponse()\r
345                                                 .withStatus(404)));\r
346         }\r
347 \r
348         public static void MockDeleteGenericVnf(String vnfId, String resourceVersion){\r
349                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))\r
350                                 .willReturn(aResponse()\r
351                                                 .withStatus(204)));\r
352         }\r
353 \r
354         public static void MockDeleteGenericVnf(String vnfId, String resourceVersion, int statusCode){\r
355                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))\r
356                                 .willReturn(aResponse()\r
357                                                 .withStatus(statusCode)));\r
358         }\r
359 \r
360         public static void MockDeleteGenericVnf_500(String vnfId, String resourceVersion){\r
361                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))\r
362                                 .willReturn(aResponse()\r
363                                                 .withStatus(500)));\r
364         }\r
365 \r
366         public static void MockPutGenericVnf(String vnfId){\r
367                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))\r
368                                 .willReturn(aResponse()\r
369                                                 .withStatus(200)));\r
370         }\r
371         \r
372         public static void MockPutGenericVnf(String vnfId, String requestBodyContaining, int statusCode) {\r
373                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))\r
374                                 .withRequestBody(containing(requestBodyContaining))\r
375                                 .willReturn(aResponse()\r
376                                         .withStatus(statusCode)));\r
377         }\r
378 \r
379         public static void MockPutGenericVnf(String vnfId, int statusCode) {\r
380                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))\r
381                                 .willReturn(aResponse()\r
382                                         .withStatus(statusCode)));\r
383         }\r
384         \r
385         public static void MockPutGenericVnf_Bad(String vnfId, int statusCode){\r
386                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))\r
387                                 .willReturn(aResponse()\r
388                                                 .withStatus(statusCode)));\r
389         }\r
390 \r
391         public static void MockPatchGenericVnf(String vnfId){\r
392                 stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))\r
393                                 .willReturn(aResponse()\r
394                                                 .withStatus(200)));\r
395         }\r
396         /**\r
397          * Vce Mock StubResponses below\r
398          */\r
399         public static void MockGetVceById(String vnfId, String responseFile){\r
400                 stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))\r
401                                 .willReturn(aResponse()\r
402                                                 .withStatus(200)\r
403                                                 .withHeader("Content-Type", "text/xml")\r
404                                                 .withBodyFile(responseFile)));\r
405         }\r
406 \r
407         public static void MockGetVceByName(String vnfName, String responseFile){\r
408                 stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName))\r
409                                 .willReturn(aResponse()\r
410                                                 .withStatus(200)\r
411                                                 .withHeader("Content-Type", "text/xml")\r
412                                                 .withBodyFile(responseFile)));\r
413         }\r
414 \r
415         public static void MockDeleteVce(String vnfId, String resourceVersion, int statusCode){\r
416                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion))\r
417                                 .willReturn(aResponse()\r
418                                                 .withStatus(statusCode)));\r
419         }\r
420 \r
421         public static void MockPutVce(String vnfId){\r
422                 stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))\r
423                                 .willReturn(aResponse()\r
424                                                 .withStatus(200)));\r
425         }\r
426         \r
427         public static void MockGetGenericVceByNameWithDepth(String vnfName, int depth, String responseFile){\r
428                 stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth))\r
429                                 .willReturn(aResponse()\r
430                                                 .withStatus(200)\r
431                                                 .withHeader("Content-Type", "text/xml")\r
432                                                 .withBodyFile(responseFile)));\r
433         }\r
434 \r
435         public static void MockGetVceGenericQuery(String serviceInstanceName, int depth, int statusCode, String responseFile){\r
436                 stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:" + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth))\r
437                                 .willReturn(aResponse()\r
438                                                 .withStatus(statusCode)\r
439                                                 .withHeader("Content-Type", "text/xml")\r
440                                                 .withBodyFile(responseFile)));\r
441         }\r
442 \r
443         /**\r
444          * Tenant Mock StubResponses below\r
445          */\r
446         public static void MockGetTenantGenericQuery(String customer, String serviceType, String responseFile) {\r
447                 stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:" + customer + "&key=service-subscription.service-type:" + serviceType + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1"))\r
448                                 .willReturn(aResponse()\r
449                                                 .withStatus(200)\r
450                                                 .withHeader("Content-Type", "text/xml")\r
451                                                 .withBodyFile(responseFile)));\r
452         }\r
453 \r
454         public static void MockGetTenant(String tenantId, String responseFile) {\r
455                 stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId))\r
456                                 .willReturn(aResponse()\r
457                                                 .withStatus(200)\r
458                                                 .withHeader("Content-Type", "text/xml")\r
459                                                 .withBodyFile(responseFile)));\r
460         }\r
461 \r
462         /**\r
463          * Network Mock StubResponses below\r
464          */\r
465         public static void MockGetNetwork(String networkId, String responseFile, int statusCode) {\r
466                 stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))\r
467                                 .willReturn(aResponse()\r
468                                                 .withStatus(statusCode)\r
469                                                 .withHeader("Content-Type", "text/xml")\r
470                                                 .withBodyFile(responseFile)));\r
471         }\r
472         \r
473         public static void MockGetNetworkByIdWithDepth(String networkId, String responseFile, String depth) {\r
474                 stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))\r
475                                 .willReturn(aResponse()\r
476                                                 .withStatus(200)\r
477                                                 .withHeader("Content-Type", "text/xml")\r
478                                                 .withBodyFile(responseFile)));\r
479         }\r
480         \r
481         public static void MockGetNetworkCloudRegion(String responseFile, String cloudRegion) {\r
482                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegion))\r
483                                 .willReturn(aResponse()\r
484                                                 .withStatus(200)\r
485                                                 .withHeader("Content-Type", "text/xml")\r
486                                                 .withBodyFile(responseFile)));\r
487         }\r
488         \r
489         public static void MockGetNetworkByName(String networkName, String responseFile) {\r
490                    stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))\r
491                                         .willReturn(aResponse()\r
492                                                         .withStatus(200)\r
493                                                         .withHeader("Content-Type", "text/xml")\r
494                                                         .withBodyFile(responseFile)));\r
495         }\r
496 \r
497         public static void MockGetNetworkByName_404(String responseFile, String networkName) {\r
498         stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))\r
499                                 .willReturn(aResponse()\r
500                                                 .withStatus(404)\r
501                                                 .withHeader("Content-Type", "text/xml")\r
502                                                 .withBodyFile(responseFile)));\r
503         }\r
504         \r
505         public static void MockGetNetworkCloudRegion_404(String cloudRegion) {\r
506                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegion))\r
507                                 .willReturn(aResponse()\r
508                                                 .withStatus(404)));\r
509         }\r
510 \r
511         public static void MockPutNetwork(String networkId, int statusCode, String responseFile) {\r
512                 stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))\r
513                                 .willReturn(aResponse()\r
514                                                 .withStatus(statusCode)\r
515                                                 .withHeader("Content-Type", "text/xml")\r
516                                                 .withBodyFile(responseFile)));\r
517         }\r
518         \r
519         public static void MockPutNetwork(String networkPolicyId, String responseFile, int statusCode) {\r
520                 stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId))\r
521                                   .willReturn(aResponse()\r
522                                   .withStatus(statusCode)\r
523                                   .withHeader("Content-Type", "text/xml")\r
524                                   .withBodyFile(responseFile)));\r
525         }\r
526         \r
527         public static void MockGetNetworkName(String networkPolicyName, String responseFile, int statusCode) {\r
528                 stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))\r
529                                   .willReturn(aResponse()\r
530                                   .withStatus(statusCode)\r
531                                   .withHeader("Content-Type", "text/xml")\r
532                                   .withBodyFile(responseFile)));\r
533         }\r
534 \r
535         public static void MockGetNetworkVpnBinding(String responseFile, String vpnBinding) {\r
536                 stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/"+vpnBinding + "[?]depth=all"))\r
537                                 .willReturn(aResponse()\r
538                                                 .withStatus(200)\r
539                                                 .withHeader("Content-Type", "text/xml")\r
540                                                 .withBodyFile(responseFile)));\r
541         }       \r
542         \r
543         public static void MockGetNetworkPolicy(String responseFile, String policy) {\r
544                 stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all"))\r
545                                 .willReturn(aResponse()\r
546                                                 .withStatus(200)\r
547                                                 .withHeader("Content-Type", "text/xml")\r
548                                                 .withBodyFile(responseFile)));\r
549         }\r
550         \r
551         public static void MockGetNetworkVpnBinding(String networkBindingId, String responseFile, int statusCode) {\r
552                 stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))\r
553                                   .willReturn(aResponse()\r
554                                   .withStatus(statusCode)\r
555                                   .withHeader("Content-Type", "text/xml")\r
556                                   .withBodyFile(responseFile)));\r
557         }\r
558         \r
559         public static void MockGetNetworkPolicy(String networkPolicy, String responseFile, int statusCode) {\r
560                 stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))\r
561                                   .willReturn(aResponse()\r
562                                   .withStatus(statusCode)\r
563                                   .withHeader("Content-Type", "text/xml")\r
564                                   .withBodyFile(responseFile)));\r
565         }\r
566         \r
567         public static void MockGetNetworkTableReference(String responseFile, String tableReference) {\r
568                 stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all"))\r
569                                 .willReturn(aResponse()\r
570                                                 .withStatus(200)\r
571                                                 .withHeader("Content-Type", "text/xml")\r
572                                                 .withBodyFile(responseFile)));\r
573         }\r
574         \r
575         public static void MockPutNetworkIdWithDepth(String responseFile, String networkId, String depth) {\r
576                 stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth ))\r
577                                 .willReturn(aResponse()\r
578                                                 .withStatus(200)\r
579                                                 .withHeader("Content-Type", "text/xml")\r
580                                                 .withBodyFile(responseFile)));\r
581         }\r
582         \r
583         public static void MockGetNetworkPolicyfqdn(String networkPolicy, String responseFile, int statusCode) {\r
584                 stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))\r
585                                   .willReturn(aResponse()\r
586                                   .withStatus(statusCode)\r
587                                   .withHeader("Content-Type", "text/xml")\r
588                                   .withBodyFile(responseFile)));\r
589         }\r
590         \r
591         public static void MockGetNetworkRouteTable(String networkRouteId, String responseFile, int statusCode) {\r
592                 stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))\r
593                                   .willReturn(aResponse()\r
594                                   .withStatus(statusCode)\r
595                                   .withHeader("Content-Type", "text/xml")\r
596                                   .withBodyFile(responseFile)));\r
597         }\r
598         \r
599         public static void MockPatchVfModuleId(String vnfId, String vfModuleId) {\r
600                 stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))\r
601                                 .willReturn(aResponse()\r
602                                                 .withStatus(200)));\r
603         }\r
604         \r
605         /////////////\r
606         \r
607         public static void MockVNFAdapterRestVfModule() {\r
608                 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))\r
609                         .willReturn(aResponse()\r
610                                 .withStatus(202)\r
611                                 .withHeader("Content-Type", "application/xml")));\r
612                 stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))\r
613                                 .willReturn(aResponse()\r
614                                         .withStatus(202)\r
615                                         .withHeader("Content-Type", "application/xml")));\r
616                 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))\r
617                         .willReturn(aResponse()\r
618                                 .withStatus(202)\r
619                                 .withHeader("Content-Type", "application/xml")));\r
620                 stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))\r
621                         .willReturn(aResponse()\r
622                                 .withStatus(202)\r
623                                 .withHeader("Content-Type", "application/xml")));\r
624         }\r
625         \r
626         public static void MockDBUpdateVfModule(){\r
627                 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))\r
628                         .willReturn(aResponse()\r
629                                 .withStatus(200)\r
630                             .withHeader("Content-Type", "text/xml")\r
631                                 .withBodyFile("VfModularity/DBUpdateResponse.xml")));\r
632         }\r
633         \r
634         // start of mocks used locally and by other VF Module unit tests\r
635         public static void MockSDNCAdapterVfModule() {\r
636                 // simplified the implementation to return "success" for all requests\r
637                 stubFor(post(urlEqualTo("/SDNCAdapter"))\r
638 //                      .withRequestBody(containing("SvcInstanceId><"))\r
639                         .willReturn(aResponse()\r
640                                 .withStatus(200)\r
641                                 .withHeader("Content-Type", "text/xml")\r
642                                 .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml")));\r
643 \r
644         }\r
645         \r
646         // start of mocks used locally and by other VF Module unit tests\r
647         public static void MockAAIVfModule() {\r
648                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))\r
649                         .atPriority(1)\r
650                         .willReturn(aResponse()\r
651                                 .withStatus(200)\r
652                                 .withHeader("Content-Type", "text/xml")\r
653                                 .withBodyFile("VfModularity/VfModule-supercool.xml")));         \r
654                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))\r
655                         .atPriority(2)\r
656                         .willReturn(aResponse()\r
657                                 .withStatus(200)\r
658                                 .withHeader("Content-Type", "text/xml")\r
659                                 .withBodyFile("VfModularity/VfModule-lukewarm.xml")));\r
660                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))\r
661                         .atPriority(5)\r
662                         .willReturn(aResponse()\r
663                                 .withStatus(200)\r
664                                 .withHeader("Content-Type", "text/xml")\r
665                                 .withBodyFile("VfModularity/VfModule-new.xml")));\r
666                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))\r
667                         .willReturn(aResponse()\r
668                                 .withStatus(200)\r
669                                 .withHeader("Content-Type", "text/xml")\r
670                                 .withBodyFile("VfModularity/GenericVnf.xml")));\r
671                 stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))\r
672 //                      .withRequestBody(containing("PCRF"))\r
673                         .willReturn(aResponse()\r
674                                 .withStatus(200)));\r
675                 stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))\r
676 //                              .withRequestBody(containing("PCRF"))\r
677                                 .willReturn(aResponse()\r
678                                         .withStatus(200)));\r
679                 // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup\r
680                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))\r
681                                 .withRequestBody(containing("PCRF"))\r
682                                 .willReturn(aResponse()\r
683                                         .withStatus(200)));\r
684                 // HTTP PUT stub still used by DoCreateVfModuleTest\r
685                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))\r
686                                 .withRequestBody(containing("MODULELABEL"))\r
687                                 .willReturn(aResponse()\r
688                                         .withStatus(200)));\r
689                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))\r
690                         .willReturn(aResponse()\r
691                                 .withStatus(200)\r
692                                 .withHeader("Content-Type", "text/xml")\r
693                                 .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));\r
694                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))\r
695                                 .willReturn(aResponse()\r
696                                 .withStatus(200)\r
697                                 .withHeader("Content-Type", "text/xml")\r
698                                 .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));\r
699                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21/volume-groups/volume-group/78987"))\r
700                         .willReturn(aResponse()\r
701                                 .withStatus(200)\r
702                                 .withHeader("Content-Type", "text/xml")\r
703                                 .withBodyFile("VfModularity/VolumeGroup.xml")));\r
704                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/78987"))\r
705                                 .willReturn(aResponse()\r
706                                         .withStatus(200)\r
707                                         .withHeader("Content-Type", "text/xml")\r
708                                         .withBodyFile("VfModularity/VolumeGroup.xml")));\r
709                 stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))\r
710                              .willReturn(aResponse()\r
711                              .withStatus(200)\r
712                              .withHeader("Content-Type", "text/xml")\r
713                              .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml")));\r
714                 stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))\r
715                                   .willReturn(aResponse()\r
716                                   .withStatus(200)\r
717                                   .withHeader("Content-Type", "text/xml")\r
718                                   .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml")));\r
719                 stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))\r
720                                 .withRequestBody(containing("NEWvBNGModuleId"))\r
721                                 .willReturn(aResponse()\r
722                                         .withStatus(200)));\r
723         }\r
724 \r
725         \r
726         \r
727         //////////////\r
728 \r
729         /**\r
730          * Cloud infrastructure below\r
731          */\r
732         \r
733         public static void MockGetCloudRegion(String cloudRegionId, int statusCode, String responseFile) {\r
734                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId))\r
735                                 .willReturn(aResponse()\r
736                                                 .withStatus(statusCode)\r
737                                                 .withHeader("Content-Type", "text/xml")\r
738                                                 .withBodyFile(responseFile)));\r
739         }\r
740         \r
741         /**\r
742          * Volume Group StubResponse below\r
743          */\r
744         public static void MockGetVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile) {\r
745                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))\r
746                                 .willReturn(aResponse()\r
747                                                 .withStatus(200)\r
748                                                 .withHeader("Content-Type", "text/xml")\r
749                                                 .withBodyFile(responseFile)));\r
750         }\r
751         \r
752         public static void MockPutVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile, int statusCode) {\r
753                 stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))\r
754                                 .willReturn(aResponse()\r
755                                                 .withStatus(statusCode)\r
756                                                 .withHeader("Content-Type", "text/xml")\r
757                                                 .withBodyFile(responseFile)));\r
758         }\r
759         \r
760         public static void MockGetVolumeGroupByName(String cloudRegionId, String volumeGroupName, String responseFile, int statusCode) {\r
761                 stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))\r
762                                 .willReturn(aResponse()\r
763                                                 .withStatus(statusCode)\r
764                                                 .withHeader("Content-Type", "text/xml")\r
765                                                 .withBodyFile(responseFile)));\r
766         }\r
767         \r
768         public static void MockDeleteVolumeGroupById(String cloudRegionId, String volumeGroupId, String resourceVersion, int statusCode) {\r
769                 stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))\r
770                                   .willReturn(aResponse()\r
771                                   .withStatus(statusCode)));\r
772         }\r
773 \r
774         public static void MockGetVolumeGroupByName_404(String cloudRegionId, String volumeGroupName) {\r
775                 stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))\r
776                                 .willReturn(aResponse()\r
777                                 .withStatus(404)));\r
778         }\r
779         \r
780         public static void MockDeleteVolumeGroup(String cloudRegionId, String volumeGroupId, String resourceVersion) {\r
781                 stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))\r
782                                 .willReturn(aResponse()\r
783                                 .withStatus(200)));\r
784         }\r
785         \r
786         /**\r
787          * VF-Module StubResponse below\r
788          * @param statusCode TODO\r
789          */\r
790         public static void MockGetVfModuleId(String vnfId, String vfModuleId, String responseFile, int statusCode) {\r
791                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))\r
792                                 .willReturn(aResponse()\r
793                                                 .withStatus(statusCode)\r
794                                                 .withHeader("Content-Type", "text/xml")\r
795                                                 .withBodyFile(responseFile)));\r
796         }\r
797         \r
798         public static void MockGetVfModuleIdNoResponse(String vnfId, String requestContaining, String vfModuleId) {\r
799                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))\r
800                                 .withRequestBody(containing(requestContaining))\r
801                                 .willReturn(aResponse()\r
802                                                 .withStatus(200)\r
803                                                 .withHeader("Content-Type", "text/xml")));\r
804         }\r
805 \r
806         public static void MockPutVfModuleIdNoResponse(String vnfId, String requestContaining, String vfModuleId) {\r
807                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId +"/vf-modules/vf-module/" +vfModuleId))\r
808                                 .withRequestBody(containing(requestContaining))\r
809                                 .willReturn(aResponse()\r
810                                         .withStatus(200)));\r
811         }\r
812         \r
813         public static void MockPutVfModuleId(String vnfId, String vfModuleId) {\r
814                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))\r
815                                 .willReturn(aResponse()\r
816                                                 .withStatus(200)));\r
817         }\r
818         \r
819         public static void MockPutVfModuleId(String vnfId, String vfModuleId, int returnCode) {\r
820                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))\r
821                                 .willReturn(aResponse()\r
822                                                 .withStatus(returnCode)));\r
823         }\r
824         \r
825         public static void MockDeleteVfModuleId(String vnfId, String vfModuleId, String resourceVersion, int returnCode) {\r
826                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))\r
827                                 .willReturn(aResponse()\r
828                                                 .withStatus(returnCode)));\r
829         }\r
830 \r
831         public static void MockAAIVfModuleBadPatch(String endpoint, int statusCode) {\r
832                 stubFor(patch(urlMatching(endpoint))\r
833                         .willReturn(aResponse()\r
834                                 .withStatus(statusCode)));\r
835         }\r
836         \r
837         /* AAI Pserver Queries */\r
838         public static void MockGetPserverByVnfId(String vnfId, String responseFile, int statusCode) {\r
839                 stubFor(put(urlMatching("/v10/query.*"))\r
840                                 .willReturn(aResponse()\r
841                                                 .withStatus(statusCode)\r
842                                                 .withHeader("Content-Type", "application/json")\r
843                                                 .withBodyFile(responseFile)));\r
844         }\r
845         \r
846         public static void MockGetGenericVnfsByVnfId(String vnfId, String responseFile, int statusCode) {\r
847                 stubFor(get(urlMatching("/v10/network/generic-vnfs/.*"))\r
848                                 .willReturn(aResponse()\r
849                                                 .withStatus(statusCode)\r
850                                                 .withHeader("Content-Type", "application/json; charset=utf-8")\r
851                                                 .withBodyFile(responseFile)));\r
852         }\r
853         \r
854         public static void MockSetInMaintFlagByVnfId(String vnfId, int statusCode) {\r
855                 stubFor(patch(urlMatching("/v10/network/generic-vnfs/.*"))\r
856                                 .willReturn(aResponse()\r
857                                                 .withStatus(statusCode)\r
858                                                 ));\r
859         }\r
860         \r
861         //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above ////\r
862         @Deprecated\r
863         public static void MockGetVceById(){\r
864                 stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))\r
865                                 .willReturn(aResponse()\r
866                                                 .withStatus(200)\r
867                                                 .withHeader("Content-Type", "text/xml")\r
868                                                 .withBodyFile("GenericFlows/getVceResponse.xml")));\r
869         }\r
870         @Deprecated\r
871         public static void MockGetVceByName(){\r
872                 stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))\r
873                                 .willReturn(aResponse()\r
874                                                 .withStatus(200)\r
875                                                 .withHeader("Content-Type", "text/xml")\r
876                                                 .withBodyFile("GenericFlows/getVceByNameResponse.xml")));\r
877         }\r
878         @Deprecated\r
879         public static void MockPutVce(){\r
880                 stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123"))\r
881                                 .willReturn(aResponse()\r
882                                                 .withStatus(200)));\r
883         }\r
884         @Deprecated\r
885         public static void MockDeleteVce(){\r
886                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))\r
887                                 .willReturn(aResponse()\r
888                                                 .withStatus(204)));\r
889         }\r
890         @Deprecated\r
891         public static void MockDeleteVce_404(){\r
892                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))\r
893                                 .willReturn(aResponse()\r
894                                                 .withStatus(404)));\r
895         }\r
896 \r
897         @Deprecated\r
898         public static void MockDeleteServiceSubscription(){\r
899                 stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))\r
900                                   .willReturn(aResponse()\r
901                                   .withStatus(204)));\r
902         }\r
903         @Deprecated\r
904         public static void MockGetServiceSubscription(){\r
905                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))\r
906                                   .willReturn(aResponse()\r
907                                   .withStatus(200)\r
908                                   .withHeader("Content-Type", "text/xml")\r
909                                   .withBodyFile("GenericFlows/getServiceSubscription.xml")));\r
910         }\r
911         @Deprecated\r
912         public static void MockGetServiceSubscription_200Empty(){\r
913                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))\r
914                                   .willReturn(aResponse()\r
915                                   .withStatus(200)\r
916                                   .withHeader("Content-Type", "text/xml")\r
917                                   .withBody(" ")));\r
918         }\r
919         @Deprecated\r
920         public static void MockGetServiceSubscription_404() {\r
921                 stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))\r
922                                 .willReturn(aResponse()\r
923                                                 .withStatus(404)));\r
924         }\r
925         @Deprecated\r
926         public static void MockGENPSIPutServiceInstance(){\r
927                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET"))\r
928                                 .willReturn(aResponse()\r
929                                                 .withStatus(200)\r
930                                                 .withHeader("Content-Type", "text/xml")\r
931                                                 .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml")));\r
932         }\r
933 \r
934         @Deprecated\r
935         public static void MockGENPSIPutServiceSubscription(){\r
936                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))\r
937                                 .willReturn(aResponse()\r
938                                                 .withStatus(200)\r
939                                                 .withHeader("Content-Type", "text/xml")\r
940                                                 .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml")));\r
941         }\r
942         @Deprecated\r
943         public static void MockGENPSIPutServiceInstance_get500(){\r
944                 stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET"))\r
945                                 .willReturn(aResponse()\r
946                                                 .withStatus(500)\r
947                                                 .withHeader("Content-Type", "text/xml")\r
948                                                 .withBodyFile("GenericPutServiceInstance/aaiFault.xml")));\r
949         }\r
950 \r
951         @Deprecated\r
952         public static void MockGetGenericVnfById(){\r
953                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))\r
954                                 .willReturn(aResponse()\r
955                                                 .withStatus(200)\r
956                                                 .withHeader("Content-Type", "text/xml")\r
957                                                 .withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));\r
958         }\r
959         @Deprecated\r
960         public static void MockGetGenericVnfById_404(){\r
961                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))\r
962                                 .willReturn(aResponse()\r
963                                                 .withStatus(404)));\r
964         }\r
965         @Deprecated\r
966         public static void MockGetGenericVnfByName(){\r
967                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))\r
968                                 .willReturn(aResponse()\r
969                                                 .withStatus(200)\r
970                                                 .withHeader("Content-Type", "text/xml")\r
971                                                 .withBodyFile("GenericFlows/getGenericVnfResponse.xml")));\r
972         }\r
973         @Deprecated\r
974         public static void MockGetGenericVnfByName_hasRelationships(){\r
975                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))\r
976                                 .willReturn(aResponse()\r
977                                                 .withStatus(200)\r
978                                                 .withHeader("Content-Type", "text/xml")\r
979                                                 .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));\r
980         }\r
981         @Deprecated\r
982         public static void MockGetGenericVnfById_hasRelationships(){\r
983                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))\r
984                                 .willReturn(aResponse()\r
985                                                 .withStatus(200)\r
986                                                 .withHeader("Content-Type", "text/xml")\r
987                                                 .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));\r
988         }\r
989         @Deprecated\r
990         public static void MockGetGenericVnfById_500(){\r
991                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))\r
992                                 .willReturn(aResponse()\r
993                                                 .withStatus(500)));\r
994         }\r
995         @Deprecated\r
996         public static void MockGetGenericVnfByName_404(){\r
997                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))\r
998                                 .willReturn(aResponse()\r
999                                                 .withStatus(404)));\r
1000         }\r
1001         @Deprecated\r
1002         public static void MockPutGenericVnf(){\r
1003                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))\r
1004                                 .willReturn(aResponse()\r
1005                                                 .withStatus(200)));\r
1006         }\r
1007         @Deprecated\r
1008         public static void MockPutGenericVnf_400(){\r
1009                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))\r
1010                                 .willReturn(aResponse()\r
1011                                                 .withStatus(400)));\r
1012         }\r
1013         @Deprecated\r
1014         public static void MockDeleteGenericVnf(){\r
1015                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))\r
1016                                 .willReturn(aResponse()\r
1017                                                 .withStatus(204)));\r
1018         }\r
1019         @Deprecated\r
1020         public static void MockDeleteGenericVnf_404(){\r
1021                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))\r
1022                                 .willReturn(aResponse()\r
1023                                                 .withStatus(404)));\r
1024         }\r
1025         @Deprecated\r
1026         public static void MockDeleteGenericVnf_500(){\r
1027                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))\r
1028                                 .willReturn(aResponse()\r
1029                                                 .withStatus(500)));\r
1030         }\r
1031         @Deprecated\r
1032         public static void MockDeleteGenericVnf_412(){\r
1033                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))\r
1034                                 .willReturn(aResponse()\r
1035                                                 .withStatus(412)));\r
1036         }\r
1037 \r
1038 }\r