2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.mock;
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;
32 * Please describe the StubResponseNetwork.java class
35 public class StubResponseNetworkAdapter {
37 private static final String EOL = "\n";
39 public static void setupAllMocks() {
44 public static void MockNetworkAdapter() {
45 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
46 .willReturn(aResponse()
50 public static void MockNetworkAdapter(String response) {
51 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
52 .willReturn(aResponse()
54 .withHeader("Content-Type", "text/xml")
55 .withBodyFile(response)));
58 public static void MockNetworkAdapter_500() {
59 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
60 .willReturn(aResponse()
64 public static void MockNetworkAdapterPost(String responseFile, String requestContaining) {
65 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
66 .withRequestBody(containing(requestContaining))
67 .willReturn(aResponse()
69 .withHeader("Content-Type", "text/xml")
70 .withBodyFile(responseFile)));
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)));
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)));
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)));
99 public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) {
100 stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
101 .willReturn(aResponse()
103 .withHeader("Content-Type", "text/xml")
104 .withBodyFile(responseFile)));
107 public static void MockNetworkAdapterRestPut(String responseFile, String networkId) {
108 stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
109 .willReturn(aResponse()
111 .withHeader("Content-Type", "text/xml")
112 .withBodyFile(responseFile)));