Change the header to SO
[so.git] / bpmn / MSOMockServer / src / main / java / org / openecomp / mso / bpmn / mock / StubResponseVNFAdapter.java
1 /*
2  * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
3  */
4 /*- 
5  * ============LICENSE_START======================================================= 
6  * ONAP - SO 
7  * ================================================================================ 
8  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. 
9  * ================================================================================ 
10  * Licensed under the Apache License, Version 2.0 (the "License"); 
11  * you may not use this file except in compliance with the License. 
12  * You may obtain a copy of the License at 
13  * 
14  *      http://www.apache.org/licenses/LICENSE-2.0 
15  * 
16  * Unless required by applicable law or agreed to in writing, software 
17  * distributed under the License is distributed on an "AS IS" BASIS, 
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
19  * See the License for the specific language governing permissions and 
20  * limitations under the License. 
21  * ============LICENSE_END========================================================= 
22  */ 
23
24 package org.openecomp.mso.bpmn.mock;
25
26 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
27 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
28 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
29 import static com.github.tomakehurst.wiremock.client.WireMock.post;
30 import static com.github.tomakehurst.wiremock.client.WireMock.put;
31 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
32 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
33 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
34
35 /**
36  * Please describe the StubResponseVNF.java class
37  */
38 public class StubResponseVNFAdapter {
39
40         public static void mockVNFAdapter() {
41                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
42                                 .willReturn(aResponse()
43                                                 .withStatus(200)));
44         }
45
46         public static void mockVNFAdapter(String responseFile) {
47                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
48                                   .willReturn(aResponse()
49                                   .withStatus(200)
50                                   .withHeader("Content-Type", "text/xml")
51                                   .withBodyFile(responseFile)));
52         }
53
54         public static void mockVNFAdapter_500() {
55                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
56                                 .willReturn(aResponse()
57                                                 .withStatus(500)));
58         }
59
60         public static void mockVNFAdapterTransformer(String transformer, String responseFile) {
61                 MockResource mockResource = new MockResource();
62                 mockResource.updateProperties("vnf_delay", "300");
63                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
64                                 .willReturn(aResponse()
65                                                 .withStatus(200)
66                                                 .withHeader("Content-Type", "application/soap+xml")
67                                                 .withTransformers(transformer)
68                                                 .withBodyFile(responseFile)));
69         }
70
71         public static void mockVNFAdapterTransformer(String transformer, String responseFile, String requestContaining) {
72                 MockResource mockResource = new MockResource();
73                 mockResource.updateProperties("vnf_delay", "300");
74                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
75                                 .withRequestBody(containing(requestContaining))
76                                 .willReturn(aResponse()
77                                                 .withStatus(200)
78                                                 .withHeader("Content-Type", "application/soap+xml")
79                                                 .withTransformers(transformer)
80                                                 .withBodyFile(responseFile)));
81         }
82         
83         public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) {
84                 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
85                                 .willReturn(aResponse()
86                                 .withStatus(statusCode)
87                                 .withHeader("Content-Type", "application/xml")));
88         }
89         
90         public static void mockVNFPut(String vfModuleId, int statusCode) {
91                 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId))
92                                 .willReturn(aResponse()
93                                 .withStatus(statusCode)
94                                 .withHeader("Content-Type", "application/xml")));
95         }
96         
97         public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
98                 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
99                                 .willReturn(aResponse()
100                                 .withStatus(statusCode)
101                                 .withHeader("Content-Type", "application/xml")));
102         }
103         
104         public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
105                 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
106                                 .willReturn(aResponse()
107                                 .withStatus(statusCode)
108                                 .withHeader("Content-Type", "application/xml")));
109         }
110         
111         public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
112                 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
113                                 .willReturn(aResponse()
114                                 .withStatus(statusCode)
115                                 .withHeader("Content-Type", "application/xml")));
116         }
117         
118         public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
119                 stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
120                                 .willReturn(aResponse()
121                                         .withStatus(statusCode)
122                                         .withHeader("Content-Type", "application/xml")));
123         }
124         
125         public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) {
126                 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
127                                 .willReturn(aResponse()
128                                 .withStatus(statusCode)
129                                 .withHeader("Content-Type", "application/xml")));
130         }
131         public static void mockPostVNFVolumeGroup(int statusCode) {
132                 stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
133                                 .willReturn(aResponse()
134                                         .withStatus(statusCode)
135                                         .withHeader("Content-Type", "application/xml")));
136         }
137         
138         public static void mockVNFAdapterRest(String vnfId) {
139                 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
140                                 .willReturn(aResponse()
141                                                 .withStatus(200)));
142         }
143
144         public static void mockVNFAdapterRest_500(String vnfId) {
145                 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
146                                 .willReturn(aResponse()
147                                                 .withStatus(500)));
148         }
149         
150         public static void mockVfModuleDelete(String volumeGroupId) {
151                 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
152                                 .willReturn(aResponse()
153                                 .withStatus(202)
154                                 .withHeader("Content-Type", "application/xml")));
155         }
156         
157         public static void mockVfModuleDelete(String volumeGroupId, int statusCode) {
158                 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
159                                 .willReturn(aResponse()
160                                 .withStatus(statusCode)
161                                 .withHeader("Content-Type", "application/xml")));
162         }
163 }