2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
19 package org.openecomp.mso.bpmn.mock;
21 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
22 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
23 import static com.github.tomakehurst.wiremock.client.WireMock.post;
24 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
25 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
28 * Please describe the StubResponseSDNC.java class
30 public class StubResponseSDNCAdapter {
32 public static void setupAllMocks() {
36 public static void mockSDNCAdapter_500() {
37 stubFor(post(urlEqualTo("/SDNCAdapter"))
38 .willReturn(aResponse()
42 public static void mockSDNCAdapter_500(String requestContaining) {
43 stubFor(post(urlEqualTo("/SDNCAdapter"))
44 .withRequestBody(containing(requestContaining))
45 .willReturn(aResponse()
49 public static void mockSDNCAdapter(int statusCode) {
50 stubFor(post(urlEqualTo("/SDNCAdapter"))
51 .willReturn(aResponse()
52 .withStatus(statusCode)));
55 public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
56 stubFor(post(urlEqualTo(endpoint))
57 .willReturn(aResponse()
58 .withStatus(statusCode)
59 .withHeader("Content-Type", "text/xml")
60 .withBodyFile(responseFile)));
63 public static void mockSDNCAdapter(String responseFile) {
64 stubFor(post(urlEqualTo("/SDNCAdapter"))
65 .willReturn(aResponse()
67 .withHeader("Content-Type", "text/xml")
68 .withBodyFile(responseFile)));
71 public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
72 stubFor(post(urlEqualTo(endpoint))
73 .withRequestBody(containing(requestContaining))
74 .willReturn(aResponse()
75 .withStatus(statusCode)
76 .withHeader("Content-Type", "text/xml")
77 .withBodyFile(responseFile)));
80 public static void mockSDNCAdapterSimulator(String responseFile) {
81 MockResource mockResource = new MockResource();
82 mockResource.updateProperties("sdnc_delay", "300");
83 stubFor(post(urlEqualTo("/SDNCAdapter"))
84 .willReturn(aResponse()
86 .withHeader("Content-Type", "application/soap+xml")
87 .withTransformers("sdnc-adapter-transformer")
88 .withBodyFile(responseFile)));
91 public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) {
92 MockResource mockResource = new MockResource();
93 mockResource.updateProperties("sdnc_delay", "300");
94 stubFor(post(urlEqualTo("/SDNCAdapter"))
95 .withRequestBody(containing(requestContaining))
96 .willReturn(aResponse()
98 .withHeader("Content-Type", "application/soap+xml")
99 .withTransformers("sdnc-adapter-transformer")
100 .withBodyFile(responseFile)));
103 public static void mockSDNCAdapterRest() {
104 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
105 .willReturn(aResponse()
107 .withHeader("Content-Type", "application/json")));
110 public static void mockSDNCAdapterRest_500() {
111 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
112 .willReturn(aResponse()
114 .withHeader("Content-Type", "application/json")));
117 public static void mockSDNCAdapterRest(String requestContaining) {
118 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
119 .withRequestBody(containing(requestContaining))
120 .willReturn(aResponse()
122 .withHeader("Content-Type", "application/json")));
125 public static void mockSDNCAdapterRest_500(String requestContaining) {
126 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
127 .withRequestBody(containing(requestContaining))
128 .willReturn(aResponse()
130 .withHeader("Content-Type", "application/json")));
133 public static void mockSDNCAdapterTopology(String responseFile, String requestContaining) {
134 MockResource mockResource = new MockResource();
135 mockResource.updateProperties("sdnc_delay", "300");
136 stubFor(post(urlEqualTo("/SDNCAdapter"))
137 .withRequestBody(containing(requestContaining))
138 .willReturn(aResponse()
140 .withHeader("Content-Type", "text/xml")
141 .withTransformers("network-topology-operation-transformer")
142 .withBodyFile(responseFile)));