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.urlEqualTo;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
29 import com.github.tomakehurst.wiremock.WireMockServer;
32 * Please describe the StubResponseSDNC.java class
34 public class StubResponseSDNCAdapter {
36 public static void setupAllMocks() {
40 public static void mockSDNCAdapter_500(WireMockServer wireMockServer) {
41 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
42 .willReturn(aResponse()
46 public static void mockSDNCAdapter_500(WireMockServer wireMockServer, String requestContaining) {
47 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
48 .withRequestBody(containing(requestContaining))
49 .willReturn(aResponse()
53 public static void mockSDNCAdapter(WireMockServer wireMockServer, int statusCode) {
54 wireMockServer.stubFor(post(urlMatching(".*/SDNCAdapter"))
55 .willReturn(aResponse()
56 .withStatus(statusCode)));
59 public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, int statusCode, String responseFile) {
60 wireMockServer.stubFor(post(urlEqualTo(endpoint))
61 .willReturn(aResponse()
62 .withStatus(statusCode)
63 .withHeader("Content-Type", "text/xml")
64 .withBodyFile(responseFile)));
67 public static void mockSDNCAdapter(WireMockServer wireMockServer, String responseFile) {
68 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
69 .willReturn(aResponse()
71 .withHeader("Content-Type", "text/xml")
72 .withBodyFile(responseFile)));
75 public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, String requestContaining, int statusCode, String responseFile) {
76 wireMockServer.stubFor(post(urlEqualTo(endpoint))
77 .withRequestBody(containing(requestContaining))
78 .willReturn(aResponse()
79 .withStatus(statusCode)
80 .withHeader("Content-Type", "text/xml")
81 .withBodyFile(responseFile)));
84 public static void mockSDNCAdapterRest(WireMockServer wireMockServer) {
85 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
86 .willReturn(aResponse()
88 .withHeader("Content-Type", "application/json")));
91 public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer) {
92 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
93 .willReturn(aResponse()
95 .withHeader("Content-Type", "application/json")));
98 public static void mockSDNCAdapterRest(WireMockServer wireMockServer, String requestContaining) {
99 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
100 .withRequestBody(containing(requestContaining))
101 .willReturn(aResponse()
103 .withHeader("Content-Type", "application/json")));
106 public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer, String requestContaining) {
107 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
108 .withRequestBody(containing(requestContaining))
109 .willReturn(aResponse()
111 .withHeader("Content-Type", "application/json")));