Change the header to SO
[so.git] / bpmn / MSOMockServer / src / main / java / org / openecomp / mso / bpmn / mock / StubResponseNetworkAdapter.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  * ONAP - SO 
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.put;
30 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
31 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
32 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
33
34 /**
35  * Please describe the StubResponseNetwork.java class
36  *
37  */
38 public class StubResponseNetworkAdapter {
39
40         private static final String EOL = "\n";
41
42         public static void setupAllMocks() {
43
44         }
45
46
47         public static void MockNetworkAdapter() {
48                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
49                         .willReturn(aResponse()
50                         .withStatus(200)));
51         }
52
53         public static void MockNetworkAdapter(String response) {
54                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
55                         .willReturn(aResponse()
56                         .withStatus(200)
57                         .withHeader("Content-Type", "text/xml")
58                         .withBodyFile(response)));
59         }
60
61         public static void MockNetworkAdapter_500() {
62                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
63                         .willReturn(aResponse()
64                         .withStatus(500)));
65         }
66
67         public static void MockNetworkAdapterPost(String responseFile, String requestContaining) {
68                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
69                         .withRequestBody(containing(requestContaining))                         
70                         .willReturn(aResponse()
71                         .withStatus(200)
72                         .withHeader("Content-Type", "text/xml")
73                         .withBodyFile(responseFile)));
74         }       
75         
76         public static void MockNetworkAdapter(String networkId, int statusCode, String responseFile) {
77                 stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId))
78                                   .willReturn(aResponse()
79                                   .withStatus(statusCode)
80                                   .withHeader("Content-Type", "application/xml")
81                                   .withBodyFile(responseFile)));
82         }
83         
84         public static void MockNetworkAdapterContainingRequest(String requestContaining, int statusCode, String responseFile) {
85                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
86                                   .withRequestBody(containing(requestContaining))
87                                   .willReturn(aResponse()
88                                   .withStatus(statusCode)
89                                   .withHeader("Content-Type", "text/xml")
90                                   .withBodyFile(responseFile)));
91         }
92         
93         public static void MockPutNetworkAdapter(String networkId, String requestContaining, int statusCode, String responseFile) {
94                 stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
95                                   .withRequestBody(containing(requestContaining))
96                                   .willReturn(aResponse()
97                                   .withStatus(statusCode)
98                                   .withHeader("Content-Type", "text/xml")
99                                   .withBodyFile(responseFile)));
100         }
101         
102         public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) {
103                 stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
104                         .willReturn(aResponse()
105                         .withStatus(200)
106                         .withHeader("Content-Type", "text/xml")
107                         .withBodyFile(responseFile)));
108         }       
109
110         public static void MockNetworkAdapterRestPut(String responseFile, String networkId) {
111                 stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
112                         .willReturn(aResponse()
113                         .withStatus(200)
114                         .withHeader("Content-Type", "text/xml")
115                         .withBodyFile(responseFile)));
116         }               
117         
118 }