Merge "Reorder modifiers"
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / mock / StubResponseVNFAdapter.java
1 /*
2  * ============LICENSE_START======================================================= 
3  * ONAP - SO 
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 
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0 
10  * 
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========================================================= 
17  */ 
18
19 package org.openecomp.mso.bpmn.mock;
20
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;
29
30 /**
31  * Please describe the StubResponseVNF.java class
32  */
33 public class StubResponseVNFAdapter {
34
35         public static void mockVNFAdapter() {
36                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
37                                 .willReturn(aResponse()
38                                                 .withStatus(200)));
39         }
40
41         public static void mockVNFAdapter(String responseFile) {
42                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
43                                   .willReturn(aResponse()
44                                   .withStatus(200)
45                                   .withHeader("Content-Type", "text/xml")
46                                   .withBodyFile(responseFile)));
47         }
48
49         public static void mockVNFAdapter_500() {
50                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
51                                 .willReturn(aResponse()
52                                                 .withStatus(500)));
53         }
54
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()
60                                                 .withStatus(200)
61                                                 .withHeader("Content-Type", "application/soap+xml")
62                                                 .withTransformers(transformer)
63                                                 .withBodyFile(responseFile)));
64         }
65
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()
72                                                 .withStatus(200)
73                                                 .withHeader("Content-Type", "application/soap+xml")
74                                                 .withTransformers(transformer)
75                                                 .withBodyFile(responseFile)));
76         }
77         
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")));
87         }
88         
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")));
98         }
99         
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")));
109         }
110         
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")));
120         }
121         
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")));
131         }
132         
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")));
142         }
143         
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")));
153         }
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")));
163         }
164         
165         public static void mockVNFAdapterRest(String vnfId) {
166                 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
167                                 .willReturn(aResponse()
168                                                 .withStatus(200)));
169                 stubFor(post(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules"))
170                                 .willReturn(aResponse()
171                                                 .withStatus(200)));
172         }
173
174         public static void mockVNFAdapterRest_500(String vnfId) {
175                 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
176                                 .willReturn(aResponse()
177                                                 .withStatus(500)));
178                 stubFor(post(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules"))
179                                 .willReturn(aResponse()
180                                                 .withStatus(500)));
181         }
182         
183         public static void mockVfModuleDelete(String volumeGroupId) {
184                 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
185                                 .willReturn(aResponse()
186                                 .withStatus(202)
187                                 .withHeader("Content-Type", "application/xml")));
188                 stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/"+ volumeGroupId))
189                                 .willReturn(aResponse()
190                                 .withStatus(202)
191                                 .withHeader("Content-Type", "application/xml")));
192         }
193         
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")));
203         }
204 }