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.delete;
29 import static com.github.tomakehurst.wiremock.client.WireMock.post;
30 import static com.github.tomakehurst.wiremock.client.WireMock.put;
31 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
32 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
33 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
36 * Please describe the StubResponseVNF.java class
38 public class StubResponseVNFAdapter {
40 public static void mockVNFAdapter() {
41 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
42 .willReturn(aResponse()
46 public static void mockVNFAdapter(String responseFile) {
47 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
48 .willReturn(aResponse()
50 .withHeader("Content-Type", "text/xml")
51 .withBodyFile(responseFile)));
54 public static void mockVNFAdapter_500() {
55 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
56 .willReturn(aResponse()
60 public static void mockVNFAdapterTransformer(String transformer, String responseFile) {
61 MockResource mockResource = new MockResource();
62 mockResource.updateProperties("vnf_delay", "300");
63 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
64 .willReturn(aResponse()
66 .withHeader("Content-Type", "application/soap+xml")
67 .withTransformers(transformer)
68 .withBodyFile(responseFile)));
71 public static void mockVNFAdapterTransformer(String transformer, String responseFile, String requestContaining) {
72 MockResource mockResource = new MockResource();
73 mockResource.updateProperties("vnf_delay", "300");
74 stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
75 .withRequestBody(containing(requestContaining))
76 .willReturn(aResponse()
78 .withHeader("Content-Type", "application/soap+xml")
79 .withTransformers(transformer)
80 .withBodyFile(responseFile)));
83 public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) {
84 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
85 .willReturn(aResponse()
86 .withStatus(statusCode)
87 .withHeader("Content-Type", "application/xml")));
90 public static void mockVNFPut(String vfModuleId, int statusCode) {
91 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId))
92 .willReturn(aResponse()
93 .withStatus(statusCode)
94 .withHeader("Content-Type", "application/xml")));
97 public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
98 stubFor(put(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
99 .willReturn(aResponse()
100 .withStatus(statusCode)
101 .withHeader("Content-Type", "application/xml")));
104 public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
105 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
106 .willReturn(aResponse()
107 .withStatus(statusCode)
108 .withHeader("Content-Type", "application/xml")));
111 public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
112 stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
113 .willReturn(aResponse()
114 .withStatus(statusCode)
115 .withHeader("Content-Type", "application/xml")));
118 public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
119 stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
120 .willReturn(aResponse()
121 .withStatus(statusCode)
122 .withHeader("Content-Type", "application/xml")));
125 public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) {
126 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
127 .willReturn(aResponse()
128 .withStatus(statusCode)
129 .withHeader("Content-Type", "application/xml")));
131 public static void mockPostVNFVolumeGroup(int statusCode) {
132 stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
133 .willReturn(aResponse()
134 .withStatus(statusCode)
135 .withHeader("Content-Type", "application/xml")));
138 public static void mockVNFAdapterRest(String vnfId) {
139 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
140 .willReturn(aResponse()
144 public static void mockVNFAdapterRest_500(String vnfId) {
145 stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
146 .willReturn(aResponse()
150 public static void mockVfModuleDelete(String volumeGroupId) {
151 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
152 .willReturn(aResponse()
154 .withHeader("Content-Type", "application/xml")));
157 public static void mockVfModuleDelete(String volumeGroupId, int statusCode) {
158 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
159 .willReturn(aResponse()
160 .withStatus(statusCode)
161 .withHeader("Content-Type", "application/xml")));