Merge "Added the "@Override" annotation"
[so.git] / bpmn / MSOMockServer / src / main / 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         }
84         
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")));
90         }
91         
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")));
97         }
98         
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")));
104         }
105         
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")));
111         }
112         
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")));
118         }
119         
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")));
125         }
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")));
131         }
132         
133         public static void mockVNFAdapterRest(String vnfId) {
134                 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
135                                 .willReturn(aResponse()
136                                                 .withStatus(200)));
137         }
138
139         public static void mockVNFAdapterRest_500(String vnfId) {
140                 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
141                                 .willReturn(aResponse()
142                                                 .withStatus(500)));
143         }
144         
145         public static void mockVfModuleDelete(String volumeGroupId) {
146                 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
147                                 .willReturn(aResponse()
148                                 .withStatus(202)
149                                 .withHeader("Content-Type", "application/xml")));
150         }
151         
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")));
157         }
158 }