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.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.put;
28 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
29 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
30 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
33 * Please describe the StubResponseVNF.java class
35 public class StubResponseVNFAdapter {
37 public static void mockVNFAdapter() {
38 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
39 .willReturn(aResponse()
43 public static void mockVNFAdapter(String responseFile) {
44 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
45 .willReturn(aResponse()
47 .withHeader("Content-Type", "text/xml")
48 .withBodyFile(responseFile)));
51 public static void mockVNFAdapter_500() {
52 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
53 .willReturn(aResponse()
57 public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) {
58 stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
59 .willReturn(aResponse()
60 .withStatus(statusCode)
61 .withHeader("Content-Type", "application/xml")));
62 stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
63 .willReturn(aResponse()
64 .withStatus(statusCode)
65 .withHeader("Content-Type", "application/xml")));
68 public static void mockVNFPut(String vfModuleId, int statusCode) {
69 stubFor(put(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId))
70 .willReturn(aResponse()
71 .withStatus(statusCode)
72 .withHeader("Content-Type", "application/xml")));
73 stubFor(put(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId))
74 .willReturn(aResponse()
75 .withStatus(statusCode)
76 .withHeader("Content-Type", "application/xml")));
79 public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
80 stubFor(put(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
81 .willReturn(aResponse()
82 .withStatus(statusCode)
83 .withHeader("Content-Type", "application/xml")));
84 stubFor(put(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
85 .willReturn(aResponse()
86 .withStatus(statusCode)
87 .withHeader("Content-Type", "application/xml")));
90 public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
91 stubFor(delete(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
92 .willReturn(aResponse()
93 .withStatus(statusCode)
94 .withHeader("Content-Type", "application/xml")));
95 stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
96 .willReturn(aResponse()
97 .withStatus(statusCode)
98 .withHeader("Content-Type", "application/xml")));
101 public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
102 stubFor(delete(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId + "/rollback"))
103 .willReturn(aResponse()
104 .withStatus(statusCode)
105 .withHeader("Content-Type", "application/xml")));
106 stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
107 .willReturn(aResponse()
108 .withStatus(statusCode)
109 .withHeader("Content-Type", "application/xml")));
112 public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
113 stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
114 .willReturn(aResponse()
115 .withStatus(statusCode)
116 .withHeader("Content-Type", "application/xml")));
117 stubFor(put(urlEqualTo("/vnfs/rest/v1/volume-groups/" + volumeGroupId))
118 .willReturn(aResponse()
119 .withStatus(statusCode)
120 .withHeader("Content-Type", "application/xml")));
123 public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) {
124 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
125 .willReturn(aResponse()
126 .withStatus(statusCode)
127 .withHeader("Content-Type", "application/xml")));
128 stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/" + volumeGroupId + "/rollback"))
129 .willReturn(aResponse()
130 .withStatus(statusCode)
131 .withHeader("Content-Type", "application/xml")));
133 public static void mockPostVNFVolumeGroup(int statusCode) {
134 stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
135 .willReturn(aResponse()
136 .withStatus(statusCode)
137 .withHeader("Content-Type", "application/xml")));
138 stubFor(post(urlEqualTo("/vnfs/rest/v1/volume-groups"))
139 .willReturn(aResponse()
140 .withStatus(statusCode)
141 .withHeader("Content-Type", "application/xml")));
144 public static void mockVNFAdapterRest(String vnfId) {
145 stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
146 .willReturn(aResponse()
148 stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
149 .willReturn(aResponse()
153 public static void mockVNFAdapterRest_500(String vnfId) {
154 stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
155 .willReturn(aResponse()
157 stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
158 .willReturn(aResponse()
162 public static void mockVfModuleDelete(String volumeGroupId) {
163 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
164 .willReturn(aResponse()
166 .withHeader("Content-Type", "application/xml")));
167 stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/"+ volumeGroupId))
168 .willReturn(aResponse()
170 .withHeader("Content-Type", "application/xml")));
173 public static void mockVfModuleDelete(String volumeGroupId, int statusCode) {
174 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
175 .willReturn(aResponse()
176 .withStatus(statusCode)
177 .withHeader("Content-Type", "application/xml")));
178 stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/78987"))
179 .willReturn(aResponse()
180 .withStatus(statusCode)
181 .withHeader("Content-Type", "application/xml")));