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;
28 import com.github.tomakehurst.wiremock.WireMockServer;
31 * Please describe the StubResponseSDNC.java class
33 public class StubResponseSDNCAdapter {
35 public static void setupAllMocks() {
39 public static void mockSDNCAdapter_500(WireMockServer wireMockServer) {
40 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter")).willReturn(aResponse().withStatus(500)));
43 public static void mockSDNCAdapter_500(WireMockServer wireMockServer, String requestContaining) {
44 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter")).withRequestBody(containing(requestContaining))
45 .willReturn(aResponse().withStatus(500)));
48 public static void mockSDNCAdapter(WireMockServer wireMockServer, int statusCode) {
49 wireMockServer.stubFor(post(urlMatching(".*/SDNCAdapter")).willReturn(aResponse().withStatus(statusCode)));
52 public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, int statusCode,
53 String responseFile) {
54 wireMockServer.stubFor(post(urlEqualTo(endpoint)).willReturn(
55 aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
58 public static void mockSDNCAdapter(WireMockServer wireMockServer, String responseFile) {
59 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter")).willReturn(
60 aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
63 public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, String requestContaining,
64 int statusCode, String responseFile) {
65 wireMockServer.stubFor(post(urlEqualTo(endpoint)).withRequestBody(containing(requestContaining)).willReturn(
66 aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
69 public static void mockSDNCAdapterRest(WireMockServer wireMockServer) {
70 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
71 .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/json")));
74 public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer) {
75 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
76 .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "application/json")));
79 public static void mockSDNCAdapterRest(WireMockServer wireMockServer, String requestContaining) {
80 wireMockServer.stubFor(
81 post(urlEqualTo("/SDNCAdapter/v1/sdnc/services")).withRequestBody(containing(requestContaining))
82 .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/json")));
85 public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer, String requestContaining) {
86 wireMockServer.stubFor(
87 post(urlEqualTo("/SDNCAdapter/v1/sdnc/services")).withRequestBody(containing(requestContaining))
88 .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "application/json")));