2 * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
5 * ============LICENSE_START=======================================================
7 * ================================================================================
8 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.openecomp.mso.bpmn.mock;
26 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
27 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
28 import static com.github.tomakehurst.wiremock.client.WireMock.post;
29 import static com.github.tomakehurst.wiremock.client.WireMock.put;
30 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
31 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
32 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
35 * Please describe the StubResponseNetwork.java class
38 public class StubResponseNetworkAdapter {
40 private static final String EOL = "\n";
42 public static void setupAllMocks() {
47 public static void MockNetworkAdapter() {
48 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
49 .willReturn(aResponse()
53 public static void MockNetworkAdapter(String response) {
54 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
55 .willReturn(aResponse()
57 .withHeader("Content-Type", "text/xml")
58 .withBodyFile(response)));
61 public static void MockNetworkAdapter_500() {
62 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
63 .willReturn(aResponse()
67 public static void MockNetworkAdapterPost(String responseFile, String requestContaining) {
68 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
69 .withRequestBody(containing(requestContaining))
70 .willReturn(aResponse()
72 .withHeader("Content-Type", "text/xml")
73 .withBodyFile(responseFile)));
76 public static void MockNetworkAdapter(String networkId, int statusCode, String responseFile) {
77 stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId))
78 .willReturn(aResponse()
79 .withStatus(statusCode)
80 .withHeader("Content-Type", "application/xml")
81 .withBodyFile(responseFile)));
84 public static void MockNetworkAdapterContainingRequest(String requestContaining, int statusCode, String responseFile) {
85 stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
86 .withRequestBody(containing(requestContaining))
87 .willReturn(aResponse()
88 .withStatus(statusCode)
89 .withHeader("Content-Type", "text/xml")
90 .withBodyFile(responseFile)));
93 public static void MockPutNetworkAdapter(String networkId, String requestContaining, int statusCode, String responseFile) {
94 stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
95 .withRequestBody(containing(requestContaining))
96 .willReturn(aResponse()
97 .withStatus(statusCode)
98 .withHeader("Content-Type", "text/xml")
99 .withBodyFile(responseFile)));
102 public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) {
103 stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
104 .willReturn(aResponse()
106 .withHeader("Content-Type", "text/xml")
107 .withBodyFile(responseFile)));
110 public static void MockNetworkAdapterRestPut(String responseFile, String networkId) {
111 stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
112 .willReturn(aResponse()
114 .withHeader("Content-Type", "text/xml")
115 .withBodyFile(responseFile)));