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