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;
34 import com.github.tomakehurst.wiremock.WireMockServer;
38 * Reusable Mock StubResponses for AAI Endpoints
41 public class StubResponseAAI {
43 public static void setupAllMocks() {
49 * Allotted Resource Mock StubResponses below
51 public static void MockGetAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String responseFile) {
52 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
53 .willReturn(aResponse()
55 .withHeader("Content-Type", "text/xml")
56 .withBodyFile(responseFile)));
59 public static void MockPutAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
60 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
61 .willReturn(aResponse()
65 public static void MockPutAllottedResource_500(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
66 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
67 .willReturn(aResponse()
71 public static void MockDeleteAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String resourceVersion) {
72 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "[?]resource-version=" + resourceVersion))
73 .willReturn(aResponse()
77 public static void MockPatchAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
78 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
79 .willReturn(aResponse()
83 public static void MockQueryAllottedResourceById(WireMockServer wireMockServer, String allottedResourceId, String responseFile){
84 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=allotted-resource[&]filter=id:EQUALS:" + allottedResourceId))
85 .willReturn(aResponse()
87 .withHeader("Content-Type", "text/xml")
88 .withBodyFile(responseFile)));
93 * Service Instance Mock StubResponses below
95 public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
96 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
97 .willReturn(aResponse()
99 .withHeader("Content-Type", "text/xml")));
103 * Service Instance Mock StubResponses below
105 public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
106 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
107 .willReturn(aResponse()
109 .withHeader("Content-Type", "text/xml")
110 .withBodyFile(responseFile)));
113 public static void MockGetServiceInstance_404(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId){
114 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
115 .willReturn(aResponse()
119 public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId){
120 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
121 .willReturn(aResponse()
125 public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String responseFile){
126 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
127 .willReturn(aResponse()
129 .withHeader("Content-Type", "text/xml")
130 .withBodyFile(responseFile)));
133 public static void MockNodeQueryServiceInstanceByName(WireMockServer wireMockServer, String serviceInstanceName, String responseFile){
134 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:" + serviceInstanceName))
135 .willReturn(aResponse()
137 .withHeader("Content-Type", "text/xml")
138 .withBodyFile(responseFile)));
141 public static void MockNodeQueryServiceInstanceByName_404(WireMockServer wireMockServer, String serviceInstanceName){
142 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
143 .willReturn(aResponse()
147 public static void MockNodeQueryServiceInstanceByName_500(WireMockServer wireMockServer, String serviceInstanceName){
148 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
149 .willReturn(aResponse()
153 public static void MockNodeQueryServiceInstanceById(WireMockServer wireMockServer, String serviceInstanceId, String responseFile){
154 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:" + serviceInstanceId))
155 .willReturn(aResponse()
157 .withHeader("Content-Type", "text/xml")
158 .withBodyFile(responseFile)));
161 public static void MockNodeQueryServiceInstanceById_404(WireMockServer wireMockServer, String serviceInstanceId){
162 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
163 .willReturn(aResponse()
167 public static void MockNodeQueryServiceInstanceById_500(WireMockServer wireMockServer, String serviceInstanceId){
168 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
169 .willReturn(aResponse()
173 public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
174 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
175 .willReturn(aResponse()
179 public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
180 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
181 .willReturn(aResponse()
182 .withStatus(statusCode)));
185 public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, int statusCode){
186 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription))
187 .willReturn(aResponse()
189 .withHeader("Content-Type", "text/xml")));
192 public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
193 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
194 .willReturn(aResponse()
195 .withStatus(statusCode)));
198 public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String resourceVersion, int statusCode){
199 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" +1234))
200 .willReturn(aResponse()
201 .withStatus(statusCode)));
204 public static void MockDeleteServiceInstance_404(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
205 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
206 .willReturn(aResponse()
210 public static void MockDeleteServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
211 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
212 .willReturn(aResponse()
216 public static void MockPutServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
217 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
218 .willReturn(aResponse()
220 .withHeader("Content-Type", "text/xml")
221 .withBodyFile(responseFile)));
224 public static void MockPutServiceInstance_500(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
225 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
226 .willReturn(aResponse()
231 * Service-Subscription Mock StubResponses below
233 public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String responseFile) {
234 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
235 .willReturn(aResponse()
237 .withHeader("Content-Type", "text/xml")
238 .withBodyFile(responseFile)));
241 public static void MockDeleteServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, int statusCode) {
242 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
243 .willReturn(aResponse()
244 .withStatus(statusCode)));
247 public static void MockDeleteServiceInstanceId(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
248 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
249 .willReturn(aResponse()
253 public static void MockPutServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType) {
254 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
255 .willReturn(aResponse()
259 public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, int statusCode) {
260 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
261 .willReturn(aResponse()
262 .withStatus(statusCode)));
266 * Customer Mock StubResponses below
268 public static void MockGetCustomer(WireMockServer wireMockServer, String globalCustId, String responseFile) {
269 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
270 .willReturn(aResponse()
272 .withHeader("Content-Type", "text/xml")
273 .withBodyFile(responseFile)));
276 public static void MockDeleteCustomer(WireMockServer wireMockServer, String globalCustId) {
277 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
278 .willReturn(aResponse()
282 public static void MockPutCustomer(WireMockServer wireMockServer, String globalCustId) {
283 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
284 .willReturn(aResponse()
288 public static void MockPutCustomer_500(WireMockServer wireMockServer, String globalCustId) {
289 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
290 .willReturn(aResponse()
296 * Generic-Vnf Mock StubResponses below
299 public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile){
300 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
301 .willReturn(aResponse()
303 .withHeader("Content-Type", "text/xml")
304 .withBodyFile(responseFile)));
307 public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode){
308 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
309 .willReturn(aResponse()
310 .withStatus(statusCode)
311 .withHeader("Content-Type", "text/xml")
312 .withBodyFile(responseFile)));
315 public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, int statusCode, String responseFile) {
316 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
318 .willReturn(aResponse()
319 .withStatus(statusCode)
320 .withHeader("Content-Type", "text/xml")
321 .withBodyFile(responseFile)));
324 public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode, String responseFile, int priority) {
325 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
326 .atPriority(priority)
327 .willReturn(aResponse()
328 .withStatus(statusCode)
329 .withHeader("Content-Type", "text/xml")
330 .withBodyFile(responseFile)));
333 public static void MockGetGenericVnfByIdWithDepth(WireMockServer wireMockServer, String vnfId, int depth, String responseFile){
334 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth))
335 .willReturn(aResponse()
337 .withHeader("Content-Type", "text/xml")
338 .withBodyFile(responseFile)));
341 public static void MockGetGenericVnfById_404(WireMockServer wireMockServer, String vnfId){
342 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
343 .willReturn(aResponse()
347 public static void MockGetGenericVnfById_500(WireMockServer wireMockServer, String vnfId){
348 wireMockServer.stubFor(get(urlMatching("/aai/v9/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
349 .withQueryParam("depth", equalTo("1"))
350 .willReturn(aResponse()
354 public static void MockGetGenericVnfByName(WireMockServer wireMockServer, String vnfName, String responseFile){
355 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
356 .willReturn(aResponse()
358 .withHeader("Content-Type", "text/xml")
359 .withBodyFile(responseFile)));
362 public static void MockGetGenericVnfByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth, String responseFile){
363 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth))
364 .willReturn(aResponse()
366 .withHeader("Content-Type", "text/xml")
367 .withBodyFile(responseFile)));
370 public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer, String vnfName){
371 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
372 .willReturn(aResponse()
376 public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion){
377 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
378 .willReturn(aResponse()
382 public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion, int statusCode){
383 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
384 .willReturn(aResponse()
385 .withStatus(statusCode)));
388 public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer, String vnfId, String resourceVersion){
389 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
390 .willReturn(aResponse()
394 public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId){
395 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
396 .willReturn(aResponse()
400 public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, String requestBodyContaining, int statusCode) {
401 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
402 .withRequestBody(containing(requestBodyContaining))
403 .willReturn(aResponse()
404 .withStatus(statusCode)));
407 public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, int statusCode) {
408 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
409 .willReturn(aResponse()
410 .withStatus(statusCode)));
413 public static void MockPutGenericVnf_Bad(WireMockServer wireMockServer, String vnfId, int statusCode){
414 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
415 .willReturn(aResponse()
416 .withStatus(statusCode)));
419 public static void MockPatchGenericVnf(WireMockServer wireMockServer, String vnfId){
420 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
421 .willReturn(aResponse()
425 * Vce Mock StubResponses below
427 public static void MockGetVceById(WireMockServer wireMockServer, String vnfId, String responseFile){
428 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
429 .willReturn(aResponse()
431 .withHeader("Content-Type", "text/xml")
432 .withBodyFile(responseFile)));
435 public static void MockGetVceByName(WireMockServer wireMockServer, String vnfName, String responseFile){
436 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName))
437 .willReturn(aResponse()
439 .withHeader("Content-Type", "text/xml")
440 .withBodyFile(responseFile)));
443 public static void MockDeleteVce(WireMockServer wireMockServer, String vnfId, String resourceVersion, int statusCode){
444 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion))
445 .willReturn(aResponse()
446 .withStatus(statusCode)));
449 public static void MockPutVce(WireMockServer wireMockServer, String vnfId){
450 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
451 .willReturn(aResponse()
455 public static void MockGetGenericVceByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth, String responseFile){
456 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth))
457 .willReturn(aResponse()
459 .withHeader("Content-Type", "text/xml")
460 .withBodyFile(responseFile)));
463 public static void MockGetVceGenericQuery(WireMockServer wireMockServer, String serviceInstanceName, int depth, int statusCode, String responseFile){
464 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:" + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth))
465 .willReturn(aResponse()
466 .withStatus(statusCode)
467 .withHeader("Content-Type", "text/xml")
468 .withBodyFile(responseFile)));
472 * Tenant Mock StubResponses below
474 public static void MockGetTenantGenericQuery(WireMockServer wireMockServer, String customer, String serviceType, String responseFile) {
475 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:" + customer + "&key=service-subscription.service-type:" + serviceType + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1"))
476 .willReturn(aResponse()
478 .withHeader("Content-Type", "text/xml")
479 .withBodyFile(responseFile)));
482 public static void MockGetTenant(WireMockServer wireMockServer, String tenantId, String responseFile) {
483 wireMockServer.stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId))
484 .willReturn(aResponse()
486 .withHeader("Content-Type", "text/xml")
487 .withBodyFile(responseFile)));
491 * Network Mock StubResponses below
493 public static void MockGetNetwork(WireMockServer wireMockServer, String networkId, String responseFile, int statusCode) {
494 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
495 .willReturn(aResponse()
496 .withStatus(statusCode)
497 .withHeader("Content-Type", "text/xml")
498 .withBodyFile(responseFile)));
501 public static void MockGetNetworkByIdWithDepth(WireMockServer wireMockServer, String networkId, String responseFile, String depth) {
502 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
503 .willReturn(aResponse()
505 .withHeader("Content-Type", "text/xml")
506 .withBodyFile(responseFile)));
509 public static void MockGetNetworkCloudRegion(WireMockServer wireMockServer, String responseFile, String cloudRegion) {
510 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegion))
511 .willReturn(aResponse()
513 .withHeader("Content-Type", "text/xml")
514 .withBodyFile(responseFile)));
517 public static void MockGetNetworkByName(WireMockServer wireMockServer, String networkName, String responseFile) {
518 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
519 .willReturn(aResponse()
521 .withHeader("Content-Type", "text/xml")
522 .withBodyFile(responseFile)));
525 public static void MockGetNetworkByName_404(WireMockServer wireMockServer, String responseFile, String networkName) {
526 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
527 .willReturn(aResponse()
529 .withHeader("Content-Type", "text/xml")
530 .withBodyFile(responseFile)));
533 public static void MockGetNetworkCloudRegion_404(WireMockServer wireMockServer, String cloudRegion) {
534 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegion))
535 .willReturn(aResponse()
539 public static void MockPutNetwork(WireMockServer wireMockServer, String networkId, int statusCode, String responseFile) {
540 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
541 .willReturn(aResponse()
542 .withStatus(statusCode)
543 .withHeader("Content-Type", "text/xml")
544 .withBodyFile(responseFile)));
547 public static void MockPutNetwork(WireMockServer wireMockServer, String networkPolicyId, String responseFile, int statusCode) {
548 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId))
549 .willReturn(aResponse()
550 .withStatus(statusCode)
551 .withHeader("Content-Type", "text/xml")
552 .withBodyFile(responseFile)));
555 public static void MockPostNetwork(WireMockServer wireMockServer, String networkId) {
556 wireMockServer.stubFor(post(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
557 .willReturn(aResponse()
559 .withHeader("Content-Type", "text/xml")));
562 public static void MockPostNetworkSubnet(WireMockServer wireMockServer, String networkId, String subnetId) {
563 wireMockServer.stubFor(post(urlMatching(
564 "/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "/subnets/subnet/" + subnetId))
565 .willReturn(aResponse()
567 .withHeader("Content-Type", "text/xml")));
570 public static void MockGetNetworkName(WireMockServer wireMockServer, String networkPolicyName, String responseFile, int statusCode) {
571 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))
572 .willReturn(aResponse()
573 .withStatus(statusCode)
574 .withHeader("Content-Type", "text/xml")
575 .withBodyFile(responseFile)));
578 public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String responseFile, String vpnBinding) {
579 MockGetNetworkVpnBindingWithDepth(wireMockServer, responseFile, vpnBinding, "all");
582 public static void MockGetNetworkVpnBindingWithDepth(WireMockServer wireMockServer, String responseFile,
583 String vpnBinding, String depth) {
584 wireMockServer.stubFor(
585 get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + vpnBinding + "[?]depth=" + depth))
586 .willReturn(aResponse()
588 .withHeader("Content-Type", "text/xml")
589 .withBodyFile(responseFile)));
592 public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String responseFile, String policy) {
593 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all"))
594 .willReturn(aResponse()
596 .withHeader("Content-Type", "text/xml")
597 .withBodyFile(responseFile)));
600 public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String networkBindingId, String responseFile, int statusCode) {
601 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
602 .willReturn(aResponse()
603 .withStatus(statusCode)
604 .withHeader("Content-Type", "text/xml")
605 .withBodyFile(responseFile)));
608 public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String networkPolicy, String responseFile, int statusCode) {
609 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))
610 .willReturn(aResponse()
611 .withStatus(statusCode)
612 .withHeader("Content-Type", "text/xml")
613 .withBodyFile(responseFile)));
616 public static void MockGetNetworkTableReference(WireMockServer wireMockServer, String responseFile, String tableReference) {
617 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all"))
618 .willReturn(aResponse()
620 .withHeader("Content-Type", "text/xml")
621 .withBodyFile(responseFile)));
624 public static void MockPutNetworkIdWithDepth(WireMockServer wireMockServer, String responseFile, String networkId, String depth) {
625 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth ))
626 .willReturn(aResponse()
628 .withHeader("Content-Type", "text/xml")
629 .withBodyFile(responseFile)));
632 public static void MockGetNetworkPolicyfqdn(WireMockServer wireMockServer, String networkPolicy, String responseFile, int statusCode) {
633 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
634 .willReturn(aResponse()
635 .withStatus(statusCode)
636 .withHeader("Content-Type", "text/xml")
637 .withBodyFile(responseFile)));
640 public static void MockGetNetworkRouteTable(WireMockServer wireMockServer, String networkRouteId, String responseFile, int statusCode) {
641 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))
642 .willReturn(aResponse()
643 .withStatus(statusCode)
644 .withHeader("Content-Type", "text/xml")
645 .withBodyFile(responseFile)));
648 public static void MockPatchVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
649 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
650 .willReturn(aResponse()
656 public static void MockVNFAdapterRestVfModule(WireMockServer wireMockServer) {
657 wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
658 .willReturn(aResponse()
660 .withHeader("Content-Type", "application/xml")));
661 wireMockServer.stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))
662 .willReturn(aResponse()
664 .withHeader("Content-Type", "application/xml")));
665 wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))
666 .willReturn(aResponse()
668 .withHeader("Content-Type", "application/xml")));
669 wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))
670 .willReturn(aResponse()
672 .withHeader("Content-Type", "application/xml")));
675 public static void MockDBUpdateVfModule(WireMockServer wireMockServer){
676 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
677 .willReturn(aResponse()
679 .withHeader("Content-Type", "text/xml")
680 .withBodyFile("VfModularity/DBUpdateResponse.xml")));
683 // start of mocks used locally and by other VF Module unit tests
684 public static void MockSDNCAdapterVfModule(WireMockServer wireMockServer) {
685 // simplified the implementation to return "success" for all requests
686 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
687 // .withRequestBody(containing("SvcInstanceId><"))
688 .willReturn(aResponse()
690 .withHeader("Content-Type", "text/xml")
691 .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml")));
695 // start of mocks used locally and by other VF Module unit tests
696 public static void MockAAIVfModule(WireMockServer wireMockServer) {
697 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
699 .willReturn(aResponse()
701 .withHeader("Content-Type", "text/xml")
702 .withBodyFile("VfModularity/VfModule-supercool.xml")));
703 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
705 .willReturn(aResponse()
707 .withHeader("Content-Type", "text/xml")
708 .withBodyFile("VfModularity/VfModule-lukewarm.xml")));
709 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
711 .willReturn(aResponse()
713 .withHeader("Content-Type", "text/xml")
714 .withBodyFile("VfModularity/VfModule-new.xml")));
715 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))
716 .willReturn(aResponse()
718 .withHeader("Content-Type", "text/xml")
719 .withBodyFile("VfModularity/GenericVnf.xml")));
720 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
721 // .withRequestBody(containing("PCRF"))
722 .willReturn(aResponse()
724 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
725 // .withRequestBody(containing("PCRF"))
726 .willReturn(aResponse()
728 // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup
729 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
730 .withRequestBody(containing("PCRF"))
731 .willReturn(aResponse()
733 // HTTP PUT stub still used by DoCreateVfModuleTest
734 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
735 .withRequestBody(containing("MODULELABEL"))
736 .willReturn(aResponse()
738 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
739 .willReturn(aResponse()
741 .withHeader("Content-Type", "text/xml")
742 .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
743 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
744 .willReturn(aResponse()
746 .withHeader("Content-Type", "text/xml")
747 .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
748 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/MDTWNJ21/volume-groups/volume-group/78987"))
749 .willReturn(aResponse()
751 .withHeader("Content-Type", "text/xml")
752 .withBodyFile("VfModularity/VolumeGroup.xml")));
753 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/volume-groups/volume-group/78987"))
754 .willReturn(aResponse()
756 .withHeader("Content-Type", "text/xml")
757 .withBodyFile("VfModularity/VolumeGroup.xml")));
758 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))
759 .willReturn(aResponse()
761 .withHeader("Content-Type", "text/xml")
762 .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml")));
763 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
764 .willReturn(aResponse()
766 .withHeader("Content-Type", "text/xml")
767 .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml")));
768 wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))
769 .withRequestBody(containing("NEWvBNGModuleId"))
770 .willReturn(aResponse()
779 * Cloud infrastructure below
782 public static void MockGetCloudRegion(WireMockServer wireMockServer, String cloudRegionId, int statusCode, String responseFile) {
783 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId))
784 .willReturn(aResponse()
785 .withStatus(statusCode)
786 .withHeader("Content-Type", "text/xml")
787 .withBodyFile(responseFile)));
791 * Volume Group StubResponse below
793 public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile) {
794 MockGetVolumeGroupById(wireMockServer, cloudRegionId, volumeGroupId, responseFile, 200);
797 public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile, int responseCode) {
798 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
799 .willReturn(aResponse()
800 .withStatus(responseCode)
801 .withHeader("Content-Type", "text/xml")
802 .withBodyFile(responseFile)));
805 public static void MockPutVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile, int statusCode) {
806 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
807 .willReturn(aResponse()
808 .withStatus(statusCode)
809 .withHeader("Content-Type", "text/xml")
810 .withBodyFile(responseFile)));
813 public static void MockGetVolumeGroupByName(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupName, String responseFile, int statusCode) {
814 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
815 .willReturn(aResponse()
816 .withStatus(statusCode)
817 .withHeader("Content-Type", "text/xml")
818 .withBodyFile(responseFile)));
821 public static void MockDeleteVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String resourceVersion, int statusCode) {
822 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
823 .willReturn(aResponse()
824 .withStatus(statusCode)));
827 public static void MockGetVolumeGroupByName_404(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupName) {
828 wireMockServer.stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
829 .willReturn(aResponse()
833 public static void MockDeleteVolumeGroup(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String resourceVersion) {
834 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
835 .willReturn(aResponse()
840 * VF-Module StubResponse below
841 * @param statusCode TODO
843 public static void MockGetVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, String responseFile, int statusCode) {
844 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
845 .willReturn(aResponse()
846 .withStatus(statusCode)
847 .withHeader("Content-Type", "text/xml")
848 .withBodyFile(responseFile)));
851 public static void MockGetVfModuleByNameWithDepth(WireMockServer wireMockServer, String vnfId, String vfModuleName, int depth, String responseFile, int statusCode) {
852 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth))
853 .willReturn(aResponse()
854 .withStatus(statusCode)
855 .withHeader("Content-Type", "text/xml")
856 .withBodyFile(responseFile)));
859 public static void MockGetVfModuleByName(WireMockServer wireMockServer, String vnfId, String vfModuleName, String responseFile, int statusCode) {
860 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName))
861 .willReturn(aResponse()
862 .withStatus(statusCode)
863 .withHeader("Content-Type", "text/xml")
864 .withBodyFile(responseFile)));
867 public static void MockGetVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId, String requestContaining, String vfModuleId) {
868 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
869 .withRequestBody(containing(requestContaining))
870 .willReturn(aResponse()
872 .withHeader("Content-Type", "text/xml")));
875 public static void MockPutVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId, String requestContaining, String vfModuleId) {
876 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId +"/vf-modules/vf-module/" +vfModuleId))
877 .withRequestBody(containing(requestContaining))
878 .willReturn(aResponse()
882 public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
883 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
884 .willReturn(aResponse()
888 public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, int returnCode) {
889 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
890 .willReturn(aResponse()
891 .withStatus(returnCode)));
894 public static void MockDeleteVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, String resourceVersion, int returnCode) {
895 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))
896 .willReturn(aResponse()
897 .withStatus(returnCode)));
900 public static void MockAAIVfModuleBadPatch(WireMockServer wireMockServer, String endpoint, int statusCode) {
901 wireMockServer.stubFor(patch(urlMatching(endpoint))
902 .willReturn(aResponse()
903 .withStatus(statusCode)));
906 /* AAI Pserver Queries */
907 public static void MockGetPserverByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
908 wireMockServer.stubFor(put(urlMatching("/aai/v1[0-9]/query.*"))
909 .willReturn(aResponse()
910 .withStatus(statusCode)
911 .withHeader("Content-Type", "application/json")
912 .withBodyFile(responseFile)));
915 public static void MockGetGenericVnfsByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
916 wireMockServer.stubFor(get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
917 .willReturn(aResponse()
918 .withStatus(statusCode)
919 .withHeader("Content-Type", "application/json; charset=utf-8")
920 .withBodyFile(responseFile)));
923 public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, int statusCode) {
924 wireMockServer.stubFor(patch(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
925 .willReturn(aResponse()
926 .withStatus(statusCode)
930 public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
931 wireMockServer.stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
932 .willReturn(aResponse()
933 .withStatus(statusCode)
934 .withBodyFile(responseFile)
938 public static void MockGetDefaultCloudRegionByCloudRegionId(WireMockServer wireMockServer, String cloudRegionId, String responseFile, int statusCode) {
939 wireMockServer.stubFor(get(urlMatching("/aai/v1[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegionId + ".*"))
940 .willReturn(aResponse()
941 .withStatus(statusCode)
942 .withHeader("Content-Type", "application/json; charset=utf-8")
943 .withBodyFile(responseFile)));
946 //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above ////
948 public static void MockGetVceById(WireMockServer wireMockServer){
949 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))
950 .willReturn(aResponse()
952 .withHeader("Content-Type", "text/xml")
953 .withBodyFile("GenericFlows/getVceResponse.xml")));
956 public static void MockGetVceByName(WireMockServer wireMockServer){
957 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))
958 .willReturn(aResponse()
960 .withHeader("Content-Type", "text/xml")
961 .withBodyFile("GenericFlows/getVceByNameResponse.xml")));
964 public static void MockPutVce(WireMockServer wireMockServer){
965 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123"))
966 .willReturn(aResponse()
970 public static void MockDeleteVce(WireMockServer wireMockServer){
971 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
972 .willReturn(aResponse()
976 public static void MockDeleteVce_404(WireMockServer wireMockServer){
977 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
978 .willReturn(aResponse()
983 public static void MockDeleteServiceSubscription(WireMockServer wireMockServer){
984 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
985 .willReturn(aResponse()
989 public static void MockGetServiceSubscription(WireMockServer wireMockServer){
990 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
991 .willReturn(aResponse()
993 .withHeader("Content-Type", "text/xml")
994 .withBodyFile("GenericFlows/getServiceSubscription.xml")));
997 public static void MockGetServiceSubscription_200Empty(WireMockServer wireMockServer){
998 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
999 .willReturn(aResponse()
1001 .withHeader("Content-Type", "text/xml")
1005 public static void MockGetServiceSubscription_404(WireMockServer wireMockServer) {
1006 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
1007 .willReturn(aResponse()
1012 public static void MockGetGenericVnfById(WireMockServer wireMockServer){
1013 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1014 .willReturn(aResponse()
1016 .withHeader("Content-Type", "text/xml")
1017 .withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
1020 public static void MockGetGenericVnfById_404(WireMockServer wireMockServer){
1021 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1022 .willReturn(aResponse()
1026 public static void MockGetGenericVnfByName(WireMockServer wireMockServer){
1027 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
1028 .willReturn(aResponse()
1030 .withHeader("Content-Type", "text/xml")
1031 .withBodyFile("GenericFlows/getGenericVnfResponse.xml")));
1034 public static void MockGetGenericVnfByName_hasRelationships(WireMockServer wireMockServer){
1035 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
1036 .willReturn(aResponse()
1038 .withHeader("Content-Type", "text/xml")
1039 .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
1042 public static void MockGetGenericVnfById_hasRelationships(WireMockServer wireMockServer){
1043 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1044 .willReturn(aResponse()
1046 .withHeader("Content-Type", "text/xml")
1047 .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
1050 public static void MockGetGenericVnfById_500(WireMockServer wireMockServer){
1051 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1052 .willReturn(aResponse()
1056 public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer){
1057 wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
1058 .willReturn(aResponse()
1062 public static void MockPutGenericVnf(WireMockServer wireMockServer){
1063 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1064 .willReturn(aResponse()
1068 public static void MockPutGenericVnf_400(WireMockServer wireMockServer){
1069 wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
1070 .willReturn(aResponse()
1074 public static void MockDeleteGenericVnf(WireMockServer wireMockServer){
1075 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1076 .willReturn(aResponse()
1080 public static void MockDeleteGenericVnf_404(WireMockServer wireMockServer){
1081 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1082 .willReturn(aResponse()
1086 public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer){
1087 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
1088 .willReturn(aResponse()
1092 public static void MockDeleteGenericVnf_412(WireMockServer wireMockServer){
1093 wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))
1094 .willReturn(aResponse()