10557ce09129c8b034c70b17fe9df5b7b78659af
[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.urlEqualTo;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
28
29 import com.github.tomakehurst.wiremock.WireMockServer;
30
31 /**
32  * Please describe the StubResponseSDNC.java class
33  */
34 public class StubResponseSDNCAdapter {
35
36         public static void setupAllMocks() {
37
38         }
39
40         public static void mockSDNCAdapter_500(WireMockServer wireMockServer) {
41                 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
42                                 .willReturn(aResponse()
43                                                 .withStatus(500)));
44         }               
45         
46         public static void mockSDNCAdapter_500(WireMockServer wireMockServer, String requestContaining) {
47                 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
48                   .withRequestBody(containing(requestContaining))
49                   .willReturn(aResponse()
50                   .withStatus(500)));
51         }               
52         
53         public static void mockSDNCAdapter(WireMockServer wireMockServer, int statusCode) {
54                 wireMockServer.stubFor(post(urlMatching(".*/SDNCAdapter"))
55                                 .willReturn(aResponse()
56                                                 .withStatus(statusCode)));
57         }
58         
59         public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, int statusCode, String responseFile) {
60                 wireMockServer.stubFor(post(urlEqualTo(endpoint))       
61                                   .willReturn(aResponse()
62                                   .withStatus(statusCode)
63                                   .withHeader("Content-Type", "text/xml")
64                                   .withBodyFile(responseFile)));
65         }
66
67         public static void mockSDNCAdapter(WireMockServer wireMockServer, String responseFile) {
68                 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
69                                   .willReturn(aResponse()
70                                   .withStatus(200)
71                                   .withHeader("Content-Type", "text/xml")
72                                   .withBodyFile(responseFile)));
73         }
74         
75         public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, String requestContaining, int statusCode, String responseFile) {
76                 wireMockServer.stubFor(post(urlEqualTo(endpoint))
77                                 .withRequestBody(containing(requestContaining))
78                                 .willReturn(aResponse()
79                                         .withStatus(statusCode)
80                                         .withHeader("Content-Type", "text/xml")
81                                         .withBodyFile(responseFile)));
82         }
83
84         public static void mockSDNCAdapterRest(WireMockServer wireMockServer) {
85                 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
86                                 .willReturn(aResponse()
87                                                 .withStatus(202)
88                                                 .withHeader("Content-Type", "application/json")));
89         }
90
91         public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer) {
92                 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
93                                 .willReturn(aResponse()
94                                                 .withStatus(500)
95                                                 .withHeader("Content-Type", "application/json")));
96         }
97
98         public static void mockSDNCAdapterRest(WireMockServer wireMockServer, String requestContaining) {
99                 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
100                                 .withRequestBody(containing(requestContaining))
101                                 .willReturn(aResponse()
102                                                 .withStatus(202)
103                                                 .withHeader("Content-Type", "application/json")));
104         }
105
106         public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer, String requestContaining) {
107                 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
108                                 .withRequestBody(containing(requestContaining))
109                                 .willReturn(aResponse()
110                                                 .withStatus(500)
111                                                 .withHeader("Content-Type", "application/json")));
112         }
113
114 }