Containerization feature of SO
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / bpmn / mock / StubResponseSDNCAdapter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.mock;
22
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
25 import static com.github.tomakehurst.wiremock.client.WireMock.post;
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 StubResponseSDNC.java class
32  */
33 public class StubResponseSDNCAdapter {
34
35         public static void setupAllMocks() {
36
37         }
38
39         public static void mockSDNCAdapter_500() {
40                 stubFor(post(urlEqualTo("/SDNCAdapter"))
41                                 .willReturn(aResponse()
42                                                 .withStatus(500)));
43         }               
44         
45         public static void mockSDNCAdapter_500(String requestContaining) {
46                 stubFor(post(urlEqualTo("/SDNCAdapter"))
47                   .withRequestBody(containing(requestContaining))
48                   .willReturn(aResponse()
49                   .withStatus(500)));
50         }               
51         
52         public static void mockSDNCAdapter(int statusCode) {
53                 stubFor(post(urlMatching(".*/SDNCAdapter"))
54                                 .willReturn(aResponse()
55                                                 .withStatus(statusCode)));
56         }
57         
58         public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
59                 stubFor(post(urlEqualTo(endpoint))      
60                                   .willReturn(aResponse()
61                                   .withStatus(statusCode)
62                                   .withHeader("Content-Type", "text/xml")
63                                   .withBodyFile(responseFile)));
64         }
65
66         public static void mockSDNCAdapter(String responseFile) {
67                 stubFor(post(urlEqualTo("/SDNCAdapter"))
68                                   .willReturn(aResponse()
69                                   .withStatus(200)
70                                   .withHeader("Content-Type", "text/xml")
71                                   .withBodyFile(responseFile)));
72         }
73         
74         public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
75                 stubFor(post(urlEqualTo(endpoint))
76                                 .withRequestBody(containing(requestContaining))
77                                 .willReturn(aResponse()
78                                         .withStatus(statusCode)
79                                         .withHeader("Content-Type", "text/xml")
80                                         .withBodyFile(responseFile)));
81         }
82
83         public static void mockSDNCAdapterSimulator(String responseFile) {
84                 MockResource mockResource = new MockResource();
85                 mockResource.updateProperties("sdnc_delay", "300");
86                 stubFor(post(urlEqualTo("/SDNCAdapter"))
87                                 .willReturn(aResponse()
88                                                 .withStatus(200)
89                                                 .withHeader("Content-Type", "application/soap+xml")
90                                                 .withTransformers("sdnc-adapter-transformer")
91                                                 .withBodyFile(responseFile)));
92         }
93
94         public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) {
95                 MockResource mockResource = new MockResource();
96                 mockResource.updateProperties("sdnc_delay", "300");
97                 stubFor(post(urlEqualTo("/SDNCAdapter"))
98                                 .withRequestBody(containing(requestContaining))
99                                 .willReturn(aResponse()
100                                                 .withStatus(200)
101                                                 .withHeader("Content-Type", "application/soap+xml")
102                                                 .withTransformers("sdnc-adapter-transformer")
103                                                 .withBodyFile(responseFile)));
104         }
105
106         public static void mockSDNCAdapterRest() {
107                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
108                                 .willReturn(aResponse()
109                                                 .withStatus(202)
110                                                 .withHeader("Content-Type", "application/json")));
111         }
112
113         public static void mockSDNCAdapterRest_500() {
114                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
115                                 .willReturn(aResponse()
116                                                 .withStatus(500)
117                                                 .withHeader("Content-Type", "application/json")));
118         }
119
120         public static void mockSDNCAdapterRest(String requestContaining) {
121                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
122                                 .withRequestBody(containing(requestContaining))
123                                 .willReturn(aResponse()
124                                                 .withStatus(202)
125                                                 .withHeader("Content-Type", "application/json")));
126         }
127
128         public static void mockSDNCAdapterRest_500(String requestContaining) {
129                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
130                                 .withRequestBody(containing(requestContaining))
131                                 .willReturn(aResponse()
132                                                 .withStatus(500)
133                                                 .withHeader("Content-Type", "application/json")));
134         }
135
136         public static void mockSDNCAdapterTopology(String responseFile, String requestContaining) {
137                 MockResource mockResource = new MockResource();
138                 mockResource.updateProperties("sdnc_delay", "300");             
139                 stubFor(post(urlEqualTo("/SDNCAdapter"))
140                                 .withRequestBody(containing(requestContaining))
141                                 .willReturn(aResponse()
142                                                 .withStatus(200)
143                                                 .withHeader("Content-Type", "text/xml")
144                                                 .withTransformers("network-topology-operation-transformer")
145                                                 .withBodyFile(responseFile)));
146         }
147
148         
149 }