2 * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
5 * ============LICENSE_START=======================================================
7 * ================================================================================
8 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.openecomp.mso.bpmn.mock;
26 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
27 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
28 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
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.stubFor;
32 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
35 * Please describe the StubResponseVNF.java class
37 public class StubResponseVNFAdapter {
39 public static void mockVNFAdapter() {
40 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
41 .willReturn(aResponse()
45 public static void mockVNFAdapter(String responseFile) {
46 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
47 .willReturn(aResponse()
49 .withHeader("Content-Type", "text/xml")
50 .withBodyFile(responseFile)));
53 public static void mockVNFAdapter_500() {
54 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
55 .willReturn(aResponse()
59 public static void mockVNFAdapterTransformer(String transformer, String responseFile) {
60 MockResource mockResource = new MockResource();
61 mockResource.updateProperties("vnf_delay", "300");
62 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
63 .willReturn(aResponse()
65 .withHeader("Content-Type", "application/soap+xml")
66 .withTransformers(transformer)
67 .withBodyFile(responseFile)));
70 public static void mockVNFAdapterTransformer(String transformer, String responseFile, String requestContaining) {
71 MockResource mockResource = new MockResource();
72 mockResource.updateProperties("vnf_delay", "300");
73 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
74 .withRequestBody(containing(requestContaining))
75 .willReturn(aResponse()
77 .withHeader("Content-Type", "application/soap+xml")
78 .withTransformers(transformer)
79 .withBodyFile(responseFile)));
82 public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) {
83 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
84 .willReturn(aResponse()
85 .withStatus(statusCode)
86 .withHeader("Content-Type", "application/xml")));
89 public static void mockVNFPut(String vfModuleId, int statusCode) {
90 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId))
91 .willReturn(aResponse()
92 .withStatus(statusCode)
93 .withHeader("Content-Type", "application/xml")));
96 public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
97 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
98 .willReturn(aResponse()
99 .withStatus(statusCode)
100 .withHeader("Content-Type", "application/xml")));
103 public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
104 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
105 .willReturn(aResponse()
106 .withStatus(statusCode)
107 .withHeader("Content-Type", "application/xml")));
110 public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
111 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
112 .willReturn(aResponse()
113 .withStatus(statusCode)
114 .withHeader("Content-Type", "application/xml")));
117 public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
118 stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
119 .willReturn(aResponse()
120 .withStatus(statusCode)
121 .withHeader("Content-Type", "application/xml")));
124 public static void mockPostVNFVolumeGroup(int statusCode) {
125 stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
126 .willReturn(aResponse()
127 .withStatus(statusCode)
128 .withHeader("Content-Type", "application/xml")));