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