2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
19 package org.openecomp.mso.bpmn.mock;
21 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
22 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
23 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
24 import static com.github.tomakehurst.wiremock.client.WireMock.post;
25 import static com.github.tomakehurst.wiremock.client.WireMock.put;
26 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
31 * Please describe the StubResponseVNF.java class
33 public class StubResponseVNFAdapter {
35 public static void mockVNFAdapter() {
36 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
37 .willReturn(aResponse()
41 public static void mockVNFAdapter(String responseFile) {
42 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
43 .willReturn(aResponse()
45 .withHeader("Content-Type", "text/xml")
46 .withBodyFile(responseFile)));
49 public static void mockVNFAdapter_500() {
50 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
51 .willReturn(aResponse()
55 public static void mockVNFAdapterTransformer(String transformer, String responseFile) {
56 MockResource mockResource = new MockResource();
57 mockResource.updateProperties("vnf_delay", "300");
58 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
59 .willReturn(aResponse()
61 .withHeader("Content-Type", "application/soap+xml")
62 .withTransformers(transformer)
63 .withBodyFile(responseFile)));
66 public static void mockVNFAdapterTransformer(String transformer, String responseFile, String requestContaining) {
67 MockResource mockResource = new MockResource();
68 mockResource.updateProperties("vnf_delay", "300");
69 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
70 .withRequestBody(containing(requestContaining))
71 .willReturn(aResponse()
73 .withHeader("Content-Type", "application/soap+xml")
74 .withTransformers(transformer)
75 .withBodyFile(responseFile)));
78 public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) {
79 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
80 .willReturn(aResponse()
81 .withStatus(statusCode)
82 .withHeader("Content-Type", "application/xml")));
83 stubFor(post(urlEqualTo("/vnfs/rest/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")));
94 stubFor(put(urlEqualTo("/vnfs/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId))
95 .willReturn(aResponse()
96 .withStatus(statusCode)
97 .withHeader("Content-Type", "application/xml")));
100 public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
101 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
102 .willReturn(aResponse()
103 .withStatus(statusCode)
104 .withHeader("Content-Type", "application/xml")));
105 stubFor(put(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
106 .willReturn(aResponse()
107 .withStatus(statusCode)
108 .withHeader("Content-Type", "application/xml")));
111 public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
112 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
113 .willReturn(aResponse()
114 .withStatus(statusCode)
115 .withHeader("Content-Type", "application/xml")));
116 stubFor(delete(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
117 .willReturn(aResponse()
118 .withStatus(statusCode)
119 .withHeader("Content-Type", "application/xml")));
122 public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
123 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
124 .willReturn(aResponse()
125 .withStatus(statusCode)
126 .withHeader("Content-Type", "application/xml")));
127 stubFor(delete(urlEqualTo("/vnfs/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
128 .willReturn(aResponse()
129 .withStatus(statusCode)
130 .withHeader("Content-Type", "application/xml")));
133 public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
134 stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
135 .willReturn(aResponse()
136 .withStatus(statusCode)
137 .withHeader("Content-Type", "application/xml")));
138 stubFor(put(urlEqualTo("/vnfs/rest/v1/volume-groups/" + volumeGroupId))
139 .willReturn(aResponse()
140 .withStatus(statusCode)
141 .withHeader("Content-Type", "application/xml")));
144 public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) {
145 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
146 .willReturn(aResponse()
147 .withStatus(statusCode)
148 .withHeader("Content-Type", "application/xml")));
149 stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/" + volumeGroupId + "/rollback"))
150 .willReturn(aResponse()
151 .withStatus(statusCode)
152 .withHeader("Content-Type", "application/xml")));
154 public static void mockPostVNFVolumeGroup(int statusCode) {
155 stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
156 .willReturn(aResponse()
157 .withStatus(statusCode)
158 .withHeader("Content-Type", "application/xml")));
159 stubFor(post(urlEqualTo("/vnfs/rest/v1/volume-groups"))
160 .willReturn(aResponse()
161 .withStatus(statusCode)
162 .withHeader("Content-Type", "application/xml")));
165 public static void mockVNFAdapterRest(String vnfId) {
166 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
167 .willReturn(aResponse()
169 stubFor(post(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules"))
170 .willReturn(aResponse()
174 public static void mockVNFAdapterRest_500(String vnfId) {
175 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
176 .willReturn(aResponse()
178 stubFor(post(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules"))
179 .willReturn(aResponse()
183 public static void mockVfModuleDelete(String volumeGroupId) {
184 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
185 .willReturn(aResponse()
187 .withHeader("Content-Type", "application/xml")));
188 stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/"+ volumeGroupId))
189 .willReturn(aResponse()
191 .withHeader("Content-Type", "application/xml")));
194 public static void mockVfModuleDelete(String volumeGroupId, int statusCode) {
195 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
196 .willReturn(aResponse()
197 .withStatus(statusCode)
198 .withHeader("Content-Type", "application/xml")));
199 stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/78987"))
200 .willReturn(aResponse()
201 .withStatus(statusCode)
202 .withHeader("Content-Type", "application/xml")));