7951a48184175aa8b7c59329bd3eef6112ee30ae
[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  * OPENECOMP - MSO 
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
34 /**
35  * Please describe the StubResponseVNF.java class
36  */
37 public class StubResponseVNFAdapter {
38
39         public static void mockVNFAdapter() {
40                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
41                                 .willReturn(aResponse()
42                                                 .withStatus(200)));
43         }
44
45         public static void mockVNFAdapter(String responseFile) {
46                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
47                                   .willReturn(aResponse()
48                                   .withStatus(200)
49                                   .withHeader("Content-Type", "text/xml")
50                                   .withBodyFile(responseFile)));
51         }
52
53         public static void mockVNFAdapter_500() {
54                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
55                                 .willReturn(aResponse()
56                                                 .withStatus(500)));
57         }
58
59         public static void mockVNFAdapterTransformer(String transformer, String responseFile) {
60                 MockResource mockResource = new MockResource();
61                 mockResource.updateProperties("vnf_delay", "300");
62                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
63                                 .willReturn(aResponse()
64                                                 .withStatus(200)
65                                                 .withHeader("Content-Type", "application/soap+xml")
66                                                 .withTransformers(transformer)
67                                                 .withBodyFile(responseFile)));
68         }
69
70         public static void mockVNFAdapterTransformer(String transformer, String responseFile, String requestContaining) {
71                 MockResource mockResource = new MockResource();
72                 mockResource.updateProperties("vnf_delay", "300");
73                 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
74                                 .withRequestBody(containing(requestContaining))
75                                 .willReturn(aResponse()
76                                                 .withStatus(200)
77                                                 .withHeader("Content-Type", "application/soap+xml")
78                                                 .withTransformers(transformer)
79                                                 .withBodyFile(responseFile)));
80         }
81         
82         public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) {
83                 stubFor(post(urlEqualTo("/vnfs/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         }
95         
96         public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
97                 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
98                                 .willReturn(aResponse()
99                                 .withStatus(statusCode)
100                                 .withHeader("Content-Type", "application/xml")));
101         }
102         
103         public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
104                 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
105                                 .willReturn(aResponse()
106                                 .withStatus(statusCode)
107                                 .withHeader("Content-Type", "application/xml")));
108         }
109         
110         public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
111                 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
112                                 .willReturn(aResponse()
113                                 .withStatus(statusCode)
114                                 .withHeader("Content-Type", "application/xml")));
115         }
116         
117         public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
118                 stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
119                                 .willReturn(aResponse()
120                                         .withStatus(statusCode)
121                                         .withHeader("Content-Type", "application/xml")));
122         }
123         
124         public static void mockPostVNFVolumeGroup(int statusCode) {
125                 stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
126                                 .willReturn(aResponse()
127                                         .withStatus(statusCode)
128                                         .withHeader("Content-Type", "application/xml")));
129         }
130 }