230c9d4fbc935e6c7c13bd5fb3c381c228ba61c8
[so.git] / bpmn / MSOMockServer / src / main / java / org / openecomp / mso / bpmn / mock / StubResponseSDNCAdapter.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.post;
29 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
30 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
31
32 /**
33  * Please describe the StubResponseSDNC.java class
34  */
35 public class StubResponseSDNCAdapter {
36
37         public static void setupAllMocks() {
38
39         }
40
41         public static void mockSDNCAdapter_500() {
42                 stubFor(post(urlEqualTo("/SDNCAdapter"))
43                                 .willReturn(aResponse()
44                                                 .withStatus(500)));
45         }               
46         
47         public static void mockSDNCAdapter_500(String requestContaining) {
48                 stubFor(post(urlEqualTo("/SDNCAdapter"))
49                   .withRequestBody(containing(requestContaining))
50                   .willReturn(aResponse()
51                   .withStatus(500)));
52         }               
53         
54         public static void mockSDNCAdapter(int statusCode) {
55                 stubFor(post(urlEqualTo("/SDNCAdapter"))
56                                 .willReturn(aResponse()
57                                                 .withStatus(statusCode)));
58         }
59         
60         public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
61                 stubFor(post(urlEqualTo(endpoint))      
62                                   .willReturn(aResponse()
63                                   .withStatus(statusCode)
64                                   .withHeader("Content-Type", "text/xml")
65                                   .withBodyFile(responseFile)));
66         }
67
68         public static void mockSDNCAdapter(String responseFile) {
69                 stubFor(post(urlEqualTo("/SDNCAdapter"))
70                                   .willReturn(aResponse()
71                                   .withStatus(200)
72                                   .withHeader("Content-Type", "text/xml")
73                                   .withBodyFile(responseFile)));
74         }
75         
76         public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
77                 stubFor(post(urlEqualTo(endpoint))
78                                 .withRequestBody(containing(requestContaining))
79                                 .willReturn(aResponse()
80                                         .withStatus(statusCode)
81                                         .withHeader("Content-Type", "text/xml")
82                                         .withBodyFile(responseFile)));
83         }
84
85         public static void mockSDNCAdapterSimulator(String responseFile) {
86                 MockResource mockResource = new MockResource();
87                 mockResource.updateProperties("sdnc_delay", "300");
88                 stubFor(post(urlEqualTo("/SDNCAdapter"))
89                                 .willReturn(aResponse()
90                                                 .withStatus(200)
91                                                 .withHeader("Content-Type", "application/soap+xml")
92                                                 .withTransformers("sdnc-adapter-transformer")
93                                                 .withBodyFile(responseFile)));
94         }
95
96         public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) {
97                 MockResource mockResource = new MockResource();
98                 mockResource.updateProperties("sdnc_delay", "300");
99                 stubFor(post(urlEqualTo("/SDNCAdapter"))
100                                 .withRequestBody(containing(requestContaining))
101                                 .willReturn(aResponse()
102                                                 .withStatus(200)
103                                                 .withHeader("Content-Type", "application/soap+xml")
104                                                 .withTransformers("sdnc-adapter-transformer")
105                                                 .withBodyFile(responseFile)));
106         }
107
108         public static void mockSDNCAdapterRest() {
109                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
110                                 .willReturn(aResponse()
111                                                 .withStatus(202)
112                                                 .withHeader("Content-Type", "application/json")));
113         }
114
115         public static void mockSDNCAdapterRest_500() {
116                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
117                                 .willReturn(aResponse()
118                                                 .withStatus(500)
119                                                 .withHeader("Content-Type", "application/json")));
120         }
121
122         public static void mockSDNCAdapterRest(String requestContaining) {
123                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
124                                 .withRequestBody(containing(requestContaining))
125                                 .willReturn(aResponse()
126                                                 .withStatus(202)
127                                                 .withHeader("Content-Type", "application/json")));
128         }
129
130         public static void mockSDNCAdapterRest_500(String requestContaining) {
131                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
132                                 .withRequestBody(containing(requestContaining))
133                                 .willReturn(aResponse()
134                                                 .withStatus(500)
135                                                 .withHeader("Content-Type", "application/json")));
136         }
137
138         public static void mockSDNCAdapterTopology(String responseFile, String requestContaining) {
139                 MockResource mockResource = new MockResource();
140                 mockResource.updateProperties("sdnc_delay", "300");             
141                 stubFor(post(urlEqualTo("/SDNCAdapter"))
142                                 .withRequestBody(containing(requestContaining))
143                                 .willReturn(aResponse()
144                                                 .withStatus(200)
145                                                 .withHeader("Content-Type", "text/xml")
146                                                 .withTransformers("network-topology-operation-transformer")
147                                                 .withBodyFile(responseFile)));
148         }
149
150         
151 }