2 * ============LICENSE_START=======================================================
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
19 package org.openecomp.mso.bpmn.mock;
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;
30 * Please describe the StubResponseNetwork.java class
33 public class StubResponseNetworkAdapter {
35 private static final String EOL = "\n";
37 public static void setupAllMocks() {
42 public static void MockNetworkAdapter() {
43 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
44 .willReturn(aResponse()
48 public static void MockNetworkAdapter(String response) {
49 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
50 .willReturn(aResponse()
52 .withHeader("Content-Type", "text/xml")
53 .withBodyFile(response)));
56 public static void MockNetworkAdapter_500() {
57 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
58 .willReturn(aResponse()
62 public static void MockNetworkAdapterPost(String responseFile, String requestContaining) {
63 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
64 .withRequestBody(containing(requestContaining))
65 .willReturn(aResponse()
67 .withHeader("Content-Type", "text/xml")
68 .withBodyFile(responseFile)));
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)));
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)));
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)));
97 public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) {
98 stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
99 .willReturn(aResponse()
101 .withHeader("Content-Type", "text/xml")
102 .withBodyFile(responseFile)));
105 public static void MockNetworkAdapterRestPut(String responseFile, String networkId) {
106 stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
107 .willReturn(aResponse()
109 .withHeader("Content-Type", "text/xml")
110 .withBodyFile(responseFile)));