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.delete;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.put;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
30 import com.github.tomakehurst.wiremock.WireMockServer;
33 * Please describe the StubResponseNetwork.java class
36 public class StubResponseNetworkAdapter {
38 private static final String EOL = "\n";
40 public static void setupAllMocks() {
45 public static void MockNetworkAdapter(WireMockServer wireMockServer) {
46 wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
47 .willReturn(aResponse()
51 public static void MockNetworkAdapter(WireMockServer wireMockServer, String response) {
52 wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
53 .willReturn(aResponse()
55 .withHeader("Content-Type", "text/xml")
56 .withBodyFile(response)));
59 public static void MockNetworkAdapter_500(WireMockServer wireMockServer) {
60 wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
61 .willReturn(aResponse()
65 public static void MockNetworkAdapterPost(WireMockServer wireMockServer, String responseFile, String requestContaining) {
66 wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
67 .withRequestBody(containing(requestContaining))
68 .willReturn(aResponse()
70 .withHeader("Content-Type", "text/xml")
71 .withBodyFile(responseFile)));
74 public static void MockNetworkAdapter(WireMockServer wireMockServer, String networkId, int statusCode, String responseFile) {
75 wireMockServer.stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId))
76 .willReturn(aResponse()
77 .withStatus(statusCode)
78 .withHeader("Content-Type", "application/xml")
79 .withBodyFile(responseFile)));
82 public static void MockNetworkAdapterContainingRequest(WireMockServer wireMockServer, String requestContaining, int statusCode, String responseFile) {
83 wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
84 .withRequestBody(containing(requestContaining))
85 .willReturn(aResponse()
86 .withStatus(statusCode)
87 .withHeader("Content-Type", "text/xml")
88 .withBodyFile(responseFile)));
91 public static void MockPutNetworkAdapter(WireMockServer wireMockServer, String networkId, String requestContaining, int statusCode, String responseFile) {
92 wireMockServer.stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
93 .withRequestBody(containing(requestContaining))
94 .willReturn(aResponse()
95 .withStatus(statusCode)
96 .withHeader("Content-Type", "text/xml")
97 .withBodyFile(responseFile)));
100 public static void MockNetworkAdapterRestRollbackDelete(WireMockServer wireMockServer, String responseFile, String networkId) {
101 wireMockServer.stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
102 .willReturn(aResponse()
104 .withHeader("Content-Type", "text/xml")
105 .withBodyFile(responseFile)));
108 public static void MockNetworkAdapterRestPut(WireMockServer wireMockServer, String responseFile, String networkId) {
109 wireMockServer.stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
110 .willReturn(aResponse()
112 .withHeader("Content-Type", "text/xml")
113 .withBodyFile(responseFile)));