80625dd4d56e225c710a1efaaa0e0d3e4939a879
[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 MockPostNetwork(WireMockServer wireMockServer, String networkId) {
556         wireMockServer.stubFor(post(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
557             .willReturn(aResponse()
558                 .withStatus(201)
559                 .withHeader("Content-Type", "text/xml")));
560     }
561
562     public static void MockPostNetworkSubnet(WireMockServer wireMockServer, String networkId, String subnetId) {
563         wireMockServer.stubFor(post(urlMatching(
564             "/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "/subnets/subnet/" + subnetId))
565             .willReturn(aResponse()
566                 .withStatus(201)
567                 .withHeader("Content-Type", "text/xml")));
568     }
569
570         public static void MockGetNetworkName(WireMockServer wireMockServer, String networkPolicyName, String responseFile, int statusCode) {
571                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))
572                                   .willReturn(aResponse()
573                                   .withStatus(statusCode)
574                                   .withHeader("Content-Type", "text/xml")
575                                   .withBodyFile(responseFile)));
576         }
577
578     public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String responseFile, String vpnBinding) {
579         MockGetNetworkVpnBindingWithDepth(wireMockServer, responseFile, vpnBinding, "all");
580     }
581
582     public static void MockGetNetworkVpnBindingWithDepth(WireMockServer wireMockServer, String responseFile,
583         String vpnBinding, String depth) {
584         wireMockServer.stubFor(
585             get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + vpnBinding + "[?]depth=" + depth))
586                 .willReturn(aResponse()
587                     .withStatus(200)
588                     .withHeader("Content-Type", "text/xml")
589                     .withBodyFile(responseFile)));
590     }
591
592         public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String responseFile, String policy) {
593                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all"))
594                                 .willReturn(aResponse()
595                                                 .withStatus(200)
596                                                 .withHeader("Content-Type", "text/xml")
597                                                 .withBodyFile(responseFile)));
598         }
599
600         public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String networkBindingId, String responseFile, int statusCode) {
601                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
602                                   .willReturn(aResponse()
603                                   .withStatus(statusCode)
604                                   .withHeader("Content-Type", "text/xml")
605                                   .withBodyFile(responseFile)));
606         }
607
608         public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String networkPolicy, String responseFile, int statusCode) {
609                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))
610                                   .willReturn(aResponse()
611                                   .withStatus(statusCode)
612                                   .withHeader("Content-Type", "text/xml")
613                                   .withBodyFile(responseFile)));
614         }
615
616         public static void MockGetNetworkTableReference(WireMockServer wireMockServer, String responseFile, String tableReference) {
617                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all"))
618                                 .willReturn(aResponse()
619                                                 .withStatus(200)
620                                                 .withHeader("Content-Type", "text/xml")
621                                                 .withBodyFile(responseFile)));
622         }
623
624         public static void MockPutNetworkIdWithDepth(WireMockServer wireMockServer, String responseFile, String networkId, String depth) {
625                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth ))
626                                 .willReturn(aResponse()
627                                                 .withStatus(200)
628                                                 .withHeader("Content-Type", "text/xml")
629                                                 .withBodyFile(responseFile)));
630         }
631
632         public static void MockGetNetworkPolicyfqdn(WireMockServer wireMockServer, String networkPolicy, String responseFile, int statusCode) {
633                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
634                                   .willReturn(aResponse()
635                                   .withStatus(statusCode)
636                                   .withHeader("Content-Type", "text/xml")
637                                   .withBodyFile(responseFile)));
638         }
639
640         public static void MockGetNetworkRouteTable(WireMockServer wireMockServer, String networkRouteId, String responseFile, int statusCode) {
641                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))
642                                   .willReturn(aResponse()
643                                   .withStatus(statusCode)
644                                   .withHeader("Content-Type", "text/xml")
645                                   .withBodyFile(responseFile)));
646         }
647
648         public static void MockPatchVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
649                 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
650                                 .willReturn(aResponse()
651                                                 .withStatus(200)));
652         }
653
654         /////////////
655
656         public static void MockVNFAdapterRestVfModule(WireMockServer wireMockServer) {
657                 wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
658                         .willReturn(aResponse()
659                                 .withStatus(202)
660                                 .withHeader("Content-Type", "application/xml")));
661                 wireMockServer.stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))
662                                 .willReturn(aResponse()
663                                         .withStatus(202)
664                                         .withHeader("Content-Type", "application/xml")));
665                 wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))
666                         .willReturn(aResponse()
667                                 .withStatus(202)
668                                 .withHeader("Content-Type", "application/xml")));
669                 wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))
670                         .willReturn(aResponse()
671                                 .withStatus(202)
672                                 .withHeader("Content-Type", "application/xml")));
673         }
674
675         public static void MockDBUpdateVfModule(WireMockServer wireMockServer){
676                 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
677                         .willReturn(aResponse()
678                                 .withStatus(200)
679                             .withHeader("Content-Type", "text/xml")
680                                 .withBodyFile("VfModularity/DBUpdateResponse.xml")));
681         }
682
683         // start of mocks used locally and by other VF Module unit tests
684         public static void MockSDNCAdapterVfModule(WireMockServer wireMockServer) {
685                 // simplified the implementation to return "success" for all requests
686                 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
687 //                      .withRequestBody(containing("SvcInstanceId><"))
688                         .willReturn(aResponse()
689                                 .withStatus(200)
690                                 .withHeader("Content-Type", "text/xml")
691                                 .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml")));
692
693         }
694
695         // start of mocks used locally and by other VF Module unit tests
696         public static void MockAAIVfModule(WireMockServer wireMockServer) {
697                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
698                         .atPriority(1)
699                         .willReturn(aResponse()
700                                 .withStatus(200)
701                                 .withHeader("Content-Type", "text/xml")
702                                 .withBodyFile("VfModularity/VfModule-supercool.xml")));
703                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
704                         .atPriority(2)
705                         .willReturn(aResponse()
706                                 .withStatus(200)
707                                 .withHeader("Content-Type", "text/xml")
708                                 .withBodyFile("VfModularity/VfModule-lukewarm.xml")));
709                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
710                         .atPriority(5)
711                         .willReturn(aResponse()
712                                 .withStatus(200)
713                                 .withHeader("Content-Type", "text/xml")
714                                 .withBodyFile("VfModularity/VfModule-new.xml")));
715                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))
716                         .willReturn(aResponse()
717                                 .withStatus(200)
718                                 .withHeader("Content-Type", "text/xml")
719                                 .withBodyFile("VfModularity/GenericVnf.xml")));
720                 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
721 //                      .withRequestBody(containing("PCRF"))
722                         .willReturn(aResponse()
723                                 .withStatus(200)));
724                 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
725 //                              .withRequestBody(containing("PCRF"))
726                                 .willReturn(aResponse()
727                                         .withStatus(200)));
728                 // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup
729                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
730                                 .withRequestBody(containing("PCRF"))
731                                 .willReturn(aResponse()
732                                         .withStatus(200)));
733                 // HTTP PUT stub still used by DoCreateVfModuleTest
734                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
735                                 .withRequestBody(containing("MODULELABEL"))
736                                 .willReturn(aResponse()
737                                         .withStatus(200)));
738                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
739                         .willReturn(aResponse()
740                                 .withStatus(200)
741                                 .withHeader("Content-Type", "text/xml")
742                                 .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
743                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
744                                 .willReturn(aResponse()
745                                 .withStatus(200)
746                                 .withHeader("Content-Type", "text/xml")
747                                 .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
748                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/MDTWNJ21/volume-groups/volume-group/78987"))
749                         .willReturn(aResponse()
750                                 .withStatus(200)
751                                 .withHeader("Content-Type", "text/xml")
752                                 .withBodyFile("VfModularity/VolumeGroup.xml")));
753                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/volume-groups/volume-group/78987"))
754                                 .willReturn(aResponse()
755                                         .withStatus(200)
756                                         .withHeader("Content-Type", "text/xml")
757                                         .withBodyFile("VfModularity/VolumeGroup.xml")));
758                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))
759                              .willReturn(aResponse()
760                              .withStatus(200)
761                              .withHeader("Content-Type", "text/xml")
762                              .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml")));
763                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
764                                   .willReturn(aResponse()
765                                   .withStatus(200)
766                                   .withHeader("Content-Type", "text/xml")
767                                   .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml")));
768                 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))
769                                 .withRequestBody(containing("NEWvBNGModuleId"))
770                                 .willReturn(aResponse()
771                                         .withStatus(200)));
772         }
773
774
775
776         //////////////
777
778         /**
779          * Cloud infrastructure below
780          */
781
782         public static void MockGetCloudRegion(WireMockServer wireMockServer, String cloudRegionId, int statusCode, String responseFile) {
783                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId))
784                                 .willReturn(aResponse()
785                                                 .withStatus(statusCode)
786                                                 .withHeader("Content-Type", "text/xml")
787                                                 .withBodyFile(responseFile)));
788         }
789
790         /**
791          * Volume Group StubResponse below
792          */
793         public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile) {
794                 MockGetVolumeGroupById(wireMockServer, cloudRegionId, volumeGroupId, responseFile, 200);
795         }
796
797         public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile, int responseCode) {
798                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
799                                 .willReturn(aResponse()
800                                                 .withStatus(responseCode)
801                                                 .withHeader("Content-Type", "text/xml")
802                                                 .withBodyFile(responseFile)));
803         }
804
805         public static void MockPutVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile, int statusCode) {
806                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
807                                 .willReturn(aResponse()
808                                                 .withStatus(statusCode)
809                                                 .withHeader("Content-Type", "text/xml")
810                                                 .withBodyFile(responseFile)));
811         }
812
813         public static void MockGetVolumeGroupByName(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupName, String responseFile, int statusCode) {
814                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
815                                 .willReturn(aResponse()
816                                                 .withStatus(statusCode)
817                                                 .withHeader("Content-Type", "text/xml")
818                                                 .withBodyFile(responseFile)));
819         }
820
821         public static void MockDeleteVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String resourceVersion, int statusCode) {
822                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
823                                   .willReturn(aResponse()
824                                   .withStatus(statusCode)));
825         }
826
827         public static void MockGetVolumeGroupByName_404(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupName) {
828                 wireMockServer.stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
829                                 .willReturn(aResponse()
830                                 .withStatus(404)));
831         }
832
833         public static void MockDeleteVolumeGroup(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String resourceVersion) {
834                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
835                                 .willReturn(aResponse()
836                                 .withStatus(200)));
837         }
838
839         /**
840          * VF-Module StubResponse below
841          * @param statusCode TODO
842          */
843         public static void MockGetVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, String responseFile, int statusCode) {
844                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
845                                 .willReturn(aResponse()
846                                                 .withStatus(statusCode)
847                                                 .withHeader("Content-Type", "text/xml")
848                                                 .withBodyFile(responseFile)));
849         }
850
851         public static void MockGetVfModuleByNameWithDepth(WireMockServer wireMockServer, String vnfId, String vfModuleName, int depth, String responseFile, int statusCode) {
852                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth))
853                                 .willReturn(aResponse()
854                                                 .withStatus(statusCode)
855                                                 .withHeader("Content-Type", "text/xml")
856                                                 .withBodyFile(responseFile)));
857         }
858
859         public static void MockGetVfModuleByName(WireMockServer wireMockServer, String vnfId, String vfModuleName, String responseFile, int statusCode) {
860                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName))
861                                 .willReturn(aResponse()
862                                                 .withStatus(statusCode)
863                                                 .withHeader("Content-Type", "text/xml")
864                                                 .withBodyFile(responseFile)));
865         }
866
867         public static void MockGetVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId, String requestContaining, String vfModuleId) {
868                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
869                                 .withRequestBody(containing(requestContaining))
870                                 .willReturn(aResponse()
871                                                 .withStatus(200)
872                                                 .withHeader("Content-Type", "text/xml")));
873         }
874
875         public static void MockPutVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId, String requestContaining, String vfModuleId) {
876                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId +"/vf-modules/vf-module/" +vfModuleId))
877                                 .withRequestBody(containing(requestContaining))
878                                 .willReturn(aResponse()
879                                         .withStatus(200)));
880         }
881
882         public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
883                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
884                                 .willReturn(aResponse()
885                                                 .withStatus(200)));
886         }
887
888         public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, int returnCode) {
889                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
890                                 .willReturn(aResponse()
891                                                 .withStatus(returnCode)));
892         }
893
894         public static void MockDeleteVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, String resourceVersion, int returnCode) {
895                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))
896                                 .willReturn(aResponse()
897                                                 .withStatus(returnCode)));
898         }
899
900         public static void MockAAIVfModuleBadPatch(WireMockServer wireMockServer, String endpoint, int statusCode) {
901                 wireMockServer.stubFor(patch(urlMatching(endpoint))
902                         .willReturn(aResponse()
903                                 .withStatus(statusCode)));
904         }
905
906         /* AAI Pserver Queries */
907         public static void MockGetPserverByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
908                 wireMockServer.stubFor(put(urlMatching("/aai/v1[0-9]/query.*"))
909                                 .willReturn(aResponse()
910                                                 .withStatus(statusCode)
911                                                 .withHeader("Content-Type", "application/json")
912                                                 .withBodyFile(responseFile)));
913         }
914
915         public static void MockGetGenericVnfsByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
916                 wireMockServer.stubFor(get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
917                                 .willReturn(aResponse()
918                                                 .withStatus(statusCode)
919                                                 .withHeader("Content-Type", "application/json; charset=utf-8")
920                                                 .withBodyFile(responseFile)));
921         }
922
923         public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, int statusCode) {
924                 wireMockServer.stubFor(patch(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
925                                 .willReturn(aResponse()
926                                                 .withStatus(statusCode)
927                                                 ));
928         }
929
930         public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
931                 wireMockServer.stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
932                                 .willReturn(aResponse()
933                                                 .withStatus(statusCode)
934                                                 .withBodyFile(responseFile)
935                                                 ));
936         }
937
938         public static void MockGetDefaultCloudRegionByCloudRegionId(WireMockServer wireMockServer, String cloudRegionId, String responseFile, int statusCode) {
939                 wireMockServer.stubFor(get(urlMatching("/aai/v1[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegionId + ".*"))
940                                 .willReturn(aResponse()
941                                                 .withStatus(statusCode)
942                                                 .withHeader("Content-Type", "application/json; charset=utf-8")
943                                                 .withBodyFile(responseFile)));
944         }
945
946         //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above ////
947         @Deprecated
948         public static void MockGetVceById(WireMockServer wireMockServer){
949                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))
950                                 .willReturn(aResponse()
951                                                 .withStatus(200)
952                                                 .withHeader("Content-Type", "text/xml")
953                                                 .withBodyFile("GenericFlows/getVceResponse.xml")));
954         }
955         @Deprecated
956         public static void MockGetVceByName(WireMockServer wireMockServer){
957                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))
958                                 .willReturn(aResponse()
959                                                 .withStatus(200)
960                                                 .withHeader("Content-Type", "text/xml")
961                                                 .withBodyFile("GenericFlows/getVceByNameResponse.xml")));
962         }
963         @Deprecated
964         public static void MockPutVce(WireMockServer wireMockServer){
965                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123"))
966                                 .willReturn(aResponse()
967                                                 .withStatus(200)));
968         }
969         @Deprecated
970         public static void MockDeleteVce(WireMockServer wireMockServer){
971                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
972                                 .willReturn(aResponse()
973                                                 .withStatus(204)));
974         }
975         @Deprecated
976         public static void MockDeleteVce_404(WireMockServer wireMockServer){
977                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
978                                 .willReturn(aResponse()
979                                                 .withStatus(404)));
980         }
981
982         @Deprecated
983         public static void MockDeleteServiceSubscription(WireMockServer wireMockServer){
984                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
985                                   .willReturn(aResponse()
986                                   .withStatus(204)));
987         }
988         @Deprecated
989         public static void MockGetServiceSubscription(WireMockServer wireMockServer){
990                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
991                                   .willReturn(aResponse()
992                                   .withStatus(200)
993                                   .withHeader("Content-Type", "text/xml")
994                                   .withBodyFile("GenericFlows/getServiceSubscription.xml")));
995         }
996         @Deprecated
997         public static void MockGetServiceSubscription_200Empty(WireMockServer wireMockServer){
998                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
999                                   .willReturn(aResponse()
1000                                   .withStatus(200)
1001                                   .withHeader("Content-Type", "text/xml")
1002                                   .withBody(" ")));
1003         }
1004         @Deprecated
1005         public static void MockGetServiceSubscription_404(WireMockServer wireMockServer) {
1006                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
1007                                 .willReturn(aResponse()
1008                                                 .withStatus(404)));
1009         }
1010
1011         @Deprecated
1012         public static void MockGetGenericVnfById(WireMockServer wireMockServer){
1013                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1014                                 .willReturn(aResponse()
1015                                                 .withStatus(200)
1016                                                 .withHeader("Content-Type", "text/xml")
1017                                                 .withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
1018         }
1019         @Deprecated
1020         public static void MockGetGenericVnfById_404(WireMockServer wireMockServer){
1021                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1022                                 .willReturn(aResponse()
1023                                                 .withStatus(404)));
1024         }
1025         @Deprecated
1026         public static void MockGetGenericVnfByName(WireMockServer wireMockServer){
1027                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
1028                                 .willReturn(aResponse()
1029                                                 .withStatus(200)
1030                                                 .withHeader("Content-Type", "text/xml")
1031                                                 .withBodyFile("GenericFlows/getGenericVnfResponse.xml")));
1032         }
1033         @Deprecated
1034         public static void MockGetGenericVnfByName_hasRelationships(WireMockServer wireMockServer){
1035                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
1036                                 .willReturn(aResponse()
1037                                                 .withStatus(200)
1038                                                 .withHeader("Content-Type", "text/xml")
1039                                                 .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
1040         }
1041         @Deprecated
1042         public static void MockGetGenericVnfById_hasRelationships(WireMockServer wireMockServer){
1043                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1044                                 .willReturn(aResponse()
1045                                                 .withStatus(200)
1046                                                 .withHeader("Content-Type", "text/xml")
1047                                                 .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
1048         }
1049         @Deprecated
1050         public static void MockGetGenericVnfById_500(WireMockServer wireMockServer){
1051                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1052                                 .willReturn(aResponse()
1053                                                 .withStatus(500)));
1054         }
1055         @Deprecated
1056         public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer){
1057                 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
1058                                 .willReturn(aResponse()
1059                                                 .withStatus(404)));
1060         }
1061         @Deprecated
1062         public static void MockPutGenericVnf(WireMockServer wireMockServer){
1063                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1064                                 .willReturn(aResponse()
1065                                                 .withStatus(200)));
1066         }
1067         @Deprecated
1068         public static void MockPutGenericVnf_400(WireMockServer wireMockServer){
1069                 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1070                                 .willReturn(aResponse()
1071                                                 .withStatus(400)));
1072         }
1073         @Deprecated
1074         public static void MockDeleteGenericVnf(WireMockServer wireMockServer){
1075                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1076                                 .willReturn(aResponse()
1077                                                 .withStatus(204)));
1078         }
1079         @Deprecated
1080         public static void MockDeleteGenericVnf_404(WireMockServer wireMockServer){
1081                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1082                                 .willReturn(aResponse()
1083                                                 .withStatus(404)));
1084         }
1085         @Deprecated
1086         public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer){
1087                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1088                                 .willReturn(aResponse()
1089                                                 .withStatus(500)));
1090         }
1091         @Deprecated
1092         public static void MockDeleteGenericVnf_412(WireMockServer wireMockServer){
1093                 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))
1094                                 .willReturn(aResponse()
1095                                                 .withStatus(412)));
1096         }
1097
1098 }