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.post;
28 import static com.github.tomakehurst.wiremock.client.WireMock.get;
29 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
30 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
33 * Stub response class for Database stubs
34 * including database adapter, catalog db,
35 * and other databases.
37 public class StubResponseDatabase {
39 public static void setupAllMocks() {
43 public static void MockUpdateRequestDB(String fileName){
44 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
45 .willReturn(aResponse()
47 .withHeader("Content-Type", "text/xml")
48 .withBodyFile(fileName)));
51 public static void mockUpdateRequestDB(int statusCode, String reponseFile) {
52 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
53 .willReturn(aResponse()
54 .withStatus(statusCode)
55 .withHeader("Content-Type", "text/xml")
56 .withBodyFile(reponseFile)));
59 public static void MockGetAllottedResourcesByModelInvariantId(String modelInvariantId, String responseFile){
60 stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
61 .willReturn(aResponse()
63 .withHeader("Content-Type", "application/json")
64 .withBodyFile(responseFile)));
67 public static void MockGetAllottedResourcesByModelInvariantId_500(String modelInvariantId, String responseFile){
68 stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
69 .willReturn(aResponse()
73 public static void MockGetVnfCatalogDataCustomizationUuid(String vnfModelCustomizationUuid, String responseFile){
74 stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
75 .willReturn(aResponse()
77 .withHeader("Content-Type", "application/json")
78 .withBodyFile(responseFile)));
81 public static void MockGetVfModuleByModelNameCatalogData(String vfModuleModelName, String responseFile){
82 stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
83 .willReturn(aResponse()
85 .withHeader("Content-Type", "application/json")
86 .withBodyFile(responseFile)));
89 public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){
90 stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid +
91 "&serviceModelVersion=" + serviceModelVersion))
92 .willReturn(aResponse()
94 .withHeader("Content-Type", "application/json")
95 .withBodyFile(responseFile)));
98 public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String responseFile){
99 stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
100 .willReturn(aResponse()
102 .withHeader("Content-Type", "application/json")
103 .withBodyFile(responseFile)));