8e4b7893660fd8bafac982fb468f9a6593e88435
[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(int statusCode) {
42                 stubFor(post(urlEqualTo("/SDNCAdapter"))
43                                 .willReturn(aResponse()
44                                                 .withStatus(statusCode)));
45         }
46         
47         public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
48                 stubFor(post(urlEqualTo(endpoint))      
49                                   .willReturn(aResponse()
50                                   .withStatus(statusCode)
51                                   .withHeader("Content-Type", "text/xml")
52                                   .withBodyFile(responseFile)));
53         }
54
55         public static void mockSDNCAdapter(String responseFile) {
56                 stubFor(post(urlEqualTo("/SDNCAdapter"))
57                                   .willReturn(aResponse()
58                                   .withStatus(200)
59                                   .withHeader("Content-Type", "text/xml")
60                                   .withBodyFile(responseFile)));
61         }
62         
63         public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
64                 stubFor(post(urlEqualTo(endpoint))
65                                 .withRequestBody(containing(requestContaining))
66                                 .willReturn(aResponse()
67                                         .withStatus(statusCode)
68                                         .withHeader("Content-Type", "text/xml")
69                                         .withBodyFile(responseFile)));
70         }
71
72         public static void mockSDNCAdapterSimulator(String responseFile) {
73                 MockResource mockResource = new MockResource();
74                 mockResource.updateProperties("sdnc_delay", "300");
75                 stubFor(post(urlEqualTo("/SDNCAdapter"))
76                                 .willReturn(aResponse()
77                                                 .withStatus(200)
78                                                 .withHeader("Content-Type", "application/soap+xml")
79                                                 .withTransformers("sdnc-adapter-transformer")
80                                                 .withBodyFile(responseFile)));
81         }
82
83         public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) {
84                 MockResource mockResource = new MockResource();
85                 mockResource.updateProperties("sdnc_delay", "300");
86                 stubFor(post(urlEqualTo("/SDNCAdapter"))
87                                 .withRequestBody(containing(requestContaining))
88                                 .willReturn(aResponse()
89                                                 .withStatus(200)
90                                                 .withHeader("Content-Type", "application/soap+xml")
91                                                 .withTransformers("sdnc-adapter-transformer")
92                                                 .withBodyFile(responseFile)));
93         }
94
95         public static void mockSDNCAdapterRest() {
96                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
97                                 .willReturn(aResponse()
98                                                 .withStatus(202)
99                                                 .withHeader("Content-Type", "application/json")));
100         }
101
102         public static void mockSDNCAdapterRest_500() {
103                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
104                                 .willReturn(aResponse()
105                                                 .withStatus(500)
106                                                 .withHeader("Content-Type", "application/json")));
107         }
108
109         public static void mockSDNCAdapterRest(String requestContaining) {
110                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
111                                 .withRequestBody(containing(requestContaining))
112                                 .willReturn(aResponse()
113                                                 .withStatus(202)
114                                                 .withHeader("Content-Type", "application/json")));
115         }
116
117         public static void mockSDNCAdapterRest_500(String requestContaining) {
118                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
119                                 .withRequestBody(containing(requestContaining))
120                                 .willReturn(aResponse()
121                                                 .withStatus(500)
122                                                 .withHeader("Content-Type", "application/json")));
123         }
124
125         public static void mockSDNCAdapterTopology(String responseFile, String requestContaining) {
126                 MockResource mockResource = new MockResource();
127                 mockResource.updateProperties("sdnc_delay", "300");             
128                 stubFor(post(urlEqualTo("/SDNCAdapter"))
129                                 .withRequestBody(containing(requestContaining))
130                                 .willReturn(aResponse()
131                                                 .withStatus(200)
132                                                 .withHeader("Content-Type", "text/xml")
133                                                 .withTransformers("network-topology-operation-transformer")
134                                                 .withBodyFile(responseFile)));
135         }
136
137         
138 }