Merge "Reorder modifiers"
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / mock / StubResponseNetworkAdapter.java
1 /*
2  * ============LICENSE_START======================================================= 
3  * ONAP - SO 
4  * ================================================================================ 
5  * Licensed under the Apache License, Version 2.0 (the "License"); 
6  * you may not use this file except in compliance with the License. 
7  * You may obtain a copy of the License at 
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0 
10  * 
11  * Unless required by applicable law or agreed to in writing, software 
12  * distributed under the License is distributed on an "AS IS" BASIS, 
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14  * See the License for the specific language governing permissions and 
15  * limitations under the License. 
16  * ============LICENSE_END========================================================= 
17  */ 
18
19 package org.openecomp.mso.bpmn.mock;
20
21 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
22 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
23 import static com.github.tomakehurst.wiremock.client.WireMock.post;
24 import static com.github.tomakehurst.wiremock.client.WireMock.put;
25 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
26 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
28
29 /**
30  * Please describe the StubResponseNetwork.java class
31  *
32  */
33 public class StubResponseNetworkAdapter {
34
35         private static final String EOL = "\n";
36
37         public static void setupAllMocks() {
38
39         }
40
41
42         public static void MockNetworkAdapter() {
43                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
44                         .willReturn(aResponse()
45                         .withStatus(200)));
46         }
47
48         public static void MockNetworkAdapter(String response) {
49                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
50                         .willReturn(aResponse()
51                         .withStatus(200)
52                         .withHeader("Content-Type", "text/xml")
53                         .withBodyFile(response)));
54         }
55
56         public static void MockNetworkAdapter_500() {
57                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
58                         .willReturn(aResponse()
59                         .withStatus(500)));
60         }
61
62         public static void MockNetworkAdapterPost(String responseFile, String requestContaining) {
63                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
64                         .withRequestBody(containing(requestContaining))                         
65                         .willReturn(aResponse()
66                         .withStatus(200)
67                         .withHeader("Content-Type", "text/xml")
68                         .withBodyFile(responseFile)));
69         }       
70         
71         public static void MockNetworkAdapter(String networkId, int statusCode, String responseFile) {
72                 stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId))
73                                   .willReturn(aResponse()
74                                   .withStatus(statusCode)
75                                   .withHeader("Content-Type", "application/xml")
76                                   .withBodyFile(responseFile)));
77         }
78         
79         public static void MockNetworkAdapterContainingRequest(String requestContaining, int statusCode, String responseFile) {
80                 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
81                                   .withRequestBody(containing(requestContaining))
82                                   .willReturn(aResponse()
83                                   .withStatus(statusCode)
84                                   .withHeader("Content-Type", "text/xml")
85                                   .withBodyFile(responseFile)));
86         }
87         
88         public static void MockPutNetworkAdapter(String networkId, String requestContaining, int statusCode, String responseFile) {
89                 stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
90                                   .withRequestBody(containing(requestContaining))
91                                   .willReturn(aResponse()
92                                   .withStatus(statusCode)
93                                   .withHeader("Content-Type", "text/xml")
94                                   .withBodyFile(responseFile)));
95         }
96         
97         public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) {
98                 stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
99                         .willReturn(aResponse()
100                         .withStatus(200)
101                         .withHeader("Content-Type", "text/xml")
102                         .withBodyFile(responseFile)));
103         }       
104
105         public static void MockNetworkAdapterRestPut(String responseFile, String networkId) {
106                 stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
107                         .willReturn(aResponse()
108                         .withStatus(200)
109                         .withHeader("Content-Type", "text/xml")
110                         .withBodyFile(responseFile)));
111         }               
112         
113 }