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")));
85 public static void mockVNFPut(String vfModuleId, int statusCode) {
86 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId))
87 .willReturn(aResponse()
88 .withStatus(statusCode)
89 .withHeader("Content-Type", "application/xml")));
92 public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
93 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
94 .willReturn(aResponse()
95 .withStatus(statusCode)
96 .withHeader("Content-Type", "application/xml")));
99 public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
100 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
101 .willReturn(aResponse()
102 .withStatus(statusCode)
103 .withHeader("Content-Type", "application/xml")));
106 public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
107 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
108 .willReturn(aResponse()
109 .withStatus(statusCode)
110 .withHeader("Content-Type", "application/xml")));
113 public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
114 stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
115 .willReturn(aResponse()
116 .withStatus(statusCode)
117 .withHeader("Content-Type", "application/xml")));
120 public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) {
121 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
122 .willReturn(aResponse()
123 .withStatus(statusCode)
124 .withHeader("Content-Type", "application/xml")));
126 public static void mockPostVNFVolumeGroup(int statusCode) {
127 stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
128 .willReturn(aResponse()
129 .withStatus(statusCode)
130 .withHeader("Content-Type", "application/xml")));
133 public static void mockVNFAdapterRest(String vnfId) {
134 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
135 .willReturn(aResponse()
139 public static void mockVNFAdapterRest_500(String vnfId) {
140 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
141 .willReturn(aResponse()
145 public static void mockVfModuleDelete(String volumeGroupId) {
146 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
147 .willReturn(aResponse()
149 .withHeader("Content-Type", "application/xml")));
152 public static void mockVfModuleDelete(String volumeGroupId, int statusCode) {
153 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
154 .willReturn(aResponse()
155 .withStatus(statusCode)
156 .withHeader("Content-Type", "application/xml")));