aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/test/java/org/onap/so/bpmn/mock/StubOpenStack.java
blob: 98d5f7eb5f50bf9f27a069cd0a3a9922aaf9ba8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/*-
 * ============LICENSE_START=======================================================
 * ONAP - SO
 * ================================================================================
 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.so.bpmn.mock;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import org.apache.http.HttpStatus;

public class StubOpenStack {
	private static final String NETWORK_NAME = "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0";
	private static final String NETWORK_ID = "da886914-efb2-4917-b335-c8381528d90b";
	private static final String NETWORK_NAME_2 = "stackname";
	private static final String NETWORK_ID_2 = "stackId";
	
	public static void mockOpenStackResponseAccess(int port) throws IOException {
		stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
			.withBody(getBodyFromFile("OpenstackResponse_Access.json", port, "/mockPublicUrl"))
				.withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackResponseAccessQueryNetwork(int port) throws IOException {
		stubFor(post(urlPathEqualTo("/v2.0/tokens"))
				.withRequestBody(containing("tenantId"))
				.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBody(getBodyFromFile("OpenstackResponse_Access_queryNetwork.json", port, "/mockPublicUrl"))
				.withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackResponseAccessAdmin(int port) throws IOException {
		stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBody(getBodyFromFile("OpenstackResponse_Access_Admin.json", port, "/mockPublicUrl"))
					.withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackPublicUrlStackByName_200(int port) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME)).willReturn(aResponse()
			.withHeader("X-Openstack-Request-Id", "openstackRquest")
				.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/"+NETWORK_NAME)
					.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/" + NETWORK_NAME))
						.withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackPublicUrlStackByID_200(int port) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_ID)).willReturn(aResponse()
			.withHeader("X-Openstack-Request-Id", "openstackRquest")
				.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/"+NETWORK_NAME)
					.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/" + NETWORK_NAME))
						.withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetPublicUrlStackByNameAndID_200(int port) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
			.withHeader("X-Openstack-Request-Id", "openstackRquest")
				.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/"+NETWORK_NAME)
					.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/" + NETWORK_NAME))
						.withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetPublicUrlStackByNameAndID_204(int port) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
			.withHeader("X-Openstack-Request-Id", "openstackRquest")
				.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)
					.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/" + NETWORK_NAME))
						.withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackPutPublicUrlStackByNameAndID_200() {
		stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
			.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200() {
		stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME_2+"/"+NETWORK_ID_2)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackDeletePublicUrlStackByNameAndID_204() {
		stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
			.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NO_CONTENT)));
	}
	
	public static void mockOpenStackPostPublicUrlWithBodyFile_200() {
		stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks"))
			.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBodyFile("OpenstackResponse_Stack.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetStackCreatedAppC_200() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3/stackId"))
			.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBodyFile("OpenstackResponse_Stack_Created.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetStackAppC_404() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3"))
			.willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackGetStackCreatedVUSP_200() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/stackId"))
			.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBodyFile("OpenstackResponse_Stack_Created.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetStackVUSP_404() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0"))
			.willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackPostStack_200(String filename) {
		stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackPostNeutronNetwork_200(String filename) {
		stubFor(post(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackPutNeutronNetwork_200(String filename,String networkId) {
		stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackPutNeutronNetwork(String networkId, int responseCode) {
		stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withStatus(responseCode)));
	}

	public static void mockOpenStackGetAllNeutronNetworks_200(String filename){
		stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetNeutronNetwork_404(String networkName) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkName)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withStatus(HttpStatus.SC_NOT_FOUND)));
	}

	public static void mockOpenStackGetAllNeutronNetworks_404() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withStatus(HttpStatus.SC_NOT_FOUND)));
	}

	public static void mockOpenstackGetWithResponse(String url,int responseCode, String responseFile) {
		stubFor(get(urlPathEqualTo(url)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withBodyFile(responseFile)
				.withStatus(responseCode)));
	}
	
	public static void mockOpenstackPostWithResponse(String url,int responseCode, String responseFile) {
		stubFor(post(urlPathEqualTo(url)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withBodyFile(responseFile)
				.withStatus(responseCode)));
	}

	public static void mockOpenstackGet(String url,int responseCode) {
		stubFor(get(urlPathEqualTo(url)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withStatus(responseCode)));
	}

	public static void mockOpenstackPost(String url,int responseCode) {
		stubFor(post(urlPathEqualTo(url)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withStatus(responseCode)));
	}

	public static void mockOpenStackGetStackVfModule_200() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
			.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBodyFile("OpenstackResponse_Stack_Created_VfModule.json")
					.withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetStackVfModule_404() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
			.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackPostStacks_200() {
		stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks"))
			.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBodyFile("OpenstackResponse_Stack.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetStacks_404() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/3d7ff7b4-720b-4604-be0a-1974fc58ed96"))
			.willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackGetStacksWithBody_200(String replaceWith) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
			.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBody(getBodyFromFileVnfAdapter(replaceWith))
					.withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackGetStackWithBody_200(String replaceWith) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
				.willReturn(aResponse().withHeader("Content-Type", "application/json")
						.withBody(getBodyFromFileVnfAdapter(replaceWith))
						.withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetStacksWithBody_404() throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
			.willReturn(aResponse().withHeader("Content-Type", "application/json")
				.withBody(getBodyFromFileVnfAdapter(null))
					.withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackGetStacksStackId_404() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/stackId"))
			.willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackGetStacksVfModule_200(int port) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
			.withHeader("X-Openstack-Request-Id", "openstackRquest")
				.withBody(getBodyFromFile("OpenstackResponse_VnfStackId.json", port, "/mockPublicUrl/stacks/stackId")).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetStacksVfModuleWithLocationHeader_200(int port) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
			.withHeader("X-Openstack-Request-Id", "openstackRquest")
				.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")
					.withBody(getBodyFromFile("OpenstackResponse_VnfStackId.json", port, "/mockPublicUrl/stacks/stackId")).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetStacksBaseStack_200(int port) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfModuleStackId")).willReturn(aResponse()
			.withHeader("X-Openstack-Request-Id", "openstackRquest")
				.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/baseVfModuleStackId")
					.withBody(getBodyFromFile("OpenstackResponse_VnfBaseStackId.json", port, "/mockPublicUrl/stacks/stackId")).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackPutStacks_200() {
		stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
			.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackPutStack(String networkId,int responseCode) {
		stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+networkId))
				.willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
				.withStatus(responseCode)));
	}
	
	public static void mockOpenStackGetStacksStackId_200(int port) throws IOException {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/StackId")).willReturn(aResponse()
			.withHeader("X-Openstack-Request-Id", "openstackRquest")
				.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/stackId")
					.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/stackId")).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackDeleteStacks() {
		stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/da886914-efb2-4917-b335-c8381528d90b"))
			.willReturn(aResponse().withHeader("X-Openstack-Request-Id", "openstackRquest")));
	}
	
	public static void mockOpenStackGetStacksVUSP_404() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/da886914-efb2-4917-b335-c8381528d90b"))
			.willReturn(aResponse()
				.withHeader("X-Openstack-Request-Id", "openstackRquest")
					.withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackGetStackCreated_200(String filename, String networkName) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
				.willReturn(aResponse().withHeader("Content-Type", "application/json")
						.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackGetStack_404(String networkName) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
				.willReturn(aResponse().withHeader("Content-Type", "application/json")
						.withStatus(HttpStatus.SC_NOT_FOUND)));
	}

	public static void mockOpenStackGetStack_500(String networkName) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
				.willReturn(aResponse().withHeader("Content-Type", "application/json")
						.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
	}

	public static void mockOpenStackGetStackDeleteOrUpdateComplete_200(String filename) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
				.willReturn(aResponse().withHeader("Content-Type", "application/json")
						.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackGetNeutronNetwork(String filename,String networkId,int status) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
				.willReturn(aResponse().withHeader("Content-Type", "application/json")
						.withBodyFile(filename).withStatus(status)));
	}

	public static void mockOpenStackGetNeutronNetwork(String networkId,int status) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
				.willReturn(aResponse().withHeader("Content-Type", "application/json")
						.withStatus(status)));
	}
	
	public static void mockOpenStackDeleteStack_200() {
		stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
				.willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
	}

	public static void mockOpenStackDeleteStack_500() {
		stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
				.willReturn(aResponse().withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
	}

	public static void mockOpenStackDeleteNeutronNetwork(String networkId,int responseCode) {
		stubFor(delete(urlPathEqualTo("/mockPublicUrl/v2.0/networks/" + networkId))
				.willReturn(aResponse().withStatus(responseCode)));
	}
	
	public static void mockOpenStackPostMetadata_200() {
		stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/metadata")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
						.withBodyFile("OpenstackResponse_Metadata.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetMetadata_200() {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/metadata")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
						.withBodyFile("OpenstackResponse_Metadata.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackPostTenantWithBodyFile_200() throws IOException {
		stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants"))
				.withRequestBody(equalToJson(readFile("src/test/resources/__files/OpenstackRequest_Tenant.json"))).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
						.withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackPostTenant_200() throws IOException {
		stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetTenantByName_200(String tenantName) {
		stubFor(get(urlEqualTo("/mockPublicUrl/tenants/?name=" + tenantName)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
						.withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetTenantByName_404(String tenantName) {
		stubFor(get(urlEqualTo("/mockPublicUrl/tenants/?name=" + tenantName)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackGetTenantById_200(String tenantId) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
						.withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetTenantById_404(String tenantId) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
	}
	
	public static void mockOpenStackDeleteTenantById_200(String tenantId) {
		stubFor(delete(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetUser_200(String user) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/users/" + user)).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
						.withBodyFile("OpenstackResponse_User.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackGetRoles_200(String roleFor) {
		stubFor(get(urlPathEqualTo("/mockPublicUrl/" + roleFor + "/roles")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
						.withBodyFile("OpenstackResponse_Roles.json").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockOpenStackPutRolesAdmin_200(String roleFor) {
		stubFor(put(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/users/msoId/roles/" + roleFor + "/admin")).willReturn(aResponse()
				.withHeader("Content-Type", "application/json")
						.withBody("").withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockValetCreatePostResponse_200(String requestId, String body) {
		stubFor(post(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
                .willReturn(aResponse().withHeader("Content-Type", "application/json")
                		.withBody(body).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockValetCreatePutResponse_200(String requestId, String body) {
		stubFor(put(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
              .willReturn(aResponse().withHeader("Content-Type", "application/json")
            		  .withBody(body).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockValetDeleteDeleteResponse_200(String requestId, String body) {
		stubFor(delete(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
                .willReturn(aResponse().withHeader("Content-Type", "application/json")
                		.withBody(body).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockValetConfirmPutRequest_200(String requestId, String body) {
		stubFor(put(urlPathEqualTo("/api/valet/placement/v1/" + requestId + "/confirm/"))
                .willReturn(aResponse().withHeader("Content-Type", "application/json")
                		.withBody(body).withStatus(HttpStatus.SC_OK)));
	}
	
	public static void mockValetRollbackPutRequest_200(String requestId, String body) {
		stubFor(put(urlPathEqualTo("/api/valet/placement/v1/" + requestId + "/rollback/"))
                .willReturn(aResponse().withHeader("Content-Type", "application/json")
                		.withBody(body).withStatus(HttpStatus.SC_OK)));
	}
	
	private static String getBodyFromFileVnfAdapter(String replaceWith) throws IOException {
		String temp = readFile("src/test/resources/__files/OpenstackResponse_Stack_Created_VfModule.json");
		if (replaceWith == null) {
			return temp;
		}
		return temp.replaceAll("CREATE_COMPLETE", replaceWith);
	}
	
	private static String readFile(String fileName) throws IOException {
		try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
			StringBuilder sb = new StringBuilder();
			String line = br.readLine();

			while (line != null) {
				sb.append(line);
				sb.append("\n");
				line = br.readLine();
			}
			return sb.toString();
		}
	}
	
	public static String getBodyFromFile(String fileName, int port, String urlPath) throws IOException {
		return readFile("src/test/resources/__files/" + fileName).replaceAll("port", "http://localhost:" + port + urlPath);
	}
}