2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.mock;
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
25 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
26 import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
27 import static com.github.tomakehurst.wiremock.client.WireMock.get;
28 import static com.github.tomakehurst.wiremock.client.WireMock.patch;
29 import static com.github.tomakehurst.wiremock.client.WireMock.post;
30 import static com.github.tomakehurst.wiremock.client.WireMock.put;
31 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
32 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
33 import com.github.tomakehurst.wiremock.WireMockServer;
37 * Reusable Mock StubResponses for AAI Endpoints
40 public class StubResponseAAI {
42 public static void setupAllMocks() {
48 * Allotted Resource Mock StubResponses below
50 public static void MockGetAllottedResource(WireMockServer wireMockServer, String globalCustId,
51 String subscriptionType, String serviceInstanceId, String allottedResourceId, String responseFile) {
52 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
53 + "/service-subscriptions/service-subscription/" + subscriptionType
54 + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
55 + allottedResourceId)).willReturn(
56 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
59 public static void MockPutAllottedResource(WireMockServer wireMockServer, String globalCustId,
60 String subscriptionType, String serviceInstanceId, String allottedResourceId) {
61 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
62 + "/service-subscriptions/service-subscription/" + subscriptionType
63 + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
64 + allottedResourceId)).willReturn(aResponse().withStatus(200)));
67 public static void MockPutAllottedResource_500(WireMockServer wireMockServer, String globalCustId,
68 String subscriptionType, String serviceInstanceId, String allottedResourceId) {
69 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
70 + "/service-subscriptions/service-subscription/" + subscriptionType
71 + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
72 + allottedResourceId)).willReturn(aResponse().withStatus(500)));
75 public static void MockDeleteAllottedResource(WireMockServer wireMockServer, String globalCustId,
76 String subscriptionType, String serviceInstanceId, String allottedResourceId, String resourceVersion) {
77 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
78 + "/service-subscriptions/service-subscription/" + subscriptionType
79 + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
80 + allottedResourceId + "[?]resource-version=" + resourceVersion))
81 .willReturn(aResponse().withStatus(204)));
84 public static void MockPatchAllottedResource(WireMockServer wireMockServer, String globalCustId,
85 String subscriptionType, String serviceInstanceId, String allottedResourceId) {
86 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
87 + "/service-subscriptions/service-subscription/" + subscriptionType
88 + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
89 + allottedResourceId)).willReturn(aResponse().withStatus(200)));
92 public static void MockQueryAllottedResourceById(WireMockServer wireMockServer, String allottedResourceId,
93 String responseFile) {
94 wireMockServer.stubFor(get(
95 urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=allotted-resource[&]filter=id:EQUALS:"
96 + allottedResourceId))
97 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
98 .withBodyFile(responseFile)));
103 * Service Instance Mock StubResponses below
105 public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId,
106 String subscriptionType, String serviceInstanceId) {
107 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
108 + "/service-subscriptions/service-subscription/" + subscriptionType
109 + "/service-instances/service-instance/" + serviceInstanceId))
110 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));
114 * Service Instance Mock StubResponses below
116 public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId,
117 String subscriptionType, String serviceInstanceId, String responseFile) {
118 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
119 + "/service-subscriptions/service-subscription/" + subscriptionType
120 + "/service-instances/service-instance/" + serviceInstanceId)).willReturn(
121 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
124 public static void MockGetServiceInstance_404(WireMockServer wireMockServer, String customer,
125 String serviceSubscription, String serviceInstanceId) {
126 wireMockServer.stubFor(get(urlMatching(
127 "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
128 + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
129 .willReturn(aResponse().withStatus(404)));
132 public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer,
133 String serviceSubscription, String serviceInstanceId) {
134 wireMockServer.stubFor(get(urlMatching(
135 "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
136 + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
137 .willReturn(aResponse().withStatus(500)));
140 public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer,
141 String serviceSubscription, String serviceInstanceId, String responseFile) {
142 wireMockServer.stubFor(get(urlMatching(
143 "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
144 + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
145 .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
146 .withBodyFile(responseFile)));
149 public static void MockNodeQueryServiceInstanceByName(WireMockServer wireMockServer, String serviceInstanceName,
150 String responseFile) {
151 wireMockServer.stubFor(get(urlMatching(
152 "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:"
153 + serviceInstanceName))
154 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
155 .withBodyFile(responseFile)));
158 public static void MockNodeQueryServiceInstanceByName_404(WireMockServer wireMockServer,
159 String serviceInstanceName) {
160 wireMockServer.stubFor(get(urlMatching(
161 "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:"
162 + serviceInstanceName)).willReturn(aResponse().withStatus(404)));
165 public static void MockNodeQueryServiceInstanceByName_500(WireMockServer wireMockServer,
166 String serviceInstanceName) {
167 wireMockServer.stubFor(get(urlMatching(
168 "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:"
169 + serviceInstanceName)).willReturn(aResponse().withStatus(500)));
172 public static void MockNodeQueryServiceInstanceById(WireMockServer wireMockServer, String serviceInstanceId,
173 String responseFile) {
174 wireMockServer.stubFor(get(urlMatching(
175 "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:"
176 + serviceInstanceId))
177 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
178 .withBodyFile(responseFile)));
181 public static void MockNodeQueryServiceInstanceById_404(WireMockServer wireMockServer, String serviceInstanceId) {
182 wireMockServer.stubFor(get(urlMatching(
183 "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:"
184 + serviceInstanceId)).willReturn(aResponse().withStatus(404)));
187 public static void MockNodeQueryServiceInstanceById_500(WireMockServer wireMockServer, String serviceInstanceId) {
188 wireMockServer.stubFor(get(urlMatching(
189 "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:"
190 + serviceInstanceId)).willReturn(aResponse().withStatus(500)));
193 public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer,
194 String serviceSubscription, String serviceInstanceId, String resourceVersion) {
195 wireMockServer.stubFor(delete(urlMatching(
196 "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
197 + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
198 + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(204)));
201 public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer,
202 String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode) {
203 wireMockServer.stubFor(get(urlMatching(
204 "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
205 + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
206 + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(statusCode)));
209 public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer,
210 String serviceSubscription, int statusCode) {
211 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer
212 + "/service-subscriptions/service-subscription/" + serviceSubscription))
213 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));
216 public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer,
217 String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode) {
218 wireMockServer.stubFor(delete(urlMatching(
219 "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
220 + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
221 + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(statusCode)));
224 public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer,
225 String serviceSubscription, String resourceVersion, int statusCode) {
226 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer
227 + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" + 1234))
228 .willReturn(aResponse().withStatus(statusCode)));
231 public static void MockDeleteServiceInstance_404(WireMockServer wireMockServer, String customer,
232 String serviceSubscription, String serviceInstanceId, String resourceVersion) {
233 wireMockServer.stubFor(delete(urlMatching(
234 "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
235 + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
236 + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(404)));
239 public static void MockDeleteServiceInstance_500(WireMockServer wireMockServer, String customer,
240 String serviceSubscription, String serviceInstanceId, String resourceVersion) {
241 wireMockServer.stubFor(delete(urlMatching(
242 "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
243 + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
244 + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(500)));
247 public static void MockPutServiceInstance(WireMockServer wireMockServer, String globalCustId,
248 String subscriptionType, String serviceInstanceId, String responseFile) {
249 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
250 + "/service-subscriptions/service-subscription/" + subscriptionType
251 + "/service-instances/service-instance/" + serviceInstanceId)).willReturn(
252 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
255 public static void MockPutServiceInstance_500(WireMockServer wireMockServer, String globalCustId,
256 String subscriptionType, String serviceInstanceId) {
257 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
258 + "/service-subscriptions/service-subscription/" + subscriptionType
259 + "/service-instances/service-instance/" + serviceInstanceId)).willReturn(aResponse().withStatus(500)));
263 * Service-Subscription Mock StubResponses below
265 public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId,
266 String subscriptionType, String responseFile) {
267 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
268 + "/service-subscriptions/service-subscription/" + subscriptionType)).willReturn(
269 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
272 public static void MockDeleteServiceSubscription(WireMockServer wireMockServer, String globalCustId,
273 String subscriptionType, int statusCode) {
274 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
275 + "/service-subscriptions/service-subscription/" + subscriptionType))
276 .willReturn(aResponse().withStatus(statusCode)));
279 public static void MockDeleteServiceInstanceId(WireMockServer wireMockServer, String globalCustId,
280 String subscriptionType, String serviceInstanceId) {
281 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
282 + "/service-subscriptions/service-subscription/" + subscriptionType
283 + "/service-instances/service-instance/" + serviceInstanceId)).willReturn(aResponse().withStatus(200)));
286 public static void MockPutServiceSubscription(WireMockServer wireMockServer, String globalCustId,
287 String subscriptionType) {
288 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
289 + "/service-subscriptions/service-subscription/" + subscriptionType))
290 .willReturn(aResponse().withStatus(200)));
293 public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId,
294 String subscriptionType, int statusCode) {
295 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
296 + "/service-subscriptions/service-subscription/" + subscriptionType))
297 .willReturn(aResponse().withStatus(statusCode)));
301 * Customer Mock StubResponses below
303 public static void MockGetCustomer(WireMockServer wireMockServer, String globalCustId, String responseFile) {
304 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId)).willReturn(
305 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
308 public static void MockDeleteCustomer(WireMockServer wireMockServer, String globalCustId) {
309 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
310 .willReturn(aResponse().withStatus(200)));
313 public static void MockPutCustomer(WireMockServer wireMockServer, String globalCustId) {
314 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
315 .willReturn(aResponse().withStatus(200)));
318 public static void MockPutCustomer_500(WireMockServer wireMockServer, String globalCustId) {
319 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
320 .willReturn(aResponse().withStatus(500)));
325 * Generic-Vnf Mock StubResponses below
328 public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile) {
329 wireMockServer.stubFor(
330 get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1")).willReturn(
331 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
334 public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile,
336 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId)).willReturn(
337 aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
340 public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, int statusCode,
341 String responseFile) {
342 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId)).atPriority(1)
343 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
344 .withBodyFile(responseFile)));
347 public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, String vfModuleId,
348 int statusCode, String responseFile, int priority) {
349 wireMockServer.stubFor(get(urlMatching(
350 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
351 .atPriority(priority).willReturn(aResponse().withStatus(statusCode)
352 .withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
355 public static void MockGetGenericVnfByIdWithDepth(WireMockServer wireMockServer, String vnfId, int depth,
356 String responseFile) {
357 wireMockServer.stubFor(
358 get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth))
359 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
360 .withBodyFile(responseFile)));
363 public static void MockGetGenericVnfById_404(WireMockServer wireMockServer, String vnfId) {
364 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
365 .willReturn(aResponse().withStatus(404)));
368 public static void MockGetGenericVnfById_500(WireMockServer wireMockServer, String vnfId) {
369 wireMockServer.stubFor(get(urlMatching("/aai/v9/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
370 .withQueryParam("depth", equalTo("1")).willReturn(aResponse().withStatus(500)));
373 public static void MockGetGenericVnfByName(WireMockServer wireMockServer, String vnfName, String responseFile) {
374 wireMockServer.stubFor(
375 get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName)).willReturn(
376 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
379 public static void MockGetGenericVnfByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth,
380 String responseFile) {
381 wireMockServer.stubFor(get(urlMatching(
382 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth))
383 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
384 .withBodyFile(responseFile)));
387 public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer, String vnfName) {
388 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
389 .willReturn(aResponse().withStatus(404)));
392 public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion) {
393 wireMockServer.stubFor(delete(urlMatching(
394 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
395 .willReturn(aResponse().withStatus(204)));
398 public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion,
400 wireMockServer.stubFor(delete(urlMatching(
401 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
402 .willReturn(aResponse().withStatus(statusCode)));
405 public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer, String vnfId, String resourceVersion) {
406 wireMockServer.stubFor(delete(urlMatching(
407 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
408 .willReturn(aResponse().withStatus(500)));
411 public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId) {
412 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
413 .willReturn(aResponse().withStatus(200)));
416 public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, String requestBodyContaining,
418 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
419 .withRequestBody(containing(requestBodyContaining)).willReturn(aResponse().withStatus(statusCode)));
422 public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, int statusCode) {
423 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
424 .willReturn(aResponse().withStatus(statusCode)));
427 public static void MockPutGenericVnf_Bad(WireMockServer wireMockServer, String vnfId, int statusCode) {
428 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
429 .willReturn(aResponse().withStatus(statusCode)));
432 public static void MockPatchGenericVnf(WireMockServer wireMockServer, String vnfId) {
433 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
434 .willReturn(aResponse().withStatus(200)));
438 * Vce Mock StubResponses below
440 public static void MockGetVceById(WireMockServer wireMockServer, String vnfId, String responseFile) {
441 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId)).willReturn(
442 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
445 public static void MockGetVceByName(WireMockServer wireMockServer, String vnfName, String responseFile) {
446 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName)).willReturn(
447 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
450 public static void MockDeleteVce(WireMockServer wireMockServer, String vnfId, String resourceVersion,
452 wireMockServer.stubFor(
453 delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion))
454 .willReturn(aResponse().withStatus(statusCode)));
457 public static void MockPutVce(WireMockServer wireMockServer, String vnfId) {
458 wireMockServer.stubFor(
459 put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId)).willReturn(aResponse().withStatus(200)));
462 public static void MockGetGenericVceByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth,
463 String responseFile) {
465 .stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth))
466 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
467 .withBodyFile(responseFile)));
470 public static void MockGetVceGenericQuery(WireMockServer wireMockServer, String serviceInstanceName, int depth,
471 int statusCode, String responseFile) {
472 wireMockServer.stubFor(
473 get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:"
474 + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth))
475 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
476 .withBodyFile(responseFile)));
480 * Tenant Mock StubResponses below
482 public static void MockGetTenantGenericQuery(WireMockServer wireMockServer, String customer, String serviceType,
483 String responseFile) {
484 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:"
485 + customer + "&key=service-subscription.service-type:" + serviceType
486 + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1"))
487 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
488 .withBodyFile(responseFile)));
491 public static void MockGetTenant(WireMockServer wireMockServer, String tenantId, String responseFile) {
492 wireMockServer.stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId)).willReturn(
493 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
497 * Network Mock StubResponses below
499 public static void MockGetNetwork(WireMockServer wireMockServer, String networkId, String responseFile,
501 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId)).willReturn(
502 aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
505 public static void MockGetNetworkByIdWithDepth(WireMockServer wireMockServer, String networkId, String responseFile,
507 wireMockServer.stubFor(
508 get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
509 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
510 .withBodyFile(responseFile)));
513 public static void MockGetNetworkCloudRegion(WireMockServer wireMockServer, String responseFile,
514 String cloudRegion) {
515 wireMockServer.stubFor(get(
516 urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegion))
517 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
518 .withBodyFile(responseFile)));
521 public static void MockGetNetworkByName(WireMockServer wireMockServer, String networkName, String responseFile) {
523 .stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkName))
524 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
525 .withBodyFile(responseFile)));
528 public static void MockGetNetworkByName_404(WireMockServer wireMockServer, String responseFile,
529 String networkName) {
531 .stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkName))
532 .willReturn(aResponse().withStatus(404).withHeader("Content-Type", "text/xml")
533 .withBodyFile(responseFile)));
536 public static void MockGetNetworkCloudRegion_404(WireMockServer wireMockServer, String cloudRegion) {
537 wireMockServer.stubFor(get(
538 urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegion))
539 .willReturn(aResponse().withStatus(404)));
542 public static void MockPutNetwork(WireMockServer wireMockServer, String networkId, int statusCode,
543 String responseFile) {
544 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId)).willReturn(
545 aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
548 public static void MockPutNetwork(WireMockServer wireMockServer, String networkPolicyId, String responseFile,
551 .stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId))
552 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
553 .withBodyFile(responseFile)));
556 public static void MockPostNetwork(WireMockServer wireMockServer, String networkId) {
557 wireMockServer.stubFor(post(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
558 .willReturn(aResponse().withStatus(201).withHeader("Content-Type", "text/xml")));
561 public static void MockPostNetworkSubnet(WireMockServer wireMockServer, String networkId, String subnetId) {
562 wireMockServer.stubFor(post(
563 urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "/subnets/subnet/" + subnetId))
564 .willReturn(aResponse().withStatus(201).withHeader("Content-Type", "text/xml")));
567 public static void MockGetNetworkName(WireMockServer wireMockServer, String networkPolicyName, String responseFile,
569 wireMockServer.stubFor(
570 get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))
571 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
572 .withBodyFile(responseFile)));
575 public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String responseFile, String vpnBinding) {
576 MockGetNetworkVpnBindingWithDepth(wireMockServer, responseFile, vpnBinding, "all");
579 public static void MockGetNetworkVpnBindingWithDepth(WireMockServer wireMockServer, String responseFile,
580 String vpnBinding, String depth) {
581 wireMockServer.stubFor(
582 get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + vpnBinding + "[?]depth=" + depth))
583 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
584 .withBodyFile(responseFile)));
587 public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String responseFile, String policy) {
588 wireMockServer.stubFor(
589 get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + policy + "[?]depth=all"))
590 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
591 .withBodyFile(responseFile)));
594 public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String networkBindingId,
595 String responseFile, int statusCode) {
596 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
597 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
598 .withBodyFile(responseFile)));
601 public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String networkPolicy, String responseFile,
603 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))
604 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
605 .withBodyFile(responseFile)));
608 public static void MockGetNetworkTableReference(WireMockServer wireMockServer, String responseFile,
609 String tableReference) {
610 wireMockServer.stubFor(get(urlMatching(
611 "/aai/v[0-9]+/network/route-table-references/route-table-reference/" + tableReference + "[?]depth=all"))
612 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
613 .withBodyFile(responseFile)));
616 public static void MockPutNetworkIdWithDepth(WireMockServer wireMockServer, String responseFile, String networkId,
618 wireMockServer.stubFor(
619 put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
620 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
621 .withBodyFile(responseFile)));
624 public static void MockGetNetworkPolicyfqdn(WireMockServer wireMockServer, String networkPolicy,
625 String responseFile, int statusCode) {
626 wireMockServer.stubFor(get(urlMatching(
627 "/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
628 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
629 .withBodyFile(responseFile)));
632 public static void MockGetNetworkRouteTable(WireMockServer wireMockServer, String networkRouteId,
633 String responseFile, int statusCode) {
634 wireMockServer.stubFor(
635 get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))
636 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
637 .withBodyFile(responseFile)));
640 public static void MockPatchVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
641 wireMockServer.stubFor(patch(urlMatching(
642 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
643 .willReturn(aResponse().withStatus(200)));
648 public static void MockVNFAdapterRestVfModule(WireMockServer wireMockServer) {
649 wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
650 .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
651 wireMockServer.stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))
652 .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
653 wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))
654 .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
655 wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))
656 .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
659 public static void MockDBUpdateVfModule(WireMockServer wireMockServer) {
660 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")).willReturn(aResponse().withStatus(200)
661 .withHeader("Content-Type", "text/xml").withBodyFile("VfModularity/DBUpdateResponse.xml")));
664 // start of mocks used locally and by other VF Module unit tests
665 public static void MockSDNCAdapterVfModule(WireMockServer wireMockServer) {
666 // simplified the implementation to return "success" for all requests
667 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
668 // .withRequestBody(containing("SvcInstanceId><"))
669 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
670 .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml")));
674 // start of mocks used locally and by other VF Module unit tests
675 public static void MockAAIVfModule(WireMockServer wireMockServer) {
676 wireMockServer.stubFor(
677 get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
678 .atPriority(1).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
679 .withBodyFile("VfModularity/VfModule-supercool.xml")));
680 wireMockServer.stubFor(
681 get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
682 .atPriority(2).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
683 .withBodyFile("VfModularity/VfModule-lukewarm.xml")));
685 .stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
686 .atPriority(5).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
687 .withBodyFile("VfModularity/VfModule-new.xml")));
688 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))
689 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
690 .withBodyFile("VfModularity/GenericVnf.xml")));
691 wireMockServer.stubFor(
692 patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
693 // .withRequestBody(containing("PCRF"))
694 .willReturn(aResponse().withStatus(200)));
695 wireMockServer.stubFor(
696 patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
697 // .withRequestBody(containing("PCRF"))
698 .willReturn(aResponse().withStatus(200)));
699 // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup
701 .stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
702 .withRequestBody(containing("PCRF")).willReturn(aResponse().withStatus(200)));
703 // HTTP PUT stub still used by DoCreateVfModuleTest
705 .stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
706 .withRequestBody(containing("MODULELABEL")).willReturn(aResponse().withStatus(200)));
707 wireMockServer.stubFor(
708 get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
709 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
710 .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
711 wireMockServer.stubFor(
712 get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
713 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
714 .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
715 wireMockServer.stubFor(get(urlMatching(
716 "/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/MDTWNJ21/volume-groups/volume-group/78987"))
717 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
718 .withBodyFile("VfModularity/VolumeGroup.xml")));
719 wireMockServer.stubFor(get(urlMatching(
720 "/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/volume-groups/volume-group/78987"))
721 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
722 .withBodyFile("VfModularity/VolumeGroup.xml")));
723 wireMockServer.stubFor(delete(urlMatching(
724 "/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))
725 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
726 .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml")));
727 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
728 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
729 .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml")));
730 wireMockServer.stubFor(patch(
731 urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))
732 .withRequestBody(containing("NEWvBNGModuleId")).willReturn(aResponse().withStatus(200)));
740 * Cloud infrastructure below
743 public static void MockGetCloudRegion(WireMockServer wireMockServer, String cloudRegionId, int statusCode,
744 String responseFile) {
745 wireMockServer.stubFor(get(
746 urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId))
747 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
748 .withBodyFile(responseFile)));
752 * Volume Group StubResponse below
754 public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId,
755 String responseFile) {
756 MockGetVolumeGroupById(wireMockServer, cloudRegionId, volumeGroupId, responseFile, 200);
759 public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId,
760 String responseFile, int responseCode) {
762 .stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"
763 + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
764 .willReturn(aResponse().withStatus(responseCode).withHeader("Content-Type", "text/xml")
765 .withBodyFile(responseFile)));
768 public static void MockPutVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId,
769 String responseFile, int statusCode) {
771 .stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"
772 + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
773 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
774 .withBodyFile(responseFile)));
777 public static void MockGetVolumeGroupByName(WireMockServer wireMockServer, String cloudRegionId,
778 String volumeGroupName, String responseFile, int statusCode) {
780 .stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"
781 + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
782 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
783 .withBodyFile(responseFile)));
786 public static void MockDeleteVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId,
787 String volumeGroupId, String resourceVersion, int statusCode) {
788 wireMockServer.stubFor(delete(
789 urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId
790 + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
791 .willReturn(aResponse().withStatus(statusCode)));
794 public static void MockGetVolumeGroupByName_404(WireMockServer wireMockServer, String cloudRegionId,
795 String volumeGroupName) {
796 wireMockServer.stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"
797 + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
798 .willReturn(aResponse().withStatus(404)));
801 public static void MockDeleteVolumeGroup(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId,
802 String resourceVersion) {
803 wireMockServer.stubFor(delete(
804 urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId
805 + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
806 .willReturn(aResponse().withStatus(200)));
810 * VF-Module StubResponse below
812 * @param statusCode TODO
814 public static void MockGetVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId,
815 String responseFile, int statusCode) {
816 wireMockServer.stubFor(get(urlMatching(
817 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
818 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
819 .withBodyFile(responseFile)));
822 public static void MockGetVfModuleByNameWithDepth(WireMockServer wireMockServer, String vnfId, String vfModuleName,
823 int depth, String responseFile, int statusCode) {
824 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId
825 + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth))
826 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
827 .withBodyFile(responseFile)));
830 public static void MockGetVfModuleByName(WireMockServer wireMockServer, String vnfId, String vfModuleName,
831 String responseFile, int statusCode) {
832 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId
833 + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName))
834 .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
835 .withBodyFile(responseFile)));
838 public static void MockGetVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId,
839 String requestContaining, String vfModuleId) {
840 wireMockServer.stubFor(get(urlMatching(
841 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
842 .withRequestBody(containing(requestContaining))
843 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));
846 public static void MockPutVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId,
847 String requestContaining, String vfModuleId) {
848 wireMockServer.stubFor(put(urlMatching(
849 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
850 .withRequestBody(containing(requestContaining)).willReturn(aResponse().withStatus(200)));
853 public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
854 wireMockServer.stubFor(put(urlMatching(
855 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
856 .willReturn(aResponse().withStatus(200)));
859 public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId,
861 wireMockServer.stubFor(put(urlMatching(
862 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
863 .willReturn(aResponse().withStatus(returnCode)));
866 public static void MockDeleteVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId,
867 String resourceVersion, int returnCode) {
868 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId
869 + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))
870 .willReturn(aResponse().withStatus(returnCode)));
873 public static void MockAAIVfModuleBadPatch(WireMockServer wireMockServer, String endpoint, int statusCode) {
874 wireMockServer.stubFor(patch(urlMatching(endpoint)).willReturn(aResponse().withStatus(statusCode)));
877 /* AAI Pserver Queries */
878 public static void MockGetPserverByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile,
880 wireMockServer.stubFor(put(urlMatching("/aai/v1[0-9]/query.*")).willReturn(aResponse().withStatus(statusCode)
881 .withHeader("Content-Type", "application/json").withBodyFile(responseFile)));
884 public static void MockGetGenericVnfsByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile,
886 wireMockServer.stubFor(
887 get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*")).willReturn(aResponse().withStatus(statusCode)
888 .withHeader("Content-Type", "application/json; charset=utf-8").withBodyFile(responseFile)));
891 public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, int statusCode) {
892 wireMockServer.stubFor(patch(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
893 .willReturn(aResponse().withStatus(statusCode)));
896 public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile,
898 wireMockServer.stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
899 .willReturn(aResponse().withStatus(statusCode).withBodyFile(responseFile)));
902 public static void MockGetDefaultCloudRegionByCloudRegionId(WireMockServer wireMockServer, String cloudRegionId,
903 String responseFile, int statusCode) {
904 wireMockServer.stubFor(get(urlMatching(
905 "/aai/v1[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + ".*"))
906 .willReturn(aResponse().withStatus(statusCode)
907 .withHeader("Content-Type", "application/json; charset=utf-8")
908 .withBodyFile(responseFile)));
911 //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones
914 public static void MockGetVceById(WireMockServer wireMockServer) {
915 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))
916 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
917 .withBodyFile("GenericFlows/getVceResponse.xml")));
921 public static void MockGetVceByName(WireMockServer wireMockServer) {
922 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))
923 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
924 .withBodyFile("GenericFlows/getVceByNameResponse.xml")));
928 public static void MockPutVce(WireMockServer wireMockServer) {
929 wireMockServer.stubFor(
930 put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123")).willReturn(aResponse().withStatus(200)));
934 public static void MockDeleteVce(WireMockServer wireMockServer) {
935 wireMockServer.stubFor(
936 delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
937 .willReturn(aResponse().withStatus(204)));
941 public static void MockDeleteVce_404(WireMockServer wireMockServer) {
942 wireMockServer.stubFor(
943 delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
944 .willReturn(aResponse().withStatus(404)));
948 public static void MockDeleteServiceSubscription(WireMockServer wireMockServer) {
949 wireMockServer.stubFor(delete(urlMatching(
950 "/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
951 .willReturn(aResponse().withStatus(204)));
955 public static void MockGetServiceSubscription(WireMockServer wireMockServer) {
956 wireMockServer.stubFor(get(urlMatching(
957 "/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
958 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
959 .withBodyFile("GenericFlows/getServiceSubscription.xml")));
963 public static void MockGetServiceSubscription_200Empty(WireMockServer wireMockServer) {
964 wireMockServer.stubFor(get(urlMatching(
965 "/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
966 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(" ")));
970 public static void MockGetServiceSubscription_404(WireMockServer wireMockServer) {
971 wireMockServer.stubFor(get(urlMatching(
972 "/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
973 .willReturn(aResponse().withStatus(404)));
977 public static void MockGetGenericVnfById(WireMockServer wireMockServer) {
978 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
979 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
980 .withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
984 public static void MockGetGenericVnfById_404(WireMockServer wireMockServer) {
985 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
986 .willReturn(aResponse().withStatus(404)));
990 public static void MockGetGenericVnfByName(WireMockServer wireMockServer) {
992 .stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
993 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
994 .withBodyFile("GenericFlows/getGenericVnfResponse.xml")));
998 public static void MockGetGenericVnfByName_hasRelationships(WireMockServer wireMockServer) {
1000 .stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
1001 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
1002 .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
1006 public static void MockGetGenericVnfById_hasRelationships(WireMockServer wireMockServer) {
1007 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1008 .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
1009 .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
1013 public static void MockGetGenericVnfById_500(WireMockServer wireMockServer) {
1014 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1015 .willReturn(aResponse().withStatus(500)));
1019 public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer) {
1021 .stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
1022 .willReturn(aResponse().withStatus(404)));
1026 public static void MockPutGenericVnf(WireMockServer wireMockServer) {
1027 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1028 .willReturn(aResponse().withStatus(200)));
1032 public static void MockPutGenericVnf_400(WireMockServer wireMockServer) {
1033 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1034 .willReturn(aResponse().withStatus(400)));
1038 public static void MockDeleteGenericVnf(WireMockServer wireMockServer) {
1039 wireMockServer.stubFor(delete(urlMatching(
1040 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1041 .willReturn(aResponse().withStatus(204)));
1045 public static void MockDeleteGenericVnf_404(WireMockServer wireMockServer) {
1046 wireMockServer.stubFor(delete(urlMatching(
1047 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1048 .willReturn(aResponse().withStatus(404)));
1052 public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer) {
1053 wireMockServer.stubFor(delete(urlMatching(
1054 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1055 .willReturn(aResponse().withStatus(500)));
1059 public static void MockDeleteGenericVnf_412(WireMockServer wireMockServer) {
1060 wireMockServer.stubFor(delete(urlMatching(
1061 "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))
1062 .willReturn(aResponse().withStatus(412)));