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.stubFor;
30 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
33 * Please describe the StubResponseSDNC.java class
35 public class StubResponseSDNCAdapter {
37 public static void setupAllMocks() {
41 public static void mockSDNCAdapter(int statusCode) {
42 stubFor(post(urlEqualTo("/SDNCAdapter"))
43 .willReturn(aResponse()
44 .withStatus(statusCode)));
47 public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
48 stubFor(post(urlEqualTo(endpoint))
49 .willReturn(aResponse()
50 .withStatus(statusCode)
51 .withHeader("Content-Type", "text/xml")
52 .withBodyFile(responseFile)));
55 public static void mockSDNCAdapter(String responseFile) {
56 stubFor(post(urlEqualTo("/SDNCAdapter"))
57 .willReturn(aResponse()
59 .withHeader("Content-Type", "text/xml")
60 .withBodyFile(responseFile)));
63 public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
64 stubFor(post(urlEqualTo(endpoint))
65 .withRequestBody(containing(requestContaining))
66 .willReturn(aResponse()
67 .withStatus(statusCode)
68 .withHeader("Content-Type", "text/xml")
69 .withBodyFile(responseFile)));
72 public static void mockSDNCAdapterSimulator(String responseFile) {
73 MockResource mockResource = new MockResource();
74 mockResource.updateProperties("sdnc_delay", "300");
75 stubFor(post(urlEqualTo("/SDNCAdapter"))
76 .willReturn(aResponse()
78 .withHeader("Content-Type", "application/soap+xml")
79 .withTransformers("sdnc-adapter-transformer")
80 .withBodyFile(responseFile)));
83 public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) {
84 MockResource mockResource = new MockResource();
85 mockResource.updateProperties("sdnc_delay", "300");
86 stubFor(post(urlEqualTo("/SDNCAdapter"))
87 .withRequestBody(containing(requestContaining))
88 .willReturn(aResponse()
90 .withHeader("Content-Type", "application/soap+xml")
91 .withTransformers("sdnc-adapter-transformer")
92 .withBodyFile(responseFile)));
95 public static void mockSDNCAdapterRest() {
96 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
97 .willReturn(aResponse()
99 .withHeader("Content-Type", "application/json")));
102 public static void mockSDNCAdapterRest_500() {
103 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
104 .willReturn(aResponse()
106 .withHeader("Content-Type", "application/json")));
109 public static void mockSDNCAdapterRest(String requestContaining) {
110 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
111 .withRequestBody(containing(requestContaining))
112 .willReturn(aResponse()
114 .withHeader("Content-Type", "application/json")));
117 public static void mockSDNCAdapterRest_500(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 mockSDNCAdapterTopology(String responseFile, String requestContaining) {
126 MockResource mockResource = new MockResource();
127 mockResource.updateProperties("sdnc_delay", "300");
128 stubFor(post(urlEqualTo("/SDNCAdapter"))
129 .withRequestBody(containing(requestContaining))
130 .willReturn(aResponse()
132 .withHeader("Content-Type", "text/xml")
133 .withTransformers("network-topology-operation-transformer")
134 .withBodyFile(responseFile)));