66dc1f9910dc325ee5b7938715ce561e9e930ddb
[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 mockSDNCAdapterRest() {
84                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
85                                 .willReturn(aResponse()
86                                                 .withStatus(202)
87                                                 .withHeader("Content-Type", "application/json")));
88         }
89
90         public static void mockSDNCAdapterRest_500() {
91                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
92                                 .willReturn(aResponse()
93                                                 .withStatus(500)
94                                                 .withHeader("Content-Type", "application/json")));
95         }
96
97         public static void mockSDNCAdapterRest(String requestContaining) {
98                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
99                                 .withRequestBody(containing(requestContaining))
100                                 .willReturn(aResponse()
101                                                 .withStatus(202)
102                                                 .withHeader("Content-Type", "application/json")));
103         }
104
105         public static void mockSDNCAdapterRest_500(String requestContaining) {
106                 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
107                                 .withRequestBody(containing(requestContaining))
108                                 .willReturn(aResponse()
109                                                 .withStatus(500)
110                                                 .withHeader("Content-Type", "application/json")));
111         }
112
113 }