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.stubFor;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
31 * Please describe the StubResponseSDNC.java class
33 public class StubResponseSDNCAdapter {
35 public static void setupAllMocks() {
39 public static void mockSDNCAdapter_500() {
40 stubFor(post(urlEqualTo("/SDNCAdapter"))
41 .willReturn(aResponse()
45 public static void mockSDNCAdapter_500(String requestContaining) {
46 stubFor(post(urlEqualTo("/SDNCAdapter"))
47 .withRequestBody(containing(requestContaining))
48 .willReturn(aResponse()
52 public static void mockSDNCAdapter(int statusCode) {
53 stubFor(post(urlMatching(".*/SDNCAdapter"))
54 .willReturn(aResponse()
55 .withStatus(statusCode)));
58 public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
59 stubFor(post(urlEqualTo(endpoint))
60 .willReturn(aResponse()
61 .withStatus(statusCode)
62 .withHeader("Content-Type", "text/xml")
63 .withBodyFile(responseFile)));
66 public static void mockSDNCAdapter(String responseFile) {
67 stubFor(post(urlEqualTo("/SDNCAdapter"))
68 .willReturn(aResponse()
70 .withHeader("Content-Type", "text/xml")
71 .withBodyFile(responseFile)));
74 public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
75 stubFor(post(urlEqualTo(endpoint))
76 .withRequestBody(containing(requestContaining))
77 .willReturn(aResponse()
78 .withStatus(statusCode)
79 .withHeader("Content-Type", "text/xml")
80 .withBodyFile(responseFile)));
83 public static void mockSDNCAdapterSimulator(String responseFile) {
84 MockResource mockResource = new MockResource();
85 mockResource.updateProperties("sdnc_delay", "300");
86 stubFor(post(urlEqualTo("/SDNCAdapter"))
87 .willReturn(aResponse()
89 .withHeader("Content-Type", "application/soap+xml")
90 .withTransformers("sdnc-adapter-transformer")
91 .withBodyFile(responseFile)));
94 public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) {
95 MockResource mockResource = new MockResource();
96 mockResource.updateProperties("sdnc_delay", "300");
97 stubFor(post(urlEqualTo("/SDNCAdapter"))
98 .withRequestBody(containing(requestContaining))
99 .willReturn(aResponse()
101 .withHeader("Content-Type", "application/soap+xml")
102 .withTransformers("sdnc-adapter-transformer")
103 .withBodyFile(responseFile)));
106 public static void mockSDNCAdapterRest() {
107 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
108 .willReturn(aResponse()
110 .withHeader("Content-Type", "application/json")));
113 public static void mockSDNCAdapterRest_500() {
114 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
115 .willReturn(aResponse()
117 .withHeader("Content-Type", "application/json")));
120 public static void mockSDNCAdapterRest(String requestContaining) {
121 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
122 .withRequestBody(containing(requestContaining))
123 .willReturn(aResponse()
125 .withHeader("Content-Type", "application/json")));
128 public static void mockSDNCAdapterRest_500(String requestContaining) {
129 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
130 .withRequestBody(containing(requestContaining))
131 .willReturn(aResponse()
133 .withHeader("Content-Type", "application/json")));
136 public static void mockSDNCAdapterTopology(String responseFile, String requestContaining) {
137 MockResource mockResource = new MockResource();
138 mockResource.updateProperties("sdnc_delay", "300");
139 stubFor(post(urlEqualTo("/SDNCAdapter"))
140 .withRequestBody(containing(requestContaining))
141 .willReturn(aResponse()
143 .withHeader("Content-Type", "text/xml")
144 .withTransformers("network-topology-operation-transformer")
145 .withBodyFile(responseFile)));