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