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