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_500() {
42 stubFor(post(urlEqualTo("/SDNCAdapter"))
43 .willReturn(aResponse()
47 public static void mockSDNCAdapter_500(String requestContaining) {
48 stubFor(post(urlEqualTo("/SDNCAdapter"))
49 .withRequestBody(containing(requestContaining))
50 .willReturn(aResponse()
54 public static void mockSDNCAdapter(int statusCode) {
55 stubFor(post(urlEqualTo("/SDNCAdapter"))
56 .willReturn(aResponse()
57 .withStatus(statusCode)));
60 public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
61 stubFor(post(urlEqualTo(endpoint))
62 .willReturn(aResponse()
63 .withStatus(statusCode)
64 .withHeader("Content-Type", "text/xml")
65 .withBodyFile(responseFile)));
68 public static void mockSDNCAdapter(String responseFile) {
69 stubFor(post(urlEqualTo("/SDNCAdapter"))
70 .willReturn(aResponse()
72 .withHeader("Content-Type", "text/xml")
73 .withBodyFile(responseFile)));
76 public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
77 stubFor(post(urlEqualTo(endpoint))
78 .withRequestBody(containing(requestContaining))
79 .willReturn(aResponse()
80 .withStatus(statusCode)
81 .withHeader("Content-Type", "text/xml")
82 .withBodyFile(responseFile)));
85 public static void mockSDNCAdapterSimulator(String responseFile) {
86 MockResource mockResource = new MockResource();
87 mockResource.updateProperties("sdnc_delay", "300");
88 stubFor(post(urlEqualTo("/SDNCAdapter"))
89 .willReturn(aResponse()
91 .withHeader("Content-Type", "application/soap+xml")
92 .withTransformers("sdnc-adapter-transformer")
93 .withBodyFile(responseFile)));
96 public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) {
97 MockResource mockResource = new MockResource();
98 mockResource.updateProperties("sdnc_delay", "300");
99 stubFor(post(urlEqualTo("/SDNCAdapter"))
100 .withRequestBody(containing(requestContaining))
101 .willReturn(aResponse()
103 .withHeader("Content-Type", "application/soap+xml")
104 .withTransformers("sdnc-adapter-transformer")
105 .withBodyFile(responseFile)));
108 public static void mockSDNCAdapterRest() {
109 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
110 .willReturn(aResponse()
112 .withHeader("Content-Type", "application/json")));
115 public static void mockSDNCAdapterRest_500() {
116 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
117 .willReturn(aResponse()
119 .withHeader("Content-Type", "application/json")));
122 public static void mockSDNCAdapterRest(String requestContaining) {
123 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
124 .withRequestBody(containing(requestContaining))
125 .willReturn(aResponse()
127 .withHeader("Content-Type", "application/json")));
130 public static void mockSDNCAdapterRest_500(String requestContaining) {
131 stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
132 .withRequestBody(containing(requestContaining))
133 .willReturn(aResponse()
135 .withHeader("Content-Type", "application/json")));
138 public static void mockSDNCAdapterTopology(String responseFile, String requestContaining) {
139 MockResource mockResource = new MockResource();
140 mockResource.updateProperties("sdnc_delay", "300");
141 stubFor(post(urlEqualTo("/SDNCAdapter"))
142 .withRequestBody(containing(requestContaining))
143 .willReturn(aResponse()
145 .withHeader("Content-Type", "text/xml")
146 .withTransformers("network-topology-operation-transformer")
147 .withBodyFile(responseFile)));